@microsoft/teamsfx 2.2.1 → 2.2.2-alpha.d8776a676.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +123 -44
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +131 -44
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +4 -4
- package/types/teamsfx.d.ts +111 -2
package/dist/index.node.cjs.js
CHANGED
@@ -2469,6 +2469,13 @@ class CommandBot$1 {
|
|
2469
2469
|
function cloneConversation(conversation) {
|
2470
2470
|
return JSON.parse(JSON.stringify(conversation));
|
2471
2471
|
}
|
2472
|
+
/**
|
2473
|
+
* @internal
|
2474
|
+
*/
|
2475
|
+
function getKey(reference) {
|
2476
|
+
var _a, _b;
|
2477
|
+
return `_${(_a = reference.conversation) === null || _a === void 0 ? void 0 : _a.tenantId}_${(_b = reference.conversation) === null || _b === void 0 ? void 0 : _b.id}`;
|
2478
|
+
}
|
2472
2479
|
/**
|
2473
2480
|
* @internal
|
2474
2481
|
*/
|
@@ -2532,7 +2539,9 @@ class NotificationMiddleware {
|
|
2532
2539
|
case ActivityType.CurrentBotInstalled:
|
2533
2540
|
case ActivityType.TeamRestored: {
|
2534
2541
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
2535
|
-
yield this.conversationReferenceStore.
|
2542
|
+
yield this.conversationReferenceStore.add(getKey(reference), reference, {
|
2543
|
+
overwrite: true,
|
2544
|
+
});
|
2536
2545
|
break;
|
2537
2546
|
}
|
2538
2547
|
case ActivityType.CurrentBotMessaged: {
|
@@ -2542,7 +2551,7 @@ class NotificationMiddleware {
|
|
2542
2551
|
case ActivityType.CurrentBotUninstalled:
|
2543
2552
|
case ActivityType.TeamDeleted: {
|
2544
2553
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
2545
|
-
yield this.conversationReferenceStore.
|
2554
|
+
yield this.conversationReferenceStore.remove(getKey(reference), reference);
|
2546
2555
|
break;
|
2547
2556
|
}
|
2548
2557
|
}
|
@@ -2581,18 +2590,16 @@ class NotificationMiddleware {
|
|
2581
2590
|
const reference = botbuilder.TurnContext.getConversationReference(context.activity);
|
2582
2591
|
const conversationType = (_a = reference === null || reference === void 0 ? void 0 : reference.conversation) === null || _a === void 0 ? void 0 : _a.conversationType;
|
2583
2592
|
if (conversationType === "personal" || conversationType === "groupChat") {
|
2584
|
-
|
2585
|
-
yield this.conversationReferenceStore.set(reference);
|
2586
|
-
}
|
2593
|
+
yield this.conversationReferenceStore.add(getKey(reference), reference, { overwrite: false });
|
2587
2594
|
}
|
2588
2595
|
else if (conversationType === "channel") {
|
2589
2596
|
const teamId = (_d = (_c = (_b = context.activity) === null || _b === void 0 ? void 0 : _b.channelData) === null || _c === void 0 ? void 0 : _c.team) === null || _d === void 0 ? void 0 : _d.id;
|
2590
2597
|
if (teamId !== undefined) {
|
2591
2598
|
const teamReference = cloneConversation(reference);
|
2592
2599
|
teamReference.conversation.id = teamId;
|
2593
|
-
|
2594
|
-
|
2595
|
-
}
|
2600
|
+
yield this.conversationReferenceStore.add(getKey(teamReference), teamReference, {
|
2601
|
+
overwrite: false,
|
2602
|
+
});
|
2596
2603
|
}
|
2597
2604
|
}
|
2598
2605
|
});
|
@@ -2705,28 +2712,42 @@ class LocalFileStorage {
|
|
2705
2712
|
/**
|
2706
2713
|
* @internal
|
2707
2714
|
*/
|
2708
|
-
class
|
2715
|
+
class DefaultConversationReferenceStore {
|
2709
2716
|
constructor(storage) {
|
2710
2717
|
this.storage = storage;
|
2711
2718
|
}
|
2712
|
-
|
2719
|
+
add(key, reference, options) {
|
2713
2720
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
2714
|
-
|
2715
|
-
|
2721
|
+
if (options.overwrite) {
|
2722
|
+
yield this.storage.write(key, reference);
|
2723
|
+
return true;
|
2724
|
+
}
|
2725
|
+
const ref = yield this.storage.read(key);
|
2726
|
+
if (ref === undefined) {
|
2727
|
+
yield this.storage.write(key, reference);
|
2728
|
+
return true;
|
2729
|
+
}
|
2730
|
+
return false;
|
2716
2731
|
});
|
2717
2732
|
}
|
2718
|
-
|
2719
|
-
return
|
2720
|
-
|
2721
|
-
|
2722
|
-
|
2723
|
-
|
2724
|
-
|
2725
|
-
|
2733
|
+
remove(key, reference) {
|
2734
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
2735
|
+
const ref = yield this.storage.read(key);
|
2736
|
+
if (ref === undefined) {
|
2737
|
+
return false;
|
2738
|
+
}
|
2739
|
+
yield this.storage.delete(key);
|
2740
|
+
return true;
|
2741
|
+
});
|
2726
2742
|
}
|
2727
|
-
|
2728
|
-
|
2729
|
-
|
2743
|
+
list(pageSize, continuationToken) {
|
2744
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
2745
|
+
const data = yield this.storage.list();
|
2746
|
+
return {
|
2747
|
+
data,
|
2748
|
+
continuationToken: "",
|
2749
|
+
};
|
2750
|
+
});
|
2730
2751
|
}
|
2731
2752
|
}
|
2732
2753
|
|
@@ -3133,7 +3154,7 @@ class NotificationBot$1 {
|
|
3133
3154
|
constructor(adapter, options) {
|
3134
3155
|
var _a, _b;
|
3135
3156
|
const storage = (_a = options === null || options === void 0 ? void 0 : options.storage) !== null && _a !== void 0 ? _a : new LocalFileStorage(path__namespace.resolve(process.env.RUNNING_ON_AZURE === "1" ? (_b = process.env.TEMP) !== null && _b !== void 0 ? _b : "./" : "./"));
|
3136
|
-
this.conversationReferenceStore = new
|
3157
|
+
this.conversationReferenceStore = new DefaultConversationReferenceStore(storage);
|
3137
3158
|
this.adapter = adapter.use(new NotificationMiddleware({
|
3138
3159
|
conversationReferenceStore: this.conversationReferenceStore,
|
3139
3160
|
}));
|
@@ -3151,7 +3172,7 @@ class NotificationBot$1 {
|
|
3151
3172
|
if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
|
3152
3173
|
throw new Error("NotificationBot has not been initialized.");
|
3153
3174
|
}
|
3154
|
-
const references = yield this.conversationReferenceStore.
|
3175
|
+
const { data: references } = yield this.conversationReferenceStore.list();
|
3155
3176
|
const targets = [];
|
3156
3177
|
for (const reference of references) {
|
3157
3178
|
// validate connection
|
@@ -3171,7 +3192,7 @@ class NotificationBot$1 {
|
|
3171
3192
|
targets.push(new TeamsBotInstallation$1(this.adapter, reference));
|
3172
3193
|
}
|
3173
3194
|
else {
|
3174
|
-
yield this.conversationReferenceStore.
|
3195
|
+
yield this.conversationReferenceStore.remove(getKey(reference), reference);
|
3175
3196
|
}
|
3176
3197
|
}
|
3177
3198
|
return targets;
|
@@ -4612,24 +4633,45 @@ class TeamsBotInstallation {
|
|
4612
4633
|
return channels;
|
4613
4634
|
});
|
4614
4635
|
}
|
4636
|
+
/**
|
4637
|
+
* Gets a pagined list of members from this bot installation.
|
4638
|
+
*
|
4639
|
+
* @param pageSize - Suggested number of entries on a page.
|
4640
|
+
* @param continuationToken - A continuation token.
|
4641
|
+
* @returns An array of members from where the bot is installed.
|
4642
|
+
*/
|
4643
|
+
getPagedMembers(pageSize, continuationToken) {
|
4644
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
4645
|
+
let result = {
|
4646
|
+
data: [],
|
4647
|
+
continuationToken: "",
|
4648
|
+
};
|
4649
|
+
yield this.adapter.continueConversationAsync(this.botAppId, this.conversationReference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
|
4650
|
+
const pagedMembers = yield botbuilder.TeamsInfo.getPagedMembers(context, pageSize, continuationToken);
|
4651
|
+
result = {
|
4652
|
+
data: pagedMembers.members.map((m) => new Member(this, m)),
|
4653
|
+
continuationToken: pagedMembers.continuationToken,
|
4654
|
+
};
|
4655
|
+
}));
|
4656
|
+
return result;
|
4657
|
+
});
|
4658
|
+
}
|
4615
4659
|
/**
|
4616
4660
|
* Get members from this bot installation.
|
4617
4661
|
*
|
4618
4662
|
* @returns An array of members from where the bot is installed.
|
4663
|
+
*
|
4664
|
+
* @deprecated Use `getPagedMembers` instead.
|
4619
4665
|
*/
|
4620
4666
|
members() {
|
4621
4667
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
4622
4668
|
const members = [];
|
4623
|
-
|
4624
|
-
|
4625
|
-
|
4626
|
-
|
4627
|
-
|
4628
|
-
|
4629
|
-
members.push(new Member(this, member));
|
4630
|
-
}
|
4631
|
-
} while (continuationToken !== undefined);
|
4632
|
-
}));
|
4669
|
+
let continuationToken;
|
4670
|
+
do {
|
4671
|
+
const pagedData = yield this.getPagedMembers(undefined, continuationToken);
|
4672
|
+
continuationToken = pagedData.continuationToken;
|
4673
|
+
members.push(...pagedData.data);
|
4674
|
+
} while (continuationToken);
|
4633
4675
|
return members;
|
4634
4676
|
});
|
4635
4677
|
}
|
@@ -4669,29 +4711,49 @@ class NotificationBot {
|
|
4669
4711
|
*/
|
4670
4712
|
constructor(adapter, options) {
|
4671
4713
|
var _a, _b, _c;
|
4672
|
-
|
4673
|
-
|
4714
|
+
if (options === null || options === void 0 ? void 0 : options.store) {
|
4715
|
+
this.conversationReferenceStore = options.store;
|
4716
|
+
}
|
4717
|
+
else {
|
4718
|
+
const storage = (_a = options === null || options === void 0 ? void 0 : options.storage) !== null && _a !== void 0 ? _a : new LocalFileStorage(path__namespace.resolve(process.env.RUNNING_ON_AZURE === "1" ? (_b = process.env.TEMP) !== null && _b !== void 0 ? _b : "./" : "./"));
|
4719
|
+
this.conversationReferenceStore = new DefaultConversationReferenceStore(storage);
|
4720
|
+
}
|
4674
4721
|
this.adapter = adapter.use(new NotificationMiddleware({
|
4675
4722
|
conversationReferenceStore: this.conversationReferenceStore,
|
4676
4723
|
}));
|
4677
4724
|
this.botAppId = ((_c = options === null || options === void 0 ? void 0 : options.botAppId) !== null && _c !== void 0 ? _c : process.env.BOT_ID);
|
4678
4725
|
}
|
4679
4726
|
/**
|
4680
|
-
*
|
4727
|
+
* Create a {@link TeamsBotInstallation} instance with conversation reference.
|
4728
|
+
*
|
4729
|
+
* @param conversationReference - The bound `ConversationReference`.
|
4730
|
+
* @returns - The {@link TeamsBotInstallation} instance or null.
|
4731
|
+
*/
|
4732
|
+
buildTeamsBotInstallation(conversationReference) {
|
4733
|
+
if (!conversationReference) {
|
4734
|
+
throw new Error("conversationReference is required.");
|
4735
|
+
}
|
4736
|
+
return new TeamsBotInstallation(this.adapter, conversationReference, this.botAppId);
|
4737
|
+
}
|
4738
|
+
/**
|
4739
|
+
* Gets a pagined list of targets where the bot is installed.
|
4681
4740
|
*
|
4682
4741
|
* @remarks
|
4683
4742
|
* The result is retrieving from the persisted storage.
|
4684
4743
|
*
|
4685
|
-
* @
|
4744
|
+
* @param pageSize - Suggested number of entries on a page.
|
4745
|
+
* @param continuationToken - A continuation token.
|
4746
|
+
*
|
4747
|
+
* @returns An array of {@link TeamsBotInstallation} with paged data and continuation token.
|
4686
4748
|
*/
|
4687
|
-
|
4749
|
+
getPagedInstallations(pageSize, continuationToken) {
|
4688
4750
|
return tslib.__awaiter(this, void 0, void 0, function* () {
|
4689
4751
|
if (this.conversationReferenceStore === undefined || this.adapter === undefined) {
|
4690
4752
|
throw new Error("NotificationBot has not been initialized.");
|
4691
4753
|
}
|
4692
|
-
const references = yield this.conversationReferenceStore.
|
4754
|
+
const references = yield this.conversationReferenceStore.list(pageSize, continuationToken);
|
4693
4755
|
const targets = [];
|
4694
|
-
for (const reference of references) {
|
4756
|
+
for (const reference of references.data) {
|
4695
4757
|
// validate connection
|
4696
4758
|
let valid = true;
|
4697
4759
|
yield this.adapter.continueConversationAsync(this.botAppId, reference, (context) => tslib.__awaiter(this, void 0, void 0, function* () {
|
@@ -4709,9 +4771,34 @@ class NotificationBot {
|
|
4709
4771
|
targets.push(new TeamsBotInstallation(this.adapter, reference, this.botAppId));
|
4710
4772
|
}
|
4711
4773
|
else {
|
4712
|
-
yield this.conversationReferenceStore.
|
4774
|
+
yield this.conversationReferenceStore.remove(getKey(reference), reference);
|
4713
4775
|
}
|
4714
4776
|
}
|
4777
|
+
return {
|
4778
|
+
data: targets,
|
4779
|
+
continuationToken: references.continuationToken,
|
4780
|
+
};
|
4781
|
+
});
|
4782
|
+
}
|
4783
|
+
/**
|
4784
|
+
* Get all targets where the bot is installed.
|
4785
|
+
*
|
4786
|
+
* @remarks
|
4787
|
+
* The result is retrieving from the persisted storage.
|
4788
|
+
*
|
4789
|
+
* @returns An array of {@link TeamsBotInstallation}.
|
4790
|
+
*
|
4791
|
+
* @deprecated Use getPagedInstallations instead.
|
4792
|
+
*/
|
4793
|
+
installations() {
|
4794
|
+
return tslib.__awaiter(this, void 0, void 0, function* () {
|
4795
|
+
let continuationToken;
|
4796
|
+
const targets = [];
|
4797
|
+
do {
|
4798
|
+
const result = yield this.getPagedInstallations(undefined, continuationToken);
|
4799
|
+
continuationToken = result.continuationToken;
|
4800
|
+
targets.push(...result.data);
|
4801
|
+
} while (continuationToken);
|
4715
4802
|
return targets;
|
4716
4803
|
});
|
4717
4804
|
}
|