@microsoft/m365-spec-parser 0.2.3 → 0.2.4-alpha.a2c09e877.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 +339 -253
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +462 -328
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +339 -253
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +462 -328
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/adaptiveCardGenerator.d.ts +5 -3
- package/dist/src/constants.d.ts +5 -4
- package/dist/src/interfaces.d.ts +12 -3
- package/dist/src/jsonDataGenerator.d.ts +6 -0
- package/dist/src/manifestUpdater.d.ts +3 -3
- package/dist/src/utils.d.ts +6 -4
- package/package.json +3 -3
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
-
import { AdaptiveCard, ArrayElement, ImageElement, TextBlockElement } from "./interfaces";
|
|
2
|
+
import { AdaptiveCard, ArrayElement, ImageElement, TextBlockElement, WarningResult } from "./interfaces";
|
|
3
3
|
export declare class AdaptiveCardGenerator {
|
|
4
|
-
static generateAdaptiveCard(operationItem: OpenAPIV3.OperationObject, allowMultipleMediaType?: boolean): [AdaptiveCard, string];
|
|
5
|
-
static generateCardFromResponse(schema: OpenAPIV3.SchemaObject, name: string, parentArrayName?: string
|
|
4
|
+
static generateAdaptiveCard(operationItem: OpenAPIV3.OperationObject, allowMultipleMediaType?: boolean, maxElementCount?: number): [AdaptiveCard, string, any, WarningResult[]];
|
|
5
|
+
static generateCardFromResponse(schema: OpenAPIV3.SchemaObject, name: string, parentArrayName?: string, maxElementCount?: number, counter?: {
|
|
6
|
+
count: number;
|
|
7
|
+
}): Array<TextBlockElement | ImageElement | ArrayElement>;
|
|
6
8
|
static getResponseJsonPathFromSchema(schema: OpenAPIV3.SchemaObject): string;
|
|
7
9
|
static isImageUrlProperty(schema: OpenAPIV3.NonArraySchemaObject, name: string, parentArrayName: string): boolean;
|
|
8
10
|
}
|
package/dist/src/constants.d.ts
CHANGED
|
@@ -15,22 +15,23 @@ export declare class ConstantString {
|
|
|
15
15
|
static readonly SwaggerNotSupported = "Swagger 2.0 is not supported. Please convert to OpenAPI 3.0 manually before proceeding.";
|
|
16
16
|
static readonly SpecVersionNotSupported = "Unsupported OpenAPI version %s. Please use version 3.0.x.";
|
|
17
17
|
static readonly MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
|
|
18
|
+
static readonly OperationIdContainsSpecialCharacters = "Operation id '%s' in OpenAPI description document contained special characters and was renamed to '%s'.";
|
|
19
|
+
static readonly AuthTypeIsNotSupported = "Unsupported authorization type in API '%s'. No authorization will be used.";
|
|
18
20
|
static readonly UnsupportedSchema = "Unsupported schema in %s %s: %s";
|
|
19
21
|
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.";
|
|
22
|
+
static readonly GenerateJsonDataFailed = "Failed to generate JSON data for api: %s due to %s.";
|
|
20
23
|
static readonly WrappedCardVersion = "devPreview";
|
|
21
24
|
static readonly WrappedCardSchema = "https://developer.microsoft.com/json-schemas/teams/vDevPreview/MicrosoftTeams.ResponseRenderingTemplate.schema.json";
|
|
22
25
|
static readonly WrappedCardResponseLayout = "list";
|
|
23
26
|
static readonly GetMethod = "get";
|
|
24
27
|
static readonly PostMethod = "post";
|
|
25
28
|
static readonly AdaptiveCardVersion = "1.5";
|
|
26
|
-
static readonly AdaptiveCardSchema = "
|
|
29
|
+
static readonly AdaptiveCardSchema = "https://adaptivecards.io/schemas/adaptive-card.json";
|
|
27
30
|
static readonly AdaptiveCardType = "AdaptiveCard";
|
|
28
31
|
static readonly TextBlockType = "TextBlock";
|
|
29
32
|
static readonly ImageType = "Image";
|
|
30
33
|
static readonly ContainerType = "Container";
|
|
31
|
-
static readonly RegistrationIdPostfix
|
|
32
|
-
[key: string]: string;
|
|
33
|
-
};
|
|
34
|
+
static readonly RegistrationIdPostfix = "REGISTRATION_ID";
|
|
34
35
|
static readonly ResponseCodeFor20X: string[];
|
|
35
36
|
static readonly AllOperationMethods: string[];
|
|
36
37
|
static readonly WellknownResultNames: string[];
|
package/dist/src/interfaces.d.ts
CHANGED
|
@@ -96,11 +96,8 @@ export declare enum ErrorType {
|
|
|
96
96
|
PostBodyContainMultipleMediaTypes = "post-body-contain-multiple-media-types",
|
|
97
97
|
ResponseContainMultipleMediaTypes = "response-contain-multiple-media-types",
|
|
98
98
|
ResponseJsonIsEmpty = "response-json-is-empty",
|
|
99
|
-
PostBodySchemaIsNotJson = "post-body-schema-is-not-json",
|
|
100
99
|
PostBodyContainsRequiredUnsupportedSchema = "post-body-contains-required-unsupported-schema",
|
|
101
100
|
ParamsContainRequiredUnsupportedSchema = "params-contain-required-unsupported-schema",
|
|
102
|
-
ParamsContainsNestedObject = "params-contains-nested-object",
|
|
103
|
-
RequestBodyContainsNestedObject = "request-body-contains-nested-object",
|
|
104
101
|
ExceededRequiredParamsLimit = "exceeded-required-params-limit",
|
|
105
102
|
NoParameter = "no-parameter",
|
|
106
103
|
NoAPIInfo = "no-api-info",
|
|
@@ -118,6 +115,9 @@ export declare enum WarningType {
|
|
|
118
115
|
OperationOnlyContainsOptionalParam = "operation-only-contains-optional-param",
|
|
119
116
|
ConvertSwaggerToOpenAPI = "convert-swagger-to-openapi",
|
|
120
117
|
FuncDescriptionTooLong = "function-description-too-long",
|
|
118
|
+
OperationIdContainsSpecialCharacters = "operationid-contains-special-characters",
|
|
119
|
+
UnsupportedAuthType = "unsupported-auth-type",
|
|
120
|
+
GenerateJsonDataFailed = "generate-json-data-failed",
|
|
121
121
|
Unknown = "unknown"
|
|
122
122
|
}
|
|
123
123
|
/**
|
|
@@ -282,3 +282,12 @@ export interface ExistingPluginManifestInfo {
|
|
|
282
282
|
manifestPath: string;
|
|
283
283
|
specPath: string;
|
|
284
284
|
}
|
|
285
|
+
export interface OperationAuthInfoMap {
|
|
286
|
+
[operationId: string]: AuthInfo;
|
|
287
|
+
}
|
|
288
|
+
export interface FunctionClassificationMap {
|
|
289
|
+
[authType: string]: {
|
|
290
|
+
functionNames: string[];
|
|
291
|
+
authName: string;
|
|
292
|
+
};
|
|
293
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
-
import { AuthInfo, ExistingPluginManifestInfo, ParseOptions, WarningResult } from "./interfaces";
|
|
2
|
+
import { AuthInfo, ExistingPluginManifestInfo, OperationAuthInfoMap, ParseOptions, WarningResult } from "./interfaces";
|
|
3
3
|
import { IMessagingExtensionCommand, TeamsAppManifest, PluginManifestSchema } from "@microsoft/teams-manifest";
|
|
4
4
|
export declare class ManifestUpdater {
|
|
5
|
-
static updateManifestWithAiPlugin(manifestPath: string, outputSpecPath: string, apiPluginFilePath: string, spec: OpenAPIV3.Document, options: ParseOptions,
|
|
5
|
+
static updateManifestWithAiPlugin(manifestPath: string, outputSpecPath: string, apiPluginFilePath: string, spec: OpenAPIV3.Document, options: ParseOptions, authMap: OperationAuthInfoMap, existingPluginManifestInfo?: ExistingPluginManifestInfo): Promise<[TeamsAppManifest, PluginManifestSchema, WarningResult[]]>;
|
|
6
6
|
static updateManifestDescription(manifest: TeamsAppManifest, spec: OpenAPIV3.Document): void;
|
|
7
7
|
static checkSchema(schema: OpenAPIV3.SchemaObject, method: string, pathUrl: string): void;
|
|
8
|
-
static generatePluginManifestSchema(spec: OpenAPIV3.Document, specRelativePath: string, apiPluginFilePath: string, appName: string,
|
|
8
|
+
static generatePluginManifestSchema(spec: OpenAPIV3.Document, specRelativePath: string, apiPluginFilePath: string, appName: string, authMap: OperationAuthInfoMap, options: ParseOptions, existingPluginManifestInfo?: ExistingPluginManifestInfo): Promise<[PluginManifestSchema, WarningResult[]]>;
|
|
9
9
|
static updateManifest(manifestPath: string, outputSpecPath: string, spec: OpenAPIV3.Document, options: ParseOptions, adaptiveCardFolder?: string, authInfo?: AuthInfo): Promise<[TeamsAppManifest, WarningResult[]]>;
|
|
10
10
|
static generateCommands(spec: OpenAPIV3.Document, manifestPath: string, options: ParseOptions, adaptiveCardFolder?: string): Promise<[IMessagingExtensionCommand[], WarningResult[]]>;
|
|
11
11
|
static getRelativePath(from: string, to: string): string;
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,23 +1,26 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
-
import {
|
|
2
|
+
import { AuthInfo, AuthType, ErrorResult, OperationAuthInfoMap, ParseOptions } from "./interfaces";
|
|
3
3
|
import { IMessagingExtensionCommand, IParameter } from "@microsoft/teams-manifest";
|
|
4
4
|
export declare class Utils {
|
|
5
|
-
static
|
|
5
|
+
static isObjectSchema(schema: OpenAPIV3.SchemaObject): boolean;
|
|
6
6
|
static containMultipleMediaTypes(bodyObject: OpenAPIV3.RequestBodyObject | OpenAPIV3.ResponseObject): boolean;
|
|
7
7
|
static isBearerTokenAuth(authScheme: AuthType): boolean;
|
|
8
8
|
static isAPIKeyAuth(authScheme: AuthType): boolean;
|
|
9
9
|
static isOAuthWithAuthCodeFlow(authScheme: AuthType): boolean;
|
|
10
|
+
static isNotSupportedAuth(authSchemeArray: AuthInfo[][]): boolean;
|
|
10
11
|
static getAuthArray(securities: OpenAPIV3.SecurityRequirementObject[] | undefined, spec: OpenAPIV3.Document): AuthInfo[][];
|
|
12
|
+
static getAuthMap(spec: OpenAPIV3.Document): OperationAuthInfoMap;
|
|
11
13
|
static getAuthInfo(spec: OpenAPIV3.Document): AuthInfo | undefined;
|
|
12
14
|
static updateFirstLetter(str: string): string;
|
|
13
15
|
static getResponseJson(operationObject: OpenAPIV3.OperationObject | undefined, allowMultipleMediaType?: boolean): {
|
|
14
16
|
json: OpenAPIV3.MediaTypeObject;
|
|
15
17
|
multipleMediaType: boolean;
|
|
16
18
|
};
|
|
19
|
+
static getJsonContentType(responseObject: OpenAPIV3.ResponseObject | OpenAPIV3.RequestBodyObject): OpenAPIV3.MediaTypeObject;
|
|
17
20
|
static convertPathToCamelCase(path: string): string;
|
|
18
21
|
static getUrlProtocol(urlString: string): string | undefined;
|
|
19
22
|
static resolveEnv(str: string): string;
|
|
20
|
-
static checkServerUrl(servers: OpenAPIV3.ServerObject[]): ErrorResult[];
|
|
23
|
+
static checkServerUrl(servers: OpenAPIV3.ServerObject[], allowHttp?: boolean): ErrorResult[];
|
|
21
24
|
static validateServer(spec: OpenAPIV3.Document, options: ParseOptions): ErrorResult[];
|
|
22
25
|
static isWellKnownName(name: string, wellknownNameList: string[]): boolean;
|
|
23
26
|
static generateParametersFromSchema(schema: OpenAPIV3.SchemaObject, name: string, allowMultipleParameters: boolean, isRequired?: boolean): [IParameter[], IParameter[]];
|
|
@@ -26,5 +29,4 @@ export declare class Utils {
|
|
|
26
29
|
static format(str: string, ...args: string[]): string;
|
|
27
30
|
static getSafeRegistrationIdEnvName(authName: string): string;
|
|
28
31
|
static getServerObject(spec: OpenAPIV3.Document, method: string, path: string): OpenAPIV3.ServerObject | undefined;
|
|
29
|
-
static limitACBodyProperties(body: AdaptiveCardBody, maxCount: number): AdaptiveCardBody;
|
|
30
32
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/m365-spec-parser",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4-alpha.a2c09e877.0",
|
|
4
4
|
"description": "OpenAPI specification files Parser for M365 Apps",
|
|
5
5
|
"main": "dist/index.node.cjs.js",
|
|
6
6
|
"browser": "dist/index.esm2017.js",
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"sideEffects": false,
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@apidevtools/swagger-parser": "^10.1.0",
|
|
42
|
-
"@microsoft/teams-manifest": "0.1.
|
|
42
|
+
"@microsoft/teams-manifest": "0.1.8-alpha.a2c09e877.0",
|
|
43
43
|
"fs-extra": "^11.2.0",
|
|
44
44
|
"js-yaml": "^4.1.0",
|
|
45
45
|
"openapi-types": "^7.2.3",
|
|
@@ -147,5 +147,5 @@
|
|
|
147
147
|
"npx eslint --cache --fix --quiet"
|
|
148
148
|
]
|
|
149
149
|
},
|
|
150
|
-
"gitHead": "
|
|
150
|
+
"gitHead": "079d81eaeb33e9e3de17346d12b2894cb158b89a"
|
|
151
151
|
}
|