@skmtc/core 0.38.0 → 0.40.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (343) hide show
  1. package/esm/context/CoreContext.js +22 -8
  2. package/esm/context/GenerateContext.d.ts +5 -4
  3. package/esm/context/GenerateContext.js +110 -37
  4. package/esm/context/ParseContext.d.ts +9 -1
  5. package/esm/context/ParseContext.js +12 -1
  6. package/esm/context/generateTypes.d.ts +19 -4
  7. package/esm/context/generateTypes.js +2 -0
  8. package/esm/context/toGenerationFailure.d.ts +21 -0
  9. package/esm/context/toGenerationFailure.js +38 -0
  10. package/esm/dsl/CustomValue.d.ts +4 -0
  11. package/esm/dsl/CustomValue.js +8 -0
  12. package/esm/dsl/Definition.d.ts +10 -0
  13. package/esm/dsl/Definition.js +14 -0
  14. package/esm/dsl/PendingDefinition.d.ts +47 -0
  15. package/esm/dsl/PendingDefinition.js +83 -0
  16. package/esm/dsl/model/ModelDriver.d.ts +55 -1
  17. package/esm/dsl/model/ModelDriver.js +228 -51
  18. package/esm/dsl/model/toModelEntry.d.ts +1 -1
  19. package/esm/dsl/model/toModelEntry.js +1 -1
  20. package/esm/dsl/model/types.d.ts +1 -1
  21. package/esm/dsl/operation/gql/GqlOperationDriver.js +1 -4
  22. package/esm/dsl/webhook/WebhookDriver.js +1 -4
  23. package/esm/enrichments/parseEnrichmentUmbrella.d.ts +5 -6
  24. package/esm/enrichments/parseEnrichmentUmbrella.js +23 -8
  25. package/esm/enrichments/parseEnrichmentValue.d.ts +17 -0
  26. package/esm/enrichments/parseEnrichmentValue.js +32 -0
  27. package/esm/enrichments/readEnrichments.d.ts +5 -5
  28. package/esm/enrichments/readEnrichments.js +17 -7
  29. package/esm/mod.d.ts +1 -0
  30. package/esm/mod.js +1 -0
  31. package/esm/oas/array/Array.d.ts +19 -0
  32. package/esm/oas/array/Array.js +47 -0
  33. package/esm/oas/boolean/Boolean.d.ts +19 -0
  34. package/esm/oas/boolean/Boolean.js +51 -8
  35. package/esm/oas/example/Example.d.ts +4 -0
  36. package/esm/oas/example/Example.js +8 -0
  37. package/esm/oas/header/Header.d.ts +4 -0
  38. package/esm/oas/header/Header.js +8 -0
  39. package/esm/oas/integer/Integer.d.ts +19 -0
  40. package/esm/oas/integer/Integer.js +49 -0
  41. package/esm/oas/link/Link.d.ts +4 -0
  42. package/esm/oas/link/Link.js +8 -0
  43. package/esm/oas/number/Number.d.ts +19 -0
  44. package/esm/oas/number/Number.js +49 -0
  45. package/esm/oas/object/Object.d.ts +19 -0
  46. package/esm/oas/object/Object.js +68 -18
  47. package/esm/oas/operation/Operation.d.ts +5 -1
  48. package/esm/oas/operation/Operation.js +17 -5
  49. package/esm/oas/operation/toEffectiveParameters.d.ts +16 -0
  50. package/esm/oas/operation/toEffectiveParameters.js +13 -0
  51. package/esm/oas/parameter/Parameter.d.ts +4 -0
  52. package/esm/oas/parameter/Parameter.js +8 -0
  53. package/esm/oas/ref/Ref.d.ts +147 -25
  54. package/esm/oas/ref/Ref.js +387 -25
  55. package/esm/oas/requestBody/RequestBody.d.ts +4 -0
  56. package/esm/oas/requestBody/RequestBody.js +8 -0
  57. package/esm/oas/response/Response.d.ts +4 -0
  58. package/esm/oas/response/Response.js +8 -0
  59. package/esm/oas/schema/siblings.d.ts +127 -0
  60. package/esm/oas/schema/siblings.js +240 -0
  61. package/esm/oas/securitySchemes/SecurityScheme.d.ts +16 -0
  62. package/esm/oas/securitySchemes/SecurityScheme.js +32 -0
  63. package/esm/oas/string/String.d.ts +19 -0
  64. package/esm/oas/string/String.js +47 -0
  65. package/esm/oas/union/Union.d.ts +31 -0
  66. package/esm/oas/union/Union.js +100 -0
  67. package/esm/oas/unknown/Unknown.d.ts +18 -0
  68. package/esm/oas/unknown/Unknown.js +38 -0
  69. package/esm/oas/void/Void.d.ts +4 -0
  70. package/esm/oas/void/Void.js +8 -0
  71. package/esm/oas/webhook/Webhook.d.ts +2 -2
  72. package/esm/oas/webhook/Webhook.js +6 -5
  73. package/esm/parse/allOfSystem.d.ts +32 -0
  74. package/esm/parse/allOfSystem.js +30 -0
  75. package/esm/parse/anyOfSystem.d.ts +68 -0
  76. package/esm/parse/anyOfSystem.js +107 -0
  77. package/esm/parse/toSiblingKeywords.d.ts +28 -0
  78. package/esm/parse/toSiblingKeywords.js +109 -0
  79. package/esm/parse/v3-0/_merge-all-of/decompose-union.d.ts +8 -0
  80. package/esm/parse/v3-0/_merge-all-of/decompose-union.js +9 -1
  81. package/esm/parse/v3-0/_merge-all-of/generic-merge.d.ts +2 -3
  82. package/esm/parse/v3-0/_merge-all-of/generic-merge.js +2 -2
  83. package/esm/parse/v3-0/_merge-all-of/merge-array-constraints.d.ts +2 -2
  84. package/esm/parse/v3-0/_merge-all-of/merge-array-constraints.js +5 -5
  85. package/esm/parse/v3-0/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  86. package/esm/parse/v3-0/_merge-all-of/merge-boolean-constraints.js +2 -2
  87. package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  88. package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -2
  89. package/esm/parse/v3-0/_merge-all-of/merge-intersection.d.ts +3 -2
  90. package/esm/parse/v3-0/_merge-all-of/merge-intersection.js +2 -2
  91. package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.d.ts +2 -2
  92. package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -2
  93. package/esm/parse/v3-0/_merge-all-of/merge-object-constraints.d.ts +2 -2
  94. package/esm/parse/v3-0/_merge-all-of/merge-object-constraints.js +3 -3
  95. package/esm/parse/v3-0/_merge-all-of/merge-properties.d.ts +2 -2
  96. package/esm/parse/v3-0/_merge-all-of/merge-properties.js +2 -2
  97. package/esm/parse/v3-0/_merge-all-of/merge-string-constraints.d.ts +2 -2
  98. package/esm/parse/v3-0/_merge-all-of/merge-string-constraints.js +3 -3
  99. package/esm/parse/v3-0/_merge-all-of/merge-union.d.ts +10 -3
  100. package/esm/parse/v3-0/_merge-all-of/merge-union.js +50 -12
  101. package/esm/parse/v3-0/_merge-all-of/merge.d.ts +2 -2
  102. package/esm/parse/v3-0/_merge-all-of/merge.js +78 -27
  103. package/esm/parse/v3-0/_merge-all-of/nullable-merge.d.ts +4 -0
  104. package/esm/parse/v3-0/_merge-all-of/nullable-merge.js +9 -7
  105. package/esm/parse/v3-0/_merge-all-of/types.d.ts +33 -0
  106. package/esm/parse/v3-0/ref/toRefV31.d.ts +7 -1
  107. package/esm/parse/v3-0/ref/toRefV31.js +2 -2
  108. package/esm/parse/v3-0/schema/toSchemasV3.js +107 -15
  109. package/esm/parse/v3-1/_merge-all-of/decompose-union.d.ts +7 -1
  110. package/esm/parse/v3-1/_merge-all-of/decompose-union.js +8 -2
  111. package/esm/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -3
  112. package/esm/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
  113. package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +3 -2
  114. package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.js +5 -5
  115. package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  116. package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
  117. package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  118. package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
  119. package/esm/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
  120. package/esm/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
  121. package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
  122. package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
  123. package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
  124. package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
  125. package/esm/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
  126. package/esm/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
  127. package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
  128. package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
  129. package/esm/parse/v3-1/_merge-all-of/merge-union.d.ts +10 -3
  130. package/esm/parse/v3-1/_merge-all-of/merge-union.js +54 -15
  131. package/esm/parse/v3-1/_merge-all-of/merge.d.ts +3 -2
  132. package/esm/parse/v3-1/_merge-all-of/merge.js +88 -29
  133. package/esm/parse/v3-1/_merge-all-of/nullable-merge.d.ts +4 -0
  134. package/esm/parse/v3-1/_merge-all-of/nullable-merge.js +9 -7
  135. package/esm/parse/v3-1/_merge-all-of/types.d.ts +37 -0
  136. package/esm/parse/v3-1/ref/toRefV31.d.ts +7 -1
  137. package/esm/parse/v3-1/ref/toRefV31.js +2 -2
  138. package/esm/parse/v3-1/schema/toSchemasV3.js +111 -16
  139. package/esm/parse/v3-2/_merge-all-of/decompose-union.d.ts +7 -1
  140. package/esm/parse/v3-2/_merge-all-of/decompose-union.js +8 -2
  141. package/esm/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -3
  142. package/esm/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
  143. package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +3 -2
  144. package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.js +5 -5
  145. package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  146. package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
  147. package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  148. package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
  149. package/esm/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
  150. package/esm/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
  151. package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
  152. package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
  153. package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
  154. package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
  155. package/esm/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
  156. package/esm/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
  157. package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
  158. package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
  159. package/esm/parse/v3-2/_merge-all-of/merge-union.d.ts +10 -3
  160. package/esm/parse/v3-2/_merge-all-of/merge-union.js +54 -15
  161. package/esm/parse/v3-2/_merge-all-of/merge.d.ts +3 -2
  162. package/esm/parse/v3-2/_merge-all-of/merge.js +88 -29
  163. package/esm/parse/v3-2/_merge-all-of/nullable-merge.d.ts +4 -0
  164. package/esm/parse/v3-2/_merge-all-of/nullable-merge.js +9 -7
  165. package/esm/parse/v3-2/_merge-all-of/types.d.ts +37 -0
  166. package/esm/parse/v3-2/ref/toRefV31.d.ts +7 -1
  167. package/esm/parse/v3-2/ref/toRefV31.js +2 -2
  168. package/esm/parse/v3-2/schema/toSchemasV3.js +111 -16
  169. package/esm/types/OasBase.d.ts +1 -1
  170. package/esm/types/Settings.d.ts +34 -0
  171. package/esm/types/Settings.js +8 -0
  172. package/package.json +1 -1
  173. package/script/context/CoreContext.js +22 -8
  174. package/script/context/GenerateContext.d.ts +5 -4
  175. package/script/context/GenerateContext.js +110 -37
  176. package/script/context/ParseContext.d.ts +9 -1
  177. package/script/context/ParseContext.js +12 -1
  178. package/script/context/generateTypes.d.ts +19 -4
  179. package/script/context/generateTypes.js +2 -0
  180. package/script/context/toGenerationFailure.d.ts +21 -0
  181. package/script/context/toGenerationFailure.js +43 -0
  182. package/script/dsl/CustomValue.d.ts +4 -0
  183. package/script/dsl/CustomValue.js +8 -0
  184. package/script/dsl/Definition.d.ts +10 -0
  185. package/script/dsl/Definition.js +14 -0
  186. package/script/dsl/PendingDefinition.d.ts +47 -0
  187. package/script/dsl/PendingDefinition.js +87 -0
  188. package/script/dsl/model/ModelDriver.d.ts +55 -1
  189. package/script/dsl/model/ModelDriver.js +231 -52
  190. package/script/dsl/model/toModelEntry.d.ts +1 -1
  191. package/script/dsl/model/toModelEntry.js +1 -1
  192. package/script/dsl/model/types.d.ts +1 -1
  193. package/script/dsl/operation/gql/GqlOperationDriver.js +1 -4
  194. package/script/dsl/webhook/WebhookDriver.js +1 -4
  195. package/script/enrichments/parseEnrichmentUmbrella.d.ts +5 -6
  196. package/script/enrichments/parseEnrichmentUmbrella.js +23 -41
  197. package/script/enrichments/parseEnrichmentValue.d.ts +17 -0
  198. package/script/enrichments/parseEnrichmentValue.js +69 -0
  199. package/script/enrichments/readEnrichments.d.ts +5 -5
  200. package/script/enrichments/readEnrichments.js +17 -40
  201. package/script/mod.d.ts +1 -0
  202. package/script/mod.js +1 -0
  203. package/script/oas/array/Array.d.ts +19 -0
  204. package/script/oas/array/Array.js +47 -0
  205. package/script/oas/boolean/Boolean.d.ts +19 -0
  206. package/script/oas/boolean/Boolean.js +51 -8
  207. package/script/oas/example/Example.d.ts +4 -0
  208. package/script/oas/example/Example.js +8 -0
  209. package/script/oas/header/Header.d.ts +4 -0
  210. package/script/oas/header/Header.js +8 -0
  211. package/script/oas/integer/Integer.d.ts +19 -0
  212. package/script/oas/integer/Integer.js +49 -0
  213. package/script/oas/link/Link.d.ts +4 -0
  214. package/script/oas/link/Link.js +8 -0
  215. package/script/oas/number/Number.d.ts +19 -0
  216. package/script/oas/number/Number.js +49 -0
  217. package/script/oas/object/Object.d.ts +19 -0
  218. package/script/oas/object/Object.js +68 -18
  219. package/script/oas/operation/Operation.d.ts +5 -1
  220. package/script/oas/operation/Operation.js +17 -5
  221. package/script/oas/operation/toEffectiveParameters.d.ts +16 -0
  222. package/script/oas/operation/toEffectiveParameters.js +17 -0
  223. package/script/oas/parameter/Parameter.d.ts +4 -0
  224. package/script/oas/parameter/Parameter.js +8 -0
  225. package/script/oas/ref/Ref.d.ts +147 -25
  226. package/script/oas/ref/Ref.js +387 -25
  227. package/script/oas/requestBody/RequestBody.d.ts +4 -0
  228. package/script/oas/requestBody/RequestBody.js +8 -0
  229. package/script/oas/response/Response.d.ts +4 -0
  230. package/script/oas/response/Response.js +8 -0
  231. package/script/oas/schema/siblings.d.ts +127 -0
  232. package/script/oas/schema/siblings.js +295 -0
  233. package/script/oas/securitySchemes/SecurityScheme.d.ts +16 -0
  234. package/script/oas/securitySchemes/SecurityScheme.js +32 -0
  235. package/script/oas/string/String.d.ts +19 -0
  236. package/script/oas/string/String.js +47 -0
  237. package/script/oas/union/Union.d.ts +31 -0
  238. package/script/oas/union/Union.js +100 -0
  239. package/script/oas/unknown/Unknown.d.ts +18 -0
  240. package/script/oas/unknown/Unknown.js +38 -0
  241. package/script/oas/void/Void.d.ts +4 -0
  242. package/script/oas/void/Void.js +8 -0
  243. package/script/oas/webhook/Webhook.d.ts +2 -2
  244. package/script/oas/webhook/Webhook.js +6 -5
  245. package/script/parse/allOfSystem.d.ts +32 -0
  246. package/script/parse/allOfSystem.js +35 -0
  247. package/script/parse/anyOfSystem.d.ts +68 -0
  248. package/script/parse/anyOfSystem.js +116 -0
  249. package/script/parse/toSiblingKeywords.d.ts +28 -0
  250. package/script/parse/toSiblingKeywords.js +146 -0
  251. package/script/parse/v3-0/_merge-all-of/decompose-union.d.ts +8 -0
  252. package/script/parse/v3-0/_merge-all-of/decompose-union.js +11 -2
  253. package/script/parse/v3-0/_merge-all-of/generic-merge.d.ts +2 -3
  254. package/script/parse/v3-0/_merge-all-of/generic-merge.js +2 -2
  255. package/script/parse/v3-0/_merge-all-of/merge-array-constraints.d.ts +2 -2
  256. package/script/parse/v3-0/_merge-all-of/merge-array-constraints.js +5 -5
  257. package/script/parse/v3-0/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  258. package/script/parse/v3-0/_merge-all-of/merge-boolean-constraints.js +2 -2
  259. package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  260. package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -2
  261. package/script/parse/v3-0/_merge-all-of/merge-intersection.d.ts +3 -2
  262. package/script/parse/v3-0/_merge-all-of/merge-intersection.js +2 -2
  263. package/script/parse/v3-0/_merge-all-of/merge-number-constraints.d.ts +2 -2
  264. package/script/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -2
  265. package/script/parse/v3-0/_merge-all-of/merge-object-constraints.d.ts +2 -2
  266. package/script/parse/v3-0/_merge-all-of/merge-object-constraints.js +3 -3
  267. package/script/parse/v3-0/_merge-all-of/merge-properties.d.ts +2 -2
  268. package/script/parse/v3-0/_merge-all-of/merge-properties.js +2 -2
  269. package/script/parse/v3-0/_merge-all-of/merge-string-constraints.d.ts +2 -2
  270. package/script/parse/v3-0/_merge-all-of/merge-string-constraints.js +3 -3
  271. package/script/parse/v3-0/_merge-all-of/merge-union.d.ts +10 -3
  272. package/script/parse/v3-0/_merge-all-of/merge-union.js +52 -13
  273. package/script/parse/v3-0/_merge-all-of/merge.d.ts +2 -2
  274. package/script/parse/v3-0/_merge-all-of/merge.js +77 -26
  275. package/script/parse/v3-0/_merge-all-of/nullable-merge.d.ts +4 -0
  276. package/script/parse/v3-0/_merge-all-of/nullable-merge.js +9 -7
  277. package/script/parse/v3-0/_merge-all-of/types.d.ts +33 -0
  278. package/script/parse/v3-0/ref/toRefV31.d.ts +7 -1
  279. package/script/parse/v3-0/ref/toRefV31.js +2 -2
  280. package/script/parse/v3-0/schema/toSchemasV3.js +107 -15
  281. package/script/parse/v3-1/_merge-all-of/decompose-union.d.ts +7 -1
  282. package/script/parse/v3-1/_merge-all-of/decompose-union.js +8 -2
  283. package/script/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -3
  284. package/script/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
  285. package/script/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +3 -2
  286. package/script/parse/v3-1/_merge-all-of/merge-array-constraints.js +5 -5
  287. package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  288. package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
  289. package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  290. package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
  291. package/script/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
  292. package/script/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
  293. package/script/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
  294. package/script/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
  295. package/script/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
  296. package/script/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
  297. package/script/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
  298. package/script/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
  299. package/script/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
  300. package/script/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
  301. package/script/parse/v3-1/_merge-all-of/merge-union.d.ts +10 -3
  302. package/script/parse/v3-1/_merge-all-of/merge-union.js +56 -16
  303. package/script/parse/v3-1/_merge-all-of/merge.d.ts +3 -2
  304. package/script/parse/v3-1/_merge-all-of/merge.js +87 -28
  305. package/script/parse/v3-1/_merge-all-of/nullable-merge.d.ts +4 -0
  306. package/script/parse/v3-1/_merge-all-of/nullable-merge.js +9 -7
  307. package/script/parse/v3-1/_merge-all-of/types.d.ts +37 -0
  308. package/script/parse/v3-1/ref/toRefV31.d.ts +7 -1
  309. package/script/parse/v3-1/ref/toRefV31.js +2 -2
  310. package/script/parse/v3-1/schema/toSchemasV3.js +111 -16
  311. package/script/parse/v3-2/_merge-all-of/decompose-union.d.ts +7 -1
  312. package/script/parse/v3-2/_merge-all-of/decompose-union.js +8 -2
  313. package/script/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -3
  314. package/script/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
  315. package/script/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +3 -2
  316. package/script/parse/v3-2/_merge-all-of/merge-array-constraints.js +5 -5
  317. package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  318. package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
  319. package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  320. package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
  321. package/script/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
  322. package/script/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
  323. package/script/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
  324. package/script/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
  325. package/script/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
  326. package/script/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
  327. package/script/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
  328. package/script/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
  329. package/script/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
  330. package/script/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
  331. package/script/parse/v3-2/_merge-all-of/merge-union.d.ts +10 -3
  332. package/script/parse/v3-2/_merge-all-of/merge-union.js +56 -16
  333. package/script/parse/v3-2/_merge-all-of/merge.d.ts +3 -2
  334. package/script/parse/v3-2/_merge-all-of/merge.js +87 -28
  335. package/script/parse/v3-2/_merge-all-of/nullable-merge.d.ts +4 -0
  336. package/script/parse/v3-2/_merge-all-of/nullable-merge.js +9 -7
  337. package/script/parse/v3-2/_merge-all-of/types.d.ts +37 -0
  338. package/script/parse/v3-2/ref/toRefV31.d.ts +7 -1
  339. package/script/parse/v3-2/ref/toRefV31.js +2 -2
  340. package/script/parse/v3-2/schema/toSchemasV3.js +111 -16
  341. package/script/types/OasBase.d.ts +1 -1
  342. package/script/types/Settings.d.ts +34 -0
  343. package/script/types/Settings.js +9 -1
@@ -0,0 +1,240 @@
1
+ import * as v from 'valibot';
2
+ import isEqual from 'lodash-es/isEqual.js';
3
+ import { numberFormat } from '../number/number-types.js';
4
+ import { integerFormat } from '../integer/integer-types.js';
5
+ /**
6
+ * The use-site flags, taken by every type, so they are never reported as
7
+ * left out. A union's or unknown's copy has no `readOnly` or `writeOnly`
8
+ * field, but the reference still answers `isReadOnly()` and
9
+ * `isWriteOnly()` from its own flag.
10
+ */
11
+ const FLAGS = ['nullable', 'readOnly', 'writeOnly'];
12
+ const DESCRIBING = [...FLAGS, 'title', 'description', 'extensionFields', 'example'];
13
+ const NUMERIC = [
14
+ 'deprecated',
15
+ 'default',
16
+ 'enums',
17
+ 'format',
18
+ 'multipleOf',
19
+ 'minimum',
20
+ 'maximum',
21
+ 'exclusiveMinimum',
22
+ 'exclusiveMaximum'
23
+ ];
24
+ /** The keywords each schema class's `clone` takes: the fields its type has. */
25
+ export const SIBLINGS_BY_TYPE = {
26
+ string: [...DESCRIBING, 'deprecated', 'default', 'enums', 'format', 'minLength', 'maxLength', 'pattern'],
27
+ number: [...DESCRIBING, ...NUMERIC],
28
+ integer: [...DESCRIBING, ...NUMERIC],
29
+ boolean: [...DESCRIBING, 'deprecated', 'default', 'enums'],
30
+ array: [...DESCRIBING, 'deprecated', 'default', 'enums', 'minItems', 'maxItems', 'uniqueItems'],
31
+ object: [
32
+ ...DESCRIBING,
33
+ 'deprecated',
34
+ 'default',
35
+ 'enums',
36
+ 'properties',
37
+ 'required',
38
+ 'additionalProperties',
39
+ 'minProperties',
40
+ 'maxProperties'
41
+ ],
42
+ union: [...DESCRIBING, 'default'],
43
+ unknown: DESCRIBING
44
+ };
45
+ /** Every keyword `clone` can apply, for any type. */
46
+ const SIBLING_KEYWORDS = [...new Set(Object.values(SIBLINGS_BY_TYPE).flat())];
47
+ /**
48
+ * The keywords of `over` merged over those of `base`, for a reference copied
49
+ * with what another site adds (`OasRef.clone`): a flag set on either stays
50
+ * set, a keyword `over` sets wins, extension fields and `properties` merge,
51
+ * and `required` names add up, as each schema class's `clone` merges them
52
+ * into a schema.
53
+ */
54
+ export const mergeSiblingKeywords = (base, over) => ({
55
+ nullable: base.nullable || over?.nullable || undefined,
56
+ readOnly: base.readOnly || over?.readOnly || undefined,
57
+ writeOnly: base.writeOnly || over?.writeOnly || undefined,
58
+ _type: over?._type ?? base._type,
59
+ title: over?.title ?? base.title,
60
+ description: over?.description ?? base.description,
61
+ deprecated: over?.deprecated ?? base.deprecated,
62
+ example: over?.example ?? base.example,
63
+ default: over?.default ?? base.default,
64
+ enums: over?.enums ?? base.enums,
65
+ extensionFields: base.extensionFields === undefined && over?.extensionFields === undefined
66
+ ? undefined
67
+ : { ...base.extensionFields, ...over?.extensionFields },
68
+ format: over?.format ?? base.format,
69
+ minLength: over?.minLength ?? base.minLength,
70
+ maxLength: over?.maxLength ?? base.maxLength,
71
+ pattern: over?.pattern ?? base.pattern,
72
+ multipleOf: over?.multipleOf ?? base.multipleOf,
73
+ minimum: over?.minimum ?? base.minimum,
74
+ maximum: over?.maximum ?? base.maximum,
75
+ exclusiveMinimum: over?.exclusiveMinimum ?? base.exclusiveMinimum,
76
+ exclusiveMaximum: over?.exclusiveMaximum ?? base.exclusiveMaximum,
77
+ minItems: over?.minItems ?? base.minItems,
78
+ maxItems: over?.maxItems ?? base.maxItems,
79
+ uniqueItems: over?.uniqueItems ?? base.uniqueItems,
80
+ properties: over?.properties === undefined ? base.properties : { ...base.properties, ...over.properties },
81
+ required: over?.required === undefined ? base.required : [...new Set([...(base.required ?? []), ...over.required])],
82
+ additionalProperties: over?.additionalProperties ?? base.additionalProperties,
83
+ minProperties: over?.minProperties ?? base.minProperties,
84
+ maxProperties: over?.maxProperties ?? base.maxProperties
85
+ });
86
+ /** Whether `siblings` holds any keyword. */
87
+ export const hasSiblingKeywords = (siblings) => siblings._type !== undefined || SIBLING_KEYWORDS.some(keyword => siblings[keyword] !== undefined);
88
+ /** The keywords that change which values a site accepts, not only how it is described. */
89
+ const VALUE_KEYWORDS = [
90
+ 'enums',
91
+ 'format',
92
+ 'minLength',
93
+ 'maxLength',
94
+ 'pattern',
95
+ 'multipleOf',
96
+ 'minimum',
97
+ 'maximum',
98
+ 'exclusiveMinimum',
99
+ 'exclusiveMaximum',
100
+ 'minItems',
101
+ 'maxItems',
102
+ 'uniqueItems',
103
+ 'properties',
104
+ 'required',
105
+ 'additionalProperties',
106
+ 'minProperties',
107
+ 'maxProperties'
108
+ ];
109
+ /** Keywords that `clone` merges with `||`: `false` and absent mean the same. */
110
+ const BOOLEAN_KEYWORDS = [
111
+ 'nullable',
112
+ 'readOnly',
113
+ 'writeOnly',
114
+ 'deprecated',
115
+ 'exclusiveMinimum',
116
+ 'exclusiveMaximum',
117
+ 'uniqueItems'
118
+ ];
119
+ /**
120
+ * The keywords next to a reference that make `copy` (the target with them
121
+ * applied) differ from `target`. A keyword the target's type does not take,
122
+ * a flag the target already has, and a value equal to the target's change
123
+ * nothing.
124
+ */
125
+ const toChangedKeywords = (copy, target, siblings) => SIBLINGS_BY_TYPE[target.type].filter(keyword => {
126
+ if (siblings[keyword] === undefined) {
127
+ return false;
128
+ }
129
+ const applied = Reflect.get(copy, keyword);
130
+ const original = Reflect.get(target, keyword);
131
+ return BOOLEAN_KEYWORDS.includes(keyword) ? (applied === true) !== (original === true) : !isEqual(applied, original);
132
+ });
133
+ /** Whether the keywords next to a reference change `target` at that site. The engine behind `OasRef.resolve`. */
134
+ export const changesTarget = (copy, target, siblings) => toChangedKeywords(copy, target, siblings).length > 0;
135
+ /**
136
+ * Whether the keywords next to a reference change which values `target`
137
+ * accepts at that site (`minLength` next to a string, `properties` next to an
138
+ * object), not only how it is described (`description`, `deprecated`,
139
+ * `default`, `x-*`). The engine behind `OasRef.hasValueSiblings`.
140
+ */
141
+ export const changesValues = (copy, target, siblings) => toChangedKeywords(copy, target, siblings).some(keyword => VALUE_KEYWORDS.includes(keyword));
142
+ /**
143
+ * The keywords next to a reference that `clone` leaves out for `target`, by
144
+ * their names in the document: one its type does not have (`minLength` next
145
+ * to an array), a `type` that disagrees with the target's, and an `example`,
146
+ * `default`, `enum` or `format` whose value does not fit. `nullable` says
147
+ * whether the site takes `null` among the `enum` members. The engine behind
148
+ * `OasRef.toSkippedSiblings`.
149
+ */
150
+ export const toSkippedSiblings = (target, siblings, nullable) => {
151
+ const taken = SIBLINGS_BY_TYPE[target.type];
152
+ const fits = VALUE_CHECKS[target.type];
153
+ const isSkipped = (keyword, value) => {
154
+ if (value === undefined) {
155
+ return false;
156
+ }
157
+ if (!taken.includes(keyword)) {
158
+ return true;
159
+ }
160
+ switch (keyword) {
161
+ case 'example':
162
+ case 'default':
163
+ return !fits(value);
164
+ case 'enums':
165
+ return !Array.isArray(value) || !value.every(item => fits(item) || (nullable === true && item === null));
166
+ case 'format':
167
+ return !fitsFormat(target.type, value);
168
+ default:
169
+ return false;
170
+ }
171
+ };
172
+ const type = siblings._type !== undefined && !agrees(siblings._type, target, 0) ? ['type'] : [];
173
+ const others = SIBLING_KEYWORDS.filter(keyword => isSkipped(keyword, siblings[keyword])).map(toDocumentKeyword);
174
+ return [...type, ...others];
175
+ };
176
+ /** How deep {@link agrees} follows union members, so a union that contains itself ends. */
177
+ const MAX_DEPTH = 10;
178
+ /**
179
+ * A `type` next to a reference agrees with the target's when it names it, or
180
+ * `number` for an integer. Next to a union, it agrees when every member,
181
+ * followed through references, has that type (`type: object` next to a
182
+ * `oneOf` of objects): leaving it out then loses nothing.
183
+ */
184
+ const agrees = (type, target, depth) => {
185
+ if (target.type === 'union') {
186
+ return depth < MAX_DEPTH &&
187
+ target.members.every(member => agrees(type, member.isRef() ? member.resolve() : member, depth + 1));
188
+ }
189
+ return type === target.type || (type === 'number' && target.type === 'integer');
190
+ };
191
+ /** Whether `format` fits a schema of `type`, as `clone` reads it: any string for a string. */
192
+ const fitsFormat = (type, format) => {
193
+ switch (type) {
194
+ case 'number':
195
+ return isNumberFormat(format);
196
+ case 'integer':
197
+ return isIntegerFormat(format);
198
+ default:
199
+ return isStringValue(format);
200
+ }
201
+ };
202
+ /** The document's name for a keyword: `enum` for `enums`. */
203
+ const toDocumentKeyword = (keyword) => (keyword === 'enums' ? 'enum' : keyword);
204
+ /** The annotations of `target` with those of `siblings` applied: a sibling's value wins, and extension fields merge. */
205
+ export const toSiblingAnnotations = (target, siblings) => ({
206
+ title: siblings?.title ?? target.title,
207
+ description: siblings?.description ?? target.description,
208
+ extensionFields: target.extensionFields === undefined && siblings?.extensionFields === undefined
209
+ ? undefined
210
+ : { ...target.extensionFields, ...siblings?.extensionFields }
211
+ });
212
+ /** The value checks the parser makes for `example`, `default` and each `enum` member, by type. */
213
+ export const isStringValue = (value) => typeof value === 'string';
214
+ export const isNumberValue = (value) => typeof value === 'number';
215
+ export const isIntegerValue = (value) => Number.isInteger(value);
216
+ export const isBooleanValue = (value) => typeof value === 'boolean';
217
+ export const isArrayValue = (value) => Array.isArray(value);
218
+ export const isObjectValue = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
219
+ const isAnyValue = (_value) => true;
220
+ /** {@link isStringValue} and the others, keyed by the type they check for. A union or unknown takes any value. */
221
+ export const VALUE_CHECKS = {
222
+ string: isStringValue,
223
+ number: isNumberValue,
224
+ integer: isIntegerValue,
225
+ boolean: isBooleanValue,
226
+ array: isArrayValue,
227
+ object: isObjectValue,
228
+ union: isAnyValue,
229
+ unknown: isAnyValue
230
+ };
231
+ /** The formats a number and an integer take. A string takes any format. */
232
+ export const isNumberFormat = (value) => v.is(numberFormat, value);
233
+ export const isIntegerFormat = (value) => v.is(integerFormat, value);
234
+ /** `value` when it passes `check`, else `undefined`: for `example`, `default` and `format`. */
235
+ export const toSiblingValue = (value, check) => check(value) ? value : undefined;
236
+ /**
237
+ * `enums` when every member passes `check`, or is `null` at a nullable site,
238
+ * else `undefined`. The parser reports the members that do not.
239
+ */
240
+ export const toSiblingEnums = (enums, check, nullable) => enums?.every((item) => check(item) || (nullable === true && item === null)) ? enums : undefined;
@@ -73,6 +73,10 @@ export declare class OasHttpSecurityScheme {
73
73
  bearerFormat: string | undefined;
74
74
  constructor(fields: HttpSecuritySchemeFields);
75
75
  isRef(): this is OasRef<'securityScheme'>;
76
+ /** Always `false`: `readOnly` is a schema keyword. */
77
+ isReadOnly(): boolean;
78
+ /** Always `false`: `writeOnly` is a schema keyword. */
79
+ isWriteOnly(): boolean;
76
80
  resolve(): OasHttpSecurityScheme;
77
81
  resolveOnce(): OasHttpSecurityScheme;
78
82
  toJsonSchema(): HttpSecuritySchemeJson;
@@ -86,6 +90,10 @@ export declare class OasApiKeySecurityScheme {
86
90
  location: 'query' | 'header' | 'cookie';
87
91
  constructor(fields: ApiKeySecuritySchemeFields);
88
92
  isRef(): this is OasRef<'securityScheme'>;
93
+ /** Always `false`: `readOnly` is a schema keyword. */
94
+ isReadOnly(): boolean;
95
+ /** Always `false`: `writeOnly` is a schema keyword. */
96
+ isWriteOnly(): boolean;
89
97
  resolve(): OasApiKeySecurityScheme;
90
98
  resolveOnce(): OasApiKeySecurityScheme;
91
99
  toJsonSchema(): ApiKeySecuritySchemeJson;
@@ -136,6 +144,10 @@ export declare class OasOAuth2SecurityScheme {
136
144
  };
137
145
  constructor(fields: OAuth2SecuritySchemeFields);
138
146
  isRef(): this is OasRef<'securityScheme'>;
147
+ /** Always `false`: `readOnly` is a schema keyword. */
148
+ isReadOnly(): boolean;
149
+ /** Always `false`: `writeOnly` is a schema keyword. */
150
+ isWriteOnly(): boolean;
139
151
  resolve(): OasOAuth2SecurityScheme;
140
152
  resolveOnce(): OasOAuth2SecurityScheme;
141
153
  toJsonSchema(): OAuth2SecuritySchemeJson;
@@ -148,6 +160,10 @@ export declare class OasOpenIdSecurityScheme {
148
160
  openIdConnectUrl: string;
149
161
  constructor(fields: OpenIdSecuritySchemeFields);
150
162
  isRef(): this is OasRef<'securityScheme'>;
163
+ /** Always `false`: `readOnly` is a schema keyword. */
164
+ isReadOnly(): boolean;
165
+ /** Always `false`: `writeOnly` is a schema keyword. */
166
+ isWriteOnly(): boolean;
151
167
  resolve(): OasOpenIdSecurityScheme;
152
168
  resolveOnce(): OasOpenIdSecurityScheme;
153
169
  toJsonSchema(): OpenIdSecuritySchemeJson;
@@ -44,6 +44,14 @@ export class OasHttpSecurityScheme {
44
44
  isRef() {
45
45
  return false;
46
46
  }
47
+ /** Always `false`: `readOnly` is a schema keyword. */
48
+ isReadOnly() {
49
+ return false;
50
+ }
51
+ /** Always `false`: `writeOnly` is a schema keyword. */
52
+ isWriteOnly() {
53
+ return false;
54
+ }
47
55
  resolve() {
48
56
  return this;
49
57
  }
@@ -106,6 +114,14 @@ export class OasApiKeySecurityScheme {
106
114
  isRef() {
107
115
  return false;
108
116
  }
117
+ /** Always `false`: `readOnly` is a schema keyword. */
118
+ isReadOnly() {
119
+ return false;
120
+ }
121
+ /** Always `false`: `writeOnly` is a schema keyword. */
122
+ isWriteOnly() {
123
+ return false;
124
+ }
109
125
  resolve() {
110
126
  return this;
111
127
  }
@@ -167,6 +183,14 @@ export class OasOAuth2SecurityScheme {
167
183
  isRef() {
168
184
  return false;
169
185
  }
186
+ /** Always `false`: `readOnly` is a schema keyword. */
187
+ isReadOnly() {
188
+ return false;
189
+ }
190
+ /** Always `false`: `writeOnly` is a schema keyword. */
191
+ isWriteOnly() {
192
+ return false;
193
+ }
170
194
  resolve() {
171
195
  return this;
172
196
  }
@@ -232,6 +256,14 @@ export class OasOpenIdSecurityScheme {
232
256
  isRef() {
233
257
  return false;
234
258
  }
259
+ /** Always `false`: `readOnly` is a schema keyword. */
260
+ isReadOnly() {
261
+ return false;
262
+ }
263
+ /** Always `false`: `writeOnly` is a schema keyword. */
264
+ isWriteOnly() {
265
+ return false;
266
+ }
235
267
  resolve() {
236
268
  return this;
237
269
  }
@@ -1,4 +1,5 @@
1
1
  import "../../_dnt.polyfills.js";
2
+ import type { OasUnknown } from '../unknown/Unknown.js';
2
3
  import type { SchemaPath } from '../../types/SchemaPath.js';
3
4
  import type { OasRef } from '../ref/Ref.js';
4
5
  import type { OasSchema, ToJsonSchemaOptions } from '../schema/Schema.js';
@@ -102,8 +103,26 @@ export declare class OasString<Nullable extends boolean | undefined = boolean |
102
103
  * Whether the string is deprecated.
103
104
  */
104
105
  deprecated: boolean | undefined;
106
+ /**
107
+ * The schema's `not`, kept as an `OasUnknown` under `client.json`
108
+ * `system.not: unknown`: the document says "not something", and core does
109
+ * not read what. `undefined` otherwise.
110
+ */
111
+ not: OasUnknown | undefined;
105
112
  constructor(fields?: StringFields<Nullable>, context?: ParseContextType);
106
113
  isRef(): this is OasRef<'schema'>;
114
+ /** Whether the value is `readOnly`: sent by the API only, never in a request. */
115
+ isReadOnly(): boolean;
116
+ /** Whether the value is `writeOnly`: sent in a request only, never by the API. */
117
+ isWriteOnly(): boolean;
118
+ /**
119
+ * A copy of this schema with what `ref` adds at its site applied: its
120
+ * `nullable`, `readOnly`, `writeOnly` and the keywords next to it (`SiblingKeywords`) that
121
+ * this type takes, a sibling's value winning. A value that does not fit
122
+ * this type is left out (the parser reports it). For `OasRef.resolve()`.
123
+ * This schema does not change, and the copy shares its child schemas.
124
+ */
125
+ clone(ref?: OasRef<'schema'>): OasString;
107
126
  traverse(path: SchemaPath): OasSchema | OasRef<'schema'>;
108
127
  resolve(): OasString<Nullable>;
109
128
  resolveOnce(): OasString<Nullable>;
@@ -1,5 +1,6 @@
1
1
  import "../../_dnt.polyfills.js";
2
2
  import { traverseSchema } from '../schemaPath/traverseSchema.js';
3
+ import { toSiblingAnnotations, toSiblingEnums, toSiblingValue, isStringValue } from '../schema/siblings.js';
3
4
  import { OasBase } from '../../types/OasBase.js';
4
5
  export class OasString extends OasBase {
5
6
  constructor(fields = {}, context) {
@@ -145,6 +146,17 @@ export class OasString extends OasBase {
145
146
  writable: true,
146
147
  value: void 0
147
148
  });
149
+ /**
150
+ * The schema's `not`, kept as an `OasUnknown` under `client.json`
151
+ * `system.not: unknown`: the document says "not something", and core does
152
+ * not read what. `undefined` otherwise.
153
+ */
154
+ Object.defineProperty(this, "not", {
155
+ enumerable: true,
156
+ configurable: true,
157
+ writable: true,
158
+ value: undefined
159
+ });
148
160
  this.title = fields.title;
149
161
  this.description = fields.description;
150
162
  this.format = fields.format;
@@ -163,6 +175,41 @@ export class OasString extends OasBase {
163
175
  isRef() {
164
176
  return false;
165
177
  }
178
+ /** Whether the value is `readOnly`: sent by the API only, never in a request. */
179
+ isReadOnly() {
180
+ return this.readOnly === true;
181
+ }
182
+ /** Whether the value is `writeOnly`: sent in a request only, never by the API. */
183
+ isWriteOnly() {
184
+ return this.writeOnly === true;
185
+ }
186
+ /**
187
+ * A copy of this schema with what `ref` adds at its site applied: its
188
+ * `nullable`, `readOnly`, `writeOnly` and the keywords next to it (`SiblingKeywords`) that
189
+ * this type takes, a sibling's value winning. A value that does not fit
190
+ * this type is left out (the parser reports it). For `OasRef.resolve()`.
191
+ * This schema does not change, and the copy shares its child schemas.
192
+ */
193
+ clone(ref) {
194
+ const nullable = this.nullable || ref?.nullable || undefined;
195
+ const copy = new OasString({
196
+ ...toSiblingAnnotations(this, ref),
197
+ example: toSiblingValue(ref?.example, isStringValue) ?? this.example,
198
+ format: ref?.format ?? this.format,
199
+ enums: toSiblingEnums(ref?.enums, isStringValue, nullable) ?? this.enums,
200
+ nullable,
201
+ maxLength: ref?.maxLength ?? this.maxLength,
202
+ minLength: ref?.minLength ?? this.minLength,
203
+ pattern: ref?.pattern ?? this.pattern,
204
+ default: toSiblingValue(ref?.default, isStringValue) ?? this.default,
205
+ readOnly: this.readOnly || ref?.readOnly || undefined,
206
+ writeOnly: this.writeOnly || ref?.writeOnly || undefined,
207
+ deprecated: ref?.deprecated ?? this.deprecated,
208
+ });
209
+ copy.stackTrail = this.stackTrail;
210
+ copy.not = this.not;
211
+ return copy;
212
+ }
166
213
  traverse(path) {
167
214
  return traverseSchema(this, path);
168
215
  }
@@ -1,3 +1,4 @@
1
+ import type { OasUnknown } from '../unknown/Unknown.js';
1
2
  import type { SchemaPath } from '../../types/SchemaPath.js';
2
3
  import type { OasDiscriminator } from '../discriminator/Discriminator.js';
3
4
  import type { OasExternalDocs } from '../externalDocs/ExternalDocs.js';
@@ -186,10 +187,40 @@ export declare class OasUnion extends OasBase {
186
187
  * The default value of the union type.
187
188
  */
188
189
  default?: unknown;
190
+ /**
191
+ * The schema's `not`, kept as an `OasUnknown` under `client.json`
192
+ * `system.not: unknown`: the document says "not something", and core does
193
+ * not read what. `undefined` otherwise.
194
+ */
195
+ not: OasUnknown | undefined;
189
196
  constructor(fields: UnionFields, context?: ParseContextType);
190
197
  isRef(): this is OasRef<'schema'>;
198
+ /** Always `false`: this schema has no `readOnly`. */
199
+ isReadOnly(): boolean;
200
+ /** Always `false`: this schema has no `writeOnly`. */
201
+ isWriteOnly(): boolean;
202
+ /**
203
+ * A copy of this schema with what `ref` adds at its site applied: its
204
+ * `nullable` and the keywords next to it (`SiblingKeywords`) that
205
+ * this type takes, a sibling's value winning. A value that does not fit
206
+ * this type is left out (the parser reports it). For `OasRef.resolve()`.
207
+ * This schema does not change, and the copy shares its child schemas.
208
+ */
209
+ clone(ref?: OasRef<'schema'>): OasUnion;
191
210
  traverse(path: SchemaPath): OasSchema | OasRef<'schema'>;
192
211
  resolve(): OasUnion;
193
212
  resolveOnce(): OasUnion;
213
+ /**
214
+ * Whether the discriminator alone picks the member of a value: the union
215
+ * names a discriminator, and each member, followed through references, is
216
+ * an object that is not nullable, that requires the discriminator's
217
+ * property, and that allows only string literals for it. No value may
218
+ * belong to two members. A member that is a union, or anything other than
219
+ * an object, makes it `false`.
220
+ *
221
+ * It reads the schemas only. A generator may refuse more: one that leaves
222
+ * out `readOnly` properties cannot discriminate on one.
223
+ */
224
+ isDiscriminable(): boolean;
194
225
  toJsonSchema(options: ToJsonSchemaOptions): OpenAPIV3.NonArraySchemaObject;
195
226
  }
@@ -1,4 +1,5 @@
1
1
  import { traverseSchema } from '../schemaPath/traverseSchema.js';
2
+ import { toSiblingAnnotations } from '../schema/siblings.js';
2
3
  import { OasBase } from '../../types/OasBase.js';
3
4
  /**
4
5
  * Represents a union type schema in the OpenAPI Specification.
@@ -213,6 +214,17 @@ export class OasUnion extends OasBase {
213
214
  writable: true,
214
215
  value: void 0
215
216
  });
217
+ /**
218
+ * The schema's `not`, kept as an `OasUnknown` under `client.json`
219
+ * `system.not: unknown`: the document says "not something", and core does
220
+ * not read what. `undefined` otherwise.
221
+ */
222
+ Object.defineProperty(this, "not", {
223
+ enumerable: true,
224
+ configurable: true,
225
+ writable: true,
226
+ value: undefined
227
+ });
216
228
  this.title = fields.title;
217
229
  this.description = fields.description;
218
230
  this.externalDocs = fields.externalDocs;
@@ -226,6 +238,36 @@ export class OasUnion extends OasBase {
226
238
  isRef() {
227
239
  return false;
228
240
  }
241
+ /** Always `false`: this schema has no `readOnly`. */
242
+ isReadOnly() {
243
+ return false;
244
+ }
245
+ /** Always `false`: this schema has no `writeOnly`. */
246
+ isWriteOnly() {
247
+ return false;
248
+ }
249
+ /**
250
+ * A copy of this schema with what `ref` adds at its site applied: its
251
+ * `nullable` and the keywords next to it (`SiblingKeywords`) that
252
+ * this type takes, a sibling's value winning. A value that does not fit
253
+ * this type is left out (the parser reports it). For `OasRef.resolve()`.
254
+ * This schema does not change, and the copy shares its child schemas.
255
+ */
256
+ clone(ref) {
257
+ const nullable = this.nullable || ref?.nullable || undefined;
258
+ const copy = new OasUnion({
259
+ ...toSiblingAnnotations(this, ref),
260
+ example: ref?.example ?? this.example,
261
+ externalDocs: this.externalDocs,
262
+ nullable,
263
+ discriminator: this.discriminator,
264
+ members: this.members,
265
+ default: ref?.default ?? this.default,
266
+ });
267
+ copy.stackTrail = this.stackTrail;
268
+ copy.not = this.not;
269
+ return copy;
270
+ }
229
271
  traverse(path) {
230
272
  return traverseSchema(this, path);
231
273
  }
@@ -235,6 +277,35 @@ export class OasUnion extends OasBase {
235
277
  resolveOnce() {
236
278
  return this;
237
279
  }
280
+ /**
281
+ * Whether the discriminator alone picks the member of a value: the union
282
+ * names a discriminator, and each member, followed through references, is
283
+ * an object that is not nullable, that requires the discriminator's
284
+ * property, and that allows only string literals for it. No value may
285
+ * belong to two members. A member that is a union, or anything other than
286
+ * an object, makes it `false`.
287
+ *
288
+ * It reads the schemas only. A generator may refuse more: one that leaves
289
+ * out `readOnly` properties cannot discriminate on one.
290
+ */
291
+ isDiscriminable() {
292
+ const key = this.discriminator?.propertyName;
293
+ if (key === undefined) {
294
+ return false;
295
+ }
296
+ const seen = new Set();
297
+ return this.members.every(member => {
298
+ const values = toDiscriminatorValues(member, key);
299
+ return (values !== undefined &&
300
+ values.every(value => {
301
+ if (seen.has(value)) {
302
+ return false;
303
+ }
304
+ seen.add(value);
305
+ return true;
306
+ }));
307
+ });
308
+ }
238
309
  toJsonSchema(options) {
239
310
  return {
240
311
  title: this.title,
@@ -246,3 +317,32 @@ export class OasUnion extends OasBase {
246
317
  };
247
318
  }
248
319
  }
320
+ /**
321
+ * The values a member allows for the discriminator `key`, or `undefined`
322
+ * when the member is not an object, is nullable, or does not require `key`
323
+ * with string literals only.
324
+ */
325
+ const toDiscriminatorValues = (member, key) => {
326
+ // `resolve()`, not `resolveOnce()`: the schema at this site, with the
327
+ // keywords next to the reference (`properties`, `required`) applied.
328
+ if (member.isRef()) {
329
+ return member.nullable ? undefined : toDiscriminatorValues(member.resolve(), key);
330
+ }
331
+ if (member.type !== 'object' || member.nullable) {
332
+ return undefined;
333
+ }
334
+ const property = member.properties?.[key];
335
+ return property === undefined || !member.required?.includes(key) ? undefined : toLiteralValues(property);
336
+ };
337
+ /** The string literals a schema allows, or `undefined` when it allows anything else too. */
338
+ const toLiteralValues = (schema) => {
339
+ if (schema.isRef()) {
340
+ return schema.nullable ? undefined : toLiteralValues(schema.resolve());
341
+ }
342
+ if (schema.type !== 'string' || schema.nullable || schema.enums === undefined) {
343
+ return undefined;
344
+ }
345
+ const enums = schema.enums;
346
+ const strings = enums.filter((value) => value !== null);
347
+ return strings.length > 0 && strings.length === enums.length ? strings : undefined;
348
+ };
@@ -43,8 +43,26 @@ export declare class OasUnknown extends OasBase {
43
43
  example: unknown | undefined;
44
44
  /** Whether the unknown type is nullable */
45
45
  nullable: boolean | undefined;
46
+ /**
47
+ * The schema's `not`, kept as an `OasUnknown` under `client.json`
48
+ * `system.not: unknown`: the document says "not something", and core does
49
+ * not read what. `undefined` otherwise.
50
+ */
51
+ not: OasUnknown | undefined;
46
52
  constructor(fields?: UnknownFields, context?: ParseContextType);
47
53
  isRef(): this is OasRef<'schema'>;
54
+ /** Always `false`: this schema has no `readOnly`. */
55
+ isReadOnly(): boolean;
56
+ /** Always `false`: this schema has no `writeOnly`. */
57
+ isWriteOnly(): boolean;
58
+ /**
59
+ * A copy of this schema with what `ref` adds at its site applied: its
60
+ * `nullable` and the keywords next to it (`SiblingKeywords`) that
61
+ * this type takes, a sibling's value winning. A value that does not fit
62
+ * this type is left out (the parser reports it). For `OasRef.resolve()`.
63
+ * This schema does not change, and the copy shares its child schemas.
64
+ */
65
+ clone(ref?: OasRef<'schema'>): OasUnknown;
48
66
  traverse(path: SchemaPath): OasSchema | OasRef<'schema'>;
49
67
  resolve(): OasUnknown;
50
68
  resolveOnce(): OasUnknown;