@microsoft/m365-spec-parser 0.2.2-alpha.6e69e41c0.0 → 0.2.2-alpha.ca8431921.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.
- package/dist/index.esm2017.js +22 -0
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +51 -10
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +22 -0
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +51 -10
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/interfaces.d.ts +7 -3
- package/dist/src/utils.d.ts +5 -4
- package/package.json +3 -3
package/dist/index.esm2017.mjs
CHANGED
|
@@ -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:
|
|
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
|
|
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(
|
|
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);
|
|
@@ -1874,19 +1897,36 @@ class SpecParser {
|
|
|
1874
1897
|
isValid: isValid,
|
|
1875
1898
|
reason: reason,
|
|
1876
1899
|
};
|
|
1877
|
-
|
|
1900
|
+
// Try best to parse server url and auth type
|
|
1901
|
+
try {
|
|
1878
1902
|
const serverObj = Utils.getServerObject(spec, method.toLocaleLowerCase(), path);
|
|
1879
1903
|
if (serverObj) {
|
|
1880
1904
|
apiResult.server = serverObj.url;
|
|
1881
1905
|
}
|
|
1906
|
+
}
|
|
1907
|
+
catch (err) {
|
|
1908
|
+
// ignore
|
|
1909
|
+
}
|
|
1910
|
+
try {
|
|
1882
1911
|
const authArray = Utils.getAuthArray(operation.security, spec);
|
|
1883
|
-
|
|
1884
|
-
|
|
1885
|
-
|
|
1886
|
-
|
|
1912
|
+
if (authArray.length !== 0) {
|
|
1913
|
+
for (const auths of authArray) {
|
|
1914
|
+
if (auths.length === 1) {
|
|
1915
|
+
apiResult.auth = auths[0];
|
|
1916
|
+
break;
|
|
1917
|
+
}
|
|
1918
|
+
else {
|
|
1919
|
+
apiResult.auth = {
|
|
1920
|
+
authScheme: { type: "multipleAuth" },
|
|
1921
|
+
name: auths.map((auth) => auth.name).join(", "),
|
|
1922
|
+
};
|
|
1923
|
+
}
|
|
1887
1924
|
}
|
|
1888
1925
|
}
|
|
1889
1926
|
}
|
|
1927
|
+
catch (err) {
|
|
1928
|
+
// ignore
|
|
1929
|
+
}
|
|
1890
1930
|
result.APIs.push(apiResult);
|
|
1891
1931
|
}
|
|
1892
1932
|
result.allAPICount = result.APIs.length;
|
|
@@ -1991,10 +2031,11 @@ class SpecParser {
|
|
|
1991
2031
|
const operation = newSpec.paths[url][method];
|
|
1992
2032
|
try {
|
|
1993
2033
|
const [card, jsonPath] = AdaptiveCardGenerator.generateAdaptiveCard(operation);
|
|
1994
|
-
const
|
|
2034
|
+
const safeAdaptiveCardName = operation.operationId.replace(/[^a-zA-Z0-9]/g, "_");
|
|
2035
|
+
const fileName = path.join(adaptiveCardFolder, `${safeAdaptiveCardName}.json`);
|
|
1995
2036
|
const wrappedCard = wrapAdaptiveCard(card, jsonPath);
|
|
1996
2037
|
await fs.outputJSON(fileName, wrappedCard, { spaces: 2 });
|
|
1997
|
-
const dataFileName = path.join(adaptiveCardFolder, `${
|
|
2038
|
+
const dataFileName = path.join(adaptiveCardFolder, `${safeAdaptiveCardName}.data.json`);
|
|
1998
2039
|
await fs.outputJSON(dataFileName, {}, { spaces: 2 });
|
|
1999
2040
|
}
|
|
2000
2041
|
catch (err) {
|