@microsoft/m365-spec-parser 0.2.7-alpha.ef180c1c1.0 → 0.2.7-alpha.fdd1bfa46.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.
@@ -7,7 +7,7 @@ var converter = require('swagger2openapi');
7
7
  var jsyaml = require('js-yaml');
8
8
  var fs = require('fs-extra');
9
9
  var path = require('path');
10
- var teamsManifest = require('@microsoft/teams-manifest');
10
+ var appManifest = require('@microsoft/app-manifest');
11
11
  var crypto = require('crypto');
12
12
 
13
13
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
@@ -100,7 +100,7 @@ exports.WarningType = void 0;
100
100
  WarningType["GenerateCardFailed"] = "generate-card-failed";
101
101
  WarningType["OperationOnlyContainsOptionalParam"] = "operation-only-contains-optional-param";
102
102
  WarningType["ConvertSwaggerToOpenAPI"] = "convert-swagger-to-openapi";
103
- WarningType["FuncDescriptionTooLong"] = "function-description-too-long";
103
+ WarningType["OpenAPI31ConvertTo30"] = "openapi31-convert-to-30";
104
104
  WarningType["OperationIdContainsSpecialCharacters"] = "operationid-contains-special-characters";
105
105
  WarningType["UnsupportedAuthType"] = "unsupported-auth-type";
106
106
  WarningType["GenerateJsonDataFailed"] = "generate-json-data-failed";
@@ -143,6 +143,7 @@ ConstantString.RelativeServerUrlNotSupported = "Server url is not correct: relat
143
143
  ConstantString.ResolveServerUrlFailed = "Unable to resolve the server URL: please make sure that the environment variable %s is defined.";
144
144
  ConstantString.OperationOnlyContainsOptionalParam = "Operation %s contains multiple optional parameters. The first optional parameter is used for this command.";
145
145
  ConstantString.ConvertSwaggerToOpenAPI = "The Swagger 2.0 file has been converted to OpenAPI 3.0.";
146
+ ConstantString.OpenAPI31ConvertTo30 = "OpenAPI 3.1 document has been converted to OpenAPI 3.0.";
146
147
  ConstantString.SwaggerNotSupported = "Swagger 2.0 is not supported. Please convert to OpenAPI 3.0 manually before proceeding.";
147
148
  ConstantString.SpecVersionNotSupported = "Unsupported OpenAPI version %s. Please use version 3.0.x.";
148
149
  ConstantString.MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
@@ -1769,11 +1770,17 @@ function inferProperties(card) {
1769
1770
 
1770
1771
  // Copyright (c) Microsoft Corporation.
1771
1772
  class ManifestUpdater {
1773
+ static useCopilotExtensionsInSchema(manifest) {
1774
+ return __awaiter(this, void 0, void 0, function* () {
1775
+ const schema = yield appManifest.AppManifestUtils.fetchSchema(manifest.$schema);
1776
+ return !!schema.properties.copilotExtensions;
1777
+ });
1778
+ }
1772
1779
  static updateManifestWithAiPlugin(manifestPath, outputSpecPath, apiPluginFilePath, spec, options, authMap, existingPluginManifestInfo) {
1773
1780
  return __awaiter(this, void 0, void 0, function* () {
1774
1781
  const manifest = yield fs__default['default'].readJSON(manifestPath);
1775
1782
  const apiPluginRelativePath = ManifestUpdater.getRelativePath(manifestPath, apiPluginFilePath);
1776
- const useCopilotExtensionsInSchema = yield teamsManifest.ManifestUtil.useCopilotExtensionsInSchema(manifest);
1783
+ const useCopilotExtensionsInSchema = yield this.useCopilotExtensionsInSchema(manifest);
1777
1784
  if (manifest.copilotExtensions || useCopilotExtensionsInSchema) {
1778
1785
  manifest.copilotExtensions = manifest.copilotExtensions || {};
1779
1786
  if (!options.isGptPlugin) {
@@ -1844,15 +1851,7 @@ class ManifestUpdater {
1844
1851
  const safeFunctionName = operationId.replace(/[^a-zA-Z0-9]/g, "_");
1845
1852
  const description = (_a = operationItem.description) !== null && _a !== void 0 ? _a : "";
1846
1853
  const summary = operationItem.summary;
1847
- let funcDescription = operationItem.description || operationItem.summary || "";
1848
- if (funcDescription.length > ConstantString.FunctionDescriptionMaxLens) {
1849
- warnings.push({
1850
- type: exports.WarningType.FuncDescriptionTooLong,
1851
- content: Utils.format(ConstantString.FuncDescriptionTooLong, safeFunctionName, funcDescription.length.toString(), ConstantString.FunctionDescriptionMaxLens.toString()),
1852
- data: safeFunctionName,
1853
- });
1854
- funcDescription = funcDescription.slice(0, ConstantString.FunctionDescriptionMaxLens);
1855
- }
1854
+ const funcDescription = operationItem.description || operationItem.summary || "";
1856
1855
  const funcObj = {
1857
1856
  name: safeFunctionName,
1858
1857
  description: funcDescription,