@microsoft/m365-spec-parser 0.2.2-alpha.0b236986a.0 → 0.2.2-alpha.17924f754.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 +24 -15
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +44 -18
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +24 -15
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +44 -18
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/constants.d.ts +2 -0
- package/dist/src/interfaces.d.ts +1 -0
- package/dist/src/specParser.d.ts +1 -1
- package/package.json +3 -3
package/dist/index.node.cjs.js
CHANGED
|
@@ -100,6 +100,7 @@ exports.WarningType = void 0;
|
|
|
100
100
|
WarningType["GenerateCardFailed"] = "generate-card-failed";
|
|
101
101
|
WarningType["OperationOnlyContainsOptionalParam"] = "operation-only-contains-optional-param";
|
|
102
102
|
WarningType["ConvertSwaggerToOpenAPI"] = "convert-swagger-to-openapi";
|
|
103
|
+
WarningType["FuncDescriptionTooLong"] = "function-description-too-long";
|
|
103
104
|
WarningType["Unknown"] = "unknown";
|
|
104
105
|
})(exports.WarningType || (exports.WarningType = {}));
|
|
105
106
|
/**
|
|
@@ -138,6 +139,7 @@ ConstantString.SwaggerNotSupported = "Swagger 2.0 is not supported. Please conve
|
|
|
138
139
|
ConstantString.SpecVersionNotSupported = "Unsupported OpenAPI version %s. Please use version 3.0.x.";
|
|
139
140
|
ConstantString.MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
|
|
140
141
|
ConstantString.UnsupportedSchema = "Unsupported schema in %s %s: %s";
|
|
142
|
+
ConstantString.FuncDescriptionTooLong = "The description of the function '%s' is too long. The current length is %s characters, while the maximum allowed length is %s characters.";
|
|
141
143
|
ConstantString.WrappedCardVersion = "devPreview";
|
|
142
144
|
ConstantString.WrappedCardSchema = "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.ResponseRenderingTemplate.schema.json";
|
|
143
145
|
ConstantString.WrappedCardResponseLayout = "list";
|
|
@@ -217,6 +219,7 @@ ConstantString.ConversationStarterMaxLens = 50;
|
|
|
217
219
|
ConstantString.CommandTitleMaxLens = 32;
|
|
218
220
|
ConstantString.ParameterTitleMaxLens = 32;
|
|
219
221
|
ConstantString.SMERequiredParamsMaxNum = 5;
|
|
222
|
+
ConstantString.FunctionDescriptionMaxLens = 100;
|
|
220
223
|
ConstantString.DefaultPluginId = "plugin_1";
|
|
221
224
|
ConstantString.PluginManifestSchema = "https://aka.ms/json-schemas/copilot-extensions/v2.1/plugin.schema.json";
|
|
222
225
|
|
|
@@ -302,23 +305,28 @@ class Utils {
|
|
|
302
305
|
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
303
306
|
}
|
|
304
307
|
static getResponseJson(operationObject, allowMultipleMediaType = false) {
|
|
305
|
-
var _a
|
|
308
|
+
var _a;
|
|
306
309
|
let json = {};
|
|
307
310
|
let multipleMediaType = false;
|
|
308
311
|
for (const code of ConstantString.ResponseCodeFor20X) {
|
|
309
312
|
const responseObject = (_a = operationObject === null || operationObject === void 0 ? void 0 : operationObject.responses) === null || _a === void 0 ? void 0 : _a[code];
|
|
310
|
-
if (
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
313
|
+
if (responseObject === null || responseObject === void 0 ? void 0 : responseObject.content) {
|
|
314
|
+
for (const contentType of Object.keys(responseObject.content)) {
|
|
315
|
+
// json media type can also be "application/json; charset=utf-8"
|
|
316
|
+
if (contentType.indexOf("application/json") >= 0) {
|
|
317
|
+
multipleMediaType = false;
|
|
318
|
+
json = responseObject.content[contentType];
|
|
319
|
+
if (Utils.containMultipleMediaTypes(responseObject)) {
|
|
320
|
+
multipleMediaType = true;
|
|
321
|
+
if (!allowMultipleMediaType) {
|
|
322
|
+
json = {};
|
|
323
|
+
}
|
|
324
|
+
}
|
|
325
|
+
else {
|
|
326
|
+
return { json, multipleMediaType };
|
|
327
|
+
}
|
|
317
328
|
}
|
|
318
329
|
}
|
|
319
|
-
else {
|
|
320
|
-
break;
|
|
321
|
-
}
|
|
322
330
|
}
|
|
323
331
|
}
|
|
324
332
|
return { json, multipleMediaType };
|
|
@@ -592,10 +600,11 @@ class Utils {
|
|
|
592
600
|
currentCount += items.length;
|
|
593
601
|
}
|
|
594
602
|
else {
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
603
|
+
result.push(element);
|
|
604
|
+
currentCount++;
|
|
605
|
+
}
|
|
606
|
+
if (currentCount >= maxCount) {
|
|
607
|
+
break;
|
|
599
608
|
}
|
|
600
609
|
}
|
|
601
610
|
return result;
|
|
@@ -1732,9 +1741,18 @@ class ManifestUpdater {
|
|
|
1732
1741
|
throw new SpecParserError(Utils.format(ConstantString.UnsupportedSchema, method, pathUrl, JSON.stringify(requestBodySchema)), exports.ErrorType.UpdateManifestFailed);
|
|
1733
1742
|
}
|
|
1734
1743
|
}
|
|
1744
|
+
let funcDescription = operationItem.description || operationItem.summary || "";
|
|
1745
|
+
if (funcDescription.length > ConstantString.FunctionDescriptionMaxLens) {
|
|
1746
|
+
warnings.push({
|
|
1747
|
+
type: exports.WarningType.FuncDescriptionTooLong,
|
|
1748
|
+
content: Utils.format(ConstantString.FuncDescriptionTooLong, safeFunctionName, funcDescription.length.toString(), ConstantString.FunctionDescriptionMaxLens.toString()),
|
|
1749
|
+
data: safeFunctionName,
|
|
1750
|
+
});
|
|
1751
|
+
funcDescription = funcDescription.slice(0, ConstantString.FunctionDescriptionMaxLens);
|
|
1752
|
+
}
|
|
1735
1753
|
const funcObj = {
|
|
1736
1754
|
name: safeFunctionName,
|
|
1737
|
-
description:
|
|
1755
|
+
description: funcDescription,
|
|
1738
1756
|
};
|
|
1739
1757
|
if (options.allowResponseSemantics) {
|
|
1740
1758
|
try {
|
|
@@ -2188,7 +2206,7 @@ class SpecParser {
|
|
|
2188
2206
|
* @param outputSpecPath File path of the new OpenAPI specification file to generate. If not specified or empty, no spec file will be generated.
|
|
2189
2207
|
* @param pluginFilePath File path of the api plugin file to generate.
|
|
2190
2208
|
*/
|
|
2191
|
-
generateForCopilot(manifestPath, filter, outputSpecPath, pluginFilePath, signal) {
|
|
2209
|
+
generateForCopilot(manifestPath, filter, outputSpecPath, pluginFilePath, existingPluginFilePath, signal) {
|
|
2192
2210
|
return __awaiter(this, void 0, void 0, function* () {
|
|
2193
2211
|
const result = {
|
|
2194
2212
|
allSuccess: true,
|
|
@@ -2206,7 +2224,15 @@ class SpecParser {
|
|
|
2206
2224
|
const [updatedManifest, apiPlugin, warnings] = yield ManifestUpdater.updateManifestWithAiPlugin(manifestPath, outputSpecPath, pluginFilePath, newSpec, this.options, authInfo);
|
|
2207
2225
|
result.warnings.push(...warnings);
|
|
2208
2226
|
yield fs__default['default'].outputJSON(manifestPath, updatedManifest, { spaces: 4 });
|
|
2209
|
-
|
|
2227
|
+
if (existingPluginFilePath) {
|
|
2228
|
+
const originPluginManifest = (yield fs__default['default'].readJSON(existingPluginFilePath));
|
|
2229
|
+
// TODO (kiota): refactor to avoid generate apiPlugin
|
|
2230
|
+
originPluginManifest.functions = apiPlugin.functions;
|
|
2231
|
+
yield fs__default['default'].outputJSON(pluginFilePath, originPluginManifest, { spaces: 4 });
|
|
2232
|
+
}
|
|
2233
|
+
else {
|
|
2234
|
+
yield fs__default['default'].outputJSON(pluginFilePath, apiPlugin, { spaces: 4 });
|
|
2235
|
+
}
|
|
2210
2236
|
}
|
|
2211
2237
|
catch (err) {
|
|
2212
2238
|
if (err instanceof SpecParserError) {
|