@microsoft/teams-js 2.29.1-beta.0 → 2.30.0-beta.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1 +1 @@
1
- import{ensureInitialized as i}from"../internal/internalAPIs.js";import{errorNotSupportedOnPlatform as n}from"../public/constants.js";import{runtime as o}from"../public/runtime.js";var t;!function(t){!function(t){function r(){var n;return i(o)&&!!(null===(n=o.hostVersionsInfo)||void 0===n?void 0:n.appEligibilityInformation)}t.isSupported=r,t.getEligibilityInfo=function(){if(i(o),!r())throw n;return o.hostVersionsInfo.appEligibilityInformation}}(t.eligibility||(t.eligibility={}))}(t||(t={}));export{t as copilot};
1
+ import{__awaiter as i}from"../../../../node_modules/.pnpm/@rollup_plugin-typescript@11.1.6_rollup@4.24.0_tslib@2.6.3_typescript@4.9.5/node_modules/tslib/tslib.es6.js";import{sendAndUnwrap as o}from"../internal/communication.js";import{ensureInitialized as t}from"../internal/internalAPIs.js";import{getLogger as r,getApiVersionTag as n}from"../internal/telemetry.js";import{errorNotSupportedOnPlatform as l}from"../public/constants.js";import{isSdkError as e}from"../public/interfaces.js";import{runtime as s}from"../public/runtime.js";const p=r("copilot");var a;!function(r){!function(r){function a(){var i,o;return t(s)&&(!!(null===(i=s.hostVersionsInfo)||void 0===i?void 0:i.appEligibilityInformation)||!!(null===(o=s.supports.copilot)||void 0===o?void 0:o.eligibility))}r.isSupported=a,r.getEligibilityInfo=function(){var r,m;return i(this,void 0,void 0,(function*(){if(t(s),!a())throw new Error(`Error code: ${l.errorCode}, message: Not supported on platform`);if(null===(r=s.hostVersionsInfo)||void 0===r?void 0:r.appEligibilityInformation)return p("Eligibility information is already available on runtime."),s.hostVersionsInfo.appEligibilityInformation;p("Eligibility information is not available on runtime. Requesting from host.");const i=yield o(n("v2","copilot.eligibility.getEligibilityInfo"),"copilot.eligibility.getEligibilityInfo");if(e(i))throw new Error(`Error code: ${i.errorCode}, message: ${null!==(m=i.message)&&void 0!==m?m:"Failed to get eligibility information from the host."}`);if(!function(i){if(void 0===i.ageGroup||void 0===i.cohort||void 0===i.userClassification||void 0===i.isCopilotEligible||void 0===i.isCopilotEnabledRegion||void 0===i.isOptedOutByAdmin)return!1;return!0}(i))throw new Error("Error deserializing eligibility information");return i}))}}(r.eligibility||(r.eligibility={}))}(a||(a={}));export{a as copilot};
@@ -1 +1 @@
1
- const t="2.29.1-beta.0";export{t as version};
1
+ const t="2.30.0-beta.0";export{t as version};
@@ -523,7 +523,7 @@ export namespace copilot {
523
523
  *
524
524
  * @throws Error if {@linkcode app.initialize} has not successfully completed
525
525
  */
526
- function getEligibilityInfo(): AppEligibilityInformation;
526
+ function getEligibilityInfo(): Promise<AppEligibilityInformation>;
527
527
  }
528
528
  }
529
529
 
@@ -3511,7 +3511,7 @@ const _minRuntimeConfigToUninitialize = {
3511
3511
  * @hidden
3512
3512
  * Package version.
3513
3513
  */
3514
- const version = "2.29.1-beta.0";
3514
+ const version = "2.30.0-beta.0";
3515
3515
 
3516
3516
  ;// CONCATENATED MODULE: ./src/internal/internalAPIs.ts
3517
3517
 
@@ -8087,9 +8087,23 @@ var conversations;
8087
8087
  })(conversations || (conversations = {}));
8088
8088
 
8089
8089
  ;// CONCATENATED MODULE: ./src/private/copilot.ts
8090
+ var copilot_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
8091
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8092
+ return new (P || (P = Promise))(function (resolve, reject) {
8093
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
8094
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8095
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8096
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8097
+ });
8098
+ };
8090
8099
 
8091
8100
 
8092
8101
 
8102
+
8103
+
8104
+
8105
+ const copilotTelemetryVersionNumber = "v2" /* ApiVersionNumber.V_2 */;
8106
+ const copilotLogger = getLogger('copilot');
8093
8107
  /**
8094
8108
  * @beta
8095
8109
  * @hidden
@@ -8118,8 +8132,9 @@ var copilot;
8118
8132
  * @throws Error if {@linkcode app.initialize} has not successfully completed
8119
8133
  */
8120
8134
  function isSupported() {
8121
- var _a;
8122
- return ensureInitialized(runtime) && !!((_a = runtime.hostVersionsInfo) === null || _a === void 0 ? void 0 : _a.appEligibilityInformation);
8135
+ var _a, _b;
8136
+ return (ensureInitialized(runtime) &&
8137
+ (!!((_a = runtime.hostVersionsInfo) === null || _a === void 0 ? void 0 : _a.appEligibilityInformation) || !!((_b = runtime.supports.copilot) === null || _b === void 0 ? void 0 : _b.eligibility)));
8123
8138
  }
8124
8139
  eligibility.isSupported = isSupported;
8125
8140
  /**
@@ -8132,13 +8147,42 @@ var copilot;
8132
8147
  * @throws Error if {@linkcode app.initialize} has not successfully completed
8133
8148
  */
8134
8149
  function getEligibilityInfo() {
8135
- ensureInitialized(runtime);
8136
- if (!isSupported()) {
8137
- throw errorNotSupportedOnPlatform;
8138
- }
8139
- return runtime.hostVersionsInfo.appEligibilityInformation;
8150
+ var _a, _b;
8151
+ return copilot_awaiter(this, void 0, void 0, function* () {
8152
+ ensureInitialized(runtime);
8153
+ if (!isSupported()) {
8154
+ throw new Error(`Error code: ${errorNotSupportedOnPlatform.errorCode}, message: Not supported on platform`);
8155
+ }
8156
+ // Return the eligibility information if it is already available
8157
+ if ((_a = runtime.hostVersionsInfo) === null || _a === void 0 ? void 0 : _a.appEligibilityInformation) {
8158
+ copilotLogger('Eligibility information is already available on runtime.');
8159
+ return runtime.hostVersionsInfo.appEligibilityInformation;
8160
+ }
8161
+ copilotLogger('Eligibility information is not available on runtime. Requesting from host.');
8162
+ // Send message to host SDK to get eligibility information
8163
+ const response = yield sendAndUnwrap(getApiVersionTag(copilotTelemetryVersionNumber, "copilot.eligibility.getEligibilityInfo" /* ApiName.Copilot_Eligibility_GetEligibilityInfo */), "copilot.eligibility.getEligibilityInfo" /* ApiName.Copilot_Eligibility_GetEligibilityInfo */);
8164
+ if (isSdkError(response)) {
8165
+ throw new Error(`Error code: ${response.errorCode}, message: ${(_b = response.message) !== null && _b !== void 0 ? _b : 'Failed to get eligibility information from the host.'}`);
8166
+ }
8167
+ // validate response
8168
+ if (!isEligibilityInfoValid(response)) {
8169
+ throw new Error('Error deserializing eligibility information');
8170
+ }
8171
+ return response;
8172
+ });
8140
8173
  }
8141
8174
  eligibility.getEligibilityInfo = getEligibilityInfo;
8175
+ function isEligibilityInfoValid(eligibilityInfo) {
8176
+ if (eligibilityInfo.ageGroup === undefined ||
8177
+ eligibilityInfo.cohort === undefined ||
8178
+ eligibilityInfo.userClassification === undefined ||
8179
+ eligibilityInfo.isCopilotEligible === undefined ||
8180
+ eligibilityInfo.isCopilotEnabledRegion === undefined ||
8181
+ eligibilityInfo.isOptedOutByAdmin === undefined) {
8182
+ return false;
8183
+ }
8184
+ return true;
8185
+ }
8142
8186
  })(eligibility = copilot.eligibility || (copilot.eligibility = {}));
8143
8187
  })(copilot || (copilot = {}));
8144
8188