@microsoft/m365-spec-parser 0.2.7-alpha.d8fe55aa3.0 → 0.2.7-alpha.e3f6ce706.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.
@@ -3,7 +3,7 @@ import converter from 'swagger2openapi';
3
3
  import jsyaml from 'js-yaml';
4
4
  import fs from 'fs-extra';
5
5
  import path from 'path';
6
- import { ManifestUtil } from '@microsoft/teams-manifest';
6
+ import { AppManifestUtils } from '@microsoft/app-manifest';
7
7
  import { createHash } from 'crypto';
8
8
 
9
9
  // Copyright (c) Microsoft Corporation.
@@ -58,7 +58,6 @@ var WarningType;
58
58
  WarningType["GenerateCardFailed"] = "generate-card-failed";
59
59
  WarningType["OperationOnlyContainsOptionalParam"] = "operation-only-contains-optional-param";
60
60
  WarningType["ConvertSwaggerToOpenAPI"] = "convert-swagger-to-openapi";
61
- WarningType["FuncDescriptionTooLong"] = "function-description-too-long";
62
61
  WarningType["OperationIdContainsSpecialCharacters"] = "operationid-contains-special-characters";
63
62
  WarningType["UnsupportedAuthType"] = "unsupported-auth-type";
64
63
  WarningType["GenerateJsonDataFailed"] = "generate-json-data-failed";
@@ -205,7 +204,7 @@ class Utils {
205
204
  return Object.keys((bodyObject === null || bodyObject === void 0 ? void 0 : bodyObject.content) || {}).length > 1;
206
205
  }
207
206
  static isBearerTokenAuth(authScheme) {
208
- return authScheme.type === "http" && authScheme.scheme === "bearer";
207
+ return authScheme.type === "http" && authScheme.scheme.toLowerCase() === "bearer";
209
208
  }
210
209
  static isAPIKeyAuth(authScheme) {
211
210
  return authScheme.type === "apiKey";
@@ -1727,10 +1726,14 @@ function inferProperties(card) {
1727
1726
 
1728
1727
  // Copyright (c) Microsoft Corporation.
1729
1728
  class ManifestUpdater {
1729
+ static async useCopilotExtensionsInSchema(manifest) {
1730
+ const schema = await AppManifestUtils.fetchSchema(manifest.$schema);
1731
+ return !!schema.properties.copilotExtensions;
1732
+ }
1730
1733
  static async updateManifestWithAiPlugin(manifestPath, outputSpecPath, apiPluginFilePath, spec, options, authMap, existingPluginManifestInfo) {
1731
1734
  const manifest = await fs.readJSON(manifestPath);
1732
1735
  const apiPluginRelativePath = ManifestUpdater.getRelativePath(manifestPath, apiPluginFilePath);
1733
- const useCopilotExtensionsInSchema = await ManifestUtil.useCopilotExtensionsInSchema(manifest);
1736
+ const useCopilotExtensionsInSchema = await this.useCopilotExtensionsInSchema(manifest);
1734
1737
  if (manifest.copilotExtensions || useCopilotExtensionsInSchema) {
1735
1738
  manifest.copilotExtensions = manifest.copilotExtensions || {};
1736
1739
  if (!options.isGptPlugin) {
@@ -1799,15 +1802,7 @@ class ManifestUpdater {
1799
1802
  const safeFunctionName = operationId.replace(/[^a-zA-Z0-9]/g, "_");
1800
1803
  const description = (_a = operationItem.description) !== null && _a !== void 0 ? _a : "";
1801
1804
  const summary = operationItem.summary;
1802
- let funcDescription = operationItem.description || operationItem.summary || "";
1803
- if (funcDescription.length > ConstantString.FunctionDescriptionMaxLens) {
1804
- warnings.push({
1805
- type: WarningType.FuncDescriptionTooLong,
1806
- content: Utils.format(ConstantString.FuncDescriptionTooLong, safeFunctionName, funcDescription.length.toString(), ConstantString.FunctionDescriptionMaxLens.toString()),
1807
- data: safeFunctionName,
1808
- });
1809
- funcDescription = funcDescription.slice(0, ConstantString.FunctionDescriptionMaxLens);
1810
- }
1805
+ const funcDescription = operationItem.description || operationItem.summary || "";
1811
1806
  const funcObj = {
1812
1807
  name: safeFunctionName,
1813
1808
  description: funcDescription,