Skip to content

Commit 728ed17

Browse files
feat: botframework http adapter (#3375)
* fix: stdlib delay, various small clean ups - Add ActivityTypes.Delay consolidate sinon versions in root package * fix: Partial<Activity> conversation API fixes * feat: BotFrameworkHttpAdapter interface * fix: remove Delay activity type * fix: typo
1 parent abeef13 commit 728ed17

File tree

24 files changed

+186
-153
lines changed

24 files changed

+186
-153
lines changed

libraries/adaptive-expressions/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
"devDependencies": {
4444
"@types/jspath": "^0.4.0",
4545
"antlr4ts-cli": "0.5.0-alpha.3",
46-
"sinon": "^7.5.0",
4746
"typescript": "3.5.3"
4847
},
4948
"scripts": {

libraries/botbuilder-ai-orchestrator/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,6 @@
3535
"orchestrator-core": "4.12.0-preview",
3636
"uuid": "^8.3.2"
3737
},
38-
"devDependencies": {
39-
"sinon": "^9.2.1"
40-
},
4138
"scripts": {
4239
"build": "tsc -b",
4340
"build-docs": "typedoc --theme markdown --entryPoint botbuilder-ai-orchestrator --excludePrivate --includeDeclarations --ignoreCompilerErrors --module amd --out ..\\..\\doc\\botbuilder-ai-orchestrator .\\lib\\index.d.ts --hideGenerator --name \"Bot Builder SDK - Orchestrator\" --readme none",

libraries/botbuilder-applicationinsights/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@
3434
},
3535
"devDependencies": {
3636
"assert": "^1.4.1",
37-
"chatdown": "^1.0.2",
38-
"sinon": "^7.5.0"
37+
"chatdown": "^1.0.2"
3938
},
4039
"scripts": {
4140
"build": "tsc -b",

libraries/botbuilder-azure-blobs/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,6 @@
3434
"get-stream": "^6.0.0",
3535
"p-map": "^4.0.0"
3636
},
37-
"devDependencies": {
38-
"sinon": "^9.2.0"
39-
},
4037
"scripts": {
4138
"build": "tsc -b",
4239
"build-docs": "typedoc --theme markdown --entryPoint botbuilder-azure-blobs --excludePrivate --includeDeclarations --ignoreCompilerErrors --module amd --out ..\\..\\doc\\botbuilder-azure-blobs .\\lib\\index.d.ts --hideGenerator --name \"Bot Builder SDK - Azure Blobs\" --readme none",

libraries/botbuilder-azure-queues/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"botbuilder-core": "4.1.6"
3333
},
3434
"devDependencies": {
35-
"sinon": "^9.2.0",
3635
"ts-essentials": "^7.0.1"
3736
},
3837
"scripts": {

libraries/botbuilder-core/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
"uuid": "^8.3.2"
3535
},
3636
"devDependencies": {
37-
"sinon": "^9.2.4",
3837
"unzipper": "^0.10.9"
3938
},
4039
"scripts": {

libraries/botbuilder-repo-utils/package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
},
2222
"devDependencies": {
2323
"@types/minimist": "^1.2.1",
24-
"@types/sinon": "^9.0.8",
25-
"sinon": "^9.2.1",
2624
"ts-node": "^9.0.0",
2725
"typescript": "^4.0.5"
2826
},
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
/**
5+
* Delay resolution of `promise`
6+
*
7+
* @template T type that promise will yield, defaults to `void`
8+
* @param {Promise<T>} promise an optional promise to delay
9+
* @param {number} milliseconds how long to delay
10+
* @returns {Promise<T>} a promise that will resolve to the result of `promise`, delayed by `milliseconds`.
11+
*/
12+
export function delay<T>(promise: Promise<T>, milliseconds: number): Promise<T>;
13+
14+
/**
15+
* Return a promise that resolves after `milliseconds`.
16+
*
17+
* @param {number} milliseconds how long to delay
18+
* @returns {Promise<void>} a promise that will resolve to the result of `promise`, delayed by `milliseconds`.
19+
*/
20+
export function delay(milliseconds: number): Promise<void>;
21+
22+
/**
23+
* @internal
24+
*/
25+
export function delay<T>(promiseOrmilliseconds: Promise<T> | number, maybeMilliseconds?: number): Promise<T> {
26+
if (typeof promiseOrmilliseconds === 'number') {
27+
return new Promise<T>((resolve) => setTimeout(resolve, promiseOrmilliseconds));
28+
}
29+
30+
return new Promise<T>((resolve) => setTimeout(() => resolve(promiseOrmilliseconds), maybeMilliseconds));
31+
}

libraries/botbuilder-stdlib/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,5 @@
33

44
export * as assertExt from './assertExt';
55
export * from './types';
6+
export { delay } from './delay';
67
export { maybeCast } from './maybeCast';
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT License.
3+
4+
const assert = require('assert');
5+
const sinon = require('sinon');
6+
const { delay } = require('../');
7+
8+
describe('delay', () => {
9+
let sandbox;
10+
beforeEach(() => {
11+
sandbox = sinon.createSandbox({ useFakeTimers: true });
12+
});
13+
14+
afterEach(() => {
15+
sandbox.restore();
16+
});
17+
18+
it('works with a promise arg', async () => {
19+
const promise = Promise.resolve(10);
20+
21+
let result = delay(promise, 250);
22+
sandbox.clock.tick(251);
23+
24+
result = await result;
25+
assert.strictEqual(result, 10);
26+
});
27+
28+
it('works without a promise arg', async () => {
29+
const promise = delay(250);
30+
sandbox.clock.tick(251);
31+
32+
const result = await promise;
33+
assert.strictEqual(result, undefined);
34+
});
35+
});

0 commit comments

Comments
 (0)