@microsoft/m365-spec-parser 0.1.1-alpha.8d8f5a0bb.0 → 0.1.1-alpha.a372ccf67.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 +75 -51
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +143 -110
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +75 -51
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +142 -109
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/constants.d.ts +3 -1
- package/dist/src/index.browser.d.ts +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/interfaces.d.ts +31 -3
- package/dist/src/manifestUpdater.d.ts +5 -5
- package/dist/src/specFilter.d.ts +2 -1
- package/dist/src/specParser.browser.d.ts +1 -1
- package/dist/src/specParser.d.ts +1 -2
- package/dist/src/utils.d.ts +11 -10
- package/package.json +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { SpecParser } from "./specParser.browser";
|
|
2
2
|
export { SpecParserError } from "./specParserError";
|
|
3
3
|
export { ValidationStatus, WarningType, ErrorType, ListAPIResult } from "./interfaces";
|
|
4
|
-
export type { ErrorResult, APIInfo, ValidateResult, WarningResult, ParseOptions, AdaptiveCard, } from "./interfaces";
|
|
4
|
+
export type { ErrorResult, APIInfo, ValidateResult, WarningResult, ParseOptions, AdaptiveCard, ProjectType, } from "./interfaces";
|
|
5
5
|
export { ConstantString } from "./constants";
|
|
6
6
|
export { Utils } from "./utils";
|
|
7
7
|
export { AdaptiveCardGenerator } from "./adaptiveCardGenerator";
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { SpecParser } from "./specParser";
|
|
2
2
|
export { SpecParserError } from "./specParserError";
|
|
3
|
-
export { ValidationStatus, WarningType, ErrorType, WarningResult, ErrorResult, ListAPIResult, APIInfo, ValidateResult, ParseOptions, AdaptiveCard, } from "./interfaces";
|
|
3
|
+
export { ValidationStatus, WarningType, ErrorType, WarningResult, ErrorResult, ListAPIResult, APIInfo, ValidateResult, ParseOptions, AdaptiveCard, ProjectType, } from "./interfaces";
|
|
4
4
|
export { ConstantString } from "./constants";
|
|
5
5
|
export { Utils } from "./utils";
|
|
6
6
|
export { AdaptiveCardGenerator } from "./adaptiveCardGenerator";
|
package/dist/src/interfaces.d.ts
CHANGED
|
@@ -67,7 +67,7 @@ export declare enum ErrorType {
|
|
|
67
67
|
NoExtraAPICanBeAdded = "no-extra-api-can-be-added",
|
|
68
68
|
ResolveServerUrlFailed = "resolve-server-url-failed",
|
|
69
69
|
SwaggerNotSupported = "swagger-not-supported",
|
|
70
|
-
|
|
70
|
+
MultipleAuthNotSupported = "multiple-auth-not-supported",
|
|
71
71
|
ListFailed = "list-failed",
|
|
72
72
|
listSupportedAPIInfoFailed = "list-supported-api-info-failed",
|
|
73
73
|
FilterSpecFailed = "filter-spec-failed",
|
|
@@ -153,12 +153,40 @@ export interface CheckParamResult {
|
|
|
153
153
|
isValid: boolean;
|
|
154
154
|
}
|
|
155
155
|
export interface ParseOptions {
|
|
156
|
+
/**
|
|
157
|
+
* If true, the parser will not throw an error if an ID is missing the spec file.
|
|
158
|
+
*/
|
|
156
159
|
allowMissingId?: boolean;
|
|
160
|
+
/**
|
|
161
|
+
* If true, the parser will allow parsing of Swagger specifications.
|
|
162
|
+
*/
|
|
157
163
|
allowSwagger?: boolean;
|
|
164
|
+
/**
|
|
165
|
+
* If true, the parser will allow API Key authentication in the spec file.
|
|
166
|
+
*/
|
|
158
167
|
allowAPIKeyAuth?: boolean;
|
|
168
|
+
/**
|
|
169
|
+
* If true, the parser will allow multiple parameters in the spec file. Teams AI project would ignore this parameters and always true
|
|
170
|
+
*/
|
|
159
171
|
allowMultipleParameters?: boolean;
|
|
172
|
+
/**
|
|
173
|
+
* If true, the parser will allow OAuth2 authentication in the spec file. Currently only support OAuth2 with auth code flow.
|
|
174
|
+
*/
|
|
160
175
|
allowOauth2?: boolean;
|
|
161
|
-
|
|
176
|
+
/**
|
|
177
|
+
* An array of HTTP methods that the parser will allow in the spec file.
|
|
178
|
+
*/
|
|
179
|
+
allowMethods?: string[];
|
|
180
|
+
/**
|
|
181
|
+
* The type of project that the parser is being used for.
|
|
182
|
+
* Project can be SME/Copilot/TeamsAi
|
|
183
|
+
*/
|
|
184
|
+
projectType?: ProjectType;
|
|
185
|
+
}
|
|
186
|
+
export declare enum ProjectType {
|
|
187
|
+
Copilot = 0,
|
|
188
|
+
SME = 1,
|
|
189
|
+
TeamsAi = 2
|
|
162
190
|
}
|
|
163
191
|
export interface APIInfo {
|
|
164
192
|
method: string;
|
|
@@ -175,7 +203,7 @@ export interface ListAPIResult {
|
|
|
175
203
|
operationId: string;
|
|
176
204
|
auth?: OpenAPIV3.SecuritySchemeObject;
|
|
177
205
|
}
|
|
178
|
-
export interface
|
|
206
|
+
export interface AuthInfo {
|
|
179
207
|
authSchema: OpenAPIV3.SecuritySchemeObject;
|
|
180
208
|
name: string;
|
|
181
209
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
-
import { WarningResult } from "./interfaces";
|
|
2
|
+
import { AuthInfo, ParseOptions, WarningResult } from "./interfaces";
|
|
3
3
|
import { IMessagingExtensionCommand, TeamsAppManifest, PluginManifestSchema, FunctionParameter } from "@microsoft/teams-manifest";
|
|
4
4
|
export declare class ManifestUpdater {
|
|
5
|
-
static updateManifestWithAiPlugin(manifestPath: string, outputSpecPath: string, apiPluginFilePath: string, spec: OpenAPIV3.Document): Promise<[TeamsAppManifest, PluginManifestSchema]>;
|
|
5
|
+
static updateManifestWithAiPlugin(manifestPath: string, outputSpecPath: string, apiPluginFilePath: string, spec: OpenAPIV3.Document, options: ParseOptions): Promise<[TeamsAppManifest, PluginManifestSchema]>;
|
|
6
6
|
static updateManifestDescription(manifest: TeamsAppManifest, spec: OpenAPIV3.Document): void;
|
|
7
7
|
static mapOpenAPISchemaToFuncParam(schema: OpenAPIV3.SchemaObject, method: string, pathUrl: string): FunctionParameter;
|
|
8
|
-
static generatePluginManifestSchema(spec: OpenAPIV3.Document, specRelativePath: string): PluginManifestSchema;
|
|
9
|
-
static updateManifest(manifestPath: string, outputSpecPath: string,
|
|
10
|
-
static generateCommands(spec: OpenAPIV3.Document,
|
|
8
|
+
static generatePluginManifestSchema(spec: OpenAPIV3.Document, specRelativePath: string, options: ParseOptions): PluginManifestSchema;
|
|
9
|
+
static updateManifest(manifestPath: string, outputSpecPath: string, spec: OpenAPIV3.Document, options: ParseOptions, adaptiveCardFolder?: string, authInfo?: AuthInfo): Promise<[TeamsAppManifest, WarningResult[]]>;
|
|
10
|
+
static generateCommands(spec: OpenAPIV3.Document, manifestPath: string, options: ParseOptions, adaptiveCardFolder?: string): Promise<[IMessagingExtensionCommand[], WarningResult[]]>;
|
|
11
11
|
static getRelativePath(from: string, to: string): string;
|
|
12
12
|
}
|
package/dist/src/specFilter.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
+
import { ParseOptions } from "./interfaces";
|
|
2
3
|
export declare class SpecFilter {
|
|
3
|
-
static specFilter(filter: string[], unResolveSpec: OpenAPIV3.Document, resolvedSpec: OpenAPIV3.Document,
|
|
4
|
+
static specFilter(filter: string[], unResolveSpec: OpenAPIV3.Document, resolvedSpec: OpenAPIV3.Document, options: ParseOptions): OpenAPIV3.Document;
|
|
4
5
|
}
|
|
@@ -53,7 +53,7 @@ export declare class SpecParser {
|
|
|
53
53
|
* @param adaptiveCardFolder Folder path where the Adaptive Card files will be generated. If not specified or empty, Adaptive Card files will not be generated.
|
|
54
54
|
* @param isMe Boolean that indicates whether the project is an Messaging Extension. For Messaging Extension, composeExtensions will be added in Teams app manifest.
|
|
55
55
|
*/
|
|
56
|
-
generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder
|
|
56
|
+
generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder?: string, signal?: AbortSignal): Promise<GenerateResult>;
|
|
57
57
|
private loadSpec;
|
|
58
58
|
private getAllSupportedAPIs;
|
|
59
59
|
}
|
package/dist/src/specParser.d.ts
CHANGED
|
@@ -51,9 +51,8 @@ export declare class SpecParser {
|
|
|
51
51
|
* @param filter An array of strings that represent the filters to apply when generating the artifacts. If filter is empty, it would process nothing.
|
|
52
52
|
* @param outputSpecPath File path of the new OpenAPI specification file to generate. If not specified or empty, no spec file will be generated.
|
|
53
53
|
* @param adaptiveCardFolder Folder path where the Adaptive Card files will be generated. If not specified or empty, Adaptive Card files will not be generated.
|
|
54
|
-
* @param isMe Boolean that indicates whether the project is an Messaging Extension. For Messaging Extension, composeExtensions will be added in Teams app manifest.
|
|
55
54
|
*/
|
|
56
|
-
generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder
|
|
55
|
+
generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder?: string, signal?: AbortSignal): Promise<GenerateResult>;
|
|
57
56
|
private loadSpec;
|
|
58
57
|
private getAllSupportedAPIs;
|
|
59
58
|
}
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
2
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
3
|
-
import {
|
|
3
|
+
import { AuthInfo, CheckParamResult, ErrorResult, Parameter, ParseOptions, ValidateResult, WarningResult } from "./interfaces";
|
|
4
4
|
import { IMessagingExtensionCommand } from "@microsoft/teams-manifest";
|
|
5
5
|
export declare class Utils {
|
|
6
6
|
static hasNestedObjectInSchema(schema: OpenAPIV3.SchemaObject): boolean;
|
|
7
7
|
static checkParameters(paramObject: OpenAPIV3.ParameterObject[], isCopilot: boolean): CheckParamResult;
|
|
8
8
|
static checkPostBody(schema: OpenAPIV3.SchemaObject, isRequired?: boolean, isCopilot?: boolean): CheckParamResult;
|
|
9
|
+
static containMultipleMediaTypes(bodyObject: OpenAPIV3.RequestBodyObject | OpenAPIV3.ResponseObject): boolean;
|
|
9
10
|
/**
|
|
10
11
|
* Checks if the given API is supported.
|
|
11
12
|
* @param {string} method - The HTTP method of the API.
|
|
@@ -20,26 +21,26 @@ export declare class Utils {
|
|
|
20
21
|
* 5. response body should be “application/json” and not empty, and response code should be 20X
|
|
21
22
|
* 6. only support request body with “application/json” content type
|
|
22
23
|
*/
|
|
23
|
-
static isSupportedApi(method: string, path: string, spec: OpenAPIV3.Document,
|
|
24
|
-
static isSupportedAuth(authSchemaArray:
|
|
24
|
+
static isSupportedApi(method: string, path: string, spec: OpenAPIV3.Document, options: ParseOptions): boolean;
|
|
25
|
+
static isSupportedAuth(authSchemaArray: AuthInfo[][], options: ParseOptions): boolean;
|
|
25
26
|
static isAPIKeyAuth(authSchema: OpenAPIV3.SecuritySchemeObject): boolean;
|
|
26
|
-
static
|
|
27
|
-
static getAuthArray(securities: OpenAPIV3.SecurityRequirementObject[] | undefined, spec: OpenAPIV3.Document):
|
|
27
|
+
static isOAuthWithAuthCodeFlow(authSchema: OpenAPIV3.SecuritySchemeObject): boolean;
|
|
28
|
+
static getAuthArray(securities: OpenAPIV3.SecurityRequirementObject[] | undefined, spec: OpenAPIV3.Document): AuthInfo[][];
|
|
28
29
|
static updateFirstLetter(str: string): string;
|
|
29
|
-
static getResponseJson(operationObject: OpenAPIV3.OperationObject | undefined): OpenAPIV3.MediaTypeObject;
|
|
30
|
+
static getResponseJson(operationObject: OpenAPIV3.OperationObject | undefined, isTeamsAiProject?: boolean): OpenAPIV3.MediaTypeObject;
|
|
30
31
|
static convertPathToCamelCase(path: string): string;
|
|
31
32
|
static getUrlProtocol(urlString: string): string | undefined;
|
|
32
33
|
static resolveServerUrl(url: string): string;
|
|
33
34
|
static checkServerUrl(servers: OpenAPIV3.ServerObject[]): ErrorResult[];
|
|
34
|
-
static validateServer(spec: OpenAPIV3.Document,
|
|
35
|
+
static validateServer(spec: OpenAPIV3.Document, options: ParseOptions): ErrorResult[];
|
|
35
36
|
static isWellKnownName(name: string, wellknownNameList: string[]): boolean;
|
|
36
37
|
static generateParametersFromSchema(schema: OpenAPIV3.SchemaObject, name: string, allowMultipleParameters: boolean, isRequired?: boolean): [Parameter[], Parameter[]];
|
|
37
38
|
static updateParameterWithInputType(schema: OpenAPIV3.SchemaObject, param: Parameter): void;
|
|
38
|
-
static parseApiInfo(operationItem: OpenAPIV3.OperationObject,
|
|
39
|
-
static listSupportedAPIs(spec: OpenAPIV3.Document,
|
|
39
|
+
static parseApiInfo(operationItem: OpenAPIV3.OperationObject, options: ParseOptions): [IMessagingExtensionCommand, WarningResult | undefined];
|
|
40
|
+
static listSupportedAPIs(spec: OpenAPIV3.Document, options: ParseOptions): {
|
|
40
41
|
[key: string]: OpenAPIV3.OperationObject;
|
|
41
42
|
};
|
|
42
|
-
static validateSpec(spec: OpenAPIV3.Document, parser: SwaggerParser, isSwaggerFile: boolean,
|
|
43
|
+
static validateSpec(spec: OpenAPIV3.Document, parser: SwaggerParser, isSwaggerFile: boolean, options: ParseOptions): ValidateResult;
|
|
43
44
|
static format(str: string, ...args: string[]): string;
|
|
44
45
|
static getSafeRegistrationIdEnvName(authName: string): string;
|
|
45
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microsoft/m365-spec-parser",
|
|
3
|
-
"version": "0.1.1-alpha.
|
|
3
|
+
"version": "0.1.1-alpha.a372ccf67.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.4-alpha.
|
|
42
|
+
"@microsoft/teams-manifest": "0.1.4-alpha.a372ccf67.0",
|
|
43
43
|
"fs-extra": "^11.2.0",
|
|
44
44
|
"js-yaml": "^4.1.0",
|
|
45
45
|
"openapi-types": "^7.2.3",
|
|
@@ -148,5 +148,5 @@
|
|
|
148
148
|
"npx eslint --cache --fix --quiet"
|
|
149
149
|
]
|
|
150
150
|
},
|
|
151
|
-
"gitHead": "
|
|
151
|
+
"gitHead": "014f015ec0ece0cad73f2fdffdffc748758a28f6"
|
|
152
152
|
}
|