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

[Breaking Change] change PagedResult and TranscriptInfo to interfaces #664

Merged
merged 1 commit into from
Nov 28, 2018
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
14 changes: 7 additions & 7 deletions libraries/botbuilder-azure/src/azureBlobTranscriptStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@ export class AzureBlobTranscriptStore implements TranscriptStore {
.then((blobs: azure.BlobService.BlobResult[]): Promise<PagedResult<Activity>> => {
return Promise.all(blobs.map((blob: azure.BlobService.BlobResult) => this.blobToActivity(blob)))
.then((activities: Activity[]) => {
const pagedResult: PagedResult<Activity> = new PagedResult<Activity>();
pagedResult.items = activities;
const pagedResult: PagedResult<Activity> = { items: activities, continuationToken: undefined };
if (pagedResult.items.length === this.pageSize) {
pagedResult.continuationToken = blobs.slice(-1).pop().name;
}
Expand Down Expand Up @@ -169,8 +168,7 @@ export class AzureBlobTranscriptStore implements TranscriptStore {
token
))
.then((transcripts: TranscriptInfo[]) => {
const pagedResult: PagedResult<TranscriptInfo> = new PagedResult<TranscriptInfo>();
pagedResult.items = transcripts;
const pagedResult: PagedResult<TranscriptInfo> = { items: transcripts, continuationToken: undefined };
if (pagedResult.items.length === this.pageSize) {
pagedResult.continuationToken = transcripts.slice(-1).pop().id;
}
Expand Down Expand Up @@ -266,9 +264,11 @@ export class AzureBlobTranscriptStore implements TranscriptStore {
this.client.listBlobDirectoriesSegmentedWithPrefixAsync(container, prefix, token).then(
(result: azure.BlobService.ListBlobsResult): void => {
result.entries.some((blob: azure.BlobService.BlobResult) => {
const conversation: TranscriptInfo = new TranscriptInfo();
conversation.id = blob.name.split('/').filter((part: string) => part).slice(-1).pop();
conversation.channelId = channelId;
const conversation: TranscriptInfo = {
channelId: channelId,
id: blob.name.split('/').filter((part: string) => part).slice(-1).pop(),
created: undefined
}
if (continuationToken) {
if (conversation.id === continuationToken) {
continuationToken = null;
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 @@ -71,7 +71,7 @@ export class MemoryTranscriptStore implements TranscriptStore {

if (!conversationId) { throw new Error('Missing conversationId'); }

const pagedResult: PagedResult<Activity> = new PagedResult<Activity>();
const pagedResult: PagedResult<Activity> = { items: [], continuationToken: undefined };
if (this.channels.has(channelId)) {
const channel: Map<string, Activity[]> = this.channels.get(channelId);
if (channel.has(conversationId)) {
Expand Down Expand Up @@ -106,7 +106,7 @@ export class MemoryTranscriptStore implements TranscriptStore {
public listTranscripts(channelId: string, continuationToken?: string): Promise<PagedResult<TranscriptInfo>> {
if (!channelId) { throw new Error('Missing channelId'); }

const pagedResult: PagedResult<TranscriptInfo> = new PagedResult<TranscriptInfo>();
const pagedResult: PagedResult<TranscriptInfo> = { items: [], continuationToken: undefined };
if (this.channels.has(channelId)) {
const channel: Map<string, Activity[]> = this.channels.get(channelId);

Expand Down
14 changes: 7 additions & 7 deletions libraries/botbuilder-core/src/transcriptLogger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,37 +185,37 @@ export interface TranscriptStore extends TranscriptLogger {
/**
* Metadata for a stored transcript.
*/
export class TranscriptInfo {
export interface TranscriptInfo {
/**
* ChannelId that the transcript was taken from.
*/
public channelId: string;
channelId: string;

/**
* Conversation Id.
*/
public id: string;
id: string;

/**
* Date conversation was started.
*/
public created: Date;
created: Date;
}

/**
* Page of results.
* @param T type of items being paged in.
*/
// tslint:disable-next-line:max-classes-per-file
export class PagedResult<T> {
export interface PagedResult<T> {

/**
* Page of items.
*/
public items: T[] = [];
items: T[];

/**
* Token used to page through multiple pages.
*/
public continuationToken: string;
continuationToken: string;
}
4 changes: 2 additions & 2 deletions libraries/botbuilder/src/fileTranscriptStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export class FileTranscriptStore implements TranscriptStore {

if (!conversationId) { throw new Error('Missing conversationId'); }

const pagedResult: PagedResult<Activity> = new PagedResult<Activity>();
const pagedResult: PagedResult<Activity> = { items: [], continuationToken: undefined };
const transcriptFolder: string = this.getTranscriptFolder(channelId, conversationId);

return fs.exists(transcriptFolder).then((exists: boolean) => {
Expand Down Expand Up @@ -119,7 +119,7 @@ export class FileTranscriptStore implements TranscriptStore {
public listTranscripts(channelId: string, continuationToken?: string): Promise<PagedResult<TranscriptInfo>> {
if (!channelId) { throw new Error('Missing channelId'); }

const pagedResult: PagedResult<TranscriptInfo> = new PagedResult<TranscriptInfo>();
const pagedResult: PagedResult<TranscriptInfo> = { items: [], continuationToken: undefined };
const channelFolder: string = this.getChannelFolder(channelId);

return fs.exists(channelFolder).then((exists: boolean) => {
Expand Down