@microsoft/m365-spec-parser 0.1.1-alpha.ae81527a9.0 → 0.1.1-alpha.b389a0e82.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.mjs
CHANGED
|
@@ -1389,39 +1389,20 @@ class ManifestUpdater {
|
|
|
1389
1389
|
full: (_b = ((_a = spec.info.description) !== null && _a !== void 0 ? _a : manifest.description.full)) === null || _b === void 0 ? void 0 : _b.slice(0, ConstantString.FullDescriptionMaxLens),
|
|
1390
1390
|
};
|
|
1391
1391
|
}
|
|
1392
|
-
static
|
|
1393
|
-
let parameter;
|
|
1392
|
+
static checkSchema(schema, method, pathUrl) {
|
|
1394
1393
|
if (schema.type === "array") {
|
|
1395
1394
|
const items = schema.items;
|
|
1396
|
-
|
|
1397
|
-
type: "array",
|
|
1398
|
-
items: ManifestUpdater.mapOpenAPISchemaToFuncParam(items, method, pathUrl),
|
|
1399
|
-
};
|
|
1395
|
+
ManifestUpdater.checkSchema(items, method, pathUrl);
|
|
1400
1396
|
}
|
|
1401
|
-
else if (schema.type
|
|
1402
|
-
schema.type
|
|
1403
|
-
schema.type
|
|
1404
|
-
schema.type
|
|
1405
|
-
parameter = {
|
|
1406
|
-
type: schema.type,
|
|
1407
|
-
};
|
|
1408
|
-
}
|
|
1409
|
-
else {
|
|
1397
|
+
else if (schema.type !== "string" &&
|
|
1398
|
+
schema.type !== "boolean" &&
|
|
1399
|
+
schema.type !== "integer" &&
|
|
1400
|
+
schema.type !== "number") {
|
|
1410
1401
|
throw new SpecParserError(Utils.format(ConstantString.UnsupportedSchema, method, pathUrl, JSON.stringify(schema)), ErrorType.UpdateManifestFailed);
|
|
1411
1402
|
}
|
|
1412
|
-
if (schema.enum) {
|
|
1413
|
-
parameter.enum = schema.enum;
|
|
1414
|
-
}
|
|
1415
|
-
if (schema.description) {
|
|
1416
|
-
parameter.description = schema.description;
|
|
1417
|
-
}
|
|
1418
|
-
if (schema.default) {
|
|
1419
|
-
parameter.default = schema.default;
|
|
1420
|
-
}
|
|
1421
|
-
return parameter;
|
|
1422
1403
|
}
|
|
1423
1404
|
static async generatePluginManifestSchema(spec, specRelativePath, apiPluginFilePath, appName, authInfo, options) {
|
|
1424
|
-
var _a, _b, _c, _d
|
|
1405
|
+
var _a, _b, _c, _d;
|
|
1425
1406
|
const functions = [];
|
|
1426
1407
|
const functionNames = [];
|
|
1427
1408
|
const conversationStarters = [];
|
|
@@ -1455,35 +1436,21 @@ class ManifestUpdater {
|
|
|
1455
1436
|
const summary = operationItem.summary;
|
|
1456
1437
|
const paramObject = operationItem.parameters;
|
|
1457
1438
|
const requestBody = operationItem.requestBody;
|
|
1458
|
-
const parameters = {
|
|
1459
|
-
type: "object",
|
|
1460
|
-
properties: {},
|
|
1461
|
-
required: [],
|
|
1462
|
-
};
|
|
1463
1439
|
if (paramObject) {
|
|
1464
1440
|
for (let i = 0; i < paramObject.length; i++) {
|
|
1465
1441
|
const param = paramObject[i];
|
|
1466
1442
|
const schema = param.schema;
|
|
1467
|
-
|
|
1443
|
+
ManifestUpdater.checkSchema(schema, method, pathUrl);
|
|
1468
1444
|
confirmationBodies.push(ManifestUpdater.getConfirmationBodyItem(param.name));
|
|
1469
|
-
if (param.required) {
|
|
1470
|
-
parameters.required.push(param.name);
|
|
1471
|
-
}
|
|
1472
|
-
if (!parameters.properties[param.name].description) {
|
|
1473
|
-
parameters.properties[param.name].description = (_b = param.description) !== null && _b !== void 0 ? _b : "";
|
|
1474
|
-
}
|
|
1475
1445
|
}
|
|
1476
1446
|
}
|
|
1477
1447
|
if (requestBody) {
|
|
1478
1448
|
const requestJsonBody = requestBody.content["application/json"];
|
|
1479
1449
|
const requestBodySchema = requestJsonBody.schema;
|
|
1480
1450
|
if (requestBodySchema.type === "object") {
|
|
1481
|
-
if (requestBodySchema.required) {
|
|
1482
|
-
parameters.required.push(...requestBodySchema.required);
|
|
1483
|
-
}
|
|
1484
1451
|
for (const property in requestBodySchema.properties) {
|
|
1485
1452
|
const schema = requestBodySchema.properties[property];
|
|
1486
|
-
|
|
1453
|
+
ManifestUpdater.checkSchema(schema, method, pathUrl);
|
|
1487
1454
|
confirmationBodies.push(ManifestUpdater.getConfirmationBodyItem(property));
|
|
1488
1455
|
}
|
|
1489
1456
|
}
|
|
@@ -1495,9 +1462,6 @@ class ManifestUpdater {
|
|
|
1495
1462
|
name: operationId,
|
|
1496
1463
|
description: description,
|
|
1497
1464
|
};
|
|
1498
|
-
if (paramObject || requestBody) {
|
|
1499
|
-
funcObj.parameters = parameters;
|
|
1500
|
-
}
|
|
1501
1465
|
if (options.allowResponseSemantics) {
|
|
1502
1466
|
const { json } = Utils.getResponseJson(operationItem);
|
|
1503
1467
|
if (json.schema) {
|
|
@@ -1514,7 +1478,7 @@ class ManifestUpdater {
|
|
|
1514
1478
|
}
|
|
1515
1479
|
funcObj.capabilities.confirmation = {
|
|
1516
1480
|
type: "AdaptiveCard",
|
|
1517
|
-
title: (
|
|
1481
|
+
title: (_b = operationItem.summary) !== null && _b !== void 0 ? _b : description,
|
|
1518
1482
|
};
|
|
1519
1483
|
if (confirmationBodies.length > 0) {
|
|
1520
1484
|
funcObj.capabilities.confirmation.body = confirmationBodies.join("\n");
|
|
@@ -1547,7 +1511,7 @@ class ManifestUpdater {
|
|
|
1547
1511
|
}
|
|
1548
1512
|
apiPlugin.functions = apiPlugin.functions || [];
|
|
1549
1513
|
for (const func of functions) {
|
|
1550
|
-
const index = (
|
|
1514
|
+
const index = (_c = apiPlugin.functions) === null || _c === void 0 ? void 0 : _c.findIndex((f) => f.name === func.name);
|
|
1551
1515
|
if (index === -1) {
|
|
1552
1516
|
apiPlugin.functions.push(func);
|
|
1553
1517
|
}
|
|
@@ -1583,7 +1547,7 @@ class ManifestUpdater {
|
|
|
1583
1547
|
}
|
|
1584
1548
|
if (!apiPlugin.description_for_human) {
|
|
1585
1549
|
apiPlugin.description_for_human =
|
|
1586
|
-
(
|
|
1550
|
+
(_d = spec.info.description) !== null && _d !== void 0 ? _d : "<Please add description of the plugin>";
|
|
1587
1551
|
}
|
|
1588
1552
|
if (options.allowConversationStarters && conversationStarters.length > 0) {
|
|
1589
1553
|
if (!apiPlugin.capabilities) {
|