Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@microsoft/m365-spec-parser

Package Overview
Dependencies
Maintainers
0
Versions
273
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@microsoft/m365-spec-parser - npm Package Compare versions

Comparing version 0.2.3-alpha.b8a9ab9fa.0 to 0.2.3-alpha.c3772a0e8.0

dist/src/jsonDataGenerator.d.ts

71

dist/index.esm2017.js

@@ -58,2 +58,4 @@ import SwaggerParser from '@apidevtools/swagger-parser';

WarningType["FuncDescriptionTooLong"] = "function-description-too-long";
WarningType["OperationIdContainsSpecialCharacters"] = "operationid-contains-special-characters";
WarningType["GenerateJsonDataFailed"] = "generate-json-data-failed";
WarningType["Unknown"] = "unknown";

@@ -104,4 +106,6 @@ })(WarningType || (WarningType = {}));

ConstantString.MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
ConstantString.OperationIdContainsSpecialCharacters = "Operation id '%s' in OpenAPI description document contained special characters and was renamed to '%s'.";
ConstantString.UnsupportedSchema = "Unsupported schema in %s %s: %s";
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.";
ConstantString.GenerateJsonDataFailed = "Failed to generate JSON data for api: %s due to %s.";
ConstantString.WrappedCardVersion = "devPreview";

@@ -548,25 +552,2 @@ ConstantString.WrappedCardSchema = "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.ResponseRenderingTemplate.schema.json";

}
static limitACBodyProperties(body, maxCount) {
const result = [];
let currentCount = 0;
for (const element of body) {
if (element.type === ConstantString.ContainerType) {
const items = this.limitACBodyProperties(element.items, maxCount - currentCount);
result.push({
type: ConstantString.ContainerType,
$data: element.$data,
items: items,
});
currentCount += items.length;
}
else {
result.push(element);
currentCount++;
}
if (currentCount >= maxCount) {
break;
}
}
return result;
}
}

@@ -1304,3 +1285,3 @@

class AdaptiveCardGenerator {
static generateAdaptiveCard(operationItem, allowMultipleMediaType = false) {
static generateAdaptiveCard(operationItem, allowMultipleMediaType = false, maxElementCount = Number.MAX_SAFE_INTEGER) {
try {

@@ -1316,3 +1297,3 @@ const { json } = Utils.getResponseJson(operationItem, allowMultipleMediaType);

}
cardBody = AdaptiveCardGenerator.generateCardFromResponse(schema, "");
cardBody = AdaptiveCardGenerator.generateCardFromResponse(schema, "", "", maxElementCount);
}

@@ -1351,6 +1332,10 @@ // if no schema, try to use example value

}
static generateCardFromResponse(schema, name, parentArrayName = "") {
static generateCardFromResponse(schema, name, parentArrayName = "", maxElementCount = Number.MAX_SAFE_INTEGER, counter = { count: 0 }) {
if (counter.count >= maxElementCount) {
return [];
}
if (schema.type === "array") {
// schema.items can be arbitrary object: schema { type: array, items: {} }
if (Object.keys(schema.items).length === 0) {
counter.count++;
return [

@@ -1364,3 +1349,3 @@ {

}
const obj = AdaptiveCardGenerator.generateCardFromResponse(schema.items, "", name);
const obj = AdaptiveCardGenerator.generateCardFromResponse(schema.items, "", name, maxElementCount, counter);
const template = {

@@ -1379,3 +1364,3 @@ type: ConstantString.ContainerType,

for (const property in properties) {
const obj = AdaptiveCardGenerator.generateCardFromResponse(properties[property], name ? `${name}.${property}` : property, parentArrayName);
const obj = AdaptiveCardGenerator.generateCardFromResponse(properties[property], name ? `${name}.${property}` : property, parentArrayName, maxElementCount, counter);
result.push(...obj);

@@ -1393,2 +1378,3 @@ }

schema.type === "number") {
counter.count++;
if (!AdaptiveCardGenerator.isImageUrlProperty(schema, name, parentArrayName)) {

@@ -1418,20 +1404,13 @@ // string in root: "ddd"

else {
if (name) {
return [
{
type: "Image",
url: `\${${name}}`,
$when: `\${${name} != null && ${name} != ''}`,
},
];
}
else {
return [
{
type: "Image",
url: "${$data}",
$when: "${$data != null && $data != ''}",
},
];
}
const url = name ? `\${${name}}` : "${$data}";
const condition = name
? `\${${name} != null && ${name} != ''}`
: "${$data != null && $data != ''}";
return [
{
type: "Image",
url,
$when: condition,
},
];
}

@@ -1438,0 +1417,0 @@ }

import { OpenAPIV3 } from "openapi-types";
import { AdaptiveCard, ArrayElement, ImageElement, TextBlockElement } from "./interfaces";
export declare class AdaptiveCardGenerator {
static generateAdaptiveCard(operationItem: OpenAPIV3.OperationObject, allowMultipleMediaType?: boolean): [AdaptiveCard, string];
static generateCardFromResponse(schema: OpenAPIV3.SchemaObject, name: string, parentArrayName?: string): Array<TextBlockElement | ImageElement | ArrayElement>;
static generateAdaptiveCard(operationItem: OpenAPIV3.OperationObject, allowMultipleMediaType?: boolean, maxElementCount?: number): [AdaptiveCard, string];
static generateCardFromResponse(schema: OpenAPIV3.SchemaObject, name: string, parentArrayName?: string, maxElementCount?: number, counter?: {
count: number;
}): Array<TextBlockElement | ImageElement | ArrayElement>;
static getResponseJsonPathFromSchema(schema: OpenAPIV3.SchemaObject): string;
static isImageUrlProperty(schema: OpenAPIV3.NonArraySchemaObject, name: string, parentArrayName: string): boolean;
}

@@ -18,4 +18,6 @@ export declare class ConstantString {

static readonly MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
static readonly OperationIdContainsSpecialCharacters = "Operation id '%s' in OpenAPI description document contained special characters and was renamed to '%s'.";
static readonly UnsupportedSchema = "Unsupported schema in %s %s: %s";
static readonly FuncDescriptionTooLong = "The description of the function '%s' is too long. The current length is %s characters, while the maximum allowed length is %s characters.";
static readonly GenerateJsonDataFailed = "Failed to generate JSON data for api: %s due to %s.";
static readonly WrappedCardVersion = "devPreview";

@@ -22,0 +24,0 @@ static readonly WrappedCardSchema = "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.ResponseRenderingTemplate.schema.json";

@@ -121,2 +121,4 @@ import { IParameter } from "@microsoft/teams-manifest";

FuncDescriptionTooLong = "function-description-too-long",
OperationIdContainsSpecialCharacters = "operationid-contains-special-characters",
GenerateJsonDataFailed = "generate-json-data-failed",
Unknown = "unknown"

@@ -123,0 +125,0 @@ }

import { OpenAPIV3 } from "openapi-types";
import { AdaptiveCardBody, AuthInfo, AuthType, ErrorResult, ParseOptions } from "./interfaces";
import { AuthInfo, AuthType, ErrorResult, ParseOptions } from "./interfaces";
import { IMessagingExtensionCommand, IParameter } from "@microsoft/teams-manifest";

@@ -30,3 +30,2 @@ export declare class Utils {

static getServerObject(spec: OpenAPIV3.Document, method: string, path: string): OpenAPIV3.ServerObject | undefined;
static limitACBodyProperties(body: AdaptiveCardBody, maxCount: number): AdaptiveCardBody;
}
{
"name": "@microsoft/m365-spec-parser",
"version": "0.2.3-alpha.b8a9ab9fa.0",
"version": "0.2.3-alpha.c3772a0e8.0",
"description": "OpenAPI specification files Parser for M365 Apps",

@@ -42,3 +42,3 @@ "main": "dist/index.node.cjs.js",

"@apidevtools/swagger-parser": "^10.1.0",
"@microsoft/teams-manifest": "0.1.7-alpha.b8a9ab9fa.0",
"@microsoft/teams-manifest": "0.1.7-alpha.c3772a0e8.0",
"fs-extra": "^11.2.0",

@@ -151,3 +151,3 @@ "js-yaml": "^4.1.0",

},
"gitHead": "fe578371091d35cbd65a10053cd9b77a1caeaaee"
"gitHead": "2bea3543923e5862a726522e1fee8e7170991c40"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc