@microsoft/m365-spec-parser 0.2.2-alpha.9389d4dc7.0 → 0.2.2-alpha.98764a164.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.
@@ -84,6 +84,7 @@ var WarningType;
84
84
  WarningType["GenerateCardFailed"] = "generate-card-failed";
85
85
  WarningType["OperationOnlyContainsOptionalParam"] = "operation-only-contains-optional-param";
86
86
  WarningType["ConvertSwaggerToOpenAPI"] = "convert-swagger-to-openapi";
87
+ WarningType["FuncDescriptionTooLong"] = "function-description-too-long";
87
88
  WarningType["Unknown"] = "unknown";
88
89
  })(WarningType || (WarningType = {}));
89
90
  /**
@@ -130,6 +131,7 @@ ConstantString.SwaggerNotSupported = "Swagger 2.0 is not supported. Please conve
130
131
  ConstantString.SpecVersionNotSupported = "Unsupported OpenAPI version %s. Please use version 3.0.x.";
131
132
  ConstantString.MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
132
133
  ConstantString.UnsupportedSchema = "Unsupported schema in %s %s: %s";
134
+ ConstantString.FuncDescriptionTooLong = "The description of the function '%s' is too long. The current length is %s characters, while the maximum allowed length is %s characters.";
133
135
  ConstantString.WrappedCardVersion = "devPreview";
134
136
  ConstantString.WrappedCardSchema = "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.ResponseRenderingTemplate.schema.json";
135
137
  ConstantString.WrappedCardResponseLayout = "list";
@@ -209,22 +211,26 @@ ConstantString.ConversationStarterMaxLens = 50;
209
211
  ConstantString.CommandTitleMaxLens = 32;
210
212
  ConstantString.ParameterTitleMaxLens = 32;
211
213
  ConstantString.SMERequiredParamsMaxNum = 5;
214
+ ConstantString.FunctionDescriptionMaxLens = 100;
212
215
  ConstantString.DefaultPluginId = "plugin_1";
213
- ConstantString.PluginManifestSchema = "https://aka.ms/json-schemas/copilot-extensions/v2.1/plugin.schema.json";
216
+ ConstantString.PluginManifestSchema = "https://developer.microsoft.com/json-schemas/copilot/plugin/v2.1/schema.json";
214
217
 
215
218
  // Copyright (c) Microsoft Corporation.
216
219
  class Utils {
217
220
  static hasNestedObjectInSchema(schema) {
218
- if (schema.type === "object") {
221
+ if (this.isObjectSchema(schema)) {
219
222
  for (const property in schema.properties) {
220
223
  const nestedSchema = schema.properties[property];
221
- if (nestedSchema.type === "object") {
224
+ if (this.isObjectSchema(nestedSchema)) {
222
225
  return true;
223
226
  }
224
227
  }
225
228
  }
226
229
  return false;
227
230
  }
231
+ static isObjectSchema(schema) {
232
+ return schema.type === "object" || (!schema.type && !!schema.properties);
233
+ }
228
234
  static containMultipleMediaTypes(bodyObject) {
229
235
  return Object.keys((bodyObject === null || bodyObject === void 0 ? void 0 : bodyObject.content) || {}).length > 1;
230
236
  }
@@ -453,7 +459,7 @@ class Utils {
453
459
  optionalParams.push(parameter);
454
460
  }
455
461
  }
456
- else if (schema.type === "object") {
462
+ else if (Utils.isObjectSchema(schema)) {
457
463
  const { properties } = schema;
458
464
  for (const property in properties) {
459
465
  let isRequired = false;
@@ -791,7 +797,7 @@ class Validator {
791
797
  }
792
798
  const isRequiredWithoutDefault = isRequired && schema.default === undefined;
793
799
  const isCopilot = this.projectType === ProjectType.Copilot;
794
- if (isCopilot && this.hasNestedObjectInSchema(schema)) {
800
+ if (isCopilot && Utils.hasNestedObjectInSchema(schema)) {
795
801
  paramResult.isValid = false;
796
802
  paramResult.reason = [ErrorType.RequestBodyContainsNestedObject];
797
803
  return paramResult;
@@ -807,7 +813,7 @@ class Validator {
807
813
  paramResult.optionalNum = paramResult.optionalNum + 1;
808
814
  }
809
815
  }
810
- else if (schema.type === "object") {
816
+ else if (Utils.isObjectSchema(schema)) {
811
817
  const { properties } = schema;
812
818
  for (const property in properties) {
813
819
  let isRequired = false;
@@ -843,7 +849,7 @@ class Validator {
843
849
  for (let i = 0; i < paramObject.length; i++) {
844
850
  const param = paramObject[i];
845
851
  const schema = param.schema;
846
- if (isCopilot && this.hasNestedObjectInSchema(schema)) {
852
+ if (isCopilot && Utils.hasNestedObjectInSchema(schema)) {
847
853
  paramResult.isValid = false;
848
854
  paramResult.reason.push(ErrorType.ParamsContainsNestedObject);
849
855
  continue;
@@ -886,17 +892,6 @@ class Validator {
886
892
  }
887
893
  return paramResult;
888
894
  }
889
- hasNestedObjectInSchema(schema) {
890
- if (schema.type === "object") {
891
- for (const property in schema.properties) {
892
- const nestedSchema = schema.properties[property];
893
- if (nestedSchema.type === "object") {
894
- return true;
895
- }
896
- }
897
- }
898
- return false;
899
- }
900
895
  }
901
896
 
902
897
  // Copyright (c) Microsoft Corporation.
@@ -955,7 +950,7 @@ class CopilotValidator extends Validator {
955
950
  const requestJsonBody = requestBody === null || requestBody === void 0 ? void 0 : requestBody.content["application/json"];
956
951
  if (requestJsonBody) {
957
952
  const requestBodySchema = requestJsonBody.schema;
958
- if (requestBodySchema.type !== "object") {
953
+ if (!Utils.isObjectSchema(requestBodySchema)) {
959
954
  result.reason.push(ErrorType.PostBodySchemaIsNotJson);
960
955
  }
961
956
  const requestBodyParamResult = this.checkPostBodySchema(requestBodySchema, requestBody.required);
@@ -1414,7 +1409,7 @@ class AdaptiveCardGenerator {
1414
1409
  return [template];
1415
1410
  }
1416
1411
  // some schema may not contain type but contain properties
1417
- if (schema.type === "object" || (!schema.type && schema.properties)) {
1412
+ if (Utils.isObjectSchema(schema)) {
1418
1413
  const { properties } = schema;
1419
1414
  const result = [];
1420
1415
  for (const property in properties) {
@@ -1482,7 +1477,7 @@ class AdaptiveCardGenerator {
1482
1477
  }
1483
1478
  // Find the first array property in the response schema object with the well-known name
1484
1479
  static getResponseJsonPathFromSchema(schema) {
1485
- if (schema.type === "object" || (!schema.type && schema.properties)) {
1480
+ if (Utils.isObjectSchema(schema)) {
1486
1481
  const { properties } = schema;
1487
1482
  for (const property in properties) {
1488
1483
  const schema = properties[property];