@microsoft/m365-spec-parser 0.0.2-alpha.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 +846 -0
- package/dist/index.esm2017.js.map +1 -0
- package/dist/index.esm2017.mjs +1314 -0
- package/dist/index.esm2017.mjs.map +1 -0
- package/dist/index.esm5.js +886 -0
- package/dist/index.esm5.js.map +1 -0
- package/dist/index.node.cjs.js +1372 -0
- package/dist/index.node.cjs.js.map +1 -0
- package/dist/src/adaptiveCardGenerator.d.ts +8 -0
- package/dist/src/adaptiveCardWrapper.d.ts +14 -0
- package/dist/src/constants.d.ts +40 -0
- package/dist/src/index.browser.d.ts +5 -0
- package/dist/src/index.d.ts +4 -0
- package/dist/src/interfaces.d.ts +179 -0
- package/dist/src/manifestUpdater.d.ts +8 -0
- package/dist/src/specFilter.d.ts +4 -0
- package/dist/src/specParser.browser.d.ts +45 -0
- package/dist/src/specParser.d.ts +45 -0
- package/dist/src/specParserError.d.ts +5 -0
- package/dist/src/utils.d.ts +44 -0
- package/package.json +86 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { OpenAPIV3 } from "openapi-types";
|
|
2
|
+
import SwaggerParser from '@apidevtools/swagger-parser';
|
|
3
|
+
import { AuthSchema, CheckParamResult, ErrorResult, Parameter, ValidateResult, WarningResult } from "./interfaces";
|
|
4
|
+
import { IMessagingExtensionCommand } from "@microsoft/teams-manifest";
|
|
5
|
+
export declare class Utils {
|
|
6
|
+
static checkParameters(paramObject: OpenAPIV3.ParameterObject[]): CheckParamResult;
|
|
7
|
+
static checkPostBody(schema: OpenAPIV3.SchemaObject, isRequired?: boolean): CheckParamResult;
|
|
8
|
+
/**
|
|
9
|
+
* Checks if the given API is supported.
|
|
10
|
+
* @param {string} method - The HTTP method of the API.
|
|
11
|
+
* @param {string} path - The path of the API.
|
|
12
|
+
* @param {OpenAPIV3.Document} spec - The OpenAPI specification document.
|
|
13
|
+
* @returns {boolean} - Returns true if the API is supported, false otherwise.
|
|
14
|
+
* @description The following APIs are supported:
|
|
15
|
+
* 1. only support Get/Post operation without auth property
|
|
16
|
+
* 2. parameter inside query or path only support string, number, boolean and integer
|
|
17
|
+
* 3. parameter inside post body only support string, number, boolean, integer and object
|
|
18
|
+
* 4. request body + required parameters <= 1
|
|
19
|
+
* 5. response body should be “application/json” and not empty, and response code should be 20X
|
|
20
|
+
* 6. only support request body with “application/json” content type
|
|
21
|
+
*/
|
|
22
|
+
static isSupportedApi(method: string, path: string, spec: OpenAPIV3.Document, allowMissingId: boolean, allowAPIKeyAuth: boolean, allowMultipleParameters: boolean, allowOauth2: boolean): boolean;
|
|
23
|
+
static isSupportedAuth(authSchemaArray: AuthSchema[][], allowAPIKeyAuth: boolean, allowOauth2: boolean): boolean;
|
|
24
|
+
static isAPIKeyAuth(authSchema: OpenAPIV3.SecuritySchemeObject): boolean;
|
|
25
|
+
static isBearerTokenAuth(authSchema: OpenAPIV3.SecuritySchemeObject): boolean;
|
|
26
|
+
static getAuthArray(securities: OpenAPIV3.SecurityRequirementObject[] | undefined, spec: OpenAPIV3.Document): AuthSchema[][];
|
|
27
|
+
static updateFirstLetter(str: string): string;
|
|
28
|
+
static getResponseJson(operationObject: OpenAPIV3.OperationObject | undefined): OpenAPIV3.MediaTypeObject;
|
|
29
|
+
static convertPathToCamelCase(path: string): string;
|
|
30
|
+
static getUrlProtocol(urlString: string): string | undefined;
|
|
31
|
+
static resolveServerUrl(url: string): string;
|
|
32
|
+
static checkServerUrl(servers: OpenAPIV3.ServerObject[]): ErrorResult[];
|
|
33
|
+
static validateServer(spec: OpenAPIV3.Document, allowMissingId: boolean, allowAPIKeyAuth: boolean, allowMultipleParameters: boolean, allowOauth2: boolean): ErrorResult[];
|
|
34
|
+
static isWellKnownName(name: string, wellknownNameList: string[]): boolean;
|
|
35
|
+
static generateParametersFromSchema(schema: OpenAPIV3.SchemaObject, name: string, allowMultipleParameters: boolean, isRequired?: boolean): [Parameter[], Parameter[]];
|
|
36
|
+
static updateParameterWithInputType(schema: OpenAPIV3.SchemaObject, param: Parameter): void;
|
|
37
|
+
static parseApiInfo(operationItem: OpenAPIV3.OperationObject, allowMultipleParameters: boolean): [IMessagingExtensionCommand, WarningResult | undefined];
|
|
38
|
+
static listSupportedAPIs(spec: OpenAPIV3.Document, allowMissingId: boolean, allowAPIKeyAuth: boolean, allowMultipleParameters: boolean, allowOauth2: boolean): {
|
|
39
|
+
[key: string]: OpenAPIV3.OperationObject;
|
|
40
|
+
};
|
|
41
|
+
static validateSpec(spec: OpenAPIV3.Document, parser: SwaggerParser, isSwaggerFile: boolean, allowMissingId: boolean, allowAPIKeyAuth: boolean, allowMultipleParameters: boolean, allowOauth2: boolean): ValidateResult;
|
|
42
|
+
static format(str: string, ...args: string[]): string;
|
|
43
|
+
static getSafeRegistrationIdEnvName(authName: string): string;
|
|
44
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@microsoft/m365-spec-parser",
|
|
3
|
+
"version": "0.0.2-alpha.0",
|
|
4
|
+
"description": "OpenAPI specification files Parser for M365 Apps",
|
|
5
|
+
"main": "dist/index.node.cjs.js",
|
|
6
|
+
"browser": "dist/index.esm2017.js",
|
|
7
|
+
"module": "dist/index.esm2017.mjs",
|
|
8
|
+
"esm5": "dist/index.esm5.js",
|
|
9
|
+
"types": "dist/src/index.d.ts",
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "rollup -c",
|
|
12
|
+
"test:unit:node": "nyc --no-clean -- mocha \"test/*.test.ts\" -r config/mocha.env.ts --config config/.mocharc.json",
|
|
13
|
+
"test:unit:browser": "karma start karma.conf.cjs --single-run --unit",
|
|
14
|
+
"test:unit": "npm run test:unit:node && npm run test:unit:browser "
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist/*js",
|
|
18
|
+
"dist/*js.map",
|
|
19
|
+
"dist/src/*d.ts"
|
|
20
|
+
],
|
|
21
|
+
"repository": "https://github.com/OfficeDev/TeamsFx",
|
|
22
|
+
"engines": {
|
|
23
|
+
"node": ">=10.0.0"
|
|
24
|
+
},
|
|
25
|
+
"keywords": [
|
|
26
|
+
"typescript"
|
|
27
|
+
],
|
|
28
|
+
"author": "Microsoft Corporation",
|
|
29
|
+
"license": "MIT",
|
|
30
|
+
"homepage": "https://github.com/OfficeDev/TeamsFx",
|
|
31
|
+
"sideEffects": false,
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@apidevtools/swagger-parser": "^10.1.0",
|
|
34
|
+
"@microsoft/teams-manifest": "^0.1.3",
|
|
35
|
+
"@types/webpack": "^5.28.5",
|
|
36
|
+
"c8": "^9.1.0",
|
|
37
|
+
"dotenv": "^16.4.1",
|
|
38
|
+
"fs-extra": "^11.2.0",
|
|
39
|
+
"http": "^0.0.1-security",
|
|
40
|
+
"https-browserify": "^1.0.0",
|
|
41
|
+
"js-yaml": "^4.1.0",
|
|
42
|
+
"openapi-types": "^7.2.3",
|
|
43
|
+
"process": "^0.11.10",
|
|
44
|
+
"stream-browserify": "^3.0.0",
|
|
45
|
+
"stream-http": "^3.2.0",
|
|
46
|
+
"swagger2openapi": "^7.0.8",
|
|
47
|
+
"url": "^0.11.3",
|
|
48
|
+
"webpack": "^5.90.0"
|
|
49
|
+
},
|
|
50
|
+
"publishConfig": {
|
|
51
|
+
"access": "public"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
55
|
+
"@rollup/plugin-json": "^6.1.0",
|
|
56
|
+
"@types/chai": "^4.2.22",
|
|
57
|
+
"@types/fs-extra": "^11.0.4",
|
|
58
|
+
"@types/js-yaml": "^4.0.9",
|
|
59
|
+
"@types/mocha": "^9.0.0",
|
|
60
|
+
"@types/sinon": "^17.0.3",
|
|
61
|
+
"@types/swagger2openapi": "^7.0.4",
|
|
62
|
+
"chai": "^4.3.4",
|
|
63
|
+
"karma": "^6.3.8",
|
|
64
|
+
"karma-chrome-launcher": "^3.1.0",
|
|
65
|
+
"karma-cli": "^2.0.0",
|
|
66
|
+
"karma-coverage": "^2.0.0",
|
|
67
|
+
"karma-env-preprocessor": "^0.1.1",
|
|
68
|
+
"karma-junit-reporter": "^2.0.1",
|
|
69
|
+
"karma-mocha": "^2.0.1",
|
|
70
|
+
"karma-mocha-reporter": "^2.2.5",
|
|
71
|
+
"karma-sourcemap-loader": "^0.3.8",
|
|
72
|
+
"karma-webpack": "^5.0.0",
|
|
73
|
+
"mocha": "^9.2.0",
|
|
74
|
+
"mock-fs": "^5.2.0",
|
|
75
|
+
"mocked-env": "^1.3.5",
|
|
76
|
+
"puppeteer": "^13.1.3",
|
|
77
|
+
"rollup": "^2.41.0",
|
|
78
|
+
"rollup-plugin-typescript2": "^0.31.0",
|
|
79
|
+
"sinon": "^12.0.1",
|
|
80
|
+
"source-map-loader": "^3.0.0",
|
|
81
|
+
"ts-loader": "^9.2.6",
|
|
82
|
+
"ts-node": "^10.4.0",
|
|
83
|
+
"typescript": "^4.4.4",
|
|
84
|
+
"util": "^0.12.5"
|
|
85
|
+
}
|
|
86
|
+
}
|