@redocly/openapi-core 0.0.0-snapshot.1737554067

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 (322) hide show
  1. package/README.md +268 -0
  2. package/lib/benchmark/benches/lint-with-many-rules.bench.d.ts +4 -0
  3. package/lib/benchmark/benches/lint-with-many-rules.bench.js +38 -0
  4. package/lib/benchmark/benches/lint-with-nested-rule.bench.d.ts +4 -0
  5. package/lib/benchmark/benches/lint-with-nested-rule.bench.js +44 -0
  6. package/lib/benchmark/benches/lint-with-no-rules.bench.d.ts +4 -0
  7. package/lib/benchmark/benches/lint-with-no-rules.bench.js +25 -0
  8. package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.d.ts +4 -0
  9. package/lib/benchmark/benches/lint-with-top-level-rule-report.bench.js +37 -0
  10. package/lib/benchmark/benches/lint-with-top-level-rule.bench.d.ts +4 -0
  11. package/lib/benchmark/benches/lint-with-top-level-rule.bench.js +36 -0
  12. package/lib/benchmark/benches/recommended-oas3.bench.d.ts +3 -0
  13. package/lib/benchmark/benches/recommended-oas3.bench.js +21 -0
  14. package/lib/benchmark/benches/resolve-with-no-external.bench.d.ts +3 -0
  15. package/lib/benchmark/benches/resolve-with-no-external.bench.js +22 -0
  16. package/lib/benchmark/utils.d.ts +6 -0
  17. package/lib/benchmark/utils.js +34 -0
  18. package/lib/bundle.d.ts +50 -0
  19. package/lib/bundle.js +385 -0
  20. package/lib/config/all.d.ts +3 -0
  21. package/lib/config/all.js +227 -0
  22. package/lib/config/builtIn.d.ts +3 -0
  23. package/lib/config/builtIn.js +53 -0
  24. package/lib/config/config-resolvers.d.ts +30 -0
  25. package/lib/config/config-resolvers.js +447 -0
  26. package/lib/config/config.d.ts +53 -0
  27. package/lib/config/config.js +320 -0
  28. package/lib/config/index.d.ts +7 -0
  29. package/lib/config/index.js +23 -0
  30. package/lib/config/load.d.ts +38 -0
  31. package/lib/config/load.js +140 -0
  32. package/lib/config/minimal.d.ts +3 -0
  33. package/lib/config/minimal.js +203 -0
  34. package/lib/config/recommended-strict.d.ts +3 -0
  35. package/lib/config/recommended-strict.js +203 -0
  36. package/lib/config/recommended.d.ts +3 -0
  37. package/lib/config/recommended.js +203 -0
  38. package/lib/config/rules.d.ts +10 -0
  39. package/lib/config/rules.js +37 -0
  40. package/lib/config/spec.d.ts +3 -0
  41. package/lib/config/spec.js +29 -0
  42. package/lib/config/types.d.ts +189 -0
  43. package/lib/config/types.js +2 -0
  44. package/lib/config/utils.d.ts +19 -0
  45. package/lib/config/utils.js +308 -0
  46. package/lib/decorators/arazzo/index.d.ts +1 -0
  47. package/lib/decorators/arazzo/index.js +4 -0
  48. package/lib/decorators/async2/index.d.ts +1 -0
  49. package/lib/decorators/async2/index.js +4 -0
  50. package/lib/decorators/async3/index.d.ts +1 -0
  51. package/lib/decorators/async3/index.js +4 -0
  52. package/lib/decorators/common/filters/filter-helper.d.ts +3 -0
  53. package/lib/decorators/common/filters/filter-helper.js +66 -0
  54. package/lib/decorators/common/filters/filter-in.d.ts +2 -0
  55. package/lib/decorators/common/filters/filter-in.js +17 -0
  56. package/lib/decorators/common/filters/filter-out.d.ts +2 -0
  57. package/lib/decorators/common/filters/filter-out.js +17 -0
  58. package/lib/decorators/common/info-description-override.d.ts +2 -0
  59. package/lib/decorators/common/info-description-override.js +24 -0
  60. package/lib/decorators/common/info-override.d.ts +2 -0
  61. package/lib/decorators/common/info-override.js +17 -0
  62. package/lib/decorators/common/media-type-examples-override.d.ts +2 -0
  63. package/lib/decorators/common/media-type-examples-override.js +59 -0
  64. package/lib/decorators/common/operation-description-override.d.ts +2 -0
  65. package/lib/decorators/common/operation-description-override.js +29 -0
  66. package/lib/decorators/common/registry-dependencies.d.ts +2 -0
  67. package/lib/decorators/common/registry-dependencies.js +24 -0
  68. package/lib/decorators/common/remove-x-internal.d.ts +2 -0
  69. package/lib/decorators/common/remove-x-internal.js +69 -0
  70. package/lib/decorators/common/tag-description-override.d.ts +2 -0
  71. package/lib/decorators/common/tag-description-override.js +25 -0
  72. package/lib/decorators/oas2/index.d.ts +11 -0
  73. package/lib/decorators/oas2/index.js +21 -0
  74. package/lib/decorators/oas2/remove-unused-components.d.ts +2 -0
  75. package/lib/decorators/oas2/remove-unused-components.js +89 -0
  76. package/lib/decorators/oas3/index.d.ts +12 -0
  77. package/lib/decorators/oas3/index.js +23 -0
  78. package/lib/decorators/oas3/remove-unused-components.d.ts +2 -0
  79. package/lib/decorators/oas3/remove-unused-components.js +100 -0
  80. package/lib/env.d.ts +2 -0
  81. package/lib/env.js +7 -0
  82. package/lib/format/codeframes.d.ts +22 -0
  83. package/lib/format/codeframes.js +185 -0
  84. package/lib/format/format.d.ts +20 -0
  85. package/lib/format/format.js +365 -0
  86. package/lib/index.d.ts +26 -0
  87. package/lib/index.js +98 -0
  88. package/lib/js-yaml/index.d.ts +3 -0
  89. package/lib/js-yaml/index.js +15 -0
  90. package/lib/lint.d.ts +32 -0
  91. package/lib/lint.js +118 -0
  92. package/lib/logger.d.ts +10 -0
  93. package/lib/logger.js +31 -0
  94. package/lib/oas-types.d.ts +36 -0
  95. package/lib/oas-types.js +92 -0
  96. package/lib/output.d.ts +3 -0
  97. package/lib/output.js +9 -0
  98. package/lib/redocly/domains.d.ts +14 -0
  99. package/lib/redocly/domains.js +41 -0
  100. package/lib/redocly/index.d.ts +30 -0
  101. package/lib/redocly/index.js +131 -0
  102. package/lib/redocly/redocly-client-types.d.ts +8 -0
  103. package/lib/redocly/redocly-client-types.js +2 -0
  104. package/lib/redocly/registry-api-types.d.ts +29 -0
  105. package/lib/redocly/registry-api-types.js +2 -0
  106. package/lib/redocly/registry-api.d.ts +17 -0
  107. package/lib/redocly/registry-api.js +96 -0
  108. package/lib/ref-utils.d.ts +27 -0
  109. package/lib/ref-utils.js +85 -0
  110. package/lib/resolve.d.ts +66 -0
  111. package/lib/resolve.js +342 -0
  112. package/lib/rules/ajv.d.ts +10 -0
  113. package/lib/rules/ajv.js +82 -0
  114. package/lib/rules/arazzo/criteria-unique.d.ts +2 -0
  115. package/lib/rules/arazzo/criteria-unique.js +71 -0
  116. package/lib/rules/arazzo/index.d.ts +3 -0
  117. package/lib/rules/arazzo/index.js +36 -0
  118. package/lib/rules/arazzo/parameters-unique.d.ts +2 -0
  119. package/lib/rules/arazzo/parameters-unique.js +32 -0
  120. package/lib/rules/arazzo/requestBody-replacements-unique.d.ts +2 -0
  121. package/lib/rules/arazzo/requestBody-replacements-unique.js +28 -0
  122. package/lib/rules/arazzo/sourceDescription-type.d.ts +2 -0
  123. package/lib/rules/arazzo/sourceDescription-type.js +22 -0
  124. package/lib/rules/arazzo/sourceDescriptions-name-unique.d.ts +2 -0
  125. package/lib/rules/arazzo/sourceDescriptions-name-unique.js +24 -0
  126. package/lib/rules/arazzo/sourceDescriptions-not-empty.d.ts +2 -0
  127. package/lib/rules/arazzo/sourceDescriptions-not-empty.js +18 -0
  128. package/lib/rules/arazzo/step-onFailure-unique.d.ts +2 -0
  129. package/lib/rules/arazzo/step-onFailure-unique.js +32 -0
  130. package/lib/rules/arazzo/step-onSuccess-unique.d.ts +2 -0
  131. package/lib/rules/arazzo/step-onSuccess-unique.js +32 -0
  132. package/lib/rules/arazzo/stepId-unique.d.ts +2 -0
  133. package/lib/rules/arazzo/stepId-unique.js +26 -0
  134. package/lib/rules/arazzo/workflow-dependsOn.d.ts +2 -0
  135. package/lib/rules/arazzo/workflow-dependsOn.js +56 -0
  136. package/lib/rules/arazzo/workflowId-unique.d.ts +2 -0
  137. package/lib/rules/arazzo/workflowId-unique.js +22 -0
  138. package/lib/rules/async2/channels-kebab-case.d.ts +2 -0
  139. package/lib/rules/async2/channels-kebab-case.js +19 -0
  140. package/lib/rules/async2/index.d.ts +3 -0
  141. package/lib/rules/async2/index.js +27 -0
  142. package/lib/rules/async2/no-channel-trailing-slash.d.ts +2 -0
  143. package/lib/rules/async2/no-channel-trailing-slash.js +16 -0
  144. package/lib/rules/async3/channels-kebab-case.d.ts +2 -0
  145. package/lib/rules/async3/channels-kebab-case.js +19 -0
  146. package/lib/rules/async3/index.d.ts +3 -0
  147. package/lib/rules/async3/index.js +27 -0
  148. package/lib/rules/async3/no-channel-trailing-slash.d.ts +2 -0
  149. package/lib/rules/async3/no-channel-trailing-slash.js +16 -0
  150. package/lib/rules/common/assertions/asserts.d.ts +30 -0
  151. package/lib/rules/common/assertions/asserts.js +281 -0
  152. package/lib/rules/common/assertions/index.d.ts +27 -0
  153. package/lib/rules/common/assertions/index.js +24 -0
  154. package/lib/rules/common/assertions/utils.d.ts +28 -0
  155. package/lib/rules/common/assertions/utils.js +226 -0
  156. package/lib/rules/common/info-contact.d.ts +2 -0
  157. package/lib/rules/common/info-contact.js +17 -0
  158. package/lib/rules/common/info-license-strict.d.ts +2 -0
  159. package/lib/rules/common/info-license-strict.js +26 -0
  160. package/lib/rules/common/info-license-url.d.ts +2 -0
  161. package/lib/rules/common/info-license-url.js +12 -0
  162. package/lib/rules/common/info-license.d.ts +2 -0
  163. package/lib/rules/common/info-license.js +17 -0
  164. package/lib/rules/common/no-ambiguous-paths.d.ts +2 -0
  165. package/lib/rules/common/no-ambiguous-paths.js +45 -0
  166. package/lib/rules/common/no-enum-type-mismatch.d.ts +2 -0
  167. package/lib/rules/common/no-enum-type-mismatch.js +41 -0
  168. package/lib/rules/common/no-http-verbs-in-paths.d.ts +2 -0
  169. package/lib/rules/common/no-http-verbs-in-paths.js +33 -0
  170. package/lib/rules/common/no-identical-paths.d.ts +2 -0
  171. package/lib/rules/common/no-identical-paths.js +24 -0
  172. package/lib/rules/common/no-invalid-parameter-examples.d.ts +1 -0
  173. package/lib/rules/common/no-invalid-parameter-examples.js +24 -0
  174. package/lib/rules/common/no-invalid-schema-examples.d.ts +1 -0
  175. package/lib/rules/common/no-invalid-schema-examples.js +22 -0
  176. package/lib/rules/common/no-path-trailing-slash.d.ts +2 -0
  177. package/lib/rules/common/no-path-trailing-slash.js +16 -0
  178. package/lib/rules/common/no-required-schema-properties-undefined.d.ts +2 -0
  179. package/lib/rules/common/no-required-schema-properties-undefined.js +36 -0
  180. package/lib/rules/common/operation-2xx-response.d.ts +2 -0
  181. package/lib/rules/common/operation-2xx-response.js +23 -0
  182. package/lib/rules/common/operation-4xx-response.d.ts +2 -0
  183. package/lib/rules/common/operation-4xx-response.js +23 -0
  184. package/lib/rules/common/operation-description.d.ts +2 -0
  185. package/lib/rules/common/operation-description.js +12 -0
  186. package/lib/rules/common/operation-operationId-unique.d.ts +2 -0
  187. package/lib/rules/common/operation-operationId-unique.js +20 -0
  188. package/lib/rules/common/operation-operationId-url-safe.d.ts +2 -0
  189. package/lib/rules/common/operation-operationId-url-safe.js +18 -0
  190. package/lib/rules/common/operation-operationId.d.ts +2 -0
  191. package/lib/rules/common/operation-operationId.js +16 -0
  192. package/lib/rules/common/operation-parameters-unique.d.ts +2 -0
  193. package/lib/rules/common/operation-parameters-unique.js +40 -0
  194. package/lib/rules/common/operation-singular-tag.d.ts +2 -0
  195. package/lib/rules/common/operation-singular-tag.js +16 -0
  196. package/lib/rules/common/operation-summary.d.ts +2 -0
  197. package/lib/rules/common/operation-summary.js +12 -0
  198. package/lib/rules/common/operation-tag-defined.d.ts +2 -0
  199. package/lib/rules/common/operation-tag-defined.js +24 -0
  200. package/lib/rules/common/parameter-description.d.ts +2 -0
  201. package/lib/rules/common/parameter-description.js +22 -0
  202. package/lib/rules/common/path-declaration-must-exist.d.ts +2 -0
  203. package/lib/rules/common/path-declaration-must-exist.js +16 -0
  204. package/lib/rules/common/path-excludes-patterns.d.ts +2 -0
  205. package/lib/rules/common/path-excludes-patterns.js +22 -0
  206. package/lib/rules/common/path-http-verbs-order.d.ts +2 -0
  207. package/lib/rules/common/path-http-verbs-order.js +26 -0
  208. package/lib/rules/common/path-not-include-query.d.ts +2 -0
  209. package/lib/rules/common/path-not-include-query.js +18 -0
  210. package/lib/rules/common/path-params-defined.d.ts +2 -0
  211. package/lib/rules/common/path-params-defined.js +58 -0
  212. package/lib/rules/common/path-segment-plural.d.ts +2 -0
  213. package/lib/rules/common/path-segment-plural.js +33 -0
  214. package/lib/rules/common/paths-kebab-case.d.ts +2 -0
  215. package/lib/rules/common/paths-kebab-case.js +20 -0
  216. package/lib/rules/common/required-string-property-missing-min-length.d.ts +2 -0
  217. package/lib/rules/common/required-string-property-missing-min-length.js +37 -0
  218. package/lib/rules/common/response-contains-header.d.ts +2 -0
  219. package/lib/rules/common/response-contains-header.js +29 -0
  220. package/lib/rules/common/scalar-property-missing-example.d.ts +2 -0
  221. package/lib/rules/common/scalar-property-missing-example.js +42 -0
  222. package/lib/rules/common/security-defined.d.ts +2 -0
  223. package/lib/rules/common/security-defined.js +65 -0
  224. package/lib/rules/common/spec-strict-refs.d.ts +2 -0
  225. package/lib/rules/common/spec-strict-refs.js +30 -0
  226. package/lib/rules/common/struct.d.ts +2 -0
  227. package/lib/rules/common/struct.js +158 -0
  228. package/lib/rules/common/tag-description.d.ts +2 -0
  229. package/lib/rules/common/tag-description.js +12 -0
  230. package/lib/rules/common/tags-alphabetical.d.ts +2 -0
  231. package/lib/rules/common/tags-alphabetical.js +23 -0
  232. package/lib/rules/no-unresolved-refs.d.ts +5 -0
  233. package/lib/rules/no-unresolved-refs.js +46 -0
  234. package/lib/rules/oas2/boolean-parameter-prefixes.d.ts +5 -0
  235. package/lib/rules/oas2/boolean-parameter-prefixes.js +22 -0
  236. package/lib/rules/oas2/index.d.ts +3 -0
  237. package/lib/rules/oas2/index.js +98 -0
  238. package/lib/rules/oas2/request-mime-type.d.ts +2 -0
  239. package/lib/rules/oas2/request-mime-type.js +17 -0
  240. package/lib/rules/oas2/response-contains-property.d.ts +2 -0
  241. package/lib/rules/oas2/response-contains-property.js +37 -0
  242. package/lib/rules/oas2/response-mime-type.d.ts +2 -0
  243. package/lib/rules/oas2/response-mime-type.js +17 -0
  244. package/lib/rules/oas3/array-parameter-serialization.d.ts +5 -0
  245. package/lib/rules/oas3/array-parameter-serialization.js +29 -0
  246. package/lib/rules/oas3/boolean-parameter-prefixes.d.ts +5 -0
  247. package/lib/rules/oas3/boolean-parameter-prefixes.js +24 -0
  248. package/lib/rules/oas3/component-name-unique.d.ts +2 -0
  249. package/lib/rules/oas3/component-name-unique.js +133 -0
  250. package/lib/rules/oas3/index.d.ts +3 -0
  251. package/lib/rules/oas3/index.js +122 -0
  252. package/lib/rules/oas3/no-empty-servers.d.ts +2 -0
  253. package/lib/rules/oas3/no-empty-servers.js +23 -0
  254. package/lib/rules/oas3/no-example-value-and-externalValue.d.ts +2 -0
  255. package/lib/rules/oas3/no-example-value-and-externalValue.js +16 -0
  256. package/lib/rules/oas3/no-invalid-media-type-examples.d.ts +2 -0
  257. package/lib/rules/oas3/no-invalid-media-type-examples.js +39 -0
  258. package/lib/rules/oas3/no-server-example.com.d.ts +2 -0
  259. package/lib/rules/oas3/no-server-example.com.js +18 -0
  260. package/lib/rules/oas3/no-server-trailing-slash.d.ts +2 -0
  261. package/lib/rules/oas3/no-server-trailing-slash.js +18 -0
  262. package/lib/rules/oas3/no-server-variables-empty-enum.d.ts +2 -0
  263. package/lib/rules/oas3/no-server-variables-empty-enum.js +66 -0
  264. package/lib/rules/oas3/no-undefined-server-variable.d.ts +2 -0
  265. package/lib/rules/oas3/no-undefined-server-variable.js +31 -0
  266. package/lib/rules/oas3/no-unused-components.d.ts +2 -0
  267. package/lib/rules/oas3/no-unused-components.js +73 -0
  268. package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.d.ts +5 -0
  269. package/lib/rules/oas3/operation-4xx-problem-details-rfc7807.js +36 -0
  270. package/lib/rules/oas3/request-mime-type.d.ts +2 -0
  271. package/lib/rules/oas3/request-mime-type.js +31 -0
  272. package/lib/rules/oas3/response-contains-property.d.ts +2 -0
  273. package/lib/rules/oas3/response-contains-property.js +39 -0
  274. package/lib/rules/oas3/response-mime-type.d.ts +2 -0
  275. package/lib/rules/oas3/response-mime-type.js +31 -0
  276. package/lib/rules/oas3/spec-components-invalid-map-name.d.ts +2 -0
  277. package/lib/rules/oas3/spec-components-invalid-map-name.js +62 -0
  278. package/lib/rules/other/stats.d.ts +41 -0
  279. package/lib/rules/other/stats.js +75 -0
  280. package/lib/rules/spot/no-criteria-xpath.d.ts +2 -0
  281. package/lib/rules/spot/no-criteria-xpath.js +21 -0
  282. package/lib/rules/spot/spot-supported-versions.d.ts +2 -0
  283. package/lib/rules/spot/spot-supported-versions.js +21 -0
  284. package/lib/rules/utils.d.ts +22 -0
  285. package/lib/rules/utils.js +183 -0
  286. package/lib/types/arazzo.d.ts +2 -0
  287. package/lib/types/arazzo.js +311 -0
  288. package/lib/types/asyncapi2.d.ts +17 -0
  289. package/lib/types/asyncapi2.js +1008 -0
  290. package/lib/types/asyncapi3.d.ts +2 -0
  291. package/lib/types/asyncapi3.js +347 -0
  292. package/lib/types/index.d.ts +57 -0
  293. package/lib/types/index.js +94 -0
  294. package/lib/types/json-schema-adapter.d.ts +3 -0
  295. package/lib/types/json-schema-adapter.js +159 -0
  296. package/lib/types/oas2.d.ts +3 -0
  297. package/lib/types/oas2.js +456 -0
  298. package/lib/types/oas3.d.ts +7 -0
  299. package/lib/types/oas3.js +554 -0
  300. package/lib/types/oas3_1.d.ts +6 -0
  301. package/lib/types/oas3_1.js +285 -0
  302. package/lib/types/redocly-yaml.d.ts +26 -0
  303. package/lib/types/redocly-yaml.js +1126 -0
  304. package/lib/typings/arazzo.d.ts +131 -0
  305. package/lib/typings/arazzo.js +5 -0
  306. package/lib/typings/asyncapi.d.ts +21 -0
  307. package/lib/typings/asyncapi.js +2 -0
  308. package/lib/typings/asyncapi3.d.ts +53 -0
  309. package/lib/typings/asyncapi3.js +2 -0
  310. package/lib/typings/common.d.ts +8 -0
  311. package/lib/typings/common.js +2 -0
  312. package/lib/typings/openapi.d.ts +355 -0
  313. package/lib/typings/openapi.js +2 -0
  314. package/lib/typings/swagger.d.ts +217 -0
  315. package/lib/typings/swagger.js +2 -0
  316. package/lib/utils.d.ts +70 -0
  317. package/lib/utils.js +301 -0
  318. package/lib/visitors.d.ts +229 -0
  319. package/lib/visitors.js +176 -0
  320. package/lib/walk.d.ts +78 -0
  321. package/lib/walk.js +290 -0
  322. package/package.json +59 -0
@@ -0,0 +1,3 @@
1
+ import type { PluginStyleguideConfig } from './types';
2
+ declare const spec: PluginStyleguideConfig<'built-in'>;
3
+ export default spec;
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const spec = {
4
+ rules: {
5
+ struct: 'error',
6
+ },
7
+ // TODO: populate with spec-related rules similar to `arazzo1Rules`
8
+ oas2Rules: {},
9
+ oas3_0Rules: {},
10
+ oas3_1Rules: {},
11
+ async2Rules: {},
12
+ async3Rules: {},
13
+ arazzo1Rules: {
14
+ 'sourceDescription-type': 'error',
15
+ 'spot-supported-versions': 'off',
16
+ 'workflowId-unique': 'error',
17
+ 'stepId-unique': 'error',
18
+ 'sourceDescription-name-unique': 'error',
19
+ 'sourceDescriptions-not-empty': 'error',
20
+ 'workflow-dependsOn': 'error',
21
+ 'parameters-unique': 'error',
22
+ 'step-onSuccess-unique': 'error',
23
+ 'step-onFailure-unique': 'error',
24
+ 'requestBody-replacements-unique': 'error',
25
+ 'no-criteria-xpath': 'off',
26
+ 'criteria-unique': 'error',
27
+ },
28
+ };
29
+ exports.default = spec;
@@ -0,0 +1,189 @@
1
+ import type { Location } from '../ref-utils';
2
+ import type { ProblemSeverity, UserContext } from '../walk';
3
+ import type { Oas3PreprocessorsSet, SpecMajorVersion, Oas3DecoratorsSet, Oas2RuleSet, Oas2PreprocessorsSet, Oas2DecoratorsSet, Oas3RuleSet, SpecVersion, Async2PreprocessorsSet, Async2DecoratorsSet, Async2RuleSet, Async3PreprocessorsSet, Async3DecoratorsSet, Async3RuleSet, Arazzo1RuleSet, Arazzo1PreprocessorsSet, Arazzo1DecoratorsSet, RuleMap } from '../oas-types';
4
+ import type { NodeType } from '../types';
5
+ import type { SkipFunctionContext } from '../visitors';
6
+ import type { JSONSchema } from 'json-schema-to-ts';
7
+ export type RuleSeverity = ProblemSeverity | 'off';
8
+ export type RuleSettings = {
9
+ severity: RuleSeverity;
10
+ message?: string;
11
+ };
12
+ export type PreprocessorSeverity = RuleSeverity | 'on';
13
+ export type RuleConfig = RuleSeverity | (Partial<RuleSettings> & Record<string, any>);
14
+ export type PreprocessorConfig = PreprocessorSeverity | ({
15
+ severity?: ProblemSeverity;
16
+ } & Record<string, any>);
17
+ export type DecoratorConfig = PreprocessorConfig;
18
+ export type StyleguideRawConfig<T = undefined> = {
19
+ plugins?: (string | Plugin)[];
20
+ extends?: string[];
21
+ doNotResolveExamples?: boolean;
22
+ recommendedFallback?: boolean;
23
+ rules?: RuleMap<string, RuleConfig, T>;
24
+ oas2Rules?: RuleMap<string, RuleConfig, T>;
25
+ oas3_0Rules?: RuleMap<string, RuleConfig, T>;
26
+ oas3_1Rules?: RuleMap<string, RuleConfig, T>;
27
+ async2Rules?: RuleMap<string, RuleConfig, T>;
28
+ async3Rules?: RuleMap<string, RuleConfig, T>;
29
+ arazzo1Rules?: RuleMap<string, RuleConfig, T>;
30
+ preprocessors?: Record<string, PreprocessorConfig>;
31
+ oas2Preprocessors?: Record<string, PreprocessorConfig>;
32
+ oas3_0Preprocessors?: Record<string, PreprocessorConfig>;
33
+ oas3_1Preprocessors?: Record<string, PreprocessorConfig>;
34
+ async2Preprocessors?: Record<string, PreprocessorConfig>;
35
+ async3Preprocessors?: Record<string, PreprocessorConfig>;
36
+ arazzo1Preprocessors?: Record<string, PreprocessorConfig>;
37
+ decorators?: Record<string, DecoratorConfig>;
38
+ oas2Decorators?: Record<string, DecoratorConfig>;
39
+ oas3_0Decorators?: Record<string, DecoratorConfig>;
40
+ oas3_1Decorators?: Record<string, DecoratorConfig>;
41
+ async2Decorators?: Record<string, DecoratorConfig>;
42
+ async3Decorators?: Record<string, DecoratorConfig>;
43
+ arazzo1Decorators?: Record<string, DecoratorConfig>;
44
+ };
45
+ export type ApiStyleguideRawConfig = Omit<StyleguideRawConfig, 'plugins'>;
46
+ export type ResolvedStyleguideConfig = PluginStyleguideConfig & {
47
+ plugins?: Plugin[];
48
+ recommendedFallback?: boolean;
49
+ extends?: void | never;
50
+ extendPaths?: string[];
51
+ pluginPaths?: string[];
52
+ };
53
+ export type PreprocessorsConfig = {
54
+ oas3?: Oas3PreprocessorsSet;
55
+ oas2?: Oas2PreprocessorsSet;
56
+ async2?: Async2PreprocessorsSet;
57
+ async3?: Async3PreprocessorsSet;
58
+ arazzo1?: Arazzo1PreprocessorsSet;
59
+ };
60
+ export type DecoratorsConfig = {
61
+ oas3?: Oas3DecoratorsSet;
62
+ oas2?: Oas2DecoratorsSet;
63
+ async2?: Async2DecoratorsSet;
64
+ async3?: Async3DecoratorsSet;
65
+ arazzo1?: Arazzo1DecoratorsSet;
66
+ };
67
+ export type TypesExtensionFn = (types: Record<string, NodeType>, oasVersion: SpecVersion) => Record<string, NodeType>;
68
+ export type TypeExtensionsConfig = Partial<Record<SpecMajorVersion, TypesExtensionFn>>;
69
+ export type RulesConfig<T> = {
70
+ oas3?: Oas3RuleSet<T>;
71
+ oas2?: Oas2RuleSet<T>;
72
+ async2?: Async2RuleSet<T>;
73
+ async3?: Async3RuleSet<T>;
74
+ arazzo1?: Arazzo1RuleSet<T>;
75
+ };
76
+ export type CustomRulesConfig = RulesConfig<undefined>;
77
+ export type AssertionContext = Partial<UserContext> & SkipFunctionContext & {
78
+ node: any;
79
+ };
80
+ export type AssertResult = {
81
+ message?: string;
82
+ location?: Location;
83
+ };
84
+ export type CustomFunction = (value: any, options: unknown, baseLocation: Location) => AssertResult[];
85
+ export type AssertionsConfig = Record<string, CustomFunction>;
86
+ export type Plugin<T = undefined> = {
87
+ id: string;
88
+ configs?: Record<string, PluginStyleguideConfig>;
89
+ rules?: RulesConfig<T>;
90
+ preprocessors?: PreprocessorsConfig;
91
+ decorators?: DecoratorsConfig;
92
+ typeExtension?: TypeExtensionsConfig;
93
+ assertions?: AssertionsConfig;
94
+ path?: string;
95
+ absolutePath?: string;
96
+ processContent?: (actions: any, content: any) => Promise<void> | void;
97
+ afterRoutesCreated?: (actions: any, content: any) => Promise<void> | void;
98
+ loaders?: Record<string, (path: string, context: any, reportError: (error: Error) => void) => Promise<unknown>>;
99
+ requiredEntitlements?: string[];
100
+ ssoConfigSchema?: JSONSchema;
101
+ redoclyConfigSchema?: JSONSchema;
102
+ ejectIgnore?: string[];
103
+ };
104
+ type PluginCreatorOptions = {
105
+ contentDir: string;
106
+ };
107
+ export type PluginCreator = (options: PluginCreatorOptions) => Plugin | Promise<Plugin>;
108
+ export type ImportedPlugin = {
109
+ default?: PluginCreator;
110
+ } | PluginCreator | Plugin;
111
+ export type PluginStyleguideConfig<T = undefined> = Omit<StyleguideRawConfig<T>, 'plugins' | 'extends'>;
112
+ export type ResolveHeader = {
113
+ name: string;
114
+ envVariable?: undefined;
115
+ value: string;
116
+ matches: string;
117
+ } | {
118
+ name: string;
119
+ value?: undefined;
120
+ envVariable: string;
121
+ matches: string;
122
+ };
123
+ export type RawResolveConfig = {
124
+ http?: Partial<HttpResolveConfig>;
125
+ doNotResolveExamples?: boolean;
126
+ };
127
+ export type HttpResolveConfig = {
128
+ headers: ResolveHeader[];
129
+ customFetch?: Function;
130
+ };
131
+ export type ResolveConfig = {
132
+ http: HttpResolveConfig;
133
+ };
134
+ export type Region = 'us' | 'eu';
135
+ export type Telemetry = 'on' | 'off';
136
+ export type AccessTokens = {
137
+ [region in Region]?: string;
138
+ };
139
+ export type DeprecatedInRawConfig = {
140
+ apiDefinitions?: Record<string, string>;
141
+ lint?: StyleguideRawConfig;
142
+ styleguide?: StyleguideRawConfig;
143
+ referenceDocs?: Record<string, any>;
144
+ apis?: Record<string, Api & DeprecatedInApi>;
145
+ } & DeprecatedFeaturesConfig;
146
+ export type Api = {
147
+ root: string;
148
+ output?: string;
149
+ styleguide?: ApiStyleguideRawConfig;
150
+ } & ThemeConfig;
151
+ export type DeprecatedInApi = {
152
+ lint?: ApiStyleguideRawConfig;
153
+ } & DeprecatedFeaturesConfig;
154
+ export type ResolvedApi = Omit<Api, 'styleguide'> & {
155
+ styleguide: ResolvedStyleguideConfig;
156
+ files?: string[];
157
+ };
158
+ export type RawConfig = {
159
+ apis?: Record<string, Api>;
160
+ styleguide?: StyleguideRawConfig;
161
+ resolve?: RawResolveConfig;
162
+ region?: Region;
163
+ organization?: string;
164
+ files?: string[];
165
+ telemetry?: Telemetry;
166
+ } & ThemeConfig;
167
+ export type RawUniversalConfig = Omit<RawConfig, 'styleguide'> & StyleguideRawConfig;
168
+ export type FlatApi = Omit<Api, 'styleguide'> & Omit<ApiStyleguideRawConfig, 'doNotResolveExamples'>;
169
+ export type FlatRawConfig = Omit<RawConfig, 'styleguide' | 'resolve' | 'apis'> & Omit<StyleguideRawConfig, 'doNotResolveExamples'> & {
170
+ resolve?: RawResolveConfig;
171
+ apis?: Record<string, FlatApi>;
172
+ } & ThemeRawConfig;
173
+ export type ResolvedConfig = Omit<RawConfig, 'apis' | 'styleguide'> & {
174
+ apis: Record<string, ResolvedApi>;
175
+ styleguide: ResolvedStyleguideConfig;
176
+ };
177
+ type DeprecatedFeaturesConfig = {
178
+ 'features.openapi'?: Record<string, any>;
179
+ 'features.mockServer'?: Record<string, any>;
180
+ };
181
+ export type ThemeConfig = {
182
+ theme?: ThemeRawConfig;
183
+ };
184
+ export type ThemeRawConfig = {
185
+ openapi?: Record<string, any>;
186
+ mockServer?: Record<string, any>;
187
+ };
188
+ export type RulesFields = 'rules' | 'oas2Rules' | 'oas3_0Rules' | 'oas3_1Rules' | 'async2Rules' | 'async3Rules' | 'arazzo1Rules' | 'preprocessors' | 'oas2Preprocessors' | 'oas3_0Preprocessors' | 'oas3_1Preprocessors' | 'async2Preprocessors' | 'async3Preprocessors' | 'arazzo1Preprocessors' | 'decorators' | 'oas2Decorators' | 'oas3_0Decorators' | 'oas3_1Decorators' | 'async2Decorators' | 'async3Decorators' | 'arazzo1Decorators';
189
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,19 @@
1
+ import { Config } from './config';
2
+ import type { Api, DeprecatedInRawConfig, ImportedPlugin, FlatRawConfig, RawConfig, RawResolveConfig, ResolveConfig, ResolvedStyleguideConfig, RulesFields, Plugin, PluginCreator } from './types';
3
+ export declare function parsePresetName(presetName: string): {
4
+ pluginId: string;
5
+ configName: string;
6
+ };
7
+ export declare function transformApiDefinitionsToApis(apiDefinitions?: DeprecatedInRawConfig['apiDefinitions']): Record<string, Api> | undefined;
8
+ export declare function prefixRules<T extends Record<string, any>>(rules: T, prefix: string): any;
9
+ export declare function mergeExtends(rulesConfList: ResolvedStyleguideConfig[]): Omit<ResolvedStyleguideConfig, RulesFields> & Required<Pick<ResolvedStyleguideConfig, RulesFields>>;
10
+ export declare function getMergedConfig(config: Config, apiName?: string): Config;
11
+ export declare function checkForDeprecatedFields(deprecatedField: keyof (DeprecatedInRawConfig & RawConfig), updatedField: keyof FlatRawConfig | undefined, rawConfig: DeprecatedInRawConfig & RawConfig & FlatRawConfig, updatedObject: keyof FlatRawConfig | undefined, link?: string | undefined): void;
12
+ export declare function transformConfig(rawConfig: DeprecatedInRawConfig & RawConfig & FlatRawConfig): RawConfig;
13
+ export declare function getResolveConfig(resolve?: RawResolveConfig): ResolveConfig;
14
+ export declare function getUniquePlugins(plugins: Plugin[]): Plugin[];
15
+ export declare class ConfigValidationError extends Error {
16
+ }
17
+ export declare function deepCloneMapWithJSON<K, V>(originalMap: Map<K, V>): Map<K, V>;
18
+ export declare function isDeprecatedPluginFormat(plugin: ImportedPlugin | undefined): plugin is Plugin;
19
+ export declare function isCommonJsPlugin(plugin: ImportedPlugin | undefined): plugin is PluginCreator;
@@ -0,0 +1,308 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ConfigValidationError = void 0;
4
+ exports.parsePresetName = parsePresetName;
5
+ exports.transformApiDefinitionsToApis = transformApiDefinitionsToApis;
6
+ exports.prefixRules = prefixRules;
7
+ exports.mergeExtends = mergeExtends;
8
+ exports.getMergedConfig = getMergedConfig;
9
+ exports.checkForDeprecatedFields = checkForDeprecatedFields;
10
+ exports.transformConfig = transformConfig;
11
+ exports.getResolveConfig = getResolveConfig;
12
+ exports.getUniquePlugins = getUniquePlugins;
13
+ exports.deepCloneMapWithJSON = deepCloneMapWithJSON;
14
+ exports.isDeprecatedPluginFormat = isDeprecatedPluginFormat;
15
+ exports.isCommonJsPlugin = isCommonJsPlugin;
16
+ const utils_1 = require("../utils");
17
+ const config_1 = require("./config");
18
+ const logger_1 = require("../logger");
19
+ function parsePresetName(presetName) {
20
+ if (presetName.indexOf('/') > -1) {
21
+ const [pluginId, configName] = presetName.split('/');
22
+ return { pluginId, configName };
23
+ }
24
+ else {
25
+ return { pluginId: '', configName: presetName };
26
+ }
27
+ }
28
+ function transformApiDefinitionsToApis(apiDefinitions) {
29
+ if (!apiDefinitions)
30
+ return undefined;
31
+ const apis = {};
32
+ for (const [apiName, apiPath] of Object.entries(apiDefinitions)) {
33
+ apis[apiName] = { root: apiPath };
34
+ }
35
+ return apis;
36
+ }
37
+ function extractFlatConfig({ plugins, extends: _extends, rules, oas2Rules, oas3_0Rules, oas3_1Rules, async2Rules, async3Rules, arazzo1Rules, preprocessors, oas2Preprocessors, oas3_0Preprocessors, oas3_1Preprocessors, async2Preprocessors, async3Preprocessors, arazzo1Preprocessors, decorators, oas2Decorators, oas3_0Decorators, oas3_1Decorators, async2Decorators, async3Decorators, arazzo1Decorators, ...rawConfigRest }) {
38
+ const styleguideConfig = {
39
+ plugins,
40
+ extends: _extends,
41
+ rules,
42
+ oas2Rules,
43
+ oas3_0Rules,
44
+ oas3_1Rules,
45
+ async2Rules,
46
+ async3Rules,
47
+ arazzo1Rules,
48
+ preprocessors,
49
+ oas2Preprocessors,
50
+ oas3_0Preprocessors,
51
+ oas3_1Preprocessors,
52
+ async2Preprocessors,
53
+ async3Preprocessors,
54
+ arazzo1Preprocessors,
55
+ decorators,
56
+ oas2Decorators,
57
+ oas3_0Decorators,
58
+ oas3_1Decorators,
59
+ async2Decorators,
60
+ async3Decorators,
61
+ arazzo1Decorators,
62
+ doNotResolveExamples: rawConfigRest.resolve?.doNotResolveExamples,
63
+ };
64
+ if ((rawConfigRest.lint && rawConfigRest.styleguide) ||
65
+ (Object.values(styleguideConfig).some(utils_1.isDefined) &&
66
+ (rawConfigRest.lint || rawConfigRest.styleguide))) {
67
+ throw new Error(`Do not use 'lint', 'styleguide' and flat syntax together. \nSee more about the configuration in the docs: https://redocly.com/docs/cli/configuration/ \n`);
68
+ }
69
+ return {
70
+ styleguideConfig: Object.values(styleguideConfig).some(utils_1.isDefined)
71
+ ? styleguideConfig
72
+ : undefined,
73
+ rawConfigRest,
74
+ };
75
+ }
76
+ function transformApis(legacyApis) {
77
+ if (!legacyApis)
78
+ return undefined;
79
+ const apis = {};
80
+ for (const [apiName, { lint, ...apiContent }] of Object.entries(legacyApis)) {
81
+ const { styleguideConfig, rawConfigRest } = extractFlatConfig(apiContent);
82
+ apis[apiName] = {
83
+ styleguide: styleguideConfig || lint,
84
+ ...rawConfigRest,
85
+ };
86
+ }
87
+ return apis;
88
+ }
89
+ function prefixRules(rules, prefix) {
90
+ if (!prefix)
91
+ return rules;
92
+ const res = {};
93
+ for (const name of Object.keys(rules)) {
94
+ res[`${prefix}/${name}`] = rules[name];
95
+ }
96
+ return res;
97
+ }
98
+ function mergeExtends(rulesConfList) {
99
+ const result = {
100
+ rules: {},
101
+ oas2Rules: {},
102
+ oas3_0Rules: {},
103
+ oas3_1Rules: {},
104
+ async2Rules: {},
105
+ async3Rules: {},
106
+ arazzo1Rules: {},
107
+ preprocessors: {},
108
+ oas2Preprocessors: {},
109
+ oas3_0Preprocessors: {},
110
+ oas3_1Preprocessors: {},
111
+ async2Preprocessors: {},
112
+ async3Preprocessors: {},
113
+ arazzo1Preprocessors: {},
114
+ decorators: {},
115
+ oas2Decorators: {},
116
+ oas3_0Decorators: {},
117
+ oas3_1Decorators: {},
118
+ async2Decorators: {},
119
+ async3Decorators: {},
120
+ arazzo1Decorators: {},
121
+ plugins: [],
122
+ pluginPaths: [],
123
+ extendPaths: [],
124
+ };
125
+ for (const rulesConf of rulesConfList) {
126
+ if (rulesConf.extends) {
127
+ throw new Error(`'extends' is not supported in shared configs yet:\n${JSON.stringify(rulesConf, null, 2)}`);
128
+ }
129
+ (0, utils_1.assignConfig)(result.rules, rulesConf.rules);
130
+ (0, utils_1.assignConfig)(result.oas2Rules, rulesConf.oas2Rules);
131
+ (0, utils_1.assignOnlyExistingConfig)(result.oas2Rules, rulesConf.rules);
132
+ (0, utils_1.assignConfig)(result.oas3_0Rules, rulesConf.oas3_0Rules);
133
+ (0, utils_1.assignOnlyExistingConfig)(result.oas3_0Rules, rulesConf.rules);
134
+ (0, utils_1.assignConfig)(result.oas3_1Rules, rulesConf.oas3_1Rules);
135
+ (0, utils_1.assignOnlyExistingConfig)(result.oas3_1Rules, rulesConf.rules);
136
+ (0, utils_1.assignConfig)(result.async2Rules, rulesConf.async2Rules);
137
+ (0, utils_1.assignOnlyExistingConfig)(result.async2Rules, rulesConf.rules);
138
+ (0, utils_1.assignConfig)(result.async3Rules, rulesConf.async3Rules);
139
+ (0, utils_1.assignOnlyExistingConfig)(result.async3Rules, rulesConf.rules);
140
+ (0, utils_1.assignConfig)(result.arazzo1Rules, rulesConf.arazzo1Rules);
141
+ (0, utils_1.assignOnlyExistingConfig)(result.arazzo1Rules, rulesConf.rules);
142
+ (0, utils_1.assignConfig)(result.preprocessors, rulesConf.preprocessors);
143
+ (0, utils_1.assignConfig)(result.oas2Preprocessors, rulesConf.oas2Preprocessors);
144
+ (0, utils_1.assignOnlyExistingConfig)(result.oas2Preprocessors, rulesConf.preprocessors);
145
+ (0, utils_1.assignConfig)(result.oas3_0Preprocessors, rulesConf.oas3_0Preprocessors);
146
+ (0, utils_1.assignOnlyExistingConfig)(result.oas3_0Preprocessors, rulesConf.preprocessors);
147
+ (0, utils_1.assignConfig)(result.oas3_1Preprocessors, rulesConf.oas3_1Preprocessors);
148
+ (0, utils_1.assignOnlyExistingConfig)(result.oas3_1Preprocessors, rulesConf.preprocessors);
149
+ (0, utils_1.assignConfig)(result.async2Preprocessors, rulesConf.async2Preprocessors);
150
+ (0, utils_1.assignOnlyExistingConfig)(result.async2Preprocessors, rulesConf.preprocessors);
151
+ (0, utils_1.assignConfig)(result.async3Preprocessors, rulesConf.async3Preprocessors);
152
+ (0, utils_1.assignOnlyExistingConfig)(result.async3Preprocessors, rulesConf.preprocessors);
153
+ (0, utils_1.assignConfig)(result.arazzo1Preprocessors, rulesConf.arazzo1Preprocessors);
154
+ (0, utils_1.assignOnlyExistingConfig)(result.arazzo1Preprocessors, rulesConf.preprocessors);
155
+ (0, utils_1.assignConfig)(result.decorators, rulesConf.decorators);
156
+ (0, utils_1.assignConfig)(result.oas2Decorators, rulesConf.oas2Decorators);
157
+ (0, utils_1.assignOnlyExistingConfig)(result.oas2Decorators, rulesConf.decorators);
158
+ (0, utils_1.assignConfig)(result.oas3_0Decorators, rulesConf.oas3_0Decorators);
159
+ (0, utils_1.assignOnlyExistingConfig)(result.oas3_0Decorators, rulesConf.decorators);
160
+ (0, utils_1.assignConfig)(result.oas3_1Decorators, rulesConf.oas3_1Decorators);
161
+ (0, utils_1.assignOnlyExistingConfig)(result.oas3_1Decorators, rulesConf.decorators);
162
+ (0, utils_1.assignConfig)(result.async2Decorators, rulesConf.async2Decorators);
163
+ (0, utils_1.assignOnlyExistingConfig)(result.async2Decorators, rulesConf.decorators);
164
+ (0, utils_1.assignConfig)(result.async3Decorators, rulesConf.async3Decorators);
165
+ (0, utils_1.assignOnlyExistingConfig)(result.async3Decorators, rulesConf.decorators);
166
+ (0, utils_1.assignConfig)(result.arazzo1Decorators, rulesConf.arazzo1Decorators);
167
+ (0, utils_1.assignOnlyExistingConfig)(result.arazzo1Decorators, rulesConf.decorators);
168
+ result.plugins.push(...(rulesConf.plugins || []));
169
+ result.pluginPaths.push(...(rulesConf.pluginPaths || []));
170
+ result.extendPaths.push(...new Set(rulesConf.extendPaths));
171
+ }
172
+ return result;
173
+ }
174
+ function getMergedConfig(config, apiName) {
175
+ const extendPaths = [
176
+ ...Object.values(config.apis).map((api) => api?.styleguide?.extendPaths),
177
+ config.rawConfig?.styleguide?.extendPaths,
178
+ ]
179
+ .flat()
180
+ .filter(utils_1.isTruthy);
181
+ const pluginPaths = [
182
+ ...Object.values(config.apis).map((api) => api?.styleguide?.pluginPaths),
183
+ config.rawConfig?.styleguide?.pluginPaths,
184
+ ]
185
+ .flat()
186
+ .filter(utils_1.isTruthy);
187
+ return apiName
188
+ ? new config_1.Config({
189
+ ...config.rawConfig,
190
+ styleguide: {
191
+ ...(config.apis[apiName]
192
+ ? config.apis[apiName].styleguide
193
+ : config.rawConfig.styleguide),
194
+ extendPaths,
195
+ pluginPaths,
196
+ },
197
+ theme: {
198
+ ...config.rawConfig.theme,
199
+ ...config.apis[apiName]?.theme,
200
+ },
201
+ files: [...config.files, ...(config.apis?.[apiName]?.files ?? [])],
202
+ // TODO: merge everything else here
203
+ }, config.configFile)
204
+ : config;
205
+ }
206
+ function checkForDeprecatedFields(deprecatedField, updatedField, rawConfig, updatedObject, link) {
207
+ const isDeprecatedFieldInApis = rawConfig.apis &&
208
+ Object.values(rawConfig.apis).some((api) => api[deprecatedField]);
209
+ if (rawConfig[deprecatedField] && updatedField === null) {
210
+ (0, utils_1.showWarningForDeprecatedField)(deprecatedField, undefined, updatedObject, link);
211
+ }
212
+ if (rawConfig[deprecatedField] && updatedField && rawConfig[updatedField]) {
213
+ (0, utils_1.showErrorForDeprecatedField)(deprecatedField, updatedField);
214
+ }
215
+ if (rawConfig[deprecatedField] && updatedObject && rawConfig[updatedObject]) {
216
+ (0, utils_1.showErrorForDeprecatedField)(deprecatedField, updatedField, updatedObject);
217
+ }
218
+ if (rawConfig[deprecatedField] || isDeprecatedFieldInApis) {
219
+ (0, utils_1.showWarningForDeprecatedField)(deprecatedField, updatedField, updatedObject, link);
220
+ }
221
+ }
222
+ function transformConfig(rawConfig) {
223
+ const migratedFields = [
224
+ ['apiDefinitions', 'apis', undefined, undefined],
225
+ ['referenceDocs', 'openapi', 'theme', undefined],
226
+ [
227
+ 'lint',
228
+ undefined,
229
+ undefined,
230
+ 'https://redocly.com/docs/api-registry/guides/migration-guide-config-file/#changed-properties',
231
+ ],
232
+ [
233
+ 'styleguide',
234
+ undefined,
235
+ undefined,
236
+ 'https://redocly.com/docs/api-registry/guides/migration-guide-config-file/#changed-properties',
237
+ ],
238
+ ['features.openapi', 'openapi', 'theme', undefined],
239
+ ];
240
+ for (const [deprecatedField, updatedField, updatedObject, link] of migratedFields) {
241
+ checkForDeprecatedFields(deprecatedField, updatedField, rawConfig, updatedObject, link);
242
+ }
243
+ const { apis, apiDefinitions, referenceDocs, lint, ...rest } = rawConfig;
244
+ const { styleguideConfig, rawConfigRest } = extractFlatConfig(rest);
245
+ const transformedConfig = {
246
+ theme: {
247
+ openapi: {
248
+ ...referenceDocs,
249
+ ...rawConfig['features.openapi'],
250
+ ...rawConfig.theme?.openapi,
251
+ },
252
+ mockServer: {
253
+ ...rawConfig['features.mockServer'],
254
+ ...rawConfig.theme?.mockServer,
255
+ },
256
+ },
257
+ apis: transformApis(apis) || transformApiDefinitionsToApis(apiDefinitions),
258
+ styleguide: styleguideConfig || lint,
259
+ ...rawConfigRest,
260
+ };
261
+ showDeprecationMessages(transformedConfig);
262
+ return transformedConfig;
263
+ }
264
+ function showDeprecationMessages(config) {
265
+ let allRules = { ...config.styleguide?.rules };
266
+ for (const api of Object.values(config.apis || {})) {
267
+ allRules = { ...allRules, ...api?.styleguide?.rules };
268
+ }
269
+ for (const ruleKey of Object.keys(allRules)) {
270
+ if (ruleKey.startsWith('assert/')) {
271
+ logger_1.logger.warn(`\nThe 'assert/' syntax in ${ruleKey} is deprecated. Update your configuration to use 'rule/' instead. Examples and more information: https://redocly.com/docs/cli/rules/configurable-rules/\n`);
272
+ }
273
+ }
274
+ }
275
+ function getResolveConfig(resolve) {
276
+ return {
277
+ http: {
278
+ headers: resolve?.http?.headers ?? [],
279
+ customFetch: undefined,
280
+ },
281
+ };
282
+ }
283
+ function getUniquePlugins(plugins) {
284
+ const seen = new Set();
285
+ const results = [];
286
+ for (const p of plugins) {
287
+ if (!seen.has(p.id)) {
288
+ results.push(p);
289
+ seen.add(p.id);
290
+ }
291
+ else if (p.id) {
292
+ logger_1.logger.warn(`Duplicate plugin id "${logger_1.colorize.red(p.id)}".\n`);
293
+ }
294
+ }
295
+ return results;
296
+ }
297
+ class ConfigValidationError extends Error {
298
+ }
299
+ exports.ConfigValidationError = ConfigValidationError;
300
+ function deepCloneMapWithJSON(originalMap) {
301
+ return new Map(JSON.parse(JSON.stringify([...originalMap])));
302
+ }
303
+ function isDeprecatedPluginFormat(plugin) {
304
+ return plugin !== undefined && typeof plugin === 'object' && 'id' in plugin;
305
+ }
306
+ function isCommonJsPlugin(plugin) {
307
+ return typeof plugin === 'function';
308
+ }
@@ -0,0 +1 @@
1
+ export declare const decorators: {};
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decorators = void 0;
4
+ exports.decorators = {};
@@ -0,0 +1 @@
1
+ export declare const decorators: {};
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decorators = void 0;
4
+ exports.decorators = {};
@@ -0,0 +1 @@
1
+ export declare const decorators: {};
@@ -0,0 +1,4 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.decorators = void 0;
4
+ exports.decorators = {};
@@ -0,0 +1,3 @@
1
+ import type { UserContext } from '../../../walk';
2
+ export declare function filter(node: any, ctx: UserContext, criteria: (item: any) => boolean): void;
3
+ export declare function checkIfMatchByStrategy(nodeValue: any, decoratorValue: any, strategy: 'all' | 'any'): boolean;
@@ -0,0 +1,66 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.filter = filter;
4
+ exports.checkIfMatchByStrategy = checkIfMatchByStrategy;
5
+ const ref_utils_1 = require("../../../ref-utils");
6
+ const utils_1 = require("../../../utils");
7
+ function filter(node, ctx, criteria) {
8
+ const { parent, key } = ctx;
9
+ let didDelete = false;
10
+ if (Array.isArray(node)) {
11
+ for (let i = 0; i < node.length; i++) {
12
+ if ((0, ref_utils_1.isRef)(node[i])) {
13
+ const resolved = ctx.resolve(node[i]);
14
+ if (criteria(resolved.node)) {
15
+ node.splice(i, 1);
16
+ didDelete = true;
17
+ i--;
18
+ }
19
+ }
20
+ if (criteria(node[i])) {
21
+ node.splice(i, 1);
22
+ didDelete = true;
23
+ i--;
24
+ }
25
+ }
26
+ }
27
+ else if ((0, utils_1.isPlainObject)(node)) {
28
+ for (const key of Object.keys(node)) {
29
+ node = node;
30
+ if ((0, ref_utils_1.isRef)(node[key])) {
31
+ const resolved = ctx.resolve(node[key]);
32
+ if (criteria(resolved.node)) {
33
+ delete node[key];
34
+ didDelete = true;
35
+ }
36
+ }
37
+ if (criteria(node[key])) {
38
+ delete node[key];
39
+ didDelete = true;
40
+ }
41
+ }
42
+ }
43
+ if (didDelete && ((0, utils_1.isEmptyObject)(node) || (0, utils_1.isEmptyArray)(node))) {
44
+ delete parent[key];
45
+ }
46
+ }
47
+ function checkIfMatchByStrategy(nodeValue, decoratorValue, strategy) {
48
+ if (nodeValue === undefined || decoratorValue === undefined) {
49
+ return false;
50
+ }
51
+ if (!Array.isArray(decoratorValue) && !Array.isArray(nodeValue)) {
52
+ return nodeValue === decoratorValue;
53
+ }
54
+ decoratorValue = toArrayIfNeeded(decoratorValue);
55
+ nodeValue = toArrayIfNeeded(nodeValue);
56
+ if (strategy === 'any') {
57
+ return decoratorValue.some((item) => nodeValue.includes(item));
58
+ }
59
+ if (strategy === 'all') {
60
+ return decoratorValue.every((item) => nodeValue.includes(item));
61
+ }
62
+ return false;
63
+ }
64
+ function toArrayIfNeeded(value) {
65
+ return Array.isArray(value) ? value : [value];
66
+ }
@@ -0,0 +1,2 @@
1
+ import type { Oas2Decorator, Oas3Decorator } from '../../../visitors';
2
+ export declare const FilterIn: Oas3Decorator | Oas2Decorator;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FilterIn = void 0;
4
+ const filter_helper_1 = require("./filter-helper");
5
+ const DEFAULT_STRATEGY = 'any';
6
+ const FilterIn = ({ property, value, matchStrategy }) => {
7
+ const strategy = matchStrategy || DEFAULT_STRATEGY;
8
+ const filterInCriteria = (item) => item?.[property] && !(0, filter_helper_1.checkIfMatchByStrategy)(item?.[property], value, strategy);
9
+ return {
10
+ any: {
11
+ enter: (node, ctx) => {
12
+ (0, filter_helper_1.filter)(node, ctx, filterInCriteria);
13
+ },
14
+ },
15
+ };
16
+ };
17
+ exports.FilterIn = FilterIn;