@microsoft/m365-spec-parser 0.1.1-alpha.4cb5c08a8.0 → 0.1.1-alpha.4e708f092.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.
@@ -1,5 +1,7 @@
1
+ import { ResponseSemanticsObject } from "@microsoft/teams-manifest";
1
2
  import { AdaptiveCard, PreviewCardTemplate, WrappedAdaptiveCard } from "./interfaces";
2
3
  export declare function wrapAdaptiveCard(card: AdaptiveCard, jsonPath: string): WrappedAdaptiveCard;
4
+ export declare function wrapResponseSemantics(card: AdaptiveCard, jsonPath: string): ResponseSemanticsObject;
3
5
  /**
4
6
  * Infers the preview card template from an Adaptive Card and a JSON path.
5
7
  * The preview card template includes a title and an optional subtitle and image.
@@ -25,6 +25,7 @@ export declare class ConstantString {
25
25
  static readonly AdaptiveCardSchema = "http://adaptivecards.io/schemas/adaptive-card.json";
26
26
  static readonly AdaptiveCardType = "AdaptiveCard";
27
27
  static readonly TextBlockType = "TextBlock";
28
+ static readonly ImageType = "Image";
28
29
  static readonly ContainerType = "Container";
29
30
  static readonly RegistrationIdPostfix = "REGISTRATION_ID";
30
31
  static readonly OAuthRegistrationIdPostFix = "OAUTH_REGISTRATION_ID";
@@ -41,4 +42,5 @@ export declare class ConstantString {
41
42
  static readonly CommandTitleMaxLens = 32;
42
43
  static readonly ParameterTitleMaxLens = 32;
43
44
  static readonly SMERequiredParamsMaxNum = 5;
45
+ static readonly DefaultPluginId = "plugin_1";
44
46
  }
@@ -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, ProjectType, } from "./interfaces";
3
+ export { ValidationStatus, WarningType, ErrorType, WarningResult, ErrorResult, ListAPIResult, APIInfo, ValidateResult, ParseOptions, AdaptiveCard, ProjectType, InvalidAPIInfo, } from "./interfaces";
4
4
  export { ConstantString } from "./constants";
5
5
  export { Utils } from "./utils";
6
6
  export { AdaptiveCardGenerator } from "./adaptiveCardGenerator";
@@ -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
  */
@@ -187,6 +197,14 @@ export interface ParseOptions {
187
197
  * An array of HTTP methods that the parser will allow in the spec file.
188
198
  */
189
199
  allowMethods?: string[];
200
+ /**
201
+ * If true, the parser will allow conversation starters in plugin file. Only take effect in Copilot project
202
+ */
203
+ allowConversationStarters?: boolean;
204
+ /**
205
+ * If true, the parser will allow response semantics in plugin file. Only take effect in Copilot project
206
+ */
207
+ allowResponseSemantics?: boolean;
190
208
  /**
191
209
  * The type of project that the parser is being used for.
192
210
  * Project can be SME/Copilot/TeamsAi
@@ -235,3 +253,12 @@ export interface AuthInfo {
235
253
  authScheme: OpenAPIV3.SecuritySchemeObject;
236
254
  name: string;
237
255
  }
256
+ export interface InvalidAPIInfo {
257
+ api: string;
258
+ reason: ErrorType[];
259
+ }
260
+ export interface InferredProperties {
261
+ title?: string;
262
+ subtitle?: string;
263
+ imageUrl?: string;
264
+ }
@@ -5,7 +5,7 @@ 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, appName: string, options: ParseOptions): PluginManifestSchema;
8
+ static generatePluginManifestSchema(spec: OpenAPIV3.Document, specRelativePath: string, apiPluginFilePath: string, appName: string, options: ParseOptions): Promise<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;
@@ -8,8 +8,8 @@ export declare class SpecParser {
8
8
  readonly pathOrSpec: string | OpenAPIV3.Document;
9
9
  readonly parser: SwaggerParser;
10
10
  readonly options: Required<ParseOptions>;
11
- private apiMap;
12
11
  private spec;
12
+ private validator;
13
13
  private unResolveSpec;
14
14
  private isSwaggerFile;
15
15
  private defaultOptions;
@@ -55,6 +55,6 @@ export declare class SpecParser {
55
55
  */
56
56
  generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder?: string, signal?: AbortSignal): Promise<GenerateResult>;
57
57
  private loadSpec;
58
- private getAllSupportedAPIs;
59
- private listSupportedAPIs;
58
+ private getAPIs;
59
+ private getValidator;
60
60
  }
@@ -8,7 +8,7 @@ export declare class SpecParser {
8
8
  readonly pathOrSpec: string | OpenAPIV3.Document;
9
9
  readonly parser: SwaggerParser;
10
10
  readonly options: Required<ParseOptions>;
11
- private apiMap;
11
+ private validator;
12
12
  private spec;
13
13
  private unResolveSpec;
14
14
  private isSwaggerFile;
@@ -55,4 +55,5 @@ export declare class SpecParser {
55
55
  generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder?: string, signal?: AbortSignal): Promise<GenerateResult>;
56
56
  private loadSpec;
57
57
  private getAPIs;
58
+ private getValidator;
58
59
  }
@@ -1,34 +1,15 @@
1
1
  import { OpenAPIV3 } from "openapi-types";
2
- import SwaggerParser from "@apidevtools/swagger-parser";
3
- import { APIMap, APIValidationResult, 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): APIValidationResult;
25
- static isSupportedAuth(authSchemeArray: AuthInfo[][], options: ParseOptions): APIValidationResult;
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, isTeamsAiProject?: boolean): {
12
+ static getResponseJson(operationObject: OpenAPIV3.OperationObject | undefined): {
32
13
  json: OpenAPIV3.MediaTypeObject;
33
14
  multipleMediaType: boolean;
34
15
  };
@@ -40,10 +21,8 @@ export declare class Utils {
40
21
  static isWellKnownName(name: string, wellknownNameList: string[]): boolean;
41
22
  static generateParametersFromSchema(schema: OpenAPIV3.SchemaObject, name: string, allowMultipleParameters: boolean, isRequired?: boolean): [IParameter[], IParameter[]];
42
23
  static updateParameterWithInputType(schema: OpenAPIV3.SchemaObject, param: IParameter): void;
43
- static parseApiInfo(operationItem: OpenAPIV3.OperationObject, options: ParseOptions): [IMessagingExtensionCommand, WarningResult | undefined];
44
- static listAPIs(spec: OpenAPIV3.Document, options: ParseOptions): APIMap;
45
- static validateSpec(spec: OpenAPIV3.Document, parser: SwaggerParser, isSwaggerFile: boolean, options: ParseOptions): ValidateResult;
24
+ static parseApiInfo(operationItem: OpenAPIV3.OperationObject, options: ParseOptions): IMessagingExtensionCommand;
46
25
  static format(str: string, ...args: string[]): string;
47
26
  static getSafeRegistrationIdEnvName(authName: string): string;
48
- static getAllAPICount(spec: OpenAPIV3.Document): number;
27
+ static getServerObject(spec: OpenAPIV3.Document, method: string, path: string): OpenAPIV3.ServerObject | undefined;
49
28
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@microsoft/m365-spec-parser",
3
- "version": "0.1.1-alpha.4cb5c08a8.0",
3
+ "version": "0.1.1-alpha.4e708f092.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.4cb5c08a8.0",
42
+ "@microsoft/teams-manifest": "0.1.4-alpha.4e708f092.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": "315d22cbafd911ad1e3133a515995f40721529d0"
151
+ "gitHead": "378e5546410fdeb22e98f82c2edb1ac19e0b0e2c"
152
152
  }