@microsoft/m365-spec-parser 0.2.2-alpha.fa1ce1fbb.0 → 0.2.2-alpha.fe2e47f9c.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,6 +181,7 @@ 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
186
  ConstantString.PluginManifestSchema = "https://aka.ms/json-schemas/copilot-extensions/v2.1/plugin.schema.json";
184
187
 
@@ -256,23 +259,28 @@ class Utils {
256
259
  return str.charAt(0).toUpperCase() + str.slice(1);
257
260
  }
258
261
  static getResponseJson(operationObject, allowMultipleMediaType = false) {
259
- var _a, _b;
262
+ var _a;
260
263
  let json = {};
261
264
  let multipleMediaType = false;
262
265
  for (const code of ConstantString.ResponseCodeFor20X) {
263
266
  const responseObject = (_a = operationObject === null || operationObject === void 0 ? void 0 : operationObject.responses) === null || _a === void 0 ? void 0 : _a[code];
264
- if ((_b = responseObject === null || responseObject === void 0 ? void 0 : responseObject.content) === null || _b === void 0 ? void 0 : _b["application/json"]) {
265
- multipleMediaType = false;
266
- json = responseObject.content["application/json"];
267
- if (Utils.containMultipleMediaTypes(responseObject)) {
268
- multipleMediaType = true;
269
- if (!allowMultipleMediaType) {
270
- json = {};
267
+ if (responseObject === null || responseObject === void 0 ? void 0 : responseObject.content) {
268
+ for (const contentType of Object.keys(responseObject.content)) {
269
+ // json media type can also be "application/json; charset=utf-8"
270
+ if (contentType.indexOf("application/json") >= 0) {
271
+ multipleMediaType = false;
272
+ json = responseObject.content[contentType];
273
+ if (Utils.containMultipleMediaTypes(responseObject)) {
274
+ multipleMediaType = true;
275
+ if (!allowMultipleMediaType) {
276
+ json = {};
277
+ }
278
+ }
279
+ else {
280
+ return { json, multipleMediaType };
281
+ }
271
282
  }
272
283
  }
273
- else {
274
- break;
275
- }
276
284
  }
277
285
  }
278
286
  return { json, multipleMediaType };
@@ -532,6 +540,29 @@ class Utils {
532
540
  const serverUrl = operationServer || methodServer || rootServer;
533
541
  return serverUrl;
534
542
  }
543
+ static limitACBodyProperties(body, maxCount) {
544
+ const result = [];
545
+ let currentCount = 0;
546
+ for (const element of body) {
547
+ if (element.type === ConstantString.ContainerType) {
548
+ const items = this.limitACBodyProperties(element.items, maxCount - currentCount);
549
+ result.push({
550
+ type: ConstantString.ContainerType,
551
+ $data: element.$data,
552
+ items: items,
553
+ });
554
+ currentCount += items.length;
555
+ }
556
+ else {
557
+ result.push(element);
558
+ currentCount++;
559
+ }
560
+ if (currentCount >= maxCount) {
561
+ break;
562
+ }
563
+ }
564
+ return result;
565
+ }
535
566
  }
536
567
 
537
568
  // Copyright (c) Microsoft Corporation.
@@ -1388,7 +1419,7 @@ class AdaptiveCardGenerator {
1388
1419
  {
1389
1420
  type: "Image",
1390
1421
  url: `\${${name}}`,
1391
- $when: `\${${name} != null}`,
1422
+ $when: `\${${name} != null && ${name} != ''}`,
1392
1423
  },
1393
1424
  ];
1394
1425
  }
@@ -1397,7 +1428,7 @@ class AdaptiveCardGenerator {
1397
1428
  {
1398
1429
  type: "Image",
1399
1430
  url: "${$data}",
1400
- $when: "${$data != null}",
1431
+ $when: "${$data != null && $data != ''}",
1401
1432
  },
1402
1433
  ];
1403
1434
  }