@microsoft/teamsfx-core 2.0.6-alpha.ae74bd5cd.0 → 2.0.6-alpha.bb3771d20.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.
Files changed (111) hide show
  1. package/build/common/deps-checker/internal/funcToolChecker.d.ts +1 -1
  2. package/build/common/deps-checker/internal/funcToolChecker.d.ts.map +1 -1
  3. package/build/common/deps-checker/internal/funcToolChecker.js.map +1 -1
  4. package/build/common/featureFlags.d.ts +1 -0
  5. package/build/common/featureFlags.d.ts.map +1 -1
  6. package/build/common/featureFlags.js +5 -1
  7. package/build/common/featureFlags.js.map +1 -1
  8. package/build/common/local/constants.d.ts +1 -0
  9. package/build/common/local/constants.d.ts.map +1 -1
  10. package/build/common/local/constants.js +1 -0
  11. package/build/common/local/constants.js.map +1 -1
  12. package/build/common/local/localCertificateManager.d.ts +3 -2
  13. package/build/common/local/localCertificateManager.d.ts.map +1 -1
  14. package/build/common/local/localCertificateManager.js +5 -1
  15. package/build/common/local/localCertificateManager.js.map +1 -1
  16. package/build/common/m365/packageService.d.ts +1 -0
  17. package/build/common/m365/packageService.d.ts.map +1 -1
  18. package/build/common/m365/packageService.js +68 -0
  19. package/build/common/m365/packageService.js.map +1 -1
  20. package/build/common/spec-parser/adaptiveCardGenerator.d.ts.map +1 -1
  21. package/build/common/spec-parser/adaptiveCardGenerator.js +2 -4
  22. package/build/common/spec-parser/adaptiveCardGenerator.js.map +1 -1
  23. package/build/common/spec-parser/constants.d.ts +20 -13
  24. package/build/common/spec-parser/constants.d.ts.map +1 -1
  25. package/build/common/spec-parser/constants.js +20 -14
  26. package/build/common/spec-parser/constants.js.map +1 -1
  27. package/build/common/spec-parser/index.browser.d.ts +5 -0
  28. package/build/common/spec-parser/index.browser.d.ts.map +1 -0
  29. package/build/common/spec-parser/index.browser.js +16 -0
  30. package/build/common/spec-parser/index.browser.js.map +1 -0
  31. package/build/common/spec-parser/index.d.ts +5 -0
  32. package/build/common/spec-parser/index.d.ts.map +1 -0
  33. package/build/common/spec-parser/index.js +16 -0
  34. package/build/common/spec-parser/index.js.map +1 -0
  35. package/build/common/spec-parser/interfaces.d.ts +15 -2
  36. package/build/common/spec-parser/interfaces.d.ts.map +1 -1
  37. package/build/common/spec-parser/interfaces.js +2 -2
  38. package/build/common/spec-parser/interfaces.js.map +1 -1
  39. package/build/common/spec-parser/manifestUpdater.d.ts +2 -2
  40. package/build/common/spec-parser/manifestUpdater.d.ts.map +1 -1
  41. package/build/common/spec-parser/manifestUpdater.js +18 -102
  42. package/build/common/spec-parser/manifestUpdater.js.map +1 -1
  43. package/build/common/spec-parser/specFilter.d.ts +1 -1
  44. package/build/common/spec-parser/specFilter.d.ts.map +1 -1
  45. package/build/common/spec-parser/specFilter.js +2 -2
  46. package/build/common/spec-parser/specFilter.js.map +1 -1
  47. package/build/common/spec-parser/specParser.browser.d.ts +51 -0
  48. package/build/common/spec-parser/specParser.browser.d.ts.map +1 -0
  49. package/build/common/spec-parser/specParser.browser.js +144 -0
  50. package/build/common/spec-parser/specParser.browser.js.map +1 -0
  51. package/build/common/spec-parser/specParser.d.ts +10 -5
  52. package/build/common/spec-parser/specParser.d.ts.map +1 -1
  53. package/build/common/spec-parser/specParser.js +34 -84
  54. package/build/common/spec-parser/specParser.js.map +1 -1
  55. package/build/common/spec-parser/utils.d.ts +12 -5
  56. package/build/common/spec-parser/utils.d.ts.map +1 -1
  57. package/build/common/spec-parser/utils.js +190 -38
  58. package/build/common/spec-parser/utils.js.map +1 -1
  59. package/build/common/templates-config.json +2 -2
  60. package/build/common/tools.d.ts.map +1 -1
  61. package/build/common/tools.js +1 -1
  62. package/build/common/tools.js.map +1 -1
  63. package/build/component/developerPortalScaffoldUtils.d.ts.map +1 -1
  64. package/build/component/developerPortalScaffoldUtils.js +32 -0
  65. package/build/component/developerPortalScaffoldUtils.js.map +1 -1
  66. package/build/component/driver/script/scriptDriver.d.ts.map +1 -1
  67. package/build/component/driver/script/scriptDriver.js +2 -2
  68. package/build/component/driver/script/scriptDriver.js.map +1 -1
  69. package/build/component/driver/teamsApp/publishAppPackage.d.ts +1 -0
  70. package/build/component/driver/teamsApp/publishAppPackage.d.ts.map +1 -1
  71. package/build/component/driver/teamsApp/publishAppPackage.js +9 -9
  72. package/build/component/driver/teamsApp/publishAppPackage.js.map +1 -1
  73. package/build/component/driver/teamsApp/teamsappMgr.d.ts +20 -0
  74. package/build/component/driver/teamsApp/teamsappMgr.d.ts.map +1 -0
  75. package/build/component/driver/teamsApp/teamsappMgr.js +278 -0
  76. package/build/component/driver/teamsApp/teamsappMgr.js.map +1 -0
  77. package/build/component/generator/copilotPlugin/generator.d.ts.map +1 -1
  78. package/build/component/generator/copilotPlugin/generator.js +11 -14
  79. package/build/component/generator/copilotPlugin/generator.js.map +1 -1
  80. package/build/component/generator/copilotPlugin/helper.d.ts +5 -2
  81. package/build/component/generator/copilotPlugin/helper.d.ts.map +1 -1
  82. package/build/component/generator/copilotPlugin/helper.js +85 -15
  83. package/build/component/generator/copilotPlugin/helper.js.map +1 -1
  84. package/build/component/utils/envUtil.d.ts +1 -0
  85. package/build/component/utils/envUtil.d.ts.map +1 -1
  86. package/build/component/utils/envUtil.js +5 -0
  87. package/build/component/utils/envUtil.js.map +1 -1
  88. package/build/core/FxCore.d.ts +17 -1
  89. package/build/core/FxCore.d.ts.map +1 -1
  90. package/build/core/FxCore.js +71 -4
  91. package/build/core/FxCore.js.map +1 -1
  92. package/build/index.d.ts +3 -0
  93. package/build/index.d.ts.map +1 -1
  94. package/build/index.js +7 -1
  95. package/build/index.js.map +1 -1
  96. package/build/question/create.js +6 -6
  97. package/build/question/create.js.map +1 -1
  98. package/build/question/inputs/SPFxAddWebpartInputs.d.ts +2 -0
  99. package/build/question/inputs/SPFxAddWebpartInputs.d.ts.map +1 -1
  100. package/build/question/options/SPFxAddWebpartOptions.d.ts.map +1 -1
  101. package/build/question/options/SPFxAddWebpartOptions.js +9 -0
  102. package/build/question/options/SPFxAddWebpartOptions.js.map +1 -1
  103. package/build/question/other.d.ts.map +1 -1
  104. package/build/question/other.js +3 -0
  105. package/build/question/other.js.map +1 -1
  106. package/package.json +6 -6
  107. package/resource/package.nls.json +4 -8
  108. package/templates/fallback/common.zip +0 -0
  109. package/templates/fallback/csharp.zip +0 -0
  110. package/templates/fallback/js.zip +0 -0
  111. package/templates/fallback/ts.zip +0 -0
@@ -1,26 +1,31 @@
1
1
  import SwaggerParser from "@apidevtools/swagger-parser";
2
- import { GenerateResult, ValidateResult } from "./interfaces";
2
+ import { OpenAPIV3 } from "openapi-types";
3
+ import { APIInfo, GenerateResult, ParseOptions, ValidateResult } from "./interfaces";
3
4
  /**
4
5
  * A class that parses an OpenAPI specification file and provides methods to validate, list, and generate artifacts.
5
6
  */
6
7
  export declare class SpecParser {
7
- readonly specPath: string;
8
+ readonly pathOrSpec: string | OpenAPIV3.Document;
8
9
  readonly parser: SwaggerParser;
10
+ readonly options: ParseOptions;
9
11
  private apiMap;
10
12
  private spec;
11
13
  private unResolveSpec;
12
14
  private isSwaggerFile;
15
+ private defaultOptions;
13
16
  /**
14
17
  * Creates a new instance of the SpecParser class.
15
- * @param path The URL or file path of the OpenAPI specification file. The OpenAPI specification file must have a version of 3.0 or higher.
18
+ * @param pathOrDoc The path to the OpenAPI specification file or the OpenAPI specification object.
19
+ * @param options The options for parsing the OpenAPI specification file.
16
20
  */
17
- constructor(path: string);
21
+ constructor(pathOrDoc: string | OpenAPIV3.Document, options?: ParseOptions);
18
22
  /**
19
23
  * Validates the OpenAPI specification file and returns a validation result.
20
24
  *
21
25
  * @returns A validation result object that contains information about any errors or warnings in the specification file.
22
26
  */
23
27
  validate(): Promise<ValidateResult>;
28
+ listSupportedAPIInfo(): Promise<APIInfo[]>;
24
29
  /**
25
30
  * Lists all the OpenAPI operations in the specification file.
26
31
  * @returns A string array that represents the HTTP method and path of each operation, such as ['GET /pets/{petId}', 'GET /user/{userId}']
@@ -41,6 +46,6 @@ export declare class SpecParser {
41
46
  */
42
47
  generate(manifestPath: string, filter: string[], outputSpecPath: string, adaptiveCardFolder: string, signal?: AbortSignal): Promise<GenerateResult>;
43
48
  private loadSpec;
44
- private getAllSupportedApi;
49
+ private getAllSupportedAPIs;
45
50
  }
46
51
  //# sourceMappingURL=specParser.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"specParser.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"AAKA,OAAO,aAAa,MAAM,6BAA6B,CAAC;AAIxD,OAAO,EAIL,cAAc,EACd,cAAc,EAIf,MAAM,cAAc,CAAC;AAWtB;;GAEG;AACH,qBAAa,UAAU;IACrB,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,MAAM,EAAE,aAAa,CAAC;IAEtC,OAAO,CAAC,MAAM,CAA0D;IACxE,OAAO,CAAC,IAAI,CAAiC;IAC7C,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,aAAa,CAAsB;IAE3C;;;OAGG;gBACS,IAAI,EAAE,MAAM;IAKxB;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IAsFzC;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAU/B;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAqBtD;;;;;;OAMG;IACG,QAAQ,CACZ,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EAAE,EAChB,cAAc,EAAE,MAAM,EACtB,kBAAkB,EAAE,MAAM,EAC1B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,cAAc,CAAC;YA2EZ,QAAQ;IAetB,OAAO,CAAC,kBAAkB;CAqB3B"}
1
+ {"version":3,"file":"specParser.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"AAIA,OAAO,aAAa,MAAM,6BAA6B,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAK1C,OAAO,EACL,OAAO,EAEP,cAAc,EACd,YAAY,EACZ,cAAc,EAGf,MAAM,cAAc,CAAC;AAStB;;GAEG;AACH,qBAAa,UAAU;IACrB,SAAgB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC;IACxD,SAAgB,MAAM,EAAE,aAAa,CAAC;IACtC,SAAgB,OAAO,EAAE,YAAY,CAAC;IAEtC,OAAO,CAAC,MAAM,CAA0D;IACxE,OAAO,CAAC,IAAI,CAAiC;IAC7C,OAAO,CAAC,aAAa,CAAiC;IACtD,OAAO,CAAC,aAAa,CAAsB;IAE3C,OAAO,CAAC,cAAc,CAGpB;IAEF;;;;OAIG;gBACS,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,YAAY;IAS1E;;;;OAIG;IACG,QAAQ,IAAI,OAAO,CAAC,cAAc,CAAC;IA8BnC,oBAAoB,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAIhD;;;;OAIG;IACG,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAU/B;;;OAGG;IACG,gBAAgB,IAAI,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAqBtD;;;;;;OAMG;IACG,QAAQ,CACZ,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,EAAE,EAChB,cAAc,EAAE,MAAM,EACtB,kBAAkB,EAAE,MAAM,EAC1B,MAAM,CAAC,EAAE,WAAW,GACnB,OAAO,CAAC,cAAc,CAAC;YAgFZ,QAAQ;IAetB,OAAO,CAAC,mBAAmB;CAU5B"}
@@ -4,19 +4,18 @@
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.SpecParser = void 0;
6
6
  const tslib_1 = require("tslib");
7
- const util = tslib_1.__importStar(require("util"));
8
7
  const swagger_parser_1 = tslib_1.__importDefault(require("@apidevtools/swagger-parser"));
9
- const specParserError_1 = require("./specParserError");
10
8
  const swagger2openapi_1 = tslib_1.__importDefault(require("swagger2openapi"));
11
- const interfaces_1 = require("./interfaces");
12
- const constants_1 = require("./constants");
13
9
  const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
14
10
  const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
11
+ const path_1 = tslib_1.__importDefault(require("path"));
12
+ const interfaces_1 = require("./interfaces");
13
+ const constants_1 = require("./constants");
14
+ const specParserError_1 = require("./specParserError");
15
15
  const specFilter_1 = require("./specFilter");
16
16
  const utils_1 = require("./utils");
17
17
  const manifestUpdater_1 = require("./manifestUpdater");
18
18
  const adaptiveCardGenerator_1 = require("./adaptiveCardGenerator");
19
- const path_1 = tslib_1.__importDefault(require("path"));
20
19
  const adaptiveCardWrapper_1 = require("./adaptiveCardWrapper");
21
20
  /**
22
21
  * A class that parses an OpenAPI specification file and provides methods to validate, list, and generate artifacts.
@@ -24,11 +23,17 @@ const adaptiveCardWrapper_1 = require("./adaptiveCardWrapper");
24
23
  class SpecParser {
25
24
  /**
26
25
  * Creates a new instance of the SpecParser class.
27
- * @param path The URL or file path of the OpenAPI specification file. The OpenAPI specification file must have a version of 3.0 or higher.
26
+ * @param pathOrDoc The path to the OpenAPI specification file or the OpenAPI specification object.
27
+ * @param options The options for parsing the OpenAPI specification file.
28
28
  */
29
- constructor(path) {
30
- this.specPath = path;
29
+ constructor(pathOrDoc, options) {
30
+ this.defaultOptions = {
31
+ allowMissingId: true,
32
+ allowSwagger: true,
33
+ };
34
+ this.pathOrSpec = pathOrDoc;
31
35
  this.parser = new swagger_parser_1.default();
36
+ this.options = Object.assign(Object.assign({}, this.defaultOptions), (options !== null && options !== void 0 ? options : {}));
32
37
  }
33
38
  /**
34
39
  * Validates the OpenAPI specification file and returns a validation result.
@@ -37,80 +42,36 @@ class SpecParser {
37
42
  */
38
43
  async validate() {
39
44
  try {
40
- const errors = [];
41
- const warnings = [];
42
45
  try {
43
46
  await this.loadSpec();
44
47
  await this.parser.validate(this.spec);
45
48
  }
46
49
  catch (e) {
47
- // Spec not valid
48
- errors.push({ type: interfaces_1.ErrorType.SpecNotValid, content: e.toString() });
49
50
  return {
50
51
  status: interfaces_1.ValidationStatus.Error,
51
- warnings,
52
- errors,
52
+ warnings: [],
53
+ errors: [{ type: interfaces_1.ErrorType.SpecNotValid, content: e.toString() }],
53
54
  };
54
55
  }
55
- if (this.isSwaggerFile) {
56
- warnings.push({
57
- type: interfaces_1.WarningType.ConvertSwaggerToOpenAPI,
58
- content: constants_1.ConstantString.ConvertSwaggerToOpenAPI,
59
- });
60
- }
61
- // Server validation
62
- const serverErrors = utils_1.validateServer(this.spec);
63
- errors.push(...serverErrors);
64
- // Remote reference not supported
65
- const refPaths = this.parser.$refs.paths();
66
- // refPaths [0] is the current spec file path
67
- if (refPaths.length > 1) {
68
- errors.push({
69
- type: interfaces_1.ErrorType.RemoteRefNotSupported,
70
- content: util.format(constants_1.ConstantString.RemoteRefNotSupported, refPaths.join(", ")),
71
- data: refPaths,
72
- });
73
- }
74
- // No supported API
75
- const apiMap = this.getAllSupportedApi(this.spec);
76
- if (Object.keys(apiMap).length === 0) {
77
- errors.push({
78
- type: interfaces_1.ErrorType.NoSupportedApi,
79
- content: constants_1.ConstantString.NoSupportedApi,
80
- });
81
- }
82
- // OperationId missing
83
- const apisMissingOperationId = [];
84
- for (const key in apiMap) {
85
- const pathObjectItem = apiMap[key];
86
- if (!pathObjectItem.operationId) {
87
- apisMissingOperationId.push(key);
88
- }
89
- }
90
- if (apisMissingOperationId.length > 0) {
91
- warnings.push({
92
- type: interfaces_1.WarningType.OperationIdMissing,
93
- content: util.format(constants_1.ConstantString.MissingOperationId, apisMissingOperationId.join(", ")),
94
- data: apisMissingOperationId,
95
- });
96
- }
97
- let status = interfaces_1.ValidationStatus.Valid;
98
- if (warnings.length > 0 && errors.length === 0) {
99
- status = interfaces_1.ValidationStatus.Warning;
100
- }
101
- else if (errors.length > 0) {
102
- status = interfaces_1.ValidationStatus.Error;
56
+ if (!this.options.allowSwagger && this.isSwaggerFile) {
57
+ return {
58
+ status: interfaces_1.ValidationStatus.Error,
59
+ warnings: [],
60
+ errors: [
61
+ { type: interfaces_1.ErrorType.SwaggerNotSupported, content: constants_1.ConstantString.SwaggerNotSupported },
62
+ ],
63
+ };
103
64
  }
104
- return {
105
- status,
106
- warnings,
107
- errors,
108
- };
65
+ return utils_1.validateSpec(this.spec, this.parser, !!this.isSwaggerFile);
109
66
  }
110
67
  catch (err) {
111
68
  throw new specParserError_1.SpecParserError(err.toString(), interfaces_1.ErrorType.ValidateFailed);
112
69
  }
113
70
  }
71
+ // eslint-disable-next-line @typescript-eslint/require-await
72
+ async listSupportedAPIInfo() {
73
+ throw new Error("Method not implemented.");
74
+ }
114
75
  /**
115
76
  * Lists all the OpenAPI operations in the specification file.
116
77
  * @returns A string array that represents the HTTP method and path of each operation, such as ['GET /pets/{petId}', 'GET /user/{userId}']
@@ -119,7 +80,7 @@ class SpecParser {
119
80
  async list() {
120
81
  try {
121
82
  await this.loadSpec();
122
- const apiMap = this.getAllSupportedApi(this.spec);
83
+ const apiMap = this.getAllSupportedAPIs(this.spec);
123
84
  return Array.from(Object.keys(apiMap));
124
85
  }
125
86
  catch (err) {
@@ -133,7 +94,7 @@ class SpecParser {
133
94
  async listOperationMap() {
134
95
  try {
135
96
  await this.loadSpec();
136
- const apiMap = this.getAllSupportedApi(this.spec);
97
+ const apiMap = this.getAllSupportedAPIs(this.spec);
137
98
  const operationMap = new Map();
138
99
  for (const key in apiMap) {
139
100
  const pathObjectItem = apiMap[key];
@@ -171,7 +132,7 @@ class SpecParser {
171
132
  if (signal === null || signal === void 0 ? void 0 : signal.aborted) {
172
133
  throw new specParserError_1.SpecParserError(constants_1.ConstantString.CancelledMessage, interfaces_1.ErrorType.Cancelled);
173
134
  }
174
- const newUnResolvedSpec = specFilter_1.specFilter(filter, this.unResolveSpec, this.spec);
135
+ const newUnResolvedSpec = specFilter_1.specFilter(filter, this.unResolveSpec, this.spec, this.options.allowMissingId);
175
136
  let resultStr;
176
137
  if (outputSpecPath.endsWith(".yaml") || outputSpecPath.endsWith(".yml")) {
177
138
  resultStr = js_yaml_1.default.dump(newUnResolvedSpec);
@@ -222,7 +183,7 @@ class SpecParser {
222
183
  }
223
184
  async loadSpec() {
224
185
  if (!this.spec) {
225
- this.unResolveSpec = (await this.parser.parse(this.specPath));
186
+ this.unResolveSpec = (await this.parser.parse(this.pathOrSpec));
226
187
  // Convert swagger 2.0 to openapi 3.0
227
188
  if (!this.unResolveSpec.openapi && this.unResolveSpec.swagger === "2.0") {
228
189
  const specObj = await swagger2openapi_1.default.convert(this.unResolveSpec, {});
@@ -233,22 +194,11 @@ class SpecParser {
233
194
  this.spec = (await this.parser.dereference(clonedUnResolveSpec));
234
195
  }
235
196
  }
236
- getAllSupportedApi(spec) {
197
+ getAllSupportedAPIs(spec) {
237
198
  if (this.apiMap !== undefined) {
238
199
  return this.apiMap;
239
200
  }
240
- const paths = spec.paths;
241
- const result = {};
242
- for (const path in paths) {
243
- const methods = paths[path];
244
- for (const method in methods) {
245
- // For developer preview, only support GET operation with only 1 parameter without auth
246
- if (utils_1.isSupportedApi(method, path, spec)) {
247
- const operationObject = methods[method];
248
- result[`${method.toUpperCase()} ${path}`] = operationObject;
249
- }
250
- }
251
- }
201
+ const result = utils_1.listSupportedAPIs(spec, this.options.allowMissingId);
252
202
  this.apiMap = result;
253
203
  return result;
254
204
  }
@@ -1 +1 @@
1
- {"version":3,"file":"specParser.js","sourceRoot":"","sources":["../../../src/common/spec-parser/specParser.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAClC,YAAY,CAAC;;;;AAEb,mDAA6B;AAC7B,yFAAwD;AAExD,uDAAoD;AACpD,8EAAwC;AACxC,6CASsB;AACtB,2CAA6C;AAC7C,8DAA6B;AAC7B,gEAA0B;AAC1B,6CAA0C;AAC1C,mCAAiF;AACjF,uD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,KAAK,EAAE;gBAChF,MAAM,OAAO,GAAG,MAAM,yBAAS,CAAC,OAAO,CAAC,IAAI,CAAC,aAAoB,EAAE,EAAE,CAAC,CAAC;gBACvE,IAAI,CAAC,aAAa,GAAG,OAAO,CAAC,OAA6B,CAAC;gBAC3D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;aAC3B;YAED,MAAM,mBAAmB,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;YAC3E,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAuB,CAAC;SACxF;IACH,CAAC;IAEO,mBAAmB,CAAC,IAAwB;QAGlD,IAAI,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE;YAC7B,OAAO,IAAI,CAAC,MAAM,CAAC;SACpB;QACD,MAAM,MAAM,GAAG,yBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,cAAe,CAAC,CAAC;QACrE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAlOD,gCAkOC"}
@@ -1,6 +1,7 @@
1
1
  import { OpenAPIV3 } from "openapi-types";
2
- import { CheckParamResult, ErrorResult } from "./interfaces";
3
- export declare function isYamlSpecFile(specPath: string): Promise<boolean>;
2
+ import SwaggerParser from "@apidevtools/swagger-parser";
3
+ import { CheckParamResult, ErrorResult, Parameter, ValidateResult, WarningResult } from "./interfaces";
4
+ import { IMessagingExtensionCommand } from "@microsoft/teamsfx-api";
4
5
  export declare function checkParameters(paramObject: OpenAPIV3.ParameterObject[]): CheckParamResult;
5
6
  export declare function checkPostBody(schema: OpenAPIV3.SchemaObject, isRequired?: boolean): CheckParamResult;
6
7
  /**
@@ -17,14 +18,20 @@ export declare function checkPostBody(schema: OpenAPIV3.SchemaObject, isRequired
17
18
  * 5. response body should be “application/json” and not empty, and response code should be 20X
18
19
  * 6. only support request body with “application/json” content type
19
20
  */
20
- export declare function isSupportedApi(method: string, path: string, spec: OpenAPIV3.Document): boolean;
21
+ export declare function isSupportedApi(method: string, path: string, spec: OpenAPIV3.Document, allowMissingId: boolean): boolean;
21
22
  export declare function updateFirstLetter(str: string): string;
22
- export declare function getRelativePath(from: string, to: string): string;
23
23
  export declare function getResponseJson(operationObject: OpenAPIV3.OperationObject | undefined): OpenAPIV3.MediaTypeObject;
24
24
  export declare function convertPathToCamelCase(path: string): string;
25
25
  export declare function getUrlProtocol(urlString: string): string | undefined;
26
26
  export declare function resolveServerUrl(url: string): string;
27
27
  export declare function checkServerUrl(servers: OpenAPIV3.ServerObject[]): ErrorResult[];
28
- export declare function validateServer(spec: OpenAPIV3.Document): ErrorResult[];
28
+ export declare function validateServer(spec: OpenAPIV3.Document, allowMissingId: boolean): ErrorResult[];
29
29
  export declare function isWellKnownName(name: string, wellknownNameList: string[]): boolean;
30
+ export declare function generateParametersFromSchema(schema: OpenAPIV3.SchemaObject, name: string, isRequired?: boolean): [Parameter[], Parameter[]];
31
+ export declare function parseApiInfo(operationItem: OpenAPIV3.OperationObject): [IMessagingExtensionCommand, WarningResult | undefined];
32
+ export declare function listSupportedAPIs(spec: OpenAPIV3.Document, allowMissingId: boolean): {
33
+ [key: string]: OpenAPIV3.OperationObject;
34
+ };
35
+ export declare function validateSpec(spec: OpenAPIV3.Document, parser: SwaggerParser, isSwaggerFile: boolean): ValidateResult;
36
+ export declare function format(str: string, ...args: string[]): string;
30
37
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/common/spec-parser/utils.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAG1C,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAa,MAAM,cAAc,CAAC;AAGxE,wBAAsB,cAAc,CAAC,QAA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4B,CAC1C,MAAM,EAAE,SAAS,CAAC,YAAY,EAC9B,IAAI,EAAE,MAAM,EACZ,UAAU,UAAQ,GACjB,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,CAAC,CAuC5B;AAED,wBAAgB,YAAY,CAC1B,aAAa,EAAE,SAAS,CAAC,eAAe,GACvC,CAAC,0BAA0B,EAAE,aAAa,GAAG,SAAS,CAAC,CAsEzD;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,SAAS,CAAC,QAAQ,EACxB,cAAc,EAAE,OAAO,GACtB;IACD,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAC,eAAe,CAAC;CAC1C,CAcA;AAED,wBAAgB,YAAY,CAC1B,IAAI,EAAE,SAAS,CAAC,QAAQ,EACxB,MAAM,EAAE,aAAa,EACrB,aAAa,EAAE,OAAO,GACrB,cAAc,CAiEhB;AAED,wBAAgB,MAAM,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,MAAM,EAAE,GAAG,MAAM,CAM7D"}
@@ -2,35 +2,9 @@
2
2
  // Licensed under the MIT license.
3
3
  "use strict";
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.isWellKnownName = exports.validateServer = exports.checkServerUrl = exports.resolveServerUrl = exports.getUrlProtocol = exports.convertPathToCamelCase = exports.getResponseJson = exports.getRelativePath = exports.updateFirstLetter = exports.isSupportedApi = exports.checkPostBody = exports.checkParameters = exports.isYamlSpecFile = void 0;
6
- const tslib_1 = require("tslib");
7
- const axios_1 = tslib_1.__importDefault(require("axios"));
8
- const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
5
+ exports.format = exports.validateSpec = exports.listSupportedAPIs = exports.parseApiInfo = exports.generateParametersFromSchema = exports.isWellKnownName = exports.validateServer = exports.checkServerUrl = exports.resolveServerUrl = exports.getUrlProtocol = exports.convertPathToCamelCase = exports.getResponseJson = exports.updateFirstLetter = exports.isSupportedApi = exports.checkPostBody = exports.checkParameters = void 0;
9
6
  const constants_1 = require("./constants");
10
- const path_1 = tslib_1.__importDefault(require("path"));
11
- const util = tslib_1.__importStar(require("util"));
12
7
  const interfaces_1 = require("./interfaces");
13
- const util_1 = require("util");
14
- async function isYamlSpecFile(specPath) {
15
- if (specPath.endsWith(".yaml") || specPath.endsWith(".yml")) {
16
- return true;
17
- }
18
- else if (specPath.endsWith(".json")) {
19
- return false;
20
- }
21
- const isRemoteFile = specPath.startsWith("http:") || specPath.startsWith("https:");
22
- const fileContent = isRemoteFile
23
- ? (await axios_1.default.get(specPath)).data
24
- : await fs_extra_1.default.readFile(specPath, "utf-8");
25
- try {
26
- JSON.parse(fileContent);
27
- return false;
28
- }
29
- catch (error) {
30
- return true;
31
- }
32
- }
33
- exports.isYamlSpecFile = isYamlSpecFile;
34
8
  function checkParameters(paramObject) {
35
9
  const paramResult = {
36
10
  requiredNum: 0,
@@ -128,7 +102,7 @@ exports.checkPostBody = checkPostBody;
128
102
  * 5. response body should be “application/json” and not empty, and response code should be 20X
129
103
  * 6. only support request body with “application/json” content type
130
104
  */
131
- function isSupportedApi(method, path, spec) {
105
+ function isSupportedApi(method, path, spec, allowMissingId) {
132
106
  var _a;
133
107
  const pathObj = spec.paths[path];
134
108
  method = method.toLocaleLowerCase();
@@ -137,6 +111,9 @@ function isSupportedApi(method, path, spec) {
137
111
  pathObj[method] &&
138
112
  !((_a = pathObj[method]) === null || _a === void 0 ? void 0 : _a.security)) {
139
113
  const operationObject = pathObj[method];
114
+ if (!allowMissingId && !operationObject.operationId) {
115
+ return false;
116
+ }
140
117
  const paramObject = operationObject.parameters;
141
118
  const requestBody = operationObject.requestBody;
142
119
  const requestJsonBody = requestBody === null || requestBody === void 0 ? void 0 : requestBody.content["application/json"];
@@ -182,11 +159,6 @@ function updateFirstLetter(str) {
182
159
  return str.charAt(0).toUpperCase() + str.slice(1);
183
160
  }
184
161
  exports.updateFirstLetter = updateFirstLetter;
185
- function getRelativePath(from, to) {
186
- const relativePath = path_1.default.relative(path_1.default.dirname(from), to);
187
- return path_1.default.normalize(relativePath).replace(/\\/g, "/");
188
- }
189
- exports.getRelativePath = getRelativePath;
190
162
  function getResponseJson(operationObject) {
191
163
  var _a, _b;
192
164
  let json = {};
@@ -228,7 +200,7 @@ function resolveServerUrl(url) {
228
200
  const envVar = matches[1];
229
201
  const envVal = process.env[envVar];
230
202
  if (!envVal) {
231
- throw new Error(util_1.format(constants_1.ConstantString.ResolveServerUrlFailed, envVar));
203
+ throw new Error(format(constants_1.ConstantString.ResolveServerUrlFailed, envVar));
232
204
  }
233
205
  else {
234
206
  newUrl = newUrl.replace(matches[0], envVal);
@@ -263,16 +235,17 @@ function checkServerUrl(servers) {
263
235
  }
264
236
  else if (protocol !== "https:") {
265
237
  // Http server url is not supported
238
+ const protocolString = protocol.slice(0, -1);
266
239
  errors.push({
267
240
  type: interfaces_1.ErrorType.UrlProtocolNotSupported,
268
- content: util.format(constants_1.ConstantString.UrlProtocolNotSupported, protocol.slice(0, -1)),
269
- data: servers,
241
+ content: format(constants_1.ConstantString.UrlProtocolNotSupported, protocol.slice(0, -1)),
242
+ data: protocolString,
270
243
  });
271
244
  }
272
245
  return errors;
273
246
  }
274
247
  exports.checkServerUrl = checkServerUrl;
275
- function validateServer(spec) {
248
+ function validateServer(spec, allowMissingId) {
276
249
  const errors = [];
277
250
  let hasTopLevelServers = false;
278
251
  let hasPathLevelServers = false;
@@ -293,7 +266,7 @@ function validateServer(spec) {
293
266
  }
294
267
  for (const method in methods) {
295
268
  const operationObject = methods[method];
296
- if (isSupportedApi(method, path, spec)) {
269
+ if (isSupportedApi(method, path, spec, allowMissingId)) {
297
270
  if ((operationObject === null || operationObject === void 0 ? void 0 : operationObject.servers) && operationObject.servers.length >= 1) {
298
271
  hasOperationLevelServers = true;
299
272
  const serverErrors = checkServerUrl(operationObject.servers);
@@ -321,4 +294,183 @@ function isWellKnownName(name, wellknownNameList) {
321
294
  return false;
322
295
  }
323
296
  exports.isWellKnownName = isWellKnownName;
297
+ function generateParametersFromSchema(schema, name, isRequired = false) {
298
+ var _a, _b;
299
+ const requiredParams = [];
300
+ const optionalParams = [];
301
+ if (schema.type === "string" ||
302
+ schema.type === "integer" ||
303
+ schema.type === "boolean" ||
304
+ schema.type === "number") {
305
+ const parameter = {
306
+ name: name,
307
+ title: updateFirstLetter(name).slice(0, constants_1.ConstantString.ParameterTitleMaxLens),
308
+ description: ((_a = schema.description) !== null && _a !== void 0 ? _a : "").slice(0, constants_1.ConstantString.ParameterDescriptionMaxLens),
309
+ };
310
+ if (isRequired && schema.default === undefined) {
311
+ requiredParams.push(parameter);
312
+ }
313
+ else {
314
+ optionalParams.push(parameter);
315
+ }
316
+ }
317
+ else if (schema.type === "object") {
318
+ const { properties } = schema;
319
+ for (const property in properties) {
320
+ let isRequired = false;
321
+ if (schema.required && ((_b = schema.required) === null || _b === void 0 ? void 0 : _b.indexOf(property)) >= 0) {
322
+ isRequired = true;
323
+ }
324
+ const [requiredP, optionalP] = generateParametersFromSchema(properties[property], property, isRequired);
325
+ requiredParams.push(...requiredP);
326
+ optionalParams.push(...optionalP);
327
+ }
328
+ }
329
+ return [requiredParams, optionalParams];
330
+ }
331
+ exports.generateParametersFromSchema = generateParametersFromSchema;
332
+ function parseApiInfo(operationItem) {
333
+ var _a, _b;
334
+ const requiredParams = [];
335
+ const optionalParams = [];
336
+ const paramObject = operationItem.parameters;
337
+ if (paramObject) {
338
+ paramObject.forEach((param) => {
339
+ var _a;
340
+ const parameter = {
341
+ name: param.name,
342
+ title: updateFirstLetter(param.name).slice(0, constants_1.ConstantString.ParameterTitleMaxLens),
343
+ description: ((_a = param.description) !== null && _a !== void 0 ? _a : "").slice(0, constants_1.ConstantString.ParameterDescriptionMaxLens),
344
+ };
345
+ const schema = param.schema;
346
+ if (param.in !== "header" && param.in !== "cookie") {
347
+ if (param.required && (schema === null || schema === void 0 ? void 0 : schema.default) === undefined) {
348
+ requiredParams.push(parameter);
349
+ }
350
+ else {
351
+ optionalParams.push(parameter);
352
+ }
353
+ }
354
+ });
355
+ }
356
+ if (operationItem.requestBody) {
357
+ const requestBody = operationItem.requestBody;
358
+ const requestJson = requestBody.content["application/json"];
359
+ if (Object.keys(requestJson).length !== 0) {
360
+ const schema = requestJson.schema;
361
+ const [requiredP, optionalP] = generateParametersFromSchema(schema, "requestBody", requestBody.required);
362
+ requiredParams.push(...requiredP);
363
+ optionalParams.push(...optionalP);
364
+ }
365
+ }
366
+ const operationId = operationItem.operationId;
367
+ const parameters = [];
368
+ if (requiredParams.length != 0) {
369
+ parameters.push(...requiredParams);
370
+ }
371
+ else {
372
+ parameters.push(optionalParams[0]);
373
+ }
374
+ const command = {
375
+ context: ["compose"],
376
+ type: "query",
377
+ title: ((_a = operationItem.summary) !== null && _a !== void 0 ? _a : "").slice(0, constants_1.ConstantString.CommandTitleMaxLens),
378
+ id: operationId,
379
+ parameters: parameters,
380
+ description: ((_b = operationItem.description) !== null && _b !== void 0 ? _b : "").slice(0, constants_1.ConstantString.CommandDescriptionMaxLens),
381
+ };
382
+ let warning = undefined;
383
+ if (requiredParams.length === 0 && optionalParams.length > 1) {
384
+ warning = {
385
+ type: interfaces_1.WarningType.OperationOnlyContainsOptionalParam,
386
+ content: format(constants_1.ConstantString.OperationOnlyContainsOptionalParam, operationId),
387
+ data: operationId,
388
+ };
389
+ }
390
+ return [command, warning];
391
+ }
392
+ exports.parseApiInfo = parseApiInfo;
393
+ function listSupportedAPIs(spec, allowMissingId) {
394
+ const paths = spec.paths;
395
+ const result = {};
396
+ for (const path in paths) {
397
+ const methods = paths[path];
398
+ for (const method in methods) {
399
+ // For developer preview, only support GET operation with only 1 parameter without auth
400
+ if (isSupportedApi(method, path, spec, allowMissingId)) {
401
+ const operationObject = methods[method];
402
+ result[`${method.toUpperCase()} ${path}`] = operationObject;
403
+ }
404
+ }
405
+ }
406
+ return result;
407
+ }
408
+ exports.listSupportedAPIs = listSupportedAPIs;
409
+ function validateSpec(spec, parser, isSwaggerFile) {
410
+ const errors = [];
411
+ const warnings = [];
412
+ if (isSwaggerFile) {
413
+ warnings.push({
414
+ type: interfaces_1.WarningType.ConvertSwaggerToOpenAPI,
415
+ content: constants_1.ConstantString.ConvertSwaggerToOpenAPI,
416
+ });
417
+ }
418
+ // Server validation
419
+ const serverErrors = validateServer(spec, true);
420
+ errors.push(...serverErrors);
421
+ // Remote reference not supported
422
+ const refPaths = parser.$refs.paths();
423
+ // refPaths [0] is the current spec file path
424
+ if (refPaths.length > 1) {
425
+ errors.push({
426
+ type: interfaces_1.ErrorType.RemoteRefNotSupported,
427
+ content: format(constants_1.ConstantString.RemoteRefNotSupported, refPaths.join(", ")),
428
+ data: refPaths,
429
+ });
430
+ }
431
+ // No supported API
432
+ const apiMap = listSupportedAPIs(spec, true);
433
+ if (Object.keys(apiMap).length === 0) {
434
+ errors.push({
435
+ type: interfaces_1.ErrorType.NoSupportedApi,
436
+ content: constants_1.ConstantString.NoSupportedApi,
437
+ });
438
+ }
439
+ // OperationId missing
440
+ const apisMissingOperationId = [];
441
+ for (const key in apiMap) {
442
+ const pathObjectItem = apiMap[key];
443
+ if (!pathObjectItem.operationId) {
444
+ apisMissingOperationId.push(key);
445
+ }
446
+ }
447
+ if (apisMissingOperationId.length > 0) {
448
+ warnings.push({
449
+ type: interfaces_1.WarningType.OperationIdMissing,
450
+ content: format(constants_1.ConstantString.MissingOperationId, apisMissingOperationId.join(", ")),
451
+ data: apisMissingOperationId,
452
+ });
453
+ }
454
+ let status = interfaces_1.ValidationStatus.Valid;
455
+ if (warnings.length > 0 && errors.length === 0) {
456
+ status = interfaces_1.ValidationStatus.Warning;
457
+ }
458
+ else if (errors.length > 0) {
459
+ status = interfaces_1.ValidationStatus.Error;
460
+ }
461
+ return {
462
+ status,
463
+ warnings,
464
+ errors,
465
+ };
466
+ }
467
+ exports.validateSpec = validateSpec;
468
+ function format(str, ...args) {
469
+ let index = 0;
470
+ return str.replace(/%s/g, () => {
471
+ const arg = args[index++];
472
+ return arg !== undefined ? arg : "";
473
+ });
474
+ }
475
+ exports.format = format;
324
476
  //# sourceMappingURL=utils.js.map