@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.
@@ -578,6 +578,28 @@ class Utils {
578
578
  const serverUrl = operationServer || methodServer || rootServer;
579
579
  return serverUrl;
580
580
  }
581
+ static limitACBodyProperties(body, maxCount) {
582
+ const result = [];
583
+ let currentCount = 0;
584
+ for (const element of body) {
585
+ if (element.type === ConstantString.ContainerType) {
586
+ const items = this.limitACBodyProperties(element.items, maxCount - currentCount);
587
+ result.push({
588
+ type: ConstantString.ContainerType,
589
+ $data: element.$data,
590
+ items: items,
591
+ });
592
+ currentCount += items.length;
593
+ }
594
+ else {
595
+ if (currentCount < maxCount) {
596
+ result.push(element);
597
+ currentCount++;
598
+ }
599
+ }
600
+ }
601
+ return result;
602
+ }
581
603
  }
582
604
 
583
605
  // Copyright (c) Microsoft Corporation.
@@ -1528,6 +1550,7 @@ class ManifestUpdater {
1528
1550
  const confirmationBodies = [];
1529
1551
  if (operationItem) {
1530
1552
  const operationId = operationItem.operationId;
1553
+ const safeFunctionName = operationId.replace(/[^a-zA-Z0-9]/g, "_");
1531
1554
  const description = (_a = operationItem.description) !== null && _a !== void 0 ? _a : "";
1532
1555
  const summary = operationItem.summary;
1533
1556
  const paramObject = operationItem.parameters;
@@ -1555,7 +1578,7 @@ class ManifestUpdater {
1555
1578
  }
1556
1579
  }
1557
1580
  const funcObj = {
1558
- name: operationId,
1581
+ name: safeFunctionName,
1559
1582
  description: description,
1560
1583
  };
1561
1584
  if (options.allowResponseSemantics) {
@@ -1563,7 +1586,7 @@ class ManifestUpdater {
1563
1586
  const { json } = Utils.getResponseJson(operationItem);
1564
1587
  if (json.schema) {
1565
1588
  const [card, jsonPath] = AdaptiveCardGenerator.generateAdaptiveCard(operationItem);
1566
- card.body = card.body.slice(0, 5);
1589
+ card.body = Utils.limitACBodyProperties(card.body, 5);
1567
1590
  const responseSemantic = wrapResponseSemantics(card, jsonPath);
1568
1591
  funcObj.capabilities = {
1569
1592
  response_semantics: responseSemantic,
@@ -1591,7 +1614,7 @@ class ManifestUpdater {
1591
1614
  }
1592
1615
  }
1593
1616
  functions.push(funcObj);
1594
- functionNames.push(operationId);
1617
+ functionNames.push(safeFunctionName);
1595
1618
  const conversationStarterStr = (summary !== null && summary !== void 0 ? summary : description).slice(0, ConstantString.ConversationStarterMaxLens);
1596
1619
  if (conversationStarterStr) {
1597
1620
  conversationStarters.push(conversationStarterStr);