@microsoft/m365-spec-parser 0.2.2-alpha.882a28541.0 → 0.2.2-alpha.889753773.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.
@@ -54,6 +54,7 @@ var WarningType;
54
54
  WarningType["GenerateCardFailed"] = "generate-card-failed";
55
55
  WarningType["OperationOnlyContainsOptionalParam"] = "operation-only-contains-optional-param";
56
56
  WarningType["ConvertSwaggerToOpenAPI"] = "convert-swagger-to-openapi";
57
+ WarningType["FuncDescriptionTooLong"] = "function-description-too-long";
57
58
  WarningType["Unknown"] = "unknown";
58
59
  })(WarningType || (WarningType = {}));
59
60
  /**
@@ -100,6 +101,7 @@ ConstantString.SwaggerNotSupported = "Swagger 2.0 is not supported. Please conve
100
101
  ConstantString.SpecVersionNotSupported = "Unsupported OpenAPI version %s. Please use version 3.0.x.";
101
102
  ConstantString.MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
102
103
  ConstantString.UnsupportedSchema = "Unsupported schema in %s %s: %s";
104
+ 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.";
103
105
  ConstantString.WrappedCardVersion = "devPreview";
104
106
  ConstantString.WrappedCardSchema = "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.ResponseRenderingTemplate.schema.json";
105
107
  ConstantString.WrappedCardResponseLayout = "list";
@@ -179,22 +181,26 @@ ConstantString.ConversationStarterMaxLens = 50;
179
181
  ConstantString.CommandTitleMaxLens = 32;
180
182
  ConstantString.ParameterTitleMaxLens = 32;
181
183
  ConstantString.SMERequiredParamsMaxNum = 5;
184
+ ConstantString.FunctionDescriptionMaxLens = 100;
182
185
  ConstantString.DefaultPluginId = "plugin_1";
183
- ConstantString.PluginManifestSchema = "https://aka.ms/json-schemas/copilot-extensions/v2.1/plugin.schema.json";
186
+ ConstantString.PluginManifestSchema = "https://developer.microsoft.com/json-schemas/copilot/plugin/v2.1/schema.json";
184
187
 
185
188
  // Copyright (c) Microsoft Corporation.
186
189
  class Utils {
187
190
  static hasNestedObjectInSchema(schema) {
188
- if (schema.type === "object") {
191
+ if (this.isObjectSchema(schema)) {
189
192
  for (const property in schema.properties) {
190
193
  const nestedSchema = schema.properties[property];
191
- if (nestedSchema.type === "object") {
194
+ if (this.isObjectSchema(nestedSchema)) {
192
195
  return true;
193
196
  }
194
197
  }
195
198
  }
196
199
  return false;
197
200
  }
201
+ static isObjectSchema(schema) {
202
+ return schema.type === "object" || (!schema.type && !!schema.properties);
203
+ }
198
204
  static containMultipleMediaTypes(bodyObject) {
199
205
  return Object.keys((bodyObject === null || bodyObject === void 0 ? void 0 : bodyObject.content) || {}).length > 1;
200
206
  }
@@ -423,7 +429,7 @@ class Utils {
423
429
  optionalParams.push(parameter);
424
430
  }
425
431
  }
426
- else if (schema.type === "object") {
432
+ else if (Utils.isObjectSchema(schema)) {
427
433
  const { properties } = schema;
428
434
  for (const property in properties) {
429
435
  let isRequired = false;
@@ -761,7 +767,7 @@ class Validator {
761
767
  }
762
768
  const isRequiredWithoutDefault = isRequired && schema.default === undefined;
763
769
  const isCopilot = this.projectType === ProjectType.Copilot;
764
- if (isCopilot && this.hasNestedObjectInSchema(schema)) {
770
+ if (isCopilot && Utils.hasNestedObjectInSchema(schema)) {
765
771
  paramResult.isValid = false;
766
772
  paramResult.reason = [ErrorType.RequestBodyContainsNestedObject];
767
773
  return paramResult;
@@ -777,7 +783,7 @@ class Validator {
777
783
  paramResult.optionalNum = paramResult.optionalNum + 1;
778
784
  }
779
785
  }
780
- else if (schema.type === "object") {
786
+ else if (Utils.isObjectSchema(schema)) {
781
787
  const { properties } = schema;
782
788
  for (const property in properties) {
783
789
  let isRequired = false;
@@ -813,7 +819,7 @@ class Validator {
813
819
  for (let i = 0; i < paramObject.length; i++) {
814
820
  const param = paramObject[i];
815
821
  const schema = param.schema;
816
- if (isCopilot && this.hasNestedObjectInSchema(schema)) {
822
+ if (isCopilot && Utils.hasNestedObjectInSchema(schema)) {
817
823
  paramResult.isValid = false;
818
824
  paramResult.reason.push(ErrorType.ParamsContainsNestedObject);
819
825
  continue;
@@ -856,17 +862,6 @@ class Validator {
856
862
  }
857
863
  return paramResult;
858
864
  }
859
- hasNestedObjectInSchema(schema) {
860
- if (schema.type === "object") {
861
- for (const property in schema.properties) {
862
- const nestedSchema = schema.properties[property];
863
- if (nestedSchema.type === "object") {
864
- return true;
865
- }
866
- }
867
- }
868
- return false;
869
- }
870
865
  }
871
866
 
872
867
  // Copyright (c) Microsoft Corporation.
@@ -925,7 +920,7 @@ class CopilotValidator extends Validator {
925
920
  const requestJsonBody = requestBody === null || requestBody === void 0 ? void 0 : requestBody.content["application/json"];
926
921
  if (requestJsonBody) {
927
922
  const requestBodySchema = requestJsonBody.schema;
928
- if (requestBodySchema.type !== "object") {
923
+ if (!Utils.isObjectSchema(requestBodySchema)) {
929
924
  result.reason.push(ErrorType.PostBodySchemaIsNotJson);
930
925
  }
931
926
  const requestBodyParamResult = this.checkPostBodySchema(requestBodySchema, requestBody.required);
@@ -1370,7 +1365,7 @@ class AdaptiveCardGenerator {
1370
1365
  return [template];
1371
1366
  }
1372
1367
  // some schema may not contain type but contain properties
1373
- if (schema.type === "object" || (!schema.type && schema.properties)) {
1368
+ if (Utils.isObjectSchema(schema)) {
1374
1369
  const { properties } = schema;
1375
1370
  const result = [];
1376
1371
  for (const property in properties) {
@@ -1438,7 +1433,7 @@ class AdaptiveCardGenerator {
1438
1433
  }
1439
1434
  // Find the first array property in the response schema object with the well-known name
1440
1435
  static getResponseJsonPathFromSchema(schema) {
1441
- if (schema.type === "object" || (!schema.type && schema.properties)) {
1436
+ if (Utils.isObjectSchema(schema)) {
1442
1437
  const { properties } = schema;
1443
1438
  for (const property in properties) {
1444
1439
  const schema = properties[property];