@microsoft/m365-spec-parser 0.2.2-alpha.089f82c02.0 → 0.2.2-alpha.0921562c9.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.
@@ -536,6 +536,28 @@ class Utils {
536
536
  const serverUrl = operationServer || methodServer || rootServer;
537
537
  return serverUrl;
538
538
  }
539
+ static limitACBodyProperties(body, maxCount) {
540
+ const result = [];
541
+ let currentCount = 0;
542
+ for (const element of body) {
543
+ if (element.type === ConstantString.ContainerType) {
544
+ const items = this.limitACBodyProperties(element.items, maxCount - currentCount);
545
+ result.push({
546
+ type: ConstantString.ContainerType,
547
+ $data: element.$data,
548
+ items: items,
549
+ });
550
+ currentCount += items.length;
551
+ }
552
+ else {
553
+ if (currentCount < maxCount) {
554
+ result.push(element);
555
+ currentCount++;
556
+ }
557
+ }
558
+ }
559
+ return result;
560
+ }
539
561
  }
540
562
 
541
563
  // Copyright (c) Microsoft Corporation.
@@ -1483,6 +1505,7 @@ class ManifestUpdater {
1483
1505
  const confirmationBodies = [];
1484
1506
  if (operationItem) {
1485
1507
  const operationId = operationItem.operationId;
1508
+ const safeFunctionName = operationId.replace(/[^a-zA-Z0-9]/g, "_");
1486
1509
  const description = (_a = operationItem.description) !== null && _a !== void 0 ? _a : "";
1487
1510
  const summary = operationItem.summary;
1488
1511
  const paramObject = operationItem.parameters;
@@ -1510,7 +1533,7 @@ class ManifestUpdater {
1510
1533
  }
1511
1534
  }
1512
1535
  const funcObj = {
1513
- name: operationId,
1536
+ name: safeFunctionName,
1514
1537
  description: description,
1515
1538
  };
1516
1539
  if (options.allowResponseSemantics) {
@@ -1518,7 +1541,7 @@ class ManifestUpdater {
1518
1541
  const { json } = Utils.getResponseJson(operationItem);
1519
1542
  if (json.schema) {
1520
1543
  const [card, jsonPath] = AdaptiveCardGenerator.generateAdaptiveCard(operationItem);
1521
- card.body = card.body.slice(0, 5);
1544
+ card.body = Utils.limitACBodyProperties(card.body, 5);
1522
1545
  const responseSemantic = wrapResponseSemantics(card, jsonPath);
1523
1546
  funcObj.capabilities = {
1524
1547
  response_semantics: responseSemantic,
@@ -1546,7 +1569,7 @@ class ManifestUpdater {
1546
1569
  }
1547
1570
  }
1548
1571
  functions.push(funcObj);
1549
- functionNames.push(operationId);
1572
+ functionNames.push(safeFunctionName);
1550
1573
  const conversationStarterStr = (summary !== null && summary !== void 0 ? summary : description).slice(0, ConstantString.ConversationStarterMaxLens);
1551
1574
  if (conversationStarterStr) {
1552
1575
  conversationStarters.push(conversationStarterStr);