@microsoft/m365-spec-parser 0.1.1-alpha.2f5decfcc.0 → 0.1.1-alpha.42af26ca6.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 +571 -325
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +640 -365
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +571 -325
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +640 -365
- package/dist/index.node.cjs.js.map +1 -1
- package/dist/src/constants.d.ts +1 -0
- package/dist/src/interfaces.d.ts +41 -1
- package/dist/src/manifestUpdater.d.ts +2 -1
- package/dist/src/specParser.browser.d.ts +3 -1
- package/dist/src/specParser.d.ts +3 -1
- package/dist/src/utils.d.ts +8 -28
- package/package.json +3 -3
package/dist/src/constants.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare class ConstantString {
|
|
|
13
13
|
static readonly OperationOnlyContainsOptionalParam = "Operation %s contains multiple optional parameters. The first optional parameter is used for this command.";
|
|
14
14
|
static readonly ConvertSwaggerToOpenAPI = "The Swagger 2.0 file has been converted to OpenAPI 3.0.";
|
|
15
15
|
static readonly SwaggerNotSupported = "Swagger 2.0 is not supported. Please convert to OpenAPI 3.0 manually before proceeding.";
|
|
16
|
+
static readonly SpecVersionNotSupported = "Unsupported OpenAPI version %s. Please use version 3.0.x.";
|
|
16
17
|
static readonly MultipleAuthNotSupported = "Multiple authentication methods are unsupported. Ensure all selected APIs use identical authentication.";
|
|
17
18
|
static readonly UnsupportedSchema = "Unsupported schema in %s %s: %s";
|
|
18
19
|
static readonly WrappedCardVersion = "devPreview";
|
package/dist/src/interfaces.d.ts
CHANGED
|
@@ -17,6 +17,16 @@ export interface ValidateResult {
|
|
|
17
17
|
*/
|
|
18
18
|
errors: ErrorResult[];
|
|
19
19
|
}
|
|
20
|
+
export interface SpecValidationResult {
|
|
21
|
+
/**
|
|
22
|
+
* An array of warning results generated during validation.
|
|
23
|
+
*/
|
|
24
|
+
warnings: WarningResult[];
|
|
25
|
+
/**
|
|
26
|
+
* An array of error results generated during validation.
|
|
27
|
+
*/
|
|
28
|
+
errors: ErrorResult[];
|
|
29
|
+
}
|
|
20
30
|
/**
|
|
21
31
|
* An interface that represents a warning result generated during validation.
|
|
22
32
|
*/
|
|
@@ -69,6 +79,7 @@ export declare enum ErrorType {
|
|
|
69
79
|
ResolveServerUrlFailed = "resolve-server-url-failed",
|
|
70
80
|
SwaggerNotSupported = "swagger-not-supported",
|
|
71
81
|
MultipleAuthNotSupported = "multiple-auth-not-supported",
|
|
82
|
+
SpecVersionNotSupported = "spec-version-not-supported",
|
|
72
83
|
ListFailed = "list-failed",
|
|
73
84
|
listSupportedAPIInfoFailed = "list-supported-api-info-failed",
|
|
74
85
|
FilterSpecFailed = "filter-spec-failed",
|
|
@@ -77,6 +88,21 @@ export declare enum ErrorType {
|
|
|
77
88
|
GenerateFailed = "generate-failed",
|
|
78
89
|
ValidateFailed = "validate-failed",
|
|
79
90
|
GetSpecFailed = "get-spec-failed",
|
|
91
|
+
AuthTypeIsNotSupported = "auth-type-is-not-supported",
|
|
92
|
+
MissingOperationId = "missing-operation-id",
|
|
93
|
+
PostBodyContainMultipleMediaTypes = "post-body-contain-multiple-media-types",
|
|
94
|
+
ResponseContainMultipleMediaTypes = "response-contain-multiple-media-types",
|
|
95
|
+
ResponseJsonIsEmpty = "response-json-is-empty",
|
|
96
|
+
PostBodySchemaIsNotJson = "post-body-schema-is-not-json",
|
|
97
|
+
PostBodyContainsRequiredUnsupportedSchema = "post-body-contains-required-unsupported-schema",
|
|
98
|
+
ParamsContainRequiredUnsupportedSchema = "params-contain-required-unsupported-schema",
|
|
99
|
+
ParamsContainsNestedObject = "params-contains-nested-object",
|
|
100
|
+
RequestBodyContainsNestedObject = "request-body-contains-nested-object",
|
|
101
|
+
ExceededRequiredParamsLimit = "exceeded-required-params-limit",
|
|
102
|
+
NoParameter = "no-parameter",
|
|
103
|
+
NoAPIInfo = "no-api-info",
|
|
104
|
+
MethodNotAllowed = "method-not-allowed",
|
|
105
|
+
UrlPathNotExist = "url-path-not-exist",
|
|
80
106
|
Cancelled = "cancelled",
|
|
81
107
|
Unknown = "unknown"
|
|
82
108
|
}
|
|
@@ -140,6 +166,7 @@ export interface CheckParamResult {
|
|
|
140
166
|
requiredNum: number;
|
|
141
167
|
optionalNum: number;
|
|
142
168
|
isValid: boolean;
|
|
169
|
+
reason: ErrorType[];
|
|
143
170
|
}
|
|
144
171
|
export interface ParseOptions {
|
|
145
172
|
/**
|
|
@@ -194,12 +221,25 @@ export interface ListAPIInfo {
|
|
|
194
221
|
api: string;
|
|
195
222
|
server: string;
|
|
196
223
|
operationId: string;
|
|
224
|
+
isValid: boolean;
|
|
225
|
+
reason: ErrorType[];
|
|
197
226
|
auth?: AuthInfo;
|
|
198
227
|
}
|
|
228
|
+
export interface APIMap {
|
|
229
|
+
[key: string]: {
|
|
230
|
+
operation: OpenAPIV3.OperationObject;
|
|
231
|
+
isValid: boolean;
|
|
232
|
+
reason: ErrorType[];
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
export interface APIValidationResult {
|
|
236
|
+
isValid: boolean;
|
|
237
|
+
reason: ErrorType[];
|
|
238
|
+
}
|
|
199
239
|
export interface ListAPIResult {
|
|
200
240
|
allAPICount: number;
|
|
201
241
|
validAPICount: number;
|
|
202
|
-
|
|
242
|
+
APIs: ListAPIInfo[];
|
|
203
243
|
}
|
|
204
244
|
export interface AuthInfo {
|
|
205
245
|
authScheme: OpenAPIV3.SecuritySchemeObject;
|
|
@@ -5,8 +5,9 @@ export declare class ManifestUpdater {
|
|
|
5
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, options: ParseOptions): PluginManifestSchema;
|
|
8
|
+
static generatePluginManifestSchema(spec: OpenAPIV3.Document, specRelativePath: string, appName: string, options: ParseOptions): PluginManifestSchema;
|
|
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;
|
|
12
|
+
static removeEnvs(str: string): string;
|
|
12
13
|
}
|
|
@@ -10,6 +10,7 @@ export declare class SpecParser {
|
|
|
10
10
|
readonly options: Required<ParseOptions>;
|
|
11
11
|
private apiMap;
|
|
12
12
|
private spec;
|
|
13
|
+
private validator;
|
|
13
14
|
private unResolveSpec;
|
|
14
15
|
private isSwaggerFile;
|
|
15
16
|
private defaultOptions;
|
|
@@ -55,5 +56,6 @@ export declare class SpecParser {
|
|
|
55
56
|
*/
|
|
56
57
|
generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder?: string, signal?: AbortSignal): Promise<GenerateResult>;
|
|
57
58
|
private loadSpec;
|
|
58
|
-
private
|
|
59
|
+
private getAPIs;
|
|
60
|
+
private getValidator;
|
|
59
61
|
}
|
package/dist/src/specParser.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ export declare class SpecParser {
|
|
|
9
9
|
readonly parser: SwaggerParser;
|
|
10
10
|
readonly options: Required<ParseOptions>;
|
|
11
11
|
private apiMap;
|
|
12
|
+
private validator;
|
|
12
13
|
private spec;
|
|
13
14
|
private unResolveSpec;
|
|
14
15
|
private isSwaggerFile;
|
|
@@ -54,5 +55,6 @@ export declare class SpecParser {
|
|
|
54
55
|
*/
|
|
55
56
|
generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder?: string, signal?: AbortSignal): Promise<GenerateResult>;
|
|
56
57
|
private loadSpec;
|
|
57
|
-
private
|
|
58
|
+
private getAPIs;
|
|
59
|
+
private getValidator;
|
|
58
60
|
}
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -1,48 +1,28 @@
|
|
|
1
1
|
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
-
import
|
|
3
|
-
import { AuthInfo, CheckParamResult, ErrorResult, ParseOptions, ValidateResult, WarningResult } from "./interfaces";
|
|
2
|
+
import { AuthInfo, ErrorResult, ParseOptions } from "./interfaces";
|
|
4
3
|
import { IMessagingExtensionCommand, IParameter } from "@microsoft/teams-manifest";
|
|
5
4
|
export declare class Utils {
|
|
6
5
|
static hasNestedObjectInSchema(schema: OpenAPIV3.SchemaObject): boolean;
|
|
7
|
-
static checkParameters(paramObject: OpenAPIV3.ParameterObject[], isCopilot: boolean): CheckParamResult;
|
|
8
|
-
static checkPostBody(schema: OpenAPIV3.SchemaObject, isRequired?: boolean, isCopilot?: boolean): CheckParamResult;
|
|
9
6
|
static containMultipleMediaTypes(bodyObject: OpenAPIV3.RequestBodyObject | OpenAPIV3.ResponseObject): boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Checks if the given API is supported.
|
|
12
|
-
* @param {string} method - The HTTP method of the API.
|
|
13
|
-
* @param {string} path - The path of the API.
|
|
14
|
-
* @param {OpenAPIV3.Document} spec - The OpenAPI specification document.
|
|
15
|
-
* @returns {boolean} - Returns true if the API is supported, false otherwise.
|
|
16
|
-
* @description The following APIs are supported:
|
|
17
|
-
* 1. only support Get/Post operation without auth property
|
|
18
|
-
* 2. parameter inside query or path only support string, number, boolean and integer
|
|
19
|
-
* 3. parameter inside post body only support string, number, boolean, integer and object
|
|
20
|
-
* 4. request body + required parameters <= 1
|
|
21
|
-
* 5. response body should be “application/json” and not empty, and response code should be 20X
|
|
22
|
-
* 6. only support request body with “application/json” content type
|
|
23
|
-
*/
|
|
24
|
-
static isSupportedApi(method: string, path: string, spec: OpenAPIV3.Document, options: ParseOptions): boolean;
|
|
25
|
-
static isSupportedAuth(authSchemeArray: AuthInfo[][], options: ParseOptions): boolean;
|
|
26
7
|
static isBearerTokenAuth(authScheme: OpenAPIV3.SecuritySchemeObject): boolean;
|
|
27
8
|
static isAPIKeyAuth(authScheme: OpenAPIV3.SecuritySchemeObject): boolean;
|
|
28
9
|
static isOAuthWithAuthCodeFlow(authScheme: OpenAPIV3.SecuritySchemeObject): boolean;
|
|
29
10
|
static getAuthArray(securities: OpenAPIV3.SecurityRequirementObject[] | undefined, spec: OpenAPIV3.Document): AuthInfo[][];
|
|
30
11
|
static updateFirstLetter(str: string): string;
|
|
31
|
-
static getResponseJson(operationObject: OpenAPIV3.OperationObject | undefined
|
|
12
|
+
static getResponseJson(operationObject: OpenAPIV3.OperationObject | undefined): {
|
|
13
|
+
json: OpenAPIV3.MediaTypeObject;
|
|
14
|
+
multipleMediaType: boolean;
|
|
15
|
+
};
|
|
32
16
|
static convertPathToCamelCase(path: string): string;
|
|
33
17
|
static getUrlProtocol(urlString: string): string | undefined;
|
|
34
|
-
static
|
|
18
|
+
static resolveEnv(str: string): string;
|
|
35
19
|
static checkServerUrl(servers: OpenAPIV3.ServerObject[]): ErrorResult[];
|
|
36
20
|
static validateServer(spec: OpenAPIV3.Document, options: ParseOptions): ErrorResult[];
|
|
37
21
|
static isWellKnownName(name: string, wellknownNameList: string[]): boolean;
|
|
38
22
|
static generateParametersFromSchema(schema: OpenAPIV3.SchemaObject, name: string, allowMultipleParameters: boolean, isRequired?: boolean): [IParameter[], IParameter[]];
|
|
39
23
|
static updateParameterWithInputType(schema: OpenAPIV3.SchemaObject, param: IParameter): void;
|
|
40
|
-
static parseApiInfo(operationItem: OpenAPIV3.OperationObject, options: ParseOptions):
|
|
41
|
-
static listSupportedAPIs(spec: OpenAPIV3.Document, options: ParseOptions): {
|
|
42
|
-
[key: string]: OpenAPIV3.OperationObject;
|
|
43
|
-
};
|
|
44
|
-
static validateSpec(spec: OpenAPIV3.Document, parser: SwaggerParser, isSwaggerFile: boolean, options: ParseOptions): ValidateResult;
|
|
24
|
+
static parseApiInfo(operationItem: OpenAPIV3.OperationObject, options: ParseOptions): IMessagingExtensionCommand;
|
|
45
25
|
static format(str: string, ...args: string[]): string;
|
|
46
26
|
static getSafeRegistrationIdEnvName(authName: string): string;
|
|
47
|
-
static
|
|
27
|
+
static getServerObject(spec: OpenAPIV3.Document, method: string, path: string): OpenAPIV3.ServerObject | undefined;
|
|
48
28
|
}
|
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.42af26ca6.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.42af26ca6.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": "839b8377496cd0a5198eab523aea386f2e67d1c4"
|
|
152
152
|
}
|