@redocly/openapi-core 1.0.0-beta.105 → 1.0.0-beta.108

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 (240) hide show
  1. package/README.md +4 -4
  2. package/__tests__/utils.ts +5 -5
  3. package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +0 -1
  4. package/lib/benchmark/benches/recommended-oas3.bench.js +1 -1
  5. package/lib/benchmark/utils.d.ts +2 -2
  6. package/lib/benchmark/utils.js +2 -2
  7. package/lib/bundle.d.ts +2 -2
  8. package/lib/bundle.js +7 -4
  9. package/lib/config/all.d.ts +2 -2
  10. package/lib/config/all.js +3 -3
  11. package/lib/config/builtIn.d.ts +2 -2
  12. package/lib/config/builtIn.js +2 -2
  13. package/lib/config/config-resolvers.d.ts +5 -5
  14. package/lib/config/config-resolvers.js +70 -49
  15. package/lib/config/config.d.ts +8 -10
  16. package/lib/config/config.js +10 -7
  17. package/lib/config/load.d.ts +7 -0
  18. package/lib/config/load.js +18 -10
  19. package/lib/config/minimal.d.ts +2 -2
  20. package/lib/config/minimal.js +5 -4
  21. package/lib/config/recommended.d.ts +2 -2
  22. package/lib/config/recommended.js +5 -4
  23. package/lib/config/rules.d.ts +3 -3
  24. package/lib/config/rules.js +1 -1
  25. package/lib/config/types.d.ts +23 -19
  26. package/lib/config/utils.d.ts +5 -5
  27. package/lib/config/utils.js +48 -31
  28. package/lib/decorators/common/registry-dependencies.js +1 -1
  29. package/lib/decorators/common/remove-x-internal.js +2 -2
  30. package/lib/env.d.ts +3 -0
  31. package/lib/env.js +8 -0
  32. package/lib/format/codeframes.js +16 -10
  33. package/lib/format/format.js +29 -27
  34. package/lib/index.d.ts +5 -5
  35. package/lib/index.js +4 -2
  36. package/lib/js-yaml/index.js +2 -6
  37. package/lib/lint.d.ts +2 -2
  38. package/lib/lint.js +16 -6
  39. package/lib/logger.d.ts +10 -0
  40. package/lib/logger.js +31 -0
  41. package/lib/output.d.ts +3 -0
  42. package/lib/output.js +9 -0
  43. package/lib/redocly/index.js +10 -9
  44. package/lib/redocly/registry-api-types.d.ts +28 -30
  45. package/lib/redocly/registry-api.d.ts +4 -3
  46. package/lib/redocly/registry-api.js +9 -4
  47. package/lib/ref-utils.js +2 -1
  48. package/lib/resolve.d.ts +1 -1
  49. package/lib/resolve.js +1 -1
  50. package/lib/rules/ajv.d.ts +1 -1
  51. package/lib/rules/ajv.js +7 -7
  52. package/lib/rules/common/assertions/asserts.js +4 -4
  53. package/lib/rules/common/assertions/index.js +1 -1
  54. package/lib/rules/common/info-license-url.d.ts +1 -1
  55. package/lib/rules/common/info-license-url.js +5 -10
  56. package/lib/rules/common/info-license.d.ts +2 -0
  57. package/lib/rules/common/info-license.js +17 -0
  58. package/lib/rules/common/no-enum-type-mismatch.js +1 -3
  59. package/lib/rules/common/no-invalid-parameter-examples.js +3 -3
  60. package/lib/rules/common/no-invalid-schema-examples.js +3 -3
  61. package/lib/rules/common/operation-operationId.js +1 -1
  62. package/lib/rules/common/operation-security-defined.js +1 -1
  63. package/lib/rules/common/path-not-include-query.js +1 -1
  64. package/lib/rules/common/paths-kebab-case.js +4 -1
  65. package/lib/rules/common/spec.js +3 -3
  66. package/lib/rules/oas2/index.js +4 -4
  67. package/lib/rules/oas2/remove-unused-components.js +5 -5
  68. package/lib/rules/oas3/index.js +6 -6
  69. package/lib/rules/oas3/no-empty-servers.js +1 -1
  70. package/lib/rules/oas3/no-invalid-media-type-examples.js +2 -2
  71. package/lib/rules/oas3/no-server-variables-empty-enum.d.ts +2 -0
  72. package/lib/rules/oas3/{no-servers-empty-enum.js → no-server-variables-empty-enum.js} +4 -4
  73. package/lib/rules/oas3/no-unused-components.js +1 -1
  74. package/lib/rules/oas3/remove-unused-components.js +5 -5
  75. package/lib/rules/other/stats.js +43 -14
  76. package/lib/rules/utils.d.ts +3 -2
  77. package/lib/rules/utils.js +20 -5
  78. package/lib/types/index.d.ts +2 -2
  79. package/lib/types/redocly-yaml.js +9 -8
  80. package/lib/utils.d.ts +5 -0
  81. package/lib/utils.js +22 -5
  82. package/lib/visitors.d.ts +1 -1
  83. package/lib/visitors.js +2 -2
  84. package/lib/walk.d.ts +2 -1
  85. package/lib/walk.js +6 -3
  86. package/package.json +2 -2
  87. package/src/__tests__/__snapshots__/bundle.test.ts.snap +141 -0
  88. package/src/__tests__/bundle.test.ts +68 -34
  89. package/src/__tests__/codeframes.test.ts +13 -14
  90. package/src/__tests__/js-yaml.test.ts +6 -4
  91. package/src/__tests__/lint.test.ts +74 -6
  92. package/src/__tests__/logger-browser.test.ts +53 -0
  93. package/src/__tests__/logger.test.ts +47 -0
  94. package/src/__tests__/login.test.ts +2 -2
  95. package/src/__tests__/normalizeVisitors.test.ts +4 -4
  96. package/src/__tests__/output-browser.test.ts +18 -0
  97. package/src/__tests__/output.test.ts +15 -0
  98. package/src/__tests__/ref-utils.test.ts +13 -13
  99. package/src/__tests__/resolve-http.test.ts +1 -1
  100. package/src/__tests__/resolve.test.ts +14 -11
  101. package/src/__tests__/utils-browser.test.ts +11 -0
  102. package/src/__tests__/utils.test.ts +7 -0
  103. package/src/__tests__/walk.test.ts +48 -56
  104. package/src/benchmark/benches/lint-with-many-rules.bench.ts +1 -1
  105. package/src/benchmark/benches/lint-with-nested-rule.bench.ts +1 -1
  106. package/src/benchmark/benches/lint-with-no-rules.bench.ts +1 -1
  107. package/src/benchmark/benches/lint-with-top-level-rule-report.bench.ts +1 -2
  108. package/src/benchmark/benches/lint-with-top-level-rule.bench.ts +1 -1
  109. package/src/benchmark/benches/recommended-oas3.bench.ts +3 -3
  110. package/src/benchmark/benches/resolve-with-no-external.bench.ts +1 -1
  111. package/src/benchmark/benchmark.js +9 -5
  112. package/src/benchmark/utils.ts +5 -5
  113. package/src/bundle.ts +24 -20
  114. package/src/config/__tests__/__snapshots__/config-resolvers.test.ts.snap +7 -5
  115. package/src/config/__tests__/config-resolvers.test.ts +123 -121
  116. package/src/config/__tests__/config.test.ts +111 -76
  117. package/src/config/__tests__/fixtures/resolve-config/api/plugin.js +4 -2
  118. package/src/config/__tests__/fixtures/resolve-config/plugin.js +4 -1
  119. package/src/config/__tests__/load.test.ts +79 -1
  120. package/src/config/__tests__/resolve-plugins.test.ts +3 -3
  121. package/src/config/__tests__/utils.test.ts +83 -0
  122. package/src/config/all.ts +5 -6
  123. package/src/config/builtIn.ts +5 -5
  124. package/src/config/config-resolvers.ts +161 -96
  125. package/src/config/config.ts +15 -13
  126. package/src/config/load.ts +34 -11
  127. package/src/config/minimal.ts +7 -6
  128. package/src/config/recommended.ts +7 -6
  129. package/src/config/rules.ts +6 -6
  130. package/src/config/types.ts +28 -19
  131. package/src/config/utils.ts +78 -57
  132. package/src/decorators/__tests__/filter-out.test.ts +8 -4
  133. package/src/decorators/__tests__/remove-x-internal.test.ts +5 -5
  134. package/src/decorators/common/filters/filter-helper.ts +1 -1
  135. package/src/decorators/common/info-description-override.ts +1 -1
  136. package/src/decorators/common/operation-description-override.ts +1 -1
  137. package/src/decorators/common/registry-dependencies.ts +1 -1
  138. package/src/decorators/common/remove-x-internal.ts +4 -4
  139. package/src/decorators/common/tag-description-override.ts +1 -1
  140. package/src/env.ts +5 -0
  141. package/src/format/codeframes.ts +18 -12
  142. package/src/format/format.ts +37 -42
  143. package/src/index.ts +8 -7
  144. package/src/js-yaml/index.ts +4 -8
  145. package/src/lint.ts +22 -18
  146. package/src/logger.ts +34 -0
  147. package/src/oas-types.ts +1 -6
  148. package/src/output.ts +7 -0
  149. package/src/redocly/__tests__/redocly-client.test.ts +25 -19
  150. package/src/redocly/index.ts +12 -7
  151. package/src/redocly/registry-api-types.ts +27 -29
  152. package/src/redocly/registry-api.ts +22 -12
  153. package/src/ref-utils.ts +4 -3
  154. package/src/resolve.ts +11 -8
  155. package/src/rules/__tests__/no-unresolved-refs.test.ts +4 -4
  156. package/src/rules/__tests__/utils.test.ts +160 -0
  157. package/src/rules/ajv.ts +7 -8
  158. package/src/rules/common/__tests__/info-description.test.ts +3 -3
  159. package/src/rules/common/__tests__/info-license.test.ts +2 -2
  160. package/src/rules/common/__tests__/license-url.test.ts +2 -2
  161. package/src/rules/common/__tests__/no-ambiguous-paths.test.ts +1 -1
  162. package/src/rules/common/__tests__/no-enum-type-mismatch.test.ts +8 -8
  163. package/src/rules/common/__tests__/no-identical-paths.test.ts +1 -1
  164. package/src/rules/common/__tests__/no-path-trailing-slash.test.ts +3 -3
  165. package/src/rules/common/__tests__/operation-2xx-response.test.ts +3 -3
  166. package/src/rules/common/__tests__/operation-4xx-response.test.ts +3 -3
  167. package/src/rules/common/__tests__/operation-operationId-unique.test.ts +2 -2
  168. package/src/rules/common/__tests__/operation-operationId-url-safe.test.ts +1 -1
  169. package/src/rules/common/__tests__/operation-parameters-unique.test.ts +4 -4
  170. package/src/rules/common/__tests__/operation-security-defined.test.ts +2 -2
  171. package/src/rules/common/__tests__/operation-singular-tag.test.ts +2 -2
  172. package/src/rules/common/__tests__/path-http-verbs-order.test.ts +2 -2
  173. package/src/rules/common/__tests__/path-not-include-query.test.ts +2 -2
  174. package/src/rules/common/__tests__/path-params-defined.test.ts +3 -3
  175. package/src/rules/common/__tests__/paths-kebab-case.test.ts +15 -15
  176. package/src/rules/common/__tests__/scalar-property-missing-example.test.ts +8 -8
  177. package/src/rules/common/__tests__/spec.test.ts +2 -2
  178. package/src/rules/common/__tests__/tag-description.test.ts +2 -2
  179. package/src/rules/common/__tests__/tags-alphabetical.test.ts +2 -2
  180. package/src/rules/common/assertions/__tests__/asserts.test.ts +513 -130
  181. package/src/rules/common/assertions/asserts.ts +4 -4
  182. package/src/rules/common/assertions/index.ts +7 -7
  183. package/src/rules/common/info-license-url.ts +4 -9
  184. package/src/rules/common/info-license.ts +15 -0
  185. package/src/rules/common/no-ambiguous-paths.ts +1 -1
  186. package/src/rules/common/no-enum-type-mismatch.ts +12 -9
  187. package/src/rules/common/no-invalid-parameter-examples.ts +4 -4
  188. package/src/rules/common/no-invalid-schema-examples.ts +4 -4
  189. package/src/rules/common/operation-operationId.ts +1 -1
  190. package/src/rules/common/operation-parameters-unique.ts +2 -2
  191. package/src/rules/common/operation-security-defined.ts +1 -1
  192. package/src/rules/common/path-not-include-query.ts +1 -1
  193. package/src/rules/common/path-params-defined.ts +1 -1
  194. package/src/rules/common/paths-kebab-case.ts +4 -1
  195. package/src/rules/common/scalar-property-missing-example.ts +1 -1
  196. package/src/rules/common/spec.ts +12 -9
  197. package/src/rules/no-unresolved-refs.ts +1 -1
  198. package/src/rules/oas2/__tests__/boolean-parameter-prefixes.test.ts +3 -3
  199. package/src/rules/oas2/__tests__/spec/info.test.ts +12 -12
  200. package/src/rules/oas2/__tests__/spec/operation.test.ts +4 -4
  201. package/src/rules/oas2/__tests__/spec/paths.test.ts +10 -10
  202. package/src/rules/oas2/__tests__/spec/referenceableScalars.test.ts +6 -2
  203. package/src/rules/oas2/__tests__/spec/utils.ts +6 -6
  204. package/src/rules/oas2/index.ts +3 -3
  205. package/src/rules/oas2/remove-unused-components.ts +14 -9
  206. package/src/rules/oas3/__tests__/boolean-parameter-prefixes.test.ts +3 -3
  207. package/src/rules/oas3/__tests__/no-empty-enum-servers.com.test.ts +16 -16
  208. package/src/rules/oas3/__tests__/no-example-value-and-externalValue.test.ts +2 -2
  209. package/src/rules/oas3/__tests__/no-invalid-media-type-examples.test.ts +13 -13
  210. package/src/rules/oas3/__tests__/no-server-example.com.test.ts +2 -2
  211. package/src/rules/oas3/__tests__/no-server-trailing-slash.test.ts +3 -3
  212. package/src/rules/oas3/__tests__/no-unused-components.test.ts +1 -1
  213. package/src/rules/oas3/__tests__/spec/callbacks.test.ts +1 -1
  214. package/src/rules/oas3/__tests__/spec/info.test.ts +12 -12
  215. package/src/rules/oas3/__tests__/spec/operation.test.ts +8 -8
  216. package/src/rules/oas3/__tests__/spec/paths.test.ts +10 -10
  217. package/src/rules/oas3/__tests__/spec/referenceableScalars.test.ts +12 -12
  218. package/src/rules/oas3/__tests__/spec/servers.test.ts +15 -15
  219. package/src/rules/oas3/__tests__/spec/spec.test.ts +6 -6
  220. package/src/rules/oas3/__tests__/spec/utils.ts +6 -6
  221. package/src/rules/oas3/index.ts +5 -5
  222. package/src/rules/oas3/no-empty-servers.ts +1 -1
  223. package/src/rules/oas3/no-invalid-media-type-examples.ts +14 -6
  224. package/src/rules/oas3/{no-servers-empty-enum.ts → no-server-variables-empty-enum.ts} +10 -11
  225. package/src/rules/oas3/no-unused-components.ts +1 -1
  226. package/src/rules/oas3/remove-unused-components.ts +21 -10
  227. package/src/rules/other/stats.ts +46 -17
  228. package/src/rules/utils.ts +20 -4
  229. package/src/types/index.ts +5 -5
  230. package/src/types/redocly-yaml.ts +9 -8
  231. package/src/typings/common.ts +9 -1
  232. package/src/typings/openapi.ts +1 -1
  233. package/src/utils.ts +26 -3
  234. package/src/visitors.ts +9 -9
  235. package/src/walk.ts +15 -11
  236. package/tsconfig.tsbuildinfo +1 -1
  237. package/lib/rules/common/license-url.d.ts +0 -2
  238. package/lib/rules/common/license-url.js +0 -12
  239. package/lib/rules/oas3/no-servers-empty-enum.d.ts +0 -2
  240. package/src/rules/common/license-url.ts +0 -10
package/README.md CHANGED
@@ -9,9 +9,9 @@ See https://github.com/Redocly/redocly-cli
9
9
  ```js
10
10
  import { formatProblems, lint, loadConfig } from '@redocly/openapi-core';
11
11
 
12
- const pathToEntryPoint = 'openapi.yaml';
12
+ const pathToApi = 'openapi.yaml';
13
13
  const config = loadConfig('optional/path/to/.redocly.yaml');
14
- const lintResults = await lint({ ref: pathToEntryPoint, config });
14
+ const lintResults = await lint({ ref: pathToApi, config });
15
15
  ```
16
16
 
17
17
  ### Bundle
@@ -19,7 +19,7 @@ const lintResults = await lint({ ref: pathToEntryPoint, config });
19
19
  ```js
20
20
  import { formatProblems, bundle, loadConfig } from '@redocly/openapi-core';
21
21
 
22
- const pathToEntryPoint = 'openapi.yaml';
22
+ const pathToApi = 'openapi.yaml';
23
23
  const config = loadConfig('optional/path/to/.redocly.yaml');
24
- const { bundle, problems } = await bundle({ ref: pathToEntryPoint, config });
24
+ const { bundle, problems } = await bundle({ ref: pathToApi, config });
25
25
  ```
@@ -1,7 +1,7 @@
1
1
  import * as path from 'path';
2
2
 
3
3
  import { Document, Source, NormalizedProblem, parseYaml, stringifyYaml } from '../src';
4
- import { LintConfig, resolveLint, resolvePlugins } from '../src/config';
4
+ import { StyleguideConfig, resolveStyleguideConfig, resolvePlugins } from '../src/config';
5
5
  import { Oas3RuleSet } from '../src/oas-types';
6
6
 
7
7
  import type { RuleConfig, Plugin, DecoratorConfig } from '../src/config';
@@ -63,7 +63,7 @@ export function makeConfigForRuleset(
63
63
  },
64
64
  ]);
65
65
 
66
- return new LintConfig({
66
+ return new StyleguideConfig({
67
67
  plugins,
68
68
  rules: rulesConf,
69
69
  });
@@ -74,9 +74,9 @@ export async function makeConfig(
74
74
  decorators?: Record<string, DecoratorConfig>,
75
75
  configPath?: string
76
76
  ) {
77
- return new LintConfig(
78
- await resolveLint({
79
- lintConfig: {
77
+ return new StyleguideConfig(
78
+ await resolveStyleguideConfig({
79
+ styleguideConfig: {
80
80
  plugins: [],
81
81
  extends: [],
82
82
  rules,
@@ -13,7 +13,6 @@ const rebillyDocument = utils_1.parseYamlToDocument(fs_1.readFileSync(rebillyDef
13
13
  const config = utils_1.makeConfigForRuleset({
14
14
  test: () => {
15
15
  return {
16
- // @ts-ignore
17
16
  Schema(schema, ctx) {
18
17
  if (schema.type === 'number') {
19
18
  ctx.report({
@@ -15,7 +15,7 @@ function measureAsync() {
15
15
  return lint_1.lintDocument({
16
16
  externalRefResolver: new resolve_1.BaseResolver(),
17
17
  document: rebillyDocument,
18
- config: new config_1.LintConfig(config_1.resolvePreset('recommended', [config_1.defaultPlugin])),
18
+ config: new config_1.StyleguideConfig(config_1.resolvePreset('recommended', [config_1.defaultPlugin])),
19
19
  });
20
20
  }
21
21
  exports.measureAsync = measureAsync;
@@ -1,6 +1,6 @@
1
1
  import { Document } from '../resolve';
2
2
  import { Oas3RuleSet } from '../oas-types';
3
- import { LintConfig } from '../config';
3
+ import { StyleguideConfig } from '../config';
4
4
  import type { Plugin } from '../config/types';
5
5
  export declare function parseYamlToDocument(body: string, absoluteRef?: string): Document;
6
- export declare function makeConfigForRuleset(rules: Oas3RuleSet, plugin?: Partial<Plugin>): LintConfig;
6
+ export declare function makeConfigForRuleset(rules: Oas3RuleSet, plugin?: Partial<Plugin>): StyleguideConfig;
@@ -25,7 +25,7 @@ function makeConfigForRuleset(rules, plugin) {
25
25
  if (rules) {
26
26
  extendConfigs.push({ rules });
27
27
  }
28
- const lint = config_1.mergeExtends(extendConfigs);
29
- return new config_1.LintConfig(lint);
28
+ const styleguide = config_1.mergeExtends(extendConfigs);
29
+ return new config_1.StyleguideConfig(styleguide);
30
30
  }
31
31
  exports.makeConfigForRuleset = makeConfigForRuleset;
package/lib/bundle.d.ts CHANGED
@@ -2,7 +2,7 @@ import { BaseResolver, Document } from './resolve';
2
2
  import { Oas3Rule } from './visitors';
3
3
  import { NormalizedNodeType, NodeType } from './types';
4
4
  import { OasMajorVersion } from './oas-types';
5
- import type { Config, LintConfig } from './config';
5
+ import type { Config, StyleguideConfig } from './config';
6
6
  export declare type Oas3RuleSet = Record<string, Oas3Rule>;
7
7
  export declare enum OasVersion {
8
8
  Version2 = "oas2",
@@ -29,7 +29,7 @@ export declare function bundle(opts: {
29
29
  }>;
30
30
  export declare function bundleDocument(opts: {
31
31
  document: Document;
32
- config: LintConfig;
32
+ config: StyleguideConfig;
33
33
  customTypes?: Record<string, NodeType>;
34
34
  externalRefResolver: BaseResolver;
35
35
  dereference?: boolean;
package/lib/bundle.js CHANGED
@@ -42,7 +42,7 @@ function bundle(opts) {
42
42
  if (document instanceof Error) {
43
43
  throw document;
44
44
  }
45
- return bundleDocument(Object.assign(Object.assign({ document }, opts), { config: opts.config.lint, externalRefResolver }));
45
+ return bundleDocument(Object.assign(Object.assign({ document }, opts), { config: opts.config.styleguide, externalRefResolver }));
46
46
  });
47
47
  }
48
48
  exports.bundle = bundle;
@@ -71,7 +71,7 @@ function bundleDocument(opts) {
71
71
  ruleId: 'remove-unused-components',
72
72
  visitor: oasMajorVersion === oas_types_1.OasMajorVersion.Version2
73
73
  ? remove_unused_components_1.RemoveUnusedComponents({})
74
- : remove_unused_components_2.RemoveUnusedComponents({})
74
+ : remove_unused_components_2.RemoveUnusedComponents({}),
75
75
  });
76
76
  }
77
77
  const resolvedRefMap = yield resolve_1.resolveDocument({
@@ -231,9 +231,12 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
231
231
  ctx.parent[ctx.key] = resolved.node;
232
232
  }
233
233
  else {
234
+ // TODO: why $ref isn't optional in OasRef?
235
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
234
236
  // @ts-ignore
235
237
  delete ref.$ref;
236
- Object.assign(ref, resolved.node);
238
+ const obj = Object.assign({}, resolved.node, ref);
239
+ Object.assign(ref, obj); // assign ref itself again so ref fields take precedence
237
240
  }
238
241
  }
239
242
  function saveComponent(componentType, target, ctx) {
@@ -259,7 +262,7 @@ function makeBundleVisitor(version, dereference, skipRedoclyRegistryRefs, rootDo
259
262
  const [fileRef, pointer] = [target.location.source.absoluteRef, target.location.pointer];
260
263
  const componentsGroup = components[componentType];
261
264
  let name = '';
262
- const refParts = pointer.slice(2).split('/').filter(Boolean); // slice(2) removes "#/"
265
+ const refParts = pointer.slice(2).split('/').filter(utils_1.isTruthy); // slice(2) removes "#/"
263
266
  while (refParts.length > 0) {
264
267
  name = refParts.pop() + (name ? `-${name}` : '');
265
268
  if (!componentsGroup ||
@@ -1,3 +1,3 @@
1
- import type { PluginLintConfig } from "./types";
2
- declare const _default: PluginLintConfig;
1
+ import type { PluginStyleguideConfig } from './types';
2
+ declare const _default: PluginStyleguideConfig;
3
3
  export default _default;
package/lib/config/all.js CHANGED
@@ -19,7 +19,7 @@ exports.default = {
19
19
  'operation-description': 'error',
20
20
  'operation-2xx-response': 'error',
21
21
  'operation-4xx-response': 'error',
22
- 'assertions': 'error',
22
+ assertions: 'error',
23
23
  'operation-operationId': 'error',
24
24
  'operation-summary': 'error',
25
25
  'operation-operationId-unique': 'error',
@@ -51,7 +51,7 @@ exports.default = {
51
51
  'no-example-value-and-externalValue': 'error',
52
52
  'no-unused-components': 'error',
53
53
  'no-undefined-server-variable': 'error',
54
- 'no-servers-empty-enum': 'error',
54
+ 'no-server-variables-empty-enum': 'error',
55
55
  },
56
56
  oas3_1Rules: {
57
57
  'no-server-example.com': 'error',
@@ -60,6 +60,6 @@ exports.default = {
60
60
  'no-example-value-and-externalValue': 'error',
61
61
  'no-unused-components': 'error',
62
62
  'no-undefined-server-variable': 'error',
63
- 'no-servers-empty-enum': 'error',
63
+ 'no-server-variables-empty-enum': 'error',
64
64
  },
65
65
  };
@@ -1,3 +1,3 @@
1
- import type { LintRawConfig, Plugin } from './types';
2
- export declare const builtInConfigs: Record<string, LintRawConfig>;
1
+ import type { StyleguideRawConfig, Plugin } from './types';
2
+ export declare const builtInConfigs: Record<string, StyleguideRawConfig>;
3
3
  export declare const defaultPlugin: Plugin;
@@ -15,8 +15,8 @@ exports.builtInConfigs = {
15
15
  minimal: minimal_1.default,
16
16
  all: all_1.default,
17
17
  'redocly-registry': {
18
- decorators: { 'registry-dependencies': 'on' }
19
- }
18
+ decorators: { 'registry-dependencies': 'on' },
19
+ },
20
20
  };
21
21
  exports.defaultPlugin = {
22
22
  id: '',
@@ -1,5 +1,5 @@
1
1
  import { BaseResolver } from '../resolve';
2
- import type { LintRawConfig, Plugin, RawConfig, ResolvedApi, ResolvedLintConfig } from './types';
2
+ import type { StyleguideRawConfig, Plugin, RawConfig, ResolvedApi, ResolvedStyleguideConfig } from './types';
3
3
  import { Config } from './config';
4
4
  export declare function resolveConfig(rawConfig: RawConfig, configPath?: string): Promise<Config>;
5
5
  export declare function resolvePlugins(plugins: (string | Plugin)[] | null, configPath?: string): Plugin[];
@@ -8,9 +8,9 @@ export declare function resolveApis({ rawConfig, configPath, resolver, }: {
8
8
  configPath?: string;
9
9
  resolver?: BaseResolver;
10
10
  }): Promise<Record<string, ResolvedApi>>;
11
- export declare function resolveLint(lintOpts: {
12
- lintConfig?: LintRawConfig;
11
+ export declare function resolveStyleguideConfig(opts: {
12
+ styleguideConfig?: StyleguideRawConfig;
13
13
  configPath?: string;
14
14
  resolver?: BaseResolver;
15
- }, parentConfigPaths?: string[], extendPaths?: string[]): Promise<ResolvedLintConfig>;
16
- export declare function resolvePreset(presetName: string, plugins: Plugin[]): ResolvedLintConfig;
15
+ }, parentConfigPaths?: string[], extendPaths?: string[]): Promise<ResolvedStyleguideConfig>;
16
+ export declare function resolvePreset(presetName: string, plugins: Plugin[]): ResolvedStyleguideConfig;
@@ -20,62 +20,80 @@ var __rest = (this && this.__rest) || function (s, e) {
20
20
  return t;
21
21
  };
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
- exports.resolvePreset = exports.resolveLint = exports.resolveApis = exports.resolvePlugins = exports.resolveConfig = void 0;
23
+ exports.resolvePreset = exports.resolveStyleguideConfig = exports.resolveApis = exports.resolvePlugins = exports.resolveConfig = void 0;
24
24
  const path = require("path");
25
- const colorette_1 = require("colorette");
26
25
  const ref_utils_1 = require("../ref-utils");
27
26
  const resolve_1 = require("../resolve");
28
27
  const builtIn_1 = require("./builtIn");
29
28
  const utils_1 = require("./utils");
29
+ const env_1 = require("../env");
30
30
  const utils_2 = require("../utils");
31
31
  const config_1 = require("./config");
32
+ const logger_1 = require("../logger");
32
33
  function resolveConfig(rawConfig, configPath) {
33
34
  var _a, _b, _c, _d, _e;
34
35
  return __awaiter(this, void 0, void 0, function* () {
35
- if ((_b = (_a = rawConfig.lint) === null || _a === void 0 ? void 0 : _a.extends) === null || _b === void 0 ? void 0 : _b.some(utils_2.isNotString)) {
36
+ if ((_b = (_a = rawConfig.styleguide) === null || _a === void 0 ? void 0 : _a.extends) === null || _b === void 0 ? void 0 : _b.some(utils_2.isNotString)) {
36
37
  throw new Error(`Error configuration format not detected in extends value must contain strings`);
37
38
  }
38
39
  const resolver = new resolve_1.BaseResolver(utils_1.getResolveConfig(rawConfig.resolve));
39
- const configExtends = (_d = (_c = rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.lint) === null || _c === void 0 ? void 0 : _c.extends) !== null && _d !== void 0 ? _d : ['recommended'];
40
- const recommendedFallback = !((_e = rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.lint) === null || _e === void 0 ? void 0 : _e.extends);
41
- const lintConfig = Object.assign(Object.assign({}, rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.lint), { extends: configExtends, recommendedFallback });
40
+ const configExtends = (_d = (_c = rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.styleguide) === null || _c === void 0 ? void 0 : _c.extends) !== null && _d !== void 0 ? _d : ['recommended'];
41
+ const recommendedFallback = !((_e = rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.styleguide) === null || _e === void 0 ? void 0 : _e.extends);
42
+ const styleguideConfig = Object.assign(Object.assign({}, rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.styleguide), { extends: configExtends, recommendedFallback });
42
43
  const apis = yield resolveApis({
43
- rawConfig: Object.assign(Object.assign({}, rawConfig), { lint: lintConfig }),
44
+ rawConfig: Object.assign(Object.assign({}, rawConfig), { styleguide: styleguideConfig }),
44
45
  configPath,
45
46
  resolver,
46
47
  });
47
- const lint = yield resolveLint({
48
- lintConfig,
48
+ const styleguide = yield resolveStyleguideConfig({
49
+ styleguideConfig,
49
50
  configPath,
50
51
  resolver,
51
52
  });
52
53
  return new config_1.Config(Object.assign(Object.assign({}, rawConfig), { apis,
53
- lint }), configPath);
54
+ styleguide }), configPath);
54
55
  });
55
56
  }
56
57
  exports.resolveConfig = resolveConfig;
57
58
  function resolvePlugins(plugins, configPath = '') {
58
59
  if (!plugins)
59
60
  return [];
60
- // @ts-ignore
61
- const requireFunc = typeof __webpack_require__ === 'function' ? __non_webpack_require__ : require;
61
+ // TODO: implement or reuse Resolver approach so it will work in node and browser envs
62
+ const requireFunc = (plugin) => {
63
+ if (env_1.isBrowser && utils_2.isString(plugin)) {
64
+ logger_1.logger.error(`Cannot load ${plugin}. Plugins aren't supported in browser yet.`);
65
+ return undefined;
66
+ }
67
+ if (utils_2.isString(plugin)) {
68
+ const absoltePluginPath = path.resolve(path.dirname(configPath), plugin);
69
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
70
+ // @ts-ignore
71
+ return typeof __webpack_require__ === 'function'
72
+ ? // eslint-disable-next-line @typescript-eslint/ban-ts-comment
73
+ // @ts-ignore
74
+ __non_webpack_require__(absoltePluginPath)
75
+ : require(absoltePluginPath);
76
+ }
77
+ return plugin;
78
+ };
62
79
  const seenPluginIds = new Map();
63
80
  return plugins
64
81
  .map((p) => {
65
82
  if (utils_2.isString(p) && ref_utils_1.isAbsoluteUrl(p)) {
66
- throw new Error(colorette_1.red(`We don't support remote plugins yet.`));
83
+ throw new Error(logger_1.colorize.red(`We don't support remote plugins yet.`));
67
84
  }
68
85
  // TODO: resolve npm packages similar to eslint
69
- const pluginModule = utils_2.isString(p)
70
- ? requireFunc(path.resolve(path.dirname(configPath), p))
71
- : p;
86
+ const pluginModule = requireFunc(p);
87
+ if (!pluginModule) {
88
+ return;
89
+ }
72
90
  const id = pluginModule.id;
73
91
  if (typeof id !== 'string') {
74
- throw new Error(colorette_1.red(`Plugin must define \`id\` property in ${colorette_1.blue(p.toString())}.`));
92
+ throw new Error(logger_1.colorize.red(`Plugin must define \`id\` property in ${logger_1.colorize.blue(p.toString())}.`));
75
93
  }
76
94
  if (seenPluginIds.has(id)) {
77
95
  const pluginPath = seenPluginIds.get(id);
78
- throw new Error(colorette_1.red(`Plugin "id" must be unique. Plugin ${colorette_1.blue(p.toString())} uses id "${colorette_1.blue(id)}" already seen in ${colorette_1.blue(pluginPath)}`));
96
+ throw new Error(logger_1.colorize.red(`Plugin "id" must be unique. Plugin ${logger_1.colorize.blue(p.toString())} uses id "${logger_1.colorize.blue(id)}" already seen in ${logger_1.colorize.blue(pluginPath)}`));
79
97
  }
80
98
  seenPluginIds.set(id, p.toString());
81
99
  const plugin = Object.assign(Object.assign({ id }, (pluginModule.configs ? { configs: pluginModule.configs } : {})), (pluginModule.typeExtension ? { typeExtension: pluginModule.typeExtension } : {}));
@@ -123,36 +141,36 @@ exports.resolvePlugins = resolvePlugins;
123
141
  function resolveApis({ rawConfig, configPath = '', resolver, }) {
124
142
  var _a, _b;
125
143
  return __awaiter(this, void 0, void 0, function* () {
126
- const { apis = {}, lint: lintConfig = {} } = rawConfig;
127
- let resolvedApis = {};
144
+ const { apis = {}, styleguide: styleguideConfig = {} } = rawConfig;
145
+ const resolvedApis = {};
128
146
  for (const [apiName, apiContent] of Object.entries(apis || {})) {
129
- if ((_b = (_a = apiContent.lint) === null || _a === void 0 ? void 0 : _a.extends) === null || _b === void 0 ? void 0 : _b.some(utils_2.isNotString)) {
147
+ if ((_b = (_a = apiContent.styleguide) === null || _a === void 0 ? void 0 : _a.extends) === null || _b === void 0 ? void 0 : _b.some(utils_2.isNotString)) {
130
148
  throw new Error(`Error configuration format not detected in extends value must contain strings`);
131
149
  }
132
- const rawLintConfig = getMergedLintRawConfig(lintConfig, apiContent.lint);
133
- const apiLint = yield resolveLint({
134
- lintConfig: rawLintConfig,
150
+ const rawStyleguideConfig = getMergedRawStyleguideConfig(styleguideConfig, apiContent.styleguide);
151
+ const resolvedApiConfig = yield resolveStyleguideConfig({
152
+ styleguideConfig: rawStyleguideConfig,
135
153
  configPath,
136
154
  resolver,
137
155
  });
138
- resolvedApis[apiName] = Object.assign(Object.assign({}, apiContent), { lint: apiLint });
156
+ resolvedApis[apiName] = Object.assign(Object.assign({}, apiContent), { styleguide: resolvedApiConfig });
139
157
  }
140
158
  return resolvedApis;
141
159
  });
142
160
  }
143
161
  exports.resolveApis = resolveApis;
144
- function resolveAndMergeNestedLint({ lintConfig, configPath = '', resolver = new resolve_1.BaseResolver(), }, parentConfigPaths = [], extendPaths = []) {
162
+ function resolveAndMergeNestedStyleguideConfig({ styleguideConfig, configPath = '', resolver = new resolve_1.BaseResolver(), }, parentConfigPaths = [], extendPaths = []) {
145
163
  var _a, _b, _c;
146
164
  return __awaiter(this, void 0, void 0, function* () {
147
165
  if (parentConfigPaths.includes(configPath)) {
148
166
  throw new Error(`Circular dependency in config file: "${configPath}"`);
149
167
  }
150
- const plugins = utils_1.getUniquePlugins(resolvePlugins([...((lintConfig === null || lintConfig === void 0 ? void 0 : lintConfig.plugins) || []), builtIn_1.defaultPlugin], configPath));
151
- const pluginPaths = (_a = lintConfig === null || lintConfig === void 0 ? void 0 : lintConfig.plugins) === null || _a === void 0 ? void 0 : _a.filter(utils_2.isString).map((p) => path.resolve(path.dirname(configPath), p));
168
+ const plugins = utils_1.getUniquePlugins(resolvePlugins([...((styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.plugins) || []), builtIn_1.defaultPlugin], configPath));
169
+ const pluginPaths = (_a = styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.plugins) === null || _a === void 0 ? void 0 : _a.filter(utils_2.isString).map((p) => path.resolve(path.dirname(configPath), p));
152
170
  const resolvedConfigPath = ref_utils_1.isAbsoluteUrl(configPath)
153
171
  ? configPath
154
172
  : configPath && path.resolve(configPath);
155
- const extendConfigs = yield Promise.all(((_b = lintConfig === null || lintConfig === void 0 ? void 0 : lintConfig.extends) === null || _b === void 0 ? void 0 : _b.map((presetItem) => __awaiter(this, void 0, void 0, function* () {
173
+ const extendConfigs = yield Promise.all(((_b = styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.extends) === null || _b === void 0 ? void 0 : _b.map((presetItem) => __awaiter(this, void 0, void 0, function* () {
156
174
  if (!ref_utils_1.isAbsoluteUrl(presetItem) && !path.extname(presetItem)) {
157
175
  return resolvePreset(presetItem, plugins);
158
176
  }
@@ -161,63 +179,66 @@ function resolveAndMergeNestedLint({ lintConfig, configPath = '', resolver = new
161
179
  : ref_utils_1.isAbsoluteUrl(configPath)
162
180
  ? new URL(presetItem, configPath).href
163
181
  : path.resolve(path.dirname(configPath), presetItem);
164
- const extendedLintConfig = yield loadExtendLintConfig(pathItem, resolver);
165
- return yield resolveAndMergeNestedLint({
166
- lintConfig: extendedLintConfig,
182
+ const extendedStyleguideConfig = yield loadExtendStyleguideConfig(pathItem, resolver);
183
+ return yield resolveAndMergeNestedStyleguideConfig({
184
+ styleguideConfig: extendedStyleguideConfig,
167
185
  configPath: pathItem,
168
186
  resolver: resolver,
169
187
  }, [...parentConfigPaths, resolvedConfigPath], extendPaths);
170
188
  }))) || []);
171
189
  const _d = utils_1.mergeExtends([
172
190
  ...extendConfigs,
173
- Object.assign(Object.assign({}, lintConfig), { plugins, extends: undefined, extendPaths: [...parentConfigPaths, resolvedConfigPath], pluginPaths }),
174
- ]), { plugins: mergedPlugins = [] } = _d, lint = __rest(_d, ["plugins"]);
175
- return Object.assign(Object.assign({}, lint), { extendPaths: (_c = lint.extendPaths) === null || _c === void 0 ? void 0 : _c.filter((path) => path && !ref_utils_1.isAbsoluteUrl(path)), plugins: utils_1.getUniquePlugins(mergedPlugins), recommendedFallback: lintConfig === null || lintConfig === void 0 ? void 0 : lintConfig.recommendedFallback, doNotResolveExamples: lintConfig === null || lintConfig === void 0 ? void 0 : lintConfig.doNotResolveExamples });
191
+ Object.assign(Object.assign({}, styleguideConfig), { plugins, extends: undefined, extendPaths: [...parentConfigPaths, resolvedConfigPath], pluginPaths }),
192
+ ]), { plugins: mergedPlugins = [] } = _d, styleguide = __rest(_d, ["plugins"]);
193
+ return Object.assign(Object.assign({}, styleguide), { extendPaths: (_c = styleguide.extendPaths) === null || _c === void 0 ? void 0 : _c.filter((path) => path && !ref_utils_1.isAbsoluteUrl(path)), plugins: utils_1.getUniquePlugins(mergedPlugins), recommendedFallback: styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.recommendedFallback, doNotResolveExamples: styleguideConfig === null || styleguideConfig === void 0 ? void 0 : styleguideConfig.doNotResolveExamples });
176
194
  });
177
195
  }
178
- function resolveLint(lintOpts, parentConfigPaths = [], extendPaths = []) {
196
+ function resolveStyleguideConfig(opts, parentConfigPaths = [], extendPaths = []) {
179
197
  return __awaiter(this, void 0, void 0, function* () {
180
- const resolvedLint = yield resolveAndMergeNestedLint(lintOpts, parentConfigPaths, extendPaths);
181
- return Object.assign(Object.assign({}, resolvedLint), { rules: resolvedLint.rules && groupLintAssertionRules(resolvedLint.rules) });
198
+ const resolvedStyleguideConfig = yield resolveAndMergeNestedStyleguideConfig(opts, parentConfigPaths, extendPaths);
199
+ return Object.assign(Object.assign({}, resolvedStyleguideConfig), { rules: resolvedStyleguideConfig.rules &&
200
+ groupStyleguideAssertionRules(resolvedStyleguideConfig.rules) });
182
201
  });
183
202
  }
184
- exports.resolveLint = resolveLint;
203
+ exports.resolveStyleguideConfig = resolveStyleguideConfig;
185
204
  function resolvePreset(presetName, plugins) {
186
205
  var _a;
187
206
  const { pluginId, configName } = utils_1.parsePresetName(presetName);
188
207
  const plugin = plugins.find((p) => p.id === pluginId);
189
208
  if (!plugin) {
190
- throw new Error(`Invalid config ${colorette_1.red(presetName)}: plugin ${pluginId} is not included.`);
209
+ throw new Error(`Invalid config ${logger_1.colorize.red(presetName)}: plugin ${pluginId} is not included.`);
191
210
  }
192
211
  const preset = (_a = plugin.configs) === null || _a === void 0 ? void 0 : _a[configName];
193
212
  if (!preset) {
194
213
  throw new Error(pluginId
195
- ? `Invalid config ${colorette_1.red(presetName)}: plugin ${pluginId} doesn't export config with name ${configName}.`
196
- : `Invalid config ${colorette_1.red(presetName)}: there is no such built-in config.`);
214
+ ? `Invalid config ${logger_1.colorize.red(presetName)}: plugin ${pluginId} doesn't export config with name ${configName}.`
215
+ : `Invalid config ${logger_1.colorize.red(presetName)}: there is no such built-in config.`);
197
216
  }
198
217
  return preset;
199
218
  }
200
219
  exports.resolvePreset = resolvePreset;
201
- function loadExtendLintConfig(filePath, resolver) {
220
+ function loadExtendStyleguideConfig(filePath, resolver) {
202
221
  return __awaiter(this, void 0, void 0, function* () {
203
222
  try {
204
223
  const fileSource = yield resolver.loadExternalRef(filePath);
205
224
  const rawConfig = utils_1.transformConfig(utils_2.parseYaml(fileSource.body));
206
- if (!rawConfig.lint) {
207
- throw new Error(`Lint configuration format not detected: "${filePath}"`);
225
+ if (!rawConfig.styleguide) {
226
+ throw new Error(`Styleguide configuration format not detected: "${filePath}"`);
208
227
  }
209
- return rawConfig.lint;
228
+ return rawConfig.styleguide;
210
229
  }
211
230
  catch (error) {
212
231
  throw new Error(`Failed to load "${filePath}": ${error.message}`);
213
232
  }
214
233
  });
215
234
  }
216
- function getMergedLintRawConfig(configLint, apiLint) {
217
- const resultLint = Object.assign(Object.assign(Object.assign({}, configLint), apiLint), { rules: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.rules), apiLint === null || apiLint === void 0 ? void 0 : apiLint.rules), oas2Rules: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas2Rules), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas2Rules), oas3_0Rules: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas3_0Rules), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas3_0Rules), oas3_1Rules: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas3_1Rules), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas3_1Rules), preprocessors: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.preprocessors), apiLint === null || apiLint === void 0 ? void 0 : apiLint.preprocessors), oas2Preprocessors: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas2Preprocessors), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas2Preprocessors), oas3_0Preprocessors: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas3_0Preprocessors), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas3_0Preprocessors), oas3_1Preprocessors: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas3_1Preprocessors), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas3_1Preprocessors), decorators: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.decorators), apiLint === null || apiLint === void 0 ? void 0 : apiLint.decorators), oas2Decorators: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas2Decorators), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas2Decorators), oas3_0Decorators: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas3_0Decorators), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas3_0Decorators), oas3_1Decorators: Object.assign(Object.assign({}, configLint === null || configLint === void 0 ? void 0 : configLint.oas3_1Decorators), apiLint === null || apiLint === void 0 ? void 0 : apiLint.oas3_1Decorators), recommendedFallback: (apiLint === null || apiLint === void 0 ? void 0 : apiLint.extends) ? false : configLint.recommendedFallback });
235
+ function getMergedRawStyleguideConfig(rootStyleguideConfig, apiStyleguideConfig) {
236
+ const resultLint = Object.assign(Object.assign(Object.assign({}, rootStyleguideConfig), apiStyleguideConfig), { rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.rules), oas2Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Rules), oas3_0Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Rules), oas3_1Rules: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Rules), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Rules), preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.preprocessors), oas2Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Preprocessors), oas3_0Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Preprocessors), oas3_1Preprocessors: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Preprocessors), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Preprocessors), decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.decorators), oas2Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas2Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas2Decorators), oas3_0Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_0Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_0Decorators), oas3_1Decorators: Object.assign(Object.assign({}, rootStyleguideConfig === null || rootStyleguideConfig === void 0 ? void 0 : rootStyleguideConfig.oas3_1Decorators), apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.oas3_1Decorators), recommendedFallback: (apiStyleguideConfig === null || apiStyleguideConfig === void 0 ? void 0 : apiStyleguideConfig.extends)
237
+ ? false
238
+ : rootStyleguideConfig.recommendedFallback });
218
239
  return resultLint;
219
240
  }
220
- function groupLintAssertionRules(rules) {
241
+ function groupStyleguideAssertionRules(rules) {
221
242
  if (!rules) {
222
243
  return rules;
223
244
  }
@@ -1,9 +1,7 @@
1
- /// <reference types="node" />
2
1
  import { NormalizedProblem } from '../walk';
3
2
  import { OasVersion, OasMajorVersion, Oas2RuleSet, Oas3RuleSet } from '../oas-types';
4
3
  import type { NodeType } from '../types';
5
- import type { DecoratorConfig, Plugin, PreprocessorConfig, Region, ResolveConfig, ResolvedApi, ResolvedConfig, ResolvedLintConfig, RuleConfig } from './types';
6
- export declare const env: NodeJS.ProcessEnv;
4
+ import type { DecoratorConfig, Plugin, PreprocessorConfig, Region, ResolveConfig, ResolvedApi, ResolvedConfig, ResolvedStyleguideConfig, RuleConfig } from './types';
7
5
  export declare const IGNORE_FILE = ".redocly.lint-ignore.yaml";
8
6
  export declare const DEFAULT_REGION = "us";
9
7
  export declare const DOMAINS: {
@@ -11,8 +9,8 @@ export declare const DOMAINS: {
11
9
  eu: string;
12
10
  };
13
11
  export declare const AVAILABLE_REGIONS: Region[];
14
- export declare class LintConfig {
15
- rawConfig: ResolvedLintConfig;
12
+ export declare class StyleguideConfig {
13
+ rawConfig: ResolvedStyleguideConfig;
16
14
  configFile?: string | undefined;
17
15
  plugins: Plugin[];
18
16
  ignore: Record<string, Record<string, Set<string>>>;
@@ -25,20 +23,20 @@ export declare class LintConfig {
25
23
  recommendedFallback: boolean;
26
24
  extendPaths: string[];
27
25
  pluginPaths: string[];
28
- constructor(rawConfig: ResolvedLintConfig, configFile?: string | undefined);
26
+ constructor(rawConfig: ResolvedStyleguideConfig, configFile?: string | undefined);
29
27
  resolveIgnore(ignoreFile?: string): void;
30
28
  saveIgnore(): void;
31
29
  addIgnore(problem: NormalizedProblem): void;
32
30
  addProblemToIgnore(problem: NormalizedProblem): NormalizedProblem;
33
31
  extendTypes(types: Record<string, NodeType>, version: OasVersion): Record<string, NodeType>;
34
32
  getRuleSettings(ruleId: string, oasVersion: OasVersion): {
35
- severity: import("./types").RuleSeverity;
33
+ severity: string;
36
34
  };
37
35
  getPreprocessorSettings(ruleId: string, oasVersion: OasVersion): {
38
- severity: import("./types").RuleSeverity;
36
+ severity: string;
39
37
  };
40
38
  getDecoratorSettings(ruleId: string, oasVersion: OasVersion): {
41
- severity: import("./types").RuleSeverity;
39
+ severity: string;
42
40
  };
43
41
  getUnusedRules(): {
44
42
  rules: string[];
@@ -54,7 +52,7 @@ export declare class Config {
54
52
  rawConfig: ResolvedConfig;
55
53
  configFile?: string | undefined;
56
54
  apis: Record<string, ResolvedApi>;
57
- lint: LintConfig;
55
+ styleguide: StyleguideConfig;
58
56
  resolve: ResolveConfig;
59
57
  licenseKey?: string;
60
58
  region?: Region;
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Config = exports.LintConfig = exports.AVAILABLE_REGIONS = exports.DOMAINS = exports.DEFAULT_REGION = exports.IGNORE_FILE = exports.env = void 0;
3
+ exports.Config = exports.StyleguideConfig = exports.AVAILABLE_REGIONS = exports.DOMAINS = exports.DEFAULT_REGION = exports.IGNORE_FILE = void 0;
4
4
  const fs = require("fs");
5
5
  const path = require("path");
6
6
  const js_yaml_1 = require("../js-yaml");
7
7
  const utils_1 = require("../utils");
8
8
  const oas_types_1 = require("../oas-types");
9
+ const env_1 = require("../env");
9
10
  const utils_2 = require("./utils");
10
- // Alias environment here so this file can work in browser environments too.
11
- exports.env = typeof process !== 'undefined' ? process.env || {} : {};
12
11
  exports.IGNORE_FILE = '.redocly.lint-ignore.yaml';
13
12
  const IGNORE_BANNER = `# This file instructs Redocly's linter to ignore the rules contained for specific parts of your API.\n` +
14
13
  `# See https://redoc.ly/docs/cli/ for more information.\n`;
@@ -19,7 +18,7 @@ function getDomains() {
19
18
  eu: 'eu.redocly.com',
20
19
  };
21
20
  // FIXME: temporary fix for our lab environments
22
- const domain = exports.env.REDOCLY_DOMAIN;
21
+ const domain = env_1.env.REDOCLY_DOMAIN;
23
22
  if (domain === null || domain === void 0 ? void 0 : domain.endsWith('.redocly.host')) {
24
23
  domains[domain.split('.')[0]] = domain;
25
24
  }
@@ -40,7 +39,7 @@ function getIgnoreFilePath(configFile) {
40
39
  }
41
40
  exports.DOMAINS = getDomains();
42
41
  exports.AVAILABLE_REGIONS = Object.keys(exports.DOMAINS);
43
- class LintConfig {
42
+ class StyleguideConfig {
44
43
  constructor(rawConfig, configFile) {
45
44
  this.rawConfig = rawConfig;
46
45
  this.configFile = configFile;
@@ -125,10 +124,12 @@ class LintConfig {
125
124
  if (!plugin.typeExtension.oas3)
126
125
  continue;
127
126
  extendedTypes = plugin.typeExtension.oas3(extendedTypes, version);
127
+ break;
128
128
  case oas_types_1.OasVersion.Version2:
129
129
  if (!plugin.typeExtension.oas2)
130
130
  continue;
131
131
  extendedTypes = plugin.typeExtension.oas2(extendedTypes, version);
132
+ break;
132
133
  default:
133
134
  throw new Error('Not implemented');
134
135
  }
@@ -193,12 +194,14 @@ class LintConfig {
193
194
  getRulesForOasVersion(version) {
194
195
  switch (version) {
195
196
  case oas_types_1.OasMajorVersion.Version3:
197
+ // eslint-disable-next-line no-case-declarations
196
198
  const oas3Rules = []; // default ruleset
197
199
  this.plugins.forEach((p) => { var _a; return ((_a = p.preprocessors) === null || _a === void 0 ? void 0 : _a.oas3) && oas3Rules.push(p.preprocessors.oas3); });
198
200
  this.plugins.forEach((p) => { var _a; return ((_a = p.rules) === null || _a === void 0 ? void 0 : _a.oas3) && oas3Rules.push(p.rules.oas3); });
199
201
  this.plugins.forEach((p) => { var _a; return ((_a = p.decorators) === null || _a === void 0 ? void 0 : _a.oas3) && oas3Rules.push(p.decorators.oas3); });
200
202
  return oas3Rules;
201
203
  case oas_types_1.OasMajorVersion.Version2:
204
+ // eslint-disable-next-line no-case-declarations
202
205
  const oas2Rules = []; // default ruleset
203
206
  this.plugins.forEach((p) => { var _a; return ((_a = p.preprocessors) === null || _a === void 0 ? void 0 : _a.oas2) && oas2Rules.push(p.preprocessors.oas2); });
204
207
  this.plugins.forEach((p) => { var _a; return ((_a = p.rules) === null || _a === void 0 ? void 0 : _a.oas2) && oas2Rules.push(p.rules.oas2); });
@@ -234,13 +237,13 @@ class LintConfig {
234
237
  }
235
238
  }
236
239
  }
237
- exports.LintConfig = LintConfig;
240
+ exports.StyleguideConfig = StyleguideConfig;
238
241
  class Config {
239
242
  constructor(rawConfig, configFile) {
240
243
  this.rawConfig = rawConfig;
241
244
  this.configFile = configFile;
242
245
  this.apis = rawConfig.apis || {};
243
- this.lint = new LintConfig(rawConfig.lint || {}, configFile);
246
+ this.styleguide = new StyleguideConfig(rawConfig.styleguide || {}, configFile);
244
247
  this['features.openapi'] = rawConfig['features.openapi'] || {};
245
248
  this['features.mockServer'] = rawConfig['features.mockServer'] || {};
246
249
  this.resolve = utils_2.getResolveConfig(rawConfig === null || rawConfig === void 0 ? void 0 : rawConfig.resolve);
@@ -1,6 +1,13 @@
1
1
  import { Config } from './config';
2
2
  import type { RawConfig } from './types';
3
+ import { RegionalTokenWithValidity } from '../redocly/redocly-client-types';
3
4
  export declare function loadConfig(configPath?: string | undefined, customExtends?: string[], processRawConfig?: (rawConfig: RawConfig) => void | Promise<void>): Promise<Config>;
4
5
  export declare const CONFIG_FILE_NAMES: string[];
5
6
  export declare function findConfig(dir?: string): string | undefined;
6
7
  export declare function getConfig(configPath?: string | undefined): Promise<RawConfig>;
8
+ declare type CreateConfigOptions = {
9
+ extends?: string[];
10
+ tokens?: RegionalTokenWithValidity[];
11
+ };
12
+ export declare function createConfig(config: string | RawConfig, options?: CreateConfigOptions): Promise<Config>;
13
+ export {};