@skmtc/core 0.39.0 → 0.41.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 (373) hide show
  1. package/esm/context/CoreContext.js +22 -8
  2. package/esm/context/GenerateContext.d.ts +6 -5
  3. package/esm/context/GenerateContext.js +112 -38
  4. package/esm/context/ParseContext.d.ts +18 -1
  5. package/esm/context/ParseContext.js +102 -3
  6. package/esm/context/generateTypes.d.ts +33 -4
  7. package/esm/context/generateTypes.js +4 -0
  8. package/esm/context/toGenerationFailure.d.ts +21 -0
  9. package/esm/context/toGenerationFailure.js +38 -0
  10. package/esm/context/tryParseAt.d.ts +4 -1
  11. package/esm/context/tryParseAt.js +10 -3
  12. package/esm/dsl/CustomValue.d.ts +4 -0
  13. package/esm/dsl/CustomValue.js +8 -0
  14. package/esm/dsl/Definition.d.ts +10 -0
  15. package/esm/dsl/Definition.js +14 -0
  16. package/esm/dsl/PendingDefinition.d.ts +47 -0
  17. package/esm/dsl/PendingDefinition.js +83 -0
  18. package/esm/dsl/model/ModelDriver.d.ts +55 -1
  19. package/esm/dsl/model/ModelDriver.js +228 -51
  20. package/esm/dsl/model/toModelEntry.d.ts +1 -1
  21. package/esm/dsl/model/toModelEntry.js +1 -1
  22. package/esm/dsl/model/types.d.ts +1 -1
  23. package/esm/dsl/operation/gql/GqlOperationDriver.js +1 -4
  24. package/esm/dsl/webhook/WebhookDriver.js +1 -4
  25. package/esm/enrichments/parseEnrichmentUmbrella.d.ts +5 -6
  26. package/esm/enrichments/parseEnrichmentUmbrella.js +23 -8
  27. package/esm/enrichments/parseEnrichmentValue.d.ts +17 -0
  28. package/esm/enrichments/parseEnrichmentValue.js +32 -0
  29. package/esm/enrichments/readEnrichments.d.ts +5 -5
  30. package/esm/enrichments/readEnrichments.js +17 -7
  31. package/esm/helpers/collateExamples.js +15 -5
  32. package/esm/helpers/refFns.d.ts +6 -2
  33. package/esm/helpers/refFns.js +24 -7
  34. package/esm/mod.d.ts +2 -0
  35. package/esm/mod.js +2 -0
  36. package/esm/oas/array/Array.d.ts +19 -0
  37. package/esm/oas/array/Array.js +47 -0
  38. package/esm/oas/boolean/Boolean.d.ts +19 -0
  39. package/esm/oas/boolean/Boolean.js +51 -8
  40. package/esm/oas/example/Example.d.ts +4 -0
  41. package/esm/oas/example/Example.js +8 -0
  42. package/esm/oas/header/Header.d.ts +4 -0
  43. package/esm/oas/header/Header.js +8 -0
  44. package/esm/oas/integer/Integer.d.ts +19 -0
  45. package/esm/oas/integer/Integer.js +49 -0
  46. package/esm/oas/link/Link.d.ts +4 -0
  47. package/esm/oas/link/Link.js +8 -0
  48. package/esm/oas/number/Number.d.ts +19 -0
  49. package/esm/oas/number/Number.js +49 -0
  50. package/esm/oas/object/Object.d.ts +19 -0
  51. package/esm/oas/object/Object.js +68 -18
  52. package/esm/oas/operation/Operation.d.ts +8 -1
  53. package/esm/oas/operation/Operation.js +18 -5
  54. package/esm/oas/operation/toEffectiveParameters.d.ts +24 -0
  55. package/esm/oas/operation/toEffectiveParameters.js +42 -0
  56. package/esm/oas/parameter/Parameter.d.ts +4 -0
  57. package/esm/oas/parameter/Parameter.js +8 -0
  58. package/esm/oas/ref/DanglingRefError.d.ts +22 -0
  59. package/esm/oas/ref/DanglingRefError.js +33 -0
  60. package/esm/oas/ref/Ref.d.ts +152 -25
  61. package/esm/oas/ref/Ref.js +414 -26
  62. package/esm/oas/requestBody/RequestBody.d.ts +4 -0
  63. package/esm/oas/requestBody/RequestBody.js +8 -0
  64. package/esm/oas/response/Response.d.ts +4 -0
  65. package/esm/oas/response/Response.js +8 -0
  66. package/esm/oas/schema/siblings.d.ts +127 -0
  67. package/esm/oas/schema/siblings.js +250 -0
  68. package/esm/oas/securitySchemes/SecurityScheme.d.ts +16 -0
  69. package/esm/oas/securitySchemes/SecurityScheme.js +32 -0
  70. package/esm/oas/string/String.d.ts +19 -0
  71. package/esm/oas/string/String.js +47 -0
  72. package/esm/oas/union/Union.d.ts +32 -0
  73. package/esm/oas/union/Union.js +111 -0
  74. package/esm/oas/unknown/Unknown.d.ts +18 -0
  75. package/esm/oas/unknown/Unknown.js +38 -0
  76. package/esm/oas/void/Void.d.ts +4 -0
  77. package/esm/oas/void/Void.js +8 -0
  78. package/esm/oas/webhook/Webhook.d.ts +2 -2
  79. package/esm/oas/webhook/Webhook.js +4 -5
  80. package/esm/parse/allOfSystem.d.ts +32 -0
  81. package/esm/parse/allOfSystem.js +30 -0
  82. package/esm/parse/anyOfSystem.d.ts +68 -0
  83. package/esm/parse/anyOfSystem.js +107 -0
  84. package/esm/parse/securityRequirements.d.ts +6 -0
  85. package/esm/parse/securityRequirements.js +8 -0
  86. package/esm/parse/toSiblingKeywords.d.ts +28 -0
  87. package/esm/parse/toSiblingKeywords.js +109 -0
  88. package/esm/parse/v3-0/_merge-all-of/decompose-union.d.ts +8 -0
  89. package/esm/parse/v3-0/_merge-all-of/decompose-union.js +9 -1
  90. package/esm/parse/v3-0/_merge-all-of/generic-merge.d.ts +2 -3
  91. package/esm/parse/v3-0/_merge-all-of/generic-merge.js +2 -2
  92. package/esm/parse/v3-0/_merge-all-of/merge-array-constraints.d.ts +2 -2
  93. package/esm/parse/v3-0/_merge-all-of/merge-array-constraints.js +5 -5
  94. package/esm/parse/v3-0/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  95. package/esm/parse/v3-0/_merge-all-of/merge-boolean-constraints.js +2 -2
  96. package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  97. package/esm/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -2
  98. package/esm/parse/v3-0/_merge-all-of/merge-intersection.d.ts +3 -2
  99. package/esm/parse/v3-0/_merge-all-of/merge-intersection.js +2 -2
  100. package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.d.ts +2 -2
  101. package/esm/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -2
  102. package/esm/parse/v3-0/_merge-all-of/merge-object-constraints.d.ts +2 -2
  103. package/esm/parse/v3-0/_merge-all-of/merge-object-constraints.js +3 -3
  104. package/esm/parse/v3-0/_merge-all-of/merge-properties.d.ts +2 -2
  105. package/esm/parse/v3-0/_merge-all-of/merge-properties.js +2 -2
  106. package/esm/parse/v3-0/_merge-all-of/merge-string-constraints.d.ts +2 -2
  107. package/esm/parse/v3-0/_merge-all-of/merge-string-constraints.js +3 -3
  108. package/esm/parse/v3-0/_merge-all-of/merge-union.d.ts +10 -3
  109. package/esm/parse/v3-0/_merge-all-of/merge-union.js +50 -12
  110. package/esm/parse/v3-0/_merge-all-of/merge.d.ts +2 -2
  111. package/esm/parse/v3-0/_merge-all-of/merge.js +78 -27
  112. package/esm/parse/v3-0/_merge-all-of/nullable-merge.d.ts +4 -0
  113. package/esm/parse/v3-0/_merge-all-of/nullable-merge.js +9 -7
  114. package/esm/parse/v3-0/_merge-all-of/types.d.ts +33 -0
  115. package/esm/parse/v3-0/mediaType/toMediaTypeItemV3.js +4 -3
  116. package/esm/parse/v3-0/parameter/toParameterV3.js +4 -3
  117. package/esm/parse/v3-0/ref/toRefV31.d.ts +7 -1
  118. package/esm/parse/v3-0/ref/toRefV31.js +6 -3
  119. package/esm/parse/v3-0/schema/toSchemasV3.js +107 -15
  120. package/esm/parse/v3-1/_merge-all-of/decompose-union.d.ts +7 -1
  121. package/esm/parse/v3-1/_merge-all-of/decompose-union.js +8 -2
  122. package/esm/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -3
  123. package/esm/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
  124. package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +3 -2
  125. package/esm/parse/v3-1/_merge-all-of/merge-array-constraints.js +5 -5
  126. package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  127. package/esm/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
  128. package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  129. package/esm/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
  130. package/esm/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
  131. package/esm/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
  132. package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
  133. package/esm/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
  134. package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
  135. package/esm/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
  136. package/esm/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
  137. package/esm/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
  138. package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
  139. package/esm/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
  140. package/esm/parse/v3-1/_merge-all-of/merge-union.d.ts +10 -3
  141. package/esm/parse/v3-1/_merge-all-of/merge-union.js +54 -15
  142. package/esm/parse/v3-1/_merge-all-of/merge.d.ts +3 -2
  143. package/esm/parse/v3-1/_merge-all-of/merge.js +88 -29
  144. package/esm/parse/v3-1/_merge-all-of/nullable-merge.d.ts +4 -0
  145. package/esm/parse/v3-1/_merge-all-of/nullable-merge.js +9 -7
  146. package/esm/parse/v3-1/_merge-all-of/types.d.ts +37 -0
  147. package/esm/parse/v3-1/mediaType/toMediaTypeItemV3.js +4 -3
  148. package/esm/parse/v3-1/parameter/toParameterV3.js +4 -3
  149. package/esm/parse/v3-1/ref/toRefV31.d.ts +7 -1
  150. package/esm/parse/v3-1/ref/toRefV31.js +6 -3
  151. package/esm/parse/v3-1/schema/toSchemasV3.js +111 -16
  152. package/esm/parse/v3-2/_merge-all-of/decompose-union.d.ts +7 -1
  153. package/esm/parse/v3-2/_merge-all-of/decompose-union.js +8 -2
  154. package/esm/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -3
  155. package/esm/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
  156. package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +3 -2
  157. package/esm/parse/v3-2/_merge-all-of/merge-array-constraints.js +5 -5
  158. package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  159. package/esm/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
  160. package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  161. package/esm/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
  162. package/esm/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
  163. package/esm/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
  164. package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
  165. package/esm/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
  166. package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
  167. package/esm/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
  168. package/esm/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
  169. package/esm/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
  170. package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
  171. package/esm/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
  172. package/esm/parse/v3-2/_merge-all-of/merge-union.d.ts +10 -3
  173. package/esm/parse/v3-2/_merge-all-of/merge-union.js +54 -15
  174. package/esm/parse/v3-2/_merge-all-of/merge.d.ts +3 -2
  175. package/esm/parse/v3-2/_merge-all-of/merge.js +88 -29
  176. package/esm/parse/v3-2/_merge-all-of/nullable-merge.d.ts +4 -0
  177. package/esm/parse/v3-2/_merge-all-of/nullable-merge.js +9 -7
  178. package/esm/parse/v3-2/_merge-all-of/types.d.ts +37 -0
  179. package/esm/parse/v3-2/mediaType/toMediaTypeItemV3.js +4 -3
  180. package/esm/parse/v3-2/parameter/toParameterV3.js +4 -3
  181. package/esm/parse/v3-2/ref/toRefV31.d.ts +7 -1
  182. package/esm/parse/v3-2/ref/toRefV31.js +6 -3
  183. package/esm/parse/v3-2/schema/toSchemasV3.js +111 -16
  184. package/esm/types/OasBase.d.ts +1 -1
  185. package/esm/types/Settings.d.ts +44 -0
  186. package/esm/types/Settings.js +9 -0
  187. package/package.json +5 -1
  188. package/script/context/CoreContext.js +22 -8
  189. package/script/context/GenerateContext.d.ts +6 -5
  190. package/script/context/GenerateContext.js +112 -38
  191. package/script/context/ParseContext.d.ts +18 -1
  192. package/script/context/ParseContext.js +102 -3
  193. package/script/context/generateTypes.d.ts +33 -4
  194. package/script/context/generateTypes.js +4 -0
  195. package/script/context/toGenerationFailure.d.ts +21 -0
  196. package/script/context/toGenerationFailure.js +43 -0
  197. package/script/context/tryParseAt.d.ts +4 -1
  198. package/script/context/tryParseAt.js +10 -3
  199. package/script/dsl/CustomValue.d.ts +4 -0
  200. package/script/dsl/CustomValue.js +8 -0
  201. package/script/dsl/Definition.d.ts +10 -0
  202. package/script/dsl/Definition.js +14 -0
  203. package/script/dsl/PendingDefinition.d.ts +47 -0
  204. package/script/dsl/PendingDefinition.js +87 -0
  205. package/script/dsl/model/ModelDriver.d.ts +55 -1
  206. package/script/dsl/model/ModelDriver.js +231 -52
  207. package/script/dsl/model/toModelEntry.d.ts +1 -1
  208. package/script/dsl/model/toModelEntry.js +1 -1
  209. package/script/dsl/model/types.d.ts +1 -1
  210. package/script/dsl/operation/gql/GqlOperationDriver.js +1 -4
  211. package/script/dsl/webhook/WebhookDriver.js +1 -4
  212. package/script/enrichments/parseEnrichmentUmbrella.d.ts +5 -6
  213. package/script/enrichments/parseEnrichmentUmbrella.js +23 -41
  214. package/script/enrichments/parseEnrichmentValue.d.ts +17 -0
  215. package/script/enrichments/parseEnrichmentValue.js +69 -0
  216. package/script/enrichments/readEnrichments.d.ts +5 -5
  217. package/script/enrichments/readEnrichments.js +17 -40
  218. package/script/helpers/collateExamples.js +15 -5
  219. package/script/helpers/refFns.d.ts +6 -2
  220. package/script/helpers/refFns.js +24 -7
  221. package/script/mod.d.ts +2 -0
  222. package/script/mod.js +2 -0
  223. package/script/oas/array/Array.d.ts +19 -0
  224. package/script/oas/array/Array.js +47 -0
  225. package/script/oas/boolean/Boolean.d.ts +19 -0
  226. package/script/oas/boolean/Boolean.js +51 -8
  227. package/script/oas/example/Example.d.ts +4 -0
  228. package/script/oas/example/Example.js +8 -0
  229. package/script/oas/header/Header.d.ts +4 -0
  230. package/script/oas/header/Header.js +8 -0
  231. package/script/oas/integer/Integer.d.ts +19 -0
  232. package/script/oas/integer/Integer.js +49 -0
  233. package/script/oas/link/Link.d.ts +4 -0
  234. package/script/oas/link/Link.js +8 -0
  235. package/script/oas/number/Number.d.ts +19 -0
  236. package/script/oas/number/Number.js +49 -0
  237. package/script/oas/object/Object.d.ts +19 -0
  238. package/script/oas/object/Object.js +68 -18
  239. package/script/oas/operation/Operation.d.ts +8 -1
  240. package/script/oas/operation/Operation.js +18 -5
  241. package/script/oas/operation/toEffectiveParameters.d.ts +24 -0
  242. package/script/oas/operation/toEffectiveParameters.js +47 -0
  243. package/script/oas/parameter/Parameter.d.ts +4 -0
  244. package/script/oas/parameter/Parameter.js +8 -0
  245. package/script/oas/ref/DanglingRefError.d.ts +22 -0
  246. package/script/oas/ref/DanglingRefError.js +37 -0
  247. package/script/oas/ref/Ref.d.ts +152 -25
  248. package/script/oas/ref/Ref.js +414 -26
  249. package/script/oas/requestBody/RequestBody.d.ts +4 -0
  250. package/script/oas/requestBody/RequestBody.js +8 -0
  251. package/script/oas/response/Response.d.ts +4 -0
  252. package/script/oas/response/Response.js +8 -0
  253. package/script/oas/schema/siblings.d.ts +127 -0
  254. package/script/oas/schema/siblings.js +305 -0
  255. package/script/oas/securitySchemes/SecurityScheme.d.ts +16 -0
  256. package/script/oas/securitySchemes/SecurityScheme.js +32 -0
  257. package/script/oas/string/String.d.ts +19 -0
  258. package/script/oas/string/String.js +47 -0
  259. package/script/oas/union/Union.d.ts +32 -0
  260. package/script/oas/union/Union.js +111 -0
  261. package/script/oas/unknown/Unknown.d.ts +18 -0
  262. package/script/oas/unknown/Unknown.js +38 -0
  263. package/script/oas/void/Void.d.ts +4 -0
  264. package/script/oas/void/Void.js +8 -0
  265. package/script/oas/webhook/Webhook.d.ts +2 -2
  266. package/script/oas/webhook/Webhook.js +4 -5
  267. package/script/parse/allOfSystem.d.ts +32 -0
  268. package/script/parse/allOfSystem.js +35 -0
  269. package/script/parse/anyOfSystem.d.ts +68 -0
  270. package/script/parse/anyOfSystem.js +116 -0
  271. package/script/parse/securityRequirements.d.ts +6 -0
  272. package/script/parse/securityRequirements.js +8 -0
  273. package/script/parse/toSiblingKeywords.d.ts +28 -0
  274. package/script/parse/toSiblingKeywords.js +146 -0
  275. package/script/parse/v3-0/_merge-all-of/decompose-union.d.ts +8 -0
  276. package/script/parse/v3-0/_merge-all-of/decompose-union.js +11 -2
  277. package/script/parse/v3-0/_merge-all-of/generic-merge.d.ts +2 -3
  278. package/script/parse/v3-0/_merge-all-of/generic-merge.js +2 -2
  279. package/script/parse/v3-0/_merge-all-of/merge-array-constraints.d.ts +2 -2
  280. package/script/parse/v3-0/_merge-all-of/merge-array-constraints.js +5 -5
  281. package/script/parse/v3-0/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  282. package/script/parse/v3-0/_merge-all-of/merge-boolean-constraints.js +2 -2
  283. package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  284. package/script/parse/v3-0/_merge-all-of/merge-integer-constraints.js +2 -2
  285. package/script/parse/v3-0/_merge-all-of/merge-intersection.d.ts +3 -2
  286. package/script/parse/v3-0/_merge-all-of/merge-intersection.js +2 -2
  287. package/script/parse/v3-0/_merge-all-of/merge-number-constraints.d.ts +2 -2
  288. package/script/parse/v3-0/_merge-all-of/merge-number-constraints.js +2 -2
  289. package/script/parse/v3-0/_merge-all-of/merge-object-constraints.d.ts +2 -2
  290. package/script/parse/v3-0/_merge-all-of/merge-object-constraints.js +3 -3
  291. package/script/parse/v3-0/_merge-all-of/merge-properties.d.ts +2 -2
  292. package/script/parse/v3-0/_merge-all-of/merge-properties.js +2 -2
  293. package/script/parse/v3-0/_merge-all-of/merge-string-constraints.d.ts +2 -2
  294. package/script/parse/v3-0/_merge-all-of/merge-string-constraints.js +3 -3
  295. package/script/parse/v3-0/_merge-all-of/merge-union.d.ts +10 -3
  296. package/script/parse/v3-0/_merge-all-of/merge-union.js +52 -13
  297. package/script/parse/v3-0/_merge-all-of/merge.d.ts +2 -2
  298. package/script/parse/v3-0/_merge-all-of/merge.js +77 -26
  299. package/script/parse/v3-0/_merge-all-of/nullable-merge.d.ts +4 -0
  300. package/script/parse/v3-0/_merge-all-of/nullable-merge.js +9 -7
  301. package/script/parse/v3-0/_merge-all-of/types.d.ts +33 -0
  302. package/script/parse/v3-0/mediaType/toMediaTypeItemV3.js +4 -3
  303. package/script/parse/v3-0/parameter/toParameterV3.js +4 -3
  304. package/script/parse/v3-0/ref/toRefV31.d.ts +7 -1
  305. package/script/parse/v3-0/ref/toRefV31.js +6 -3
  306. package/script/parse/v3-0/schema/toSchemasV3.js +107 -15
  307. package/script/parse/v3-1/_merge-all-of/decompose-union.d.ts +7 -1
  308. package/script/parse/v3-1/_merge-all-of/decompose-union.js +8 -2
  309. package/script/parse/v3-1/_merge-all-of/generic-merge.d.ts +2 -3
  310. package/script/parse/v3-1/_merge-all-of/generic-merge.js +2 -2
  311. package/script/parse/v3-1/_merge-all-of/merge-array-constraints.d.ts +3 -2
  312. package/script/parse/v3-1/_merge-all-of/merge-array-constraints.js +5 -5
  313. package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  314. package/script/parse/v3-1/_merge-all-of/merge-boolean-constraints.js +2 -2
  315. package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  316. package/script/parse/v3-1/_merge-all-of/merge-integer-constraints.js +2 -2
  317. package/script/parse/v3-1/_merge-all-of/merge-intersection.d.ts +3 -2
  318. package/script/parse/v3-1/_merge-all-of/merge-intersection.js +2 -2
  319. package/script/parse/v3-1/_merge-all-of/merge-number-constraints.d.ts +2 -2
  320. package/script/parse/v3-1/_merge-all-of/merge-number-constraints.js +2 -2
  321. package/script/parse/v3-1/_merge-all-of/merge-object-constraints.d.ts +2 -2
  322. package/script/parse/v3-1/_merge-all-of/merge-object-constraints.js +3 -3
  323. package/script/parse/v3-1/_merge-all-of/merge-properties.d.ts +2 -2
  324. package/script/parse/v3-1/_merge-all-of/merge-properties.js +2 -2
  325. package/script/parse/v3-1/_merge-all-of/merge-string-constraints.d.ts +2 -2
  326. package/script/parse/v3-1/_merge-all-of/merge-string-constraints.js +3 -3
  327. package/script/parse/v3-1/_merge-all-of/merge-union.d.ts +10 -3
  328. package/script/parse/v3-1/_merge-all-of/merge-union.js +56 -16
  329. package/script/parse/v3-1/_merge-all-of/merge.d.ts +3 -2
  330. package/script/parse/v3-1/_merge-all-of/merge.js +87 -28
  331. package/script/parse/v3-1/_merge-all-of/nullable-merge.d.ts +4 -0
  332. package/script/parse/v3-1/_merge-all-of/nullable-merge.js +9 -7
  333. package/script/parse/v3-1/_merge-all-of/types.d.ts +37 -0
  334. package/script/parse/v3-1/mediaType/toMediaTypeItemV3.js +4 -3
  335. package/script/parse/v3-1/parameter/toParameterV3.js +4 -3
  336. package/script/parse/v3-1/ref/toRefV31.d.ts +7 -1
  337. package/script/parse/v3-1/ref/toRefV31.js +6 -3
  338. package/script/parse/v3-1/schema/toSchemasV3.js +111 -16
  339. package/script/parse/v3-2/_merge-all-of/decompose-union.d.ts +7 -1
  340. package/script/parse/v3-2/_merge-all-of/decompose-union.js +8 -2
  341. package/script/parse/v3-2/_merge-all-of/generic-merge.d.ts +2 -3
  342. package/script/parse/v3-2/_merge-all-of/generic-merge.js +2 -2
  343. package/script/parse/v3-2/_merge-all-of/merge-array-constraints.d.ts +3 -2
  344. package/script/parse/v3-2/_merge-all-of/merge-array-constraints.js +5 -5
  345. package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.d.ts +2 -2
  346. package/script/parse/v3-2/_merge-all-of/merge-boolean-constraints.js +2 -2
  347. package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.d.ts +2 -2
  348. package/script/parse/v3-2/_merge-all-of/merge-integer-constraints.js +2 -2
  349. package/script/parse/v3-2/_merge-all-of/merge-intersection.d.ts +3 -2
  350. package/script/parse/v3-2/_merge-all-of/merge-intersection.js +2 -2
  351. package/script/parse/v3-2/_merge-all-of/merge-number-constraints.d.ts +2 -2
  352. package/script/parse/v3-2/_merge-all-of/merge-number-constraints.js +2 -2
  353. package/script/parse/v3-2/_merge-all-of/merge-object-constraints.d.ts +2 -2
  354. package/script/parse/v3-2/_merge-all-of/merge-object-constraints.js +3 -3
  355. package/script/parse/v3-2/_merge-all-of/merge-properties.d.ts +2 -2
  356. package/script/parse/v3-2/_merge-all-of/merge-properties.js +2 -2
  357. package/script/parse/v3-2/_merge-all-of/merge-string-constraints.d.ts +2 -2
  358. package/script/parse/v3-2/_merge-all-of/merge-string-constraints.js +3 -3
  359. package/script/parse/v3-2/_merge-all-of/merge-union.d.ts +10 -3
  360. package/script/parse/v3-2/_merge-all-of/merge-union.js +56 -16
  361. package/script/parse/v3-2/_merge-all-of/merge.d.ts +3 -2
  362. package/script/parse/v3-2/_merge-all-of/merge.js +87 -28
  363. package/script/parse/v3-2/_merge-all-of/nullable-merge.d.ts +4 -0
  364. package/script/parse/v3-2/_merge-all-of/nullable-merge.js +9 -7
  365. package/script/parse/v3-2/_merge-all-of/types.d.ts +37 -0
  366. package/script/parse/v3-2/mediaType/toMediaTypeItemV3.js +4 -3
  367. package/script/parse/v3-2/parameter/toParameterV3.js +4 -3
  368. package/script/parse/v3-2/ref/toRefV31.d.ts +7 -1
  369. package/script/parse/v3-2/ref/toRefV31.js +6 -3
  370. package/script/parse/v3-2/schema/toSchemasV3.js +111 -16
  371. package/script/types/OasBase.d.ts +1 -1
  372. package/script/types/Settings.d.ts +44 -0
  373. package/script/types/Settings.js +10 -1
@@ -0,0 +1,127 @@
1
+ import type { OasSchema } from './Schema.js';
2
+ import type { OasRef } from '../ref/Ref.js';
3
+ /**
4
+ * The keywords next to a reference in a one-member `allOf`
5
+ * (`{ allOf: [{ $ref }], minLength: 3, description: '…' }`), the use-site
6
+ * flags `nullable`, `readOnly` and `writeOnly` among them: the fields a
7
+ * reference adds at its site (`RefFields`).
8
+ *
9
+ * The parser reads them without knowing the target's type: the reference
10
+ * stays lazy. Each schema class's `clone(ref)` takes the keywords its type
11
+ * has ({@link SIBLINGS_BY_TYPE}). A value whose type depends on the target
12
+ * (`example`, `default`, `enums`, `format`) is kept as written, and `clone`
13
+ * takes it only when it fits. {@link toSkippedSiblings} names the keywords
14
+ * `clone` leaves out, for a generator to log.
15
+ */
16
+ export type SiblingKeywords = {
17
+ /**
18
+ * Use-site nullability. A `$ref` is a per-reference node: the same
19
+ * refName may be referenced nullable at one site and non-nullable at
20
+ * another, so nullability rides the reference, not the shared referent.
21
+ * Set by the single-member `oneOf`/`anyOf` collapse for the 3.1
22
+ * `oneOf:[{$ref},{type:null}]` idiom, and next to a one-member `allOf`.
23
+ * Generators read it off the reference (`'nullable' in schema ?
24
+ * schema.nullable`) to render `Foo | null`, while `ModelDriver` builds the
25
+ * un-nullable shared model from the refName.
26
+ */
27
+ nullable?: boolean;
28
+ /**
29
+ * Use-site `readOnly`: set where a property marks a reference read-only,
30
+ * `{ allOf: [{ $ref }], readOnly: true }` (the 3.0 idiom, as keywords next
31
+ * to a bare `$ref` are ignored there). Like `nullable`, it rides the
32
+ * reference: the shared model is not read-only everywhere. Read it through
33
+ * `isReadOnly`, which also looks at what the reference points to.
34
+ */
35
+ readOnly?: boolean;
36
+ /** Use-site `writeOnly`, as {@link readOnly}. */
37
+ writeOnly?: boolean;
38
+ /**
39
+ * The `type` written next to the reference, merged in from the schema that
40
+ * holds the one-member `allOf`. It must agree with the target's; the copy
41
+ * always has the target's type. Not `type`, which on an `OasRef` is `'ref'`.
42
+ */
43
+ _type?: unknown;
44
+ title?: string;
45
+ description?: string;
46
+ deprecated?: boolean;
47
+ example?: unknown;
48
+ default?: unknown;
49
+ enums?: unknown[];
50
+ extensionFields?: Record<string, unknown>;
51
+ format?: string;
52
+ minLength?: number;
53
+ maxLength?: number;
54
+ pattern?: string;
55
+ multipleOf?: number;
56
+ minimum?: number;
57
+ maximum?: number;
58
+ exclusiveMinimum?: boolean;
59
+ exclusiveMaximum?: boolean;
60
+ minItems?: number;
61
+ maxItems?: number;
62
+ uniqueItems?: boolean;
63
+ properties?: Record<string, OasSchema | OasRef<'schema'>>;
64
+ required?: string[];
65
+ additionalProperties?: boolean | OasSchema | OasRef<'schema'>;
66
+ minProperties?: number;
67
+ maxProperties?: number;
68
+ };
69
+ /** A keyword `clone` can apply. `_type` only has to agree. */
70
+ export type SiblingKeyword = Exclude<keyof SiblingKeywords, '_type'>;
71
+ /** The keywords each schema class's `clone` takes: the fields its type has. */
72
+ export declare const SIBLINGS_BY_TYPE: Record<OasSchema['type'], SiblingKeyword[]>;
73
+ /**
74
+ * The keywords of `over` merged over those of `base`, for a reference copied
75
+ * with what another site adds (`OasRef.clone`): a flag set on either stays
76
+ * set, a keyword `over` sets wins, extension fields and `properties` merge,
77
+ * and `required` names add up, as each schema class's `clone` merges them
78
+ * into a schema.
79
+ */
80
+ export declare const mergeSiblingKeywords: (base: SiblingKeywords, over: SiblingKeywords | undefined) => SiblingKeywords;
81
+ /** Whether `siblings` holds any keyword. */
82
+ export declare const hasSiblingKeywords: (siblings: SiblingKeywords) => boolean;
83
+ /** Whether the keywords next to a reference change `target` at that site. The engine behind `OasRef.resolve`. */
84
+ export declare const changesTarget: (copy: OasSchema, target: OasSchema, siblings: SiblingKeywords) => boolean;
85
+ /**
86
+ * Whether the keywords next to a reference change which values `target`
87
+ * accepts at that site (`minLength` next to a string, `properties` next to an
88
+ * object), not only how it is described (`description`, `deprecated`,
89
+ * `default`, `x-*`). The engine behind `OasRef.hasValueSiblings`.
90
+ */
91
+ export declare const changesValues: (copy: OasSchema, target: OasSchema, siblings: SiblingKeywords) => boolean;
92
+ /**
93
+ * The keywords next to a reference that `clone` leaves out for `target`, by
94
+ * their names in the document: one its type does not have (`minLength` next
95
+ * to an array), a `type` that disagrees with the target's, and an `example`,
96
+ * `default`, `enum` or `format` whose value does not fit. `nullable` says
97
+ * whether the site takes `null` among the `enum` members. The engine behind
98
+ * `OasRef.toSkippedSiblings`.
99
+ */
100
+ export declare const toSkippedSiblings: (target: OasSchema, siblings: SiblingKeywords, nullable: boolean | undefined) => string[];
101
+ /** The annotations of `target` with those of `siblings` applied: a sibling's value wins, and extension fields merge. */
102
+ export declare const toSiblingAnnotations: (target: OasSchema, siblings: SiblingKeywords | undefined) => {
103
+ title: string | undefined;
104
+ description: string | undefined;
105
+ extensionFields: {
106
+ [x: string]: unknown;
107
+ } | undefined;
108
+ };
109
+ /** The value checks the parser makes for `example`, `default` and each `enum` member, by type. */
110
+ export declare const isStringValue: (value: unknown) => value is string;
111
+ export declare const isNumberValue: (value: unknown) => value is number;
112
+ export declare const isIntegerValue: (value: unknown) => value is number;
113
+ export declare const isBooleanValue: (value: unknown) => value is boolean;
114
+ export declare const isArrayValue: (value: unknown) => value is unknown[];
115
+ export declare const isObjectValue: (value: unknown) => value is Record<string, unknown>;
116
+ /** {@link isStringValue} and the others, keyed by the type they check for. A union or unknown takes any value. */
117
+ export declare const VALUE_CHECKS: Record<OasSchema['type'], (value: unknown) => boolean>;
118
+ /** The formats a number and an integer take. A string takes any format. */
119
+ export declare const isNumberFormat: (value: unknown) => value is "float" | "double";
120
+ export declare const isIntegerFormat: (value: unknown) => value is "int32" | "int64";
121
+ /** `value` when it passes `check`, else `undefined`: for `example`, `default` and `format`. */
122
+ export declare const toSiblingValue: <T>(value: unknown, check: (value: unknown) => value is T) => T | undefined;
123
+ /**
124
+ * `enums` when every member passes `check`, or is `null` at a nullable site,
125
+ * else `undefined`. The parser reports the members that do not.
126
+ */
127
+ export declare const toSiblingEnums: <T>(enums: unknown[] | undefined, check: (value: unknown) => value is T, nullable: boolean | undefined) => (T | null)[] | undefined;
@@ -0,0 +1,250 @@
1
+ import * as v from 'valibot';
2
+ import isEqual from 'lodash-es/isEqual.js';
3
+ import { DanglingRefError } from '../ref/DanglingRefError.js';
4
+ import { numberFormat } from '../number/number-types.js';
5
+ import { integerFormat } from '../integer/integer-types.js';
6
+ /**
7
+ * The use-site flags, taken by every type, so they are never reported as
8
+ * left out. A union's or unknown's copy has no `readOnly` or `writeOnly`
9
+ * field, but the reference still answers `isReadOnly()` and
10
+ * `isWriteOnly()` from its own flag.
11
+ */
12
+ const FLAGS = ['nullable', 'readOnly', 'writeOnly'];
13
+ const DESCRIBING = [...FLAGS, 'title', 'description', 'extensionFields', 'example'];
14
+ const NUMERIC = [
15
+ 'deprecated',
16
+ 'default',
17
+ 'enums',
18
+ 'format',
19
+ 'multipleOf',
20
+ 'minimum',
21
+ 'maximum',
22
+ 'exclusiveMinimum',
23
+ 'exclusiveMaximum'
24
+ ];
25
+ /** The keywords each schema class's `clone` takes: the fields its type has. */
26
+ export const SIBLINGS_BY_TYPE = {
27
+ string: [...DESCRIBING, 'deprecated', 'default', 'enums', 'format', 'minLength', 'maxLength', 'pattern'],
28
+ number: [...DESCRIBING, ...NUMERIC],
29
+ integer: [...DESCRIBING, ...NUMERIC],
30
+ boolean: [...DESCRIBING, 'deprecated', 'default', 'enums'],
31
+ array: [...DESCRIBING, 'deprecated', 'default', 'enums', 'minItems', 'maxItems', 'uniqueItems'],
32
+ object: [
33
+ ...DESCRIBING,
34
+ 'deprecated',
35
+ 'default',
36
+ 'enums',
37
+ 'properties',
38
+ 'required',
39
+ 'additionalProperties',
40
+ 'minProperties',
41
+ 'maxProperties'
42
+ ],
43
+ union: [...DESCRIBING, 'default'],
44
+ unknown: DESCRIBING
45
+ };
46
+ /** Every keyword `clone` can apply, for any type. */
47
+ const SIBLING_KEYWORDS = [...new Set(Object.values(SIBLINGS_BY_TYPE).flat())];
48
+ /**
49
+ * The keywords of `over` merged over those of `base`, for a reference copied
50
+ * with what another site adds (`OasRef.clone`): a flag set on either stays
51
+ * set, a keyword `over` sets wins, extension fields and `properties` merge,
52
+ * and `required` names add up, as each schema class's `clone` merges them
53
+ * into a schema.
54
+ */
55
+ export const mergeSiblingKeywords = (base, over) => ({
56
+ nullable: base.nullable || over?.nullable || undefined,
57
+ readOnly: base.readOnly || over?.readOnly || undefined,
58
+ writeOnly: base.writeOnly || over?.writeOnly || undefined,
59
+ _type: over?._type ?? base._type,
60
+ title: over?.title ?? base.title,
61
+ description: over?.description ?? base.description,
62
+ deprecated: over?.deprecated ?? base.deprecated,
63
+ example: over?.example ?? base.example,
64
+ default: over?.default ?? base.default,
65
+ enums: over?.enums ?? base.enums,
66
+ extensionFields: base.extensionFields === undefined && over?.extensionFields === undefined
67
+ ? undefined
68
+ : { ...base.extensionFields, ...over?.extensionFields },
69
+ format: over?.format ?? base.format,
70
+ minLength: over?.minLength ?? base.minLength,
71
+ maxLength: over?.maxLength ?? base.maxLength,
72
+ pattern: over?.pattern ?? base.pattern,
73
+ multipleOf: over?.multipleOf ?? base.multipleOf,
74
+ minimum: over?.minimum ?? base.minimum,
75
+ maximum: over?.maximum ?? base.maximum,
76
+ exclusiveMinimum: over?.exclusiveMinimum ?? base.exclusiveMinimum,
77
+ exclusiveMaximum: over?.exclusiveMaximum ?? base.exclusiveMaximum,
78
+ minItems: over?.minItems ?? base.minItems,
79
+ maxItems: over?.maxItems ?? base.maxItems,
80
+ uniqueItems: over?.uniqueItems ?? base.uniqueItems,
81
+ properties: over?.properties === undefined ? base.properties : { ...base.properties, ...over.properties },
82
+ required: over?.required === undefined ? base.required : [...new Set([...(base.required ?? []), ...over.required])],
83
+ additionalProperties: over?.additionalProperties ?? base.additionalProperties,
84
+ minProperties: over?.minProperties ?? base.minProperties,
85
+ maxProperties: over?.maxProperties ?? base.maxProperties
86
+ });
87
+ /** Whether `siblings` holds any keyword. */
88
+ export const hasSiblingKeywords = (siblings) => siblings._type !== undefined || SIBLING_KEYWORDS.some(keyword => siblings[keyword] !== undefined);
89
+ /** The keywords that change which values a site accepts, not only how it is described. */
90
+ const VALUE_KEYWORDS = [
91
+ 'enums',
92
+ 'format',
93
+ 'minLength',
94
+ 'maxLength',
95
+ 'pattern',
96
+ 'multipleOf',
97
+ 'minimum',
98
+ 'maximum',
99
+ 'exclusiveMinimum',
100
+ 'exclusiveMaximum',
101
+ 'minItems',
102
+ 'maxItems',
103
+ 'uniqueItems',
104
+ 'properties',
105
+ 'required',
106
+ 'additionalProperties',
107
+ 'minProperties',
108
+ 'maxProperties'
109
+ ];
110
+ /** Keywords that `clone` merges with `||`: `false` and absent mean the same. */
111
+ const BOOLEAN_KEYWORDS = [
112
+ 'nullable',
113
+ 'readOnly',
114
+ 'writeOnly',
115
+ 'deprecated',
116
+ 'exclusiveMinimum',
117
+ 'exclusiveMaximum',
118
+ 'uniqueItems'
119
+ ];
120
+ /**
121
+ * The keywords next to a reference that make `copy` (the target with them
122
+ * applied) differ from `target`. A keyword the target's type does not take,
123
+ * a flag the target already has, and a value equal to the target's change
124
+ * nothing.
125
+ */
126
+ const toChangedKeywords = (copy, target, siblings) => SIBLINGS_BY_TYPE[target.type].filter(keyword => {
127
+ if (siblings[keyword] === undefined) {
128
+ return false;
129
+ }
130
+ const applied = Reflect.get(copy, keyword);
131
+ const original = Reflect.get(target, keyword);
132
+ return BOOLEAN_KEYWORDS.includes(keyword) ? (applied === true) !== (original === true) : !isEqual(applied, original);
133
+ });
134
+ /** Whether the keywords next to a reference change `target` at that site. The engine behind `OasRef.resolve`. */
135
+ export const changesTarget = (copy, target, siblings) => toChangedKeywords(copy, target, siblings).length > 0;
136
+ /**
137
+ * Whether the keywords next to a reference change which values `target`
138
+ * accepts at that site (`minLength` next to a string, `properties` next to an
139
+ * object), not only how it is described (`description`, `deprecated`,
140
+ * `default`, `x-*`). The engine behind `OasRef.hasValueSiblings`.
141
+ */
142
+ export const changesValues = (copy, target, siblings) => toChangedKeywords(copy, target, siblings).some(keyword => VALUE_KEYWORDS.includes(keyword));
143
+ /**
144
+ * The keywords next to a reference that `clone` leaves out for `target`, by
145
+ * their names in the document: one its type does not have (`minLength` next
146
+ * to an array), a `type` that disagrees with the target's, and an `example`,
147
+ * `default`, `enum` or `format` whose value does not fit. `nullable` says
148
+ * whether the site takes `null` among the `enum` members. The engine behind
149
+ * `OasRef.toSkippedSiblings`.
150
+ */
151
+ export const toSkippedSiblings = (target, siblings, nullable) => {
152
+ const taken = SIBLINGS_BY_TYPE[target.type];
153
+ const fits = VALUE_CHECKS[target.type];
154
+ const isSkipped = (keyword, value) => {
155
+ if (value === undefined) {
156
+ return false;
157
+ }
158
+ if (!taken.includes(keyword)) {
159
+ return true;
160
+ }
161
+ switch (keyword) {
162
+ case 'example':
163
+ case 'default':
164
+ return !fits(value);
165
+ case 'enums':
166
+ return !Array.isArray(value) || !value.every(item => fits(item) || (nullable === true && item === null));
167
+ case 'format':
168
+ return !fitsFormat(target.type, value);
169
+ default:
170
+ return false;
171
+ }
172
+ };
173
+ const type = siblings._type !== undefined && !agrees(siblings._type, target, 0) ? ['type'] : [];
174
+ const others = SIBLING_KEYWORDS.filter(keyword => isSkipped(keyword, siblings[keyword])).map(toDocumentKeyword);
175
+ return [...type, ...others];
176
+ };
177
+ /** How deep {@link agrees} follows union members, so a union that contains itself ends. */
178
+ const MAX_DEPTH = 10;
179
+ /**
180
+ * A `type` next to a reference agrees with the target's when it names it, or
181
+ * `number` for an integer. Next to a union, it agrees when every member,
182
+ * followed through references, has that type (`type: object` next to a
183
+ * `oneOf` of objects): leaving it out then loses nothing.
184
+ */
185
+ const agrees = (type, target, depth) => {
186
+ if (target.type === 'union') {
187
+ try {
188
+ return depth < MAX_DEPTH &&
189
+ target.members.every(member => agrees(type, member.isRef() ? member.resolve() : member, depth + 1));
190
+ }
191
+ catch (error) {
192
+ // A member that is a dangling reference has no known type, so it does not agree.
193
+ if (DanglingRefError.is(error)) {
194
+ return false;
195
+ }
196
+ throw error;
197
+ }
198
+ }
199
+ return type === target.type || (type === 'number' && target.type === 'integer');
200
+ };
201
+ /** Whether `format` fits a schema of `type`, as `clone` reads it: any string for a string. */
202
+ const fitsFormat = (type, format) => {
203
+ switch (type) {
204
+ case 'number':
205
+ return isNumberFormat(format);
206
+ case 'integer':
207
+ return isIntegerFormat(format);
208
+ default:
209
+ return isStringValue(format);
210
+ }
211
+ };
212
+ /** The document's name for a keyword: `enum` for `enums`. */
213
+ const toDocumentKeyword = (keyword) => (keyword === 'enums' ? 'enum' : keyword);
214
+ /** The annotations of `target` with those of `siblings` applied: a sibling's value wins, and extension fields merge. */
215
+ export const toSiblingAnnotations = (target, siblings) => ({
216
+ title: siblings?.title ?? target.title,
217
+ description: siblings?.description ?? target.description,
218
+ extensionFields: target.extensionFields === undefined && siblings?.extensionFields === undefined
219
+ ? undefined
220
+ : { ...target.extensionFields, ...siblings?.extensionFields }
221
+ });
222
+ /** The value checks the parser makes for `example`, `default` and each `enum` member, by type. */
223
+ export const isStringValue = (value) => typeof value === 'string';
224
+ export const isNumberValue = (value) => typeof value === 'number';
225
+ export const isIntegerValue = (value) => Number.isInteger(value);
226
+ export const isBooleanValue = (value) => typeof value === 'boolean';
227
+ export const isArrayValue = (value) => Array.isArray(value);
228
+ export const isObjectValue = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
229
+ const isAnyValue = (_value) => true;
230
+ /** {@link isStringValue} and the others, keyed by the type they check for. A union or unknown takes any value. */
231
+ export const VALUE_CHECKS = {
232
+ string: isStringValue,
233
+ number: isNumberValue,
234
+ integer: isIntegerValue,
235
+ boolean: isBooleanValue,
236
+ array: isArrayValue,
237
+ object: isObjectValue,
238
+ union: isAnyValue,
239
+ unknown: isAnyValue
240
+ };
241
+ /** The formats a number and an integer take. A string takes any format. */
242
+ export const isNumberFormat = (value) => v.is(numberFormat, value);
243
+ export const isIntegerFormat = (value) => v.is(integerFormat, value);
244
+ /** `value` when it passes `check`, else `undefined`: for `example`, `default` and `format`. */
245
+ export const toSiblingValue = (value, check) => check(value) ? value : undefined;
246
+ /**
247
+ * `enums` when every member passes `check`, or is `null` at a nullable site,
248
+ * else `undefined`. The parser reports the members that do not.
249
+ */
250
+ 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,41 @@ 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`, as does a reference on the way that names
220
+ * nothing in the document (kept under `system.danglingRefs: keep`).
221
+ *
222
+ * It reads the schemas only. A generator may refuse more: one that leaves
223
+ * out `readOnly` properties cannot discriminate on one.
224
+ */
225
+ isDiscriminable(): boolean;
194
226
  toJsonSchema(options: ToJsonSchemaOptions): OpenAPIV3.NonArraySchemaObject;
195
227
  }