@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.node.cjs.js
CHANGED
|
@@ -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:
|
|
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
|
|
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(
|
|
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);
|
|
@@ -1929,19 +1952,36 @@ class SpecParser {
|
|
|
1929
1952
|
isValid: isValid,
|
|
1930
1953
|
reason: reason,
|
|
1931
1954
|
};
|
|
1932
|
-
|
|
1955
|
+
// Try best to parse server url and auth type
|
|
1956
|
+
try {
|
|
1933
1957
|
const serverObj = Utils.getServerObject(spec, method.toLocaleLowerCase(), path);
|
|
1934
1958
|
if (serverObj) {
|
|
1935
1959
|
apiResult.server = serverObj.url;
|
|
1936
1960
|
}
|
|
1961
|
+
}
|
|
1962
|
+
catch (err) {
|
|
1963
|
+
// ignore
|
|
1964
|
+
}
|
|
1965
|
+
try {
|
|
1937
1966
|
const authArray = Utils.getAuthArray(operation.security, spec);
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1967
|
+
if (authArray.length !== 0) {
|
|
1968
|
+
for (const auths of authArray) {
|
|
1969
|
+
if (auths.length === 1) {
|
|
1970
|
+
apiResult.auth = auths[0];
|
|
1971
|
+
break;
|
|
1972
|
+
}
|
|
1973
|
+
else {
|
|
1974
|
+
apiResult.auth = {
|
|
1975
|
+
authScheme: { type: "multipleAuth" },
|
|
1976
|
+
name: auths.map((auth) => auth.name).join(", "),
|
|
1977
|
+
};
|
|
1978
|
+
}
|
|
1942
1979
|
}
|
|
1943
1980
|
}
|
|
1944
1981
|
}
|
|
1982
|
+
catch (err) {
|
|
1983
|
+
// ignore
|
|
1984
|
+
}
|
|
1945
1985
|
result.APIs.push(apiResult);
|
|
1946
1986
|
}
|
|
1947
1987
|
result.allAPICount = result.APIs.length;
|
|
@@ -2052,10 +2092,11 @@ class SpecParser {
|
|
|
2052
2092
|
const operation = newSpec.paths[url][method];
|
|
2053
2093
|
try {
|
|
2054
2094
|
const [card, jsonPath] = AdaptiveCardGenerator.generateAdaptiveCard(operation);
|
|
2055
|
-
const
|
|
2095
|
+
const safeAdaptiveCardName = operation.operationId.replace(/[^a-zA-Z0-9]/g, "_");
|
|
2096
|
+
const fileName = path__default['default'].join(adaptiveCardFolder, `${safeAdaptiveCardName}.json`);
|
|
2056
2097
|
const wrappedCard = wrapAdaptiveCard(card, jsonPath);
|
|
2057
2098
|
yield fs__default['default'].outputJSON(fileName, wrappedCard, { spaces: 2 });
|
|
2058
|
-
const dataFileName = path__default['default'].join(adaptiveCardFolder, `${
|
|
2099
|
+
const dataFileName = path__default['default'].join(adaptiveCardFolder, `${safeAdaptiveCardName}.data.json`);
|
|
2059
2100
|
yield fs__default['default'].outputJSON(dataFileName, {}, { spaces: 2 });
|
|
2060
2101
|
}
|
|
2061
2102
|
catch (err) {
|