@unispechq/unispec-core 0.3.2 → 0.3.4

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 (440) hide show
  1. package/dist/cache/cache-factory.d.ts +2 -2
  2. package/dist/cache/cache-factory.js +1 -1
  3. package/dist/cache/cache-manager.d.ts +2 -2
  4. package/dist/cache/cache-manager.js +9 -7
  5. package/dist/cache/hash-utils.d.ts +1 -11
  6. package/dist/cache/hash-utils.js +1 -21
  7. package/dist/cache/hashing.d.ts +15 -6
  8. package/dist/cache/hashing.js +8 -12
  9. package/dist/cache/index.d.ts +6 -6
  10. package/dist/cache/index.js +5 -5
  11. package/dist/cache/lru-cache.d.ts +1 -13
  12. package/dist/cache/lru-cache.js +3 -24
  13. package/dist/cjs/cache/cache-factory.js +1 -1
  14. package/dist/cjs/cache/cache-manager.js +9 -7
  15. package/dist/cjs/cache/hash-utils.js +1 -23
  16. package/dist/cjs/cache/hashing.js +7 -13
  17. package/dist/cjs/cache/index.js +6 -8
  18. package/dist/cjs/cache/lru-cache.js +3 -24
  19. package/dist/cjs/diff/annotators.js +3 -2
  20. package/dist/cjs/diff/core.js +2 -2
  21. package/dist/cjs/diff/enhanced-diff.js +7 -21
  22. package/dist/cjs/diff/index.js +8 -8
  23. package/dist/cjs/errors/config-error.js +1 -1
  24. package/dist/cjs/errors/error-factory.js +7 -7
  25. package/dist/cjs/errors/index.js +8 -8
  26. package/dist/cjs/errors/loader-error.js +1 -1
  27. package/dist/cjs/errors/reference-error.js +1 -1
  28. package/dist/cjs/errors/schema-error.js +1 -1
  29. package/dist/cjs/errors/security-error.js +1 -1
  30. package/dist/cjs/errors/semantic-error.js +1 -1
  31. package/dist/cjs/index.js +13 -13
  32. package/dist/cjs/loader/index.js +4 -4
  33. package/dist/cjs/loader/security-validator.js +1 -1
  34. package/dist/cjs/loader/unispec-loader.js +3 -3
  35. package/dist/cjs/loader/yaml-loader.js +1 -1
  36. package/dist/cjs/normalizer/core.js +11 -6
  37. package/dist/cjs/normalizer/index.js +1 -1
  38. package/dist/cjs/normalizer/utils.js +23 -7
  39. package/dist/cjs/optimizer/core.js +35 -10
  40. package/dist/cjs/optimizer/index.js +3 -3
  41. package/dist/cjs/optimizer/optimization-functions.js +2 -2
  42. package/dist/cjs/schemas/dedupe.js +27 -14
  43. package/dist/cjs/schemas/index.js +3 -3
  44. package/dist/cjs/schemas/resolver.js +3 -2
  45. package/dist/cjs/validator/ajv-validator.js +1 -1
  46. package/dist/cjs/validator/config-validator-main.js +4 -4
  47. package/dist/cjs/validator/config-validator.js +1 -1
  48. package/dist/cjs/validator/index.js +7 -7
  49. package/dist/cjs/validator/reference-validator.js +1 -1
  50. package/dist/cjs/validator/tests-validator.js +2 -2
  51. package/dist/cjs/validator/unispec-validator.js +7 -11
  52. package/dist/cjs/validator/validator-factory.js +1 -1
  53. package/dist/diff/annotators.d.ts +1 -1
  54. package/dist/diff/annotators.js +3 -2
  55. package/dist/diff/change-reports.d.ts +1 -1
  56. package/dist/diff/core.d.ts +2 -2
  57. package/dist/diff/core.js +2 -2
  58. package/dist/diff/enhanced-diff.d.ts +3 -3
  59. package/dist/diff/enhanced-diff.js +7 -21
  60. package/dist/diff/impact-strategies-refactored.d.ts +2 -2
  61. package/dist/diff/impact-strategies.d.ts +2 -2
  62. package/dist/diff/index.d.ts +8 -8
  63. package/dist/diff/index.js +8 -8
  64. package/dist/diff/metrics-calculator.d.ts +1 -1
  65. package/dist/diff/risk-calculator.d.ts +1 -1
  66. package/dist/diff/suggestion-generator.d.ts +2 -2
  67. package/dist/errors/config-error.d.ts +1 -1
  68. package/dist/errors/config-error.js +1 -1
  69. package/dist/errors/error-factory.d.ts +7 -7
  70. package/dist/errors/error-factory.js +7 -7
  71. package/dist/errors/index.d.ts +8 -8
  72. package/dist/errors/index.js +8 -8
  73. package/dist/errors/loader-error.d.ts +1 -1
  74. package/dist/errors/loader-error.js +1 -1
  75. package/dist/errors/reference-error.d.ts +1 -1
  76. package/dist/errors/reference-error.js +1 -1
  77. package/dist/errors/schema-error.d.ts +1 -1
  78. package/dist/errors/schema-error.js +1 -1
  79. package/dist/errors/security-error.d.ts +1 -1
  80. package/dist/errors/security-error.js +1 -1
  81. package/dist/errors/semantic-error.d.ts +1 -1
  82. package/dist/errors/semantic-error.js +1 -1
  83. package/dist/index.cjs +13 -13
  84. package/dist/index.d.ts +13 -13
  85. package/dist/index.js +13 -13
  86. package/dist/loader/index.d.ts +5 -5
  87. package/dist/loader/index.js +4 -4
  88. package/dist/loader/security-validator.d.ts +1 -1
  89. package/dist/loader/security-validator.js +1 -1
  90. package/dist/loader/unispec-loader.d.ts +2 -2
  91. package/dist/loader/unispec-loader.js +3 -3
  92. package/dist/loader/yaml-loader.d.ts +1 -1
  93. package/dist/loader/yaml-loader.js +1 -1
  94. package/dist/normalizer/core.d.ts +2 -2
  95. package/dist/normalizer/core.js +11 -6
  96. package/dist/normalizer/graphql-normalizer.d.ts +1 -1
  97. package/dist/normalizer/index.d.ts +2 -2
  98. package/dist/normalizer/index.js +1 -1
  99. package/dist/normalizer/rest-normalizer.d.ts +1 -1
  100. package/dist/normalizer/types.d.ts +1 -1
  101. package/dist/normalizer/utils.d.ts +6 -3
  102. package/dist/normalizer/utils.js +23 -7
  103. package/dist/normalizer/websocket-normalizer.d.ts +1 -1
  104. package/dist/optimizer/core.d.ts +2 -2
  105. package/dist/optimizer/core.js +35 -10
  106. package/dist/optimizer/index.d.ts +4 -4
  107. package/dist/optimizer/index.js +3 -3
  108. package/dist/optimizer/optimization-functions.d.ts +2 -2
  109. package/dist/optimizer/optimization-functions.js +2 -2
  110. package/dist/optimizer/types.d.ts +1 -1
  111. package/dist/schemas/dedupe.d.ts +1 -1
  112. package/dist/schemas/dedupe.js +27 -14
  113. package/dist/schemas/index.d.ts +3 -3
  114. package/dist/schemas/index.js +3 -3
  115. package/dist/schemas/resolver.d.ts +1 -1
  116. package/dist/schemas/resolver.js +3 -2
  117. package/dist/types/index.d.ts +2 -1
  118. package/dist/validator/ajv-validator.d.ts +1 -1
  119. package/dist/validator/ajv-validator.js +1 -1
  120. package/dist/validator/config-validator-main.d.ts +2 -2
  121. package/dist/validator/config-validator-main.js +4 -4
  122. package/dist/validator/config-validator.d.ts +1 -1
  123. package/dist/validator/config-validator.js +1 -1
  124. package/dist/validator/index.d.ts +10 -10
  125. package/dist/validator/index.js +7 -7
  126. package/dist/validator/reference-validator.d.ts +1 -1
  127. package/dist/validator/reference-validator.js +1 -1
  128. package/dist/validator/schema-references.d.ts +1 -1
  129. package/dist/validator/semantic-validator.d.ts +1 -1
  130. package/dist/validator/tests-validator.d.ts +2 -2
  131. package/dist/validator/tests-validator.js +2 -2
  132. package/dist/validator/types.d.ts +3 -3
  133. package/dist/validator/unispec-validator.d.ts +2 -2
  134. package/dist/validator/unispec-validator.js +7 -11
  135. package/dist/validator/validator-factory.d.ts +3 -3
  136. package/dist/validator/validator-factory.js +1 -1
  137. package/package.json +3 -3
  138. package/dist/cjs/src/cache/cache-factory.js +0 -72
  139. package/dist/cjs/src/cache/cache-manager.js +0 -128
  140. package/dist/cjs/src/cache/constants.js +0 -25
  141. package/dist/cjs/src/cache/hash-utils.js +0 -19
  142. package/dist/cjs/src/cache/hashing.js +0 -230
  143. package/dist/cjs/src/cache/index.js +0 -24
  144. package/dist/cjs/src/cache/lru-cache.js +0 -144
  145. package/dist/cjs/src/cache/types.js +0 -5
  146. package/dist/cjs/src/diff/annotators.js +0 -160
  147. package/dist/cjs/src/diff/change-reports.js +0 -369
  148. package/dist/cjs/src/diff/core.js +0 -158
  149. package/dist/cjs/src/diff/enhanced-diff.js +0 -65
  150. package/dist/cjs/src/diff/impact-strategies-refactored.js +0 -230
  151. package/dist/cjs/src/diff/impact-strategies.js +0 -219
  152. package/dist/cjs/src/diff/index.js +0 -27
  153. package/dist/cjs/src/diff/metrics-calculator.js +0 -69
  154. package/dist/cjs/src/diff/risk-calculator.js +0 -58
  155. package/dist/cjs/src/diff/suggestion-generator.js +0 -78
  156. package/dist/cjs/src/diff/types.js +0 -11
  157. package/dist/cjs/src/errors/base-error.js +0 -33
  158. package/dist/cjs/src/errors/config-error.js +0 -11
  159. package/dist/cjs/src/errors/error-factory.js +0 -48
  160. package/dist/cjs/src/errors/index.js +0 -19
  161. package/dist/cjs/src/errors/loader-error.js +0 -11
  162. package/dist/cjs/src/errors/reference-error.js +0 -11
  163. package/dist/cjs/src/errors/schema-error.js +0 -11
  164. package/dist/cjs/src/errors/security-error.js +0 -11
  165. package/dist/cjs/src/errors/semantic-error.js +0 -11
  166. package/dist/cjs/src/generated-schemas.js +0 -2100
  167. package/dist/cjs/src/index.js +0 -59
  168. package/dist/cjs/src/loader/index.js +0 -13
  169. package/dist/cjs/src/loader/security-validator.js +0 -53
  170. package/dist/cjs/src/loader/types.js +0 -11
  171. package/dist/cjs/src/loader/unispec-loader.js +0 -84
  172. package/dist/cjs/src/loader/yaml-loader.js +0 -76
  173. package/dist/cjs/src/normalizer/core.js +0 -37
  174. package/dist/cjs/src/normalizer/graphql-normalizer.js +0 -67
  175. package/dist/cjs/src/normalizer/index.js +0 -7
  176. package/dist/cjs/src/normalizer/rest-normalizer.js +0 -51
  177. package/dist/cjs/src/normalizer/types.js +0 -2
  178. package/dist/cjs/src/normalizer/utils.js +0 -49
  179. package/dist/cjs/src/normalizer/websocket-normalizer.js +0 -81
  180. package/dist/cjs/src/optimizer/core.js +0 -140
  181. package/dist/cjs/src/optimizer/index.js +0 -17
  182. package/dist/cjs/src/optimizer/optimization-functions.js +0 -185
  183. package/dist/cjs/src/optimizer/types.js +0 -2
  184. package/dist/cjs/src/optimizer/utils.js +0 -32
  185. package/dist/cjs/src/schemas/dedupe.js +0 -113
  186. package/dist/cjs/src/schemas/index.js +0 -14
  187. package/dist/cjs/src/schemas/resolver.js +0 -42
  188. package/dist/cjs/src/schemas/utils.js +0 -53
  189. package/dist/cjs/src/types/index.js +0 -2
  190. package/dist/cjs/src/validator/ajv-validator.js +0 -82
  191. package/dist/cjs/src/validator/config-validator-main.js +0 -34
  192. package/dist/cjs/src/validator/config-validator.js +0 -17
  193. package/dist/cjs/src/validator/index.js +0 -23
  194. package/dist/cjs/src/validator/object-traversal.js +0 -112
  195. package/dist/cjs/src/validator/reference-validator.js +0 -233
  196. package/dist/cjs/src/validator/schema-references.js +0 -116
  197. package/dist/cjs/src/validator/semantic-validator.js +0 -328
  198. package/dist/cjs/src/validator/tests-validator.js +0 -16
  199. package/dist/cjs/src/validator/types.js +0 -2
  200. package/dist/cjs/src/validator/unispec-validator.js +0 -80
  201. package/dist/cjs/src/validator/validator-factory.js +0 -77
  202. package/dist/cjs/src/versions.js +0 -147
  203. package/dist/cjs/tests/cache/cache.test.js +0 -274
  204. package/dist/cjs/tests/cache/utils.js +0 -32
  205. package/dist/cjs/tests/concurrency-normalizer-optimizer.test.js +0 -1
  206. package/dist/cjs/tests/diff/diff-annotators.test.js +0 -280
  207. package/dist/cjs/tests/diff/diff-comprehensive.test.js +0 -262
  208. package/dist/cjs/tests/diff/diff-extended.test.js +0 -235
  209. package/dist/cjs/tests/diff/diff.test.js +0 -189
  210. package/dist/cjs/tests/diff/utils.js +0 -8
  211. package/dist/cjs/tests/errors/errors-integration.test.js +0 -173
  212. package/dist/cjs/tests/errors/errors.test.js +0 -280
  213. package/dist/cjs/tests/errors/utils.js +0 -7
  214. package/dist/cjs/tests/loader/integration.test.js +0 -216
  215. package/dist/cjs/tests/loader/loader.test.js +0 -341
  216. package/dist/cjs/tests/normalizer/normalizer-comprehensive.test.js +0 -648
  217. package/dist/cjs/tests/normalizer/normalizer-invalid.test.js +0 -258
  218. package/dist/cjs/tests/normalizer/normalizer-valid.test.js +0 -238
  219. package/dist/cjs/tests/normalizer/utils.js +0 -47
  220. package/dist/cjs/tests/optimizer/compress-references.test.js +0 -304
  221. package/dist/cjs/tests/optimizer/deduplication.test.js +0 -132
  222. package/dist/cjs/tests/optimizer/integration.test.js +0 -131
  223. package/dist/cjs/tests/optimizer/optimization-report.test.js +0 -222
  224. package/dist/cjs/tests/optimizer/optimize-document.test.js +0 -187
  225. package/dist/cjs/tests/optimizer/orphaned-schemas.test.js +0 -194
  226. package/dist/cjs/tests/optimizer/sort-schemas.test.js +0 -131
  227. package/dist/cjs/tests/optimizer/utils.js +0 -209
  228. package/dist/cjs/tests/schemas/schemas-edge-cases.test.js +0 -223
  229. package/dist/cjs/tests/schemas/schemas.test.js +0 -400
  230. package/dist/cjs/tests/schemas/utils.js +0 -7
  231. package/dist/cjs/tests/utils.js +0 -131
  232. package/dist/cjs/tests/validator/config-validator.test.js +0 -78
  233. package/dist/cjs/tests/validator/debug-config.js +0 -1
  234. package/dist/cjs/tests/validator/debug-missing-service.js +0 -1
  235. package/dist/cjs/tests/validator/debug-other-configs.js +0 -1
  236. package/dist/cjs/tests/validator/debug-references.js +0 -1
  237. package/dist/cjs/tests/validator/unispec-validator.test.js +0 -103
  238. package/dist/cjs/tests/validator/utils.js +0 -25
  239. package/dist/src/cache/cache-factory.d.ts +0 -31
  240. package/dist/src/cache/cache-factory.js +0 -65
  241. package/dist/src/cache/cache-manager.d.ts +0 -62
  242. package/dist/src/cache/cache-manager.js +0 -124
  243. package/dist/src/cache/constants.d.ts +0 -21
  244. package/dist/src/cache/constants.js +0 -22
  245. package/dist/src/cache/hash-utils.d.ts +0 -11
  246. package/dist/src/cache/hash-utils.js +0 -15
  247. package/dist/src/cache/hashing.d.ts +0 -28
  248. package/dist/src/cache/hashing.js +0 -193
  249. package/dist/src/cache/index.d.ts +0 -6
  250. package/dist/src/cache/index.js +0 -10
  251. package/dist/src/cache/lru-cache.d.ts +0 -44
  252. package/dist/src/cache/lru-cache.js +0 -140
  253. package/dist/src/cache/types.d.ts +0 -24
  254. package/dist/src/cache/types.js +0 -4
  255. package/dist/src/diff/annotators.d.ts +0 -4
  256. package/dist/src/diff/annotators.js +0 -155
  257. package/dist/src/diff/change-reports.d.ts +0 -37
  258. package/dist/src/diff/change-reports.js +0 -366
  259. package/dist/src/diff/core.d.ts +0 -26
  260. package/dist/src/diff/core.js +0 -155
  261. package/dist/src/diff/enhanced-diff.d.ts +0 -51
  262. package/dist/src/diff/enhanced-diff.js +0 -62
  263. package/dist/src/diff/impact-strategies-refactored.d.ts +0 -69
  264. package/dist/src/diff/impact-strategies-refactored.js +0 -223
  265. package/dist/src/diff/impact-strategies.d.ts +0 -41
  266. package/dist/src/diff/impact-strategies.js +0 -212
  267. package/dist/src/diff/index.d.ts +0 -8
  268. package/dist/src/diff/index.js +0 -11
  269. package/dist/src/diff/metrics-calculator.d.ts +0 -23
  270. package/dist/src/diff/metrics-calculator.js +0 -65
  271. package/dist/src/diff/risk-calculator.d.ts +0 -23
  272. package/dist/src/diff/risk-calculator.js +0 -55
  273. package/dist/src/diff/suggestion-generator.d.ts +0 -18
  274. package/dist/src/diff/suggestion-generator.js +0 -74
  275. package/dist/src/diff/types.d.ts +0 -24
  276. package/dist/src/diff/types.js +0 -8
  277. package/dist/src/errors/base-error.d.ts +0 -20
  278. package/dist/src/errors/base-error.js +0 -29
  279. package/dist/src/errors/config-error.d.ts +0 -4
  280. package/dist/src/errors/config-error.js +0 -7
  281. package/dist/src/errors/error-factory.d.ts +0 -22
  282. package/dist/src/errors/error-factory.js +0 -45
  283. package/dist/src/errors/index.d.ts +0 -8
  284. package/dist/src/errors/index.js +0 -8
  285. package/dist/src/errors/loader-error.d.ts +0 -4
  286. package/dist/src/errors/loader-error.js +0 -7
  287. package/dist/src/errors/reference-error.d.ts +0 -4
  288. package/dist/src/errors/reference-error.js +0 -7
  289. package/dist/src/errors/schema-error.d.ts +0 -4
  290. package/dist/src/errors/schema-error.js +0 -7
  291. package/dist/src/errors/security-error.d.ts +0 -4
  292. package/dist/src/errors/security-error.js +0 -7
  293. package/dist/src/errors/semantic-error.d.ts +0 -4
  294. package/dist/src/errors/semantic-error.js +0 -7
  295. package/dist/src/generated-schemas.d.ts +0 -2073
  296. package/dist/src/generated-schemas.js +0 -2097
  297. package/dist/src/index.d.ts +0 -13
  298. package/dist/src/index.js +0 -43
  299. package/dist/src/loader/index.d.ts +0 -5
  300. package/dist/src/loader/index.js +0 -5
  301. package/dist/src/loader/security-validator.d.ts +0 -5
  302. package/dist/src/loader/security-validator.js +0 -50
  303. package/dist/src/loader/types.d.ts +0 -30
  304. package/dist/src/loader/types.js +0 -8
  305. package/dist/src/loader/unispec-loader.d.ts +0 -10
  306. package/dist/src/loader/unispec-loader.js +0 -81
  307. package/dist/src/loader/yaml-loader.d.ts +0 -10
  308. package/dist/src/loader/yaml-loader.js +0 -39
  309. package/dist/src/normalizer/core.d.ts +0 -24
  310. package/dist/src/normalizer/core.js +0 -34
  311. package/dist/src/normalizer/graphql-normalizer.d.ts +0 -8
  312. package/dist/src/normalizer/graphql-normalizer.js +0 -64
  313. package/dist/src/normalizer/index.d.ts +0 -2
  314. package/dist/src/normalizer/index.js +0 -3
  315. package/dist/src/normalizer/rest-normalizer.d.ts +0 -8
  316. package/dist/src/normalizer/rest-normalizer.js +0 -48
  317. package/dist/src/normalizer/types.d.ts +0 -7
  318. package/dist/src/normalizer/types.js +0 -1
  319. package/dist/src/normalizer/utils.d.ts +0 -17
  320. package/dist/src/normalizer/utils.js +0 -45
  321. package/dist/src/normalizer/websocket-normalizer.d.ts +0 -8
  322. package/dist/src/normalizer/websocket-normalizer.js +0 -78
  323. package/dist/src/optimizer/core.d.ts +0 -17
  324. package/dist/src/optimizer/core.js +0 -136
  325. package/dist/src/optimizer/index.d.ts +0 -4
  326. package/dist/src/optimizer/index.js +0 -7
  327. package/dist/src/optimizer/optimization-functions.d.ts +0 -32
  328. package/dist/src/optimizer/optimization-functions.js +0 -179
  329. package/dist/src/optimizer/types.d.ts +0 -28
  330. package/dist/src/optimizer/types.js +0 -1
  331. package/dist/src/optimizer/utils.d.ts +0 -7
  332. package/dist/src/optimizer/utils.js +0 -29
  333. package/dist/src/schemas/dedupe.d.ts +0 -9
  334. package/dist/src/schemas/dedupe.js +0 -110
  335. package/dist/src/schemas/index.d.ts +0 -3
  336. package/dist/src/schemas/index.js +0 -6
  337. package/dist/src/schemas/resolver.d.ts +0 -19
  338. package/dist/src/schemas/resolver.js +0 -38
  339. package/dist/src/schemas/utils.d.ts +0 -20
  340. package/dist/src/schemas/utils.js +0 -49
  341. package/dist/src/types/index.d.ts +0 -434
  342. package/dist/src/types/index.js +0 -1
  343. package/dist/src/validator/ajv-validator.d.ts +0 -15
  344. package/dist/src/validator/ajv-validator.js +0 -75
  345. package/dist/src/validator/config-validator-main.d.ts +0 -10
  346. package/dist/src/validator/config-validator-main.js +0 -31
  347. package/dist/src/validator/config-validator.d.ts +0 -5
  348. package/dist/src/validator/config-validator.js +0 -14
  349. package/dist/src/validator/index.d.ts +0 -10
  350. package/dist/src/validator/index.js +0 -11
  351. package/dist/src/validator/object-traversal.d.ts +0 -52
  352. package/dist/src/validator/object-traversal.js +0 -104
  353. package/dist/src/validator/reference-validator.d.ts +0 -31
  354. package/dist/src/validator/reference-validator.js +0 -230
  355. package/dist/src/validator/schema-references.d.ts +0 -23
  356. package/dist/src/validator/schema-references.js +0 -111
  357. package/dist/src/validator/semantic-validator.d.ts +0 -26
  358. package/dist/src/validator/semantic-validator.js +0 -325
  359. package/dist/src/validator/tests-validator.d.ts +0 -9
  360. package/dist/src/validator/tests-validator.js +0 -13
  361. package/dist/src/validator/types.d.ts +0 -29
  362. package/dist/src/validator/types.js +0 -1
  363. package/dist/src/validator/unispec-validator.d.ts +0 -15
  364. package/dist/src/validator/unispec-validator.js +0 -77
  365. package/dist/src/validator/validator-factory.d.ts +0 -10
  366. package/dist/src/validator/validator-factory.js +0 -73
  367. package/dist/src/versions.d.ts +0 -10
  368. package/dist/src/versions.js +0 -143
  369. package/dist/tests/cache/cache.test.d.ts +0 -1
  370. package/dist/tests/cache/cache.test.js +0 -269
  371. package/dist/tests/cache/utils.d.ts +0 -4
  372. package/dist/tests/cache/utils.js +0 -24
  373. package/dist/tests/concurrency-normalizer-optimizer.test.d.ts +0 -0
  374. package/dist/tests/concurrency-normalizer-optimizer.test.js +0 -1
  375. package/dist/tests/diff/diff-annotators.test.d.ts +0 -1
  376. package/dist/tests/diff/diff-annotators.test.js +0 -275
  377. package/dist/tests/diff/diff-comprehensive.test.d.ts +0 -1
  378. package/dist/tests/diff/diff-comprehensive.test.js +0 -257
  379. package/dist/tests/diff/diff-extended.test.d.ts +0 -1
  380. package/dist/tests/diff/diff-extended.test.js +0 -230
  381. package/dist/tests/diff/diff.test.d.ts +0 -1
  382. package/dist/tests/diff/diff.test.js +0 -184
  383. package/dist/tests/diff/utils.d.ts +0 -2
  384. package/dist/tests/diff/utils.js +0 -3
  385. package/dist/tests/errors/errors-integration.test.d.ts +0 -1
  386. package/dist/tests/errors/errors-integration.test.js +0 -168
  387. package/dist/tests/errors/errors.test.d.ts +0 -1
  388. package/dist/tests/errors/errors.test.js +0 -275
  389. package/dist/tests/errors/utils.d.ts +0 -2
  390. package/dist/tests/errors/utils.js +0 -3
  391. package/dist/tests/loader/integration.test.d.ts +0 -1
  392. package/dist/tests/loader/integration.test.js +0 -211
  393. package/dist/tests/loader/loader.test.d.ts +0 -1
  394. package/dist/tests/loader/loader.test.js +0 -336
  395. package/dist/tests/normalizer/normalizer-comprehensive.test.d.ts +0 -1
  396. package/dist/tests/normalizer/normalizer-comprehensive.test.js +0 -643
  397. package/dist/tests/normalizer/normalizer-invalid.test.d.ts +0 -1
  398. package/dist/tests/normalizer/normalizer-invalid.test.js +0 -253
  399. package/dist/tests/normalizer/normalizer-valid.test.d.ts +0 -1
  400. package/dist/tests/normalizer/normalizer-valid.test.js +0 -233
  401. package/dist/tests/normalizer/utils.d.ts +0 -18
  402. package/dist/tests/normalizer/utils.js +0 -36
  403. package/dist/tests/optimizer/compress-references.test.d.ts +0 -1
  404. package/dist/tests/optimizer/compress-references.test.js +0 -299
  405. package/dist/tests/optimizer/deduplication.test.d.ts +0 -1
  406. package/dist/tests/optimizer/deduplication.test.js +0 -127
  407. package/dist/tests/optimizer/integration.test.d.ts +0 -1
  408. package/dist/tests/optimizer/integration.test.js +0 -126
  409. package/dist/tests/optimizer/optimization-report.test.d.ts +0 -1
  410. package/dist/tests/optimizer/optimization-report.test.js +0 -217
  411. package/dist/tests/optimizer/optimize-document.test.d.ts +0 -1
  412. package/dist/tests/optimizer/optimize-document.test.js +0 -182
  413. package/dist/tests/optimizer/orphaned-schemas.test.d.ts +0 -1
  414. package/dist/tests/optimizer/orphaned-schemas.test.js +0 -189
  415. package/dist/tests/optimizer/sort-schemas.test.d.ts +0 -1
  416. package/dist/tests/optimizer/sort-schemas.test.js +0 -126
  417. package/dist/tests/optimizer/utils.d.ts +0 -8
  418. package/dist/tests/optimizer/utils.js +0 -199
  419. package/dist/tests/schemas/schemas-edge-cases.test.d.ts +0 -1
  420. package/dist/tests/schemas/schemas-edge-cases.test.js +0 -218
  421. package/dist/tests/schemas/schemas.test.d.ts +0 -1
  422. package/dist/tests/schemas/schemas.test.js +0 -395
  423. package/dist/tests/schemas/utils.d.ts +0 -2
  424. package/dist/tests/schemas/utils.js +0 -3
  425. package/dist/tests/utils.d.ts +0 -10
  426. package/dist/tests/utils.js +0 -118
  427. package/dist/tests/validator/config-validator.test.d.ts +0 -1
  428. package/dist/tests/validator/config-validator.test.js +0 -73
  429. package/dist/tests/validator/debug-config.d.ts +0 -0
  430. package/dist/tests/validator/debug-config.js +0 -1
  431. package/dist/tests/validator/debug-missing-service.d.ts +0 -0
  432. package/dist/tests/validator/debug-missing-service.js +0 -1
  433. package/dist/tests/validator/debug-other-configs.d.ts +0 -0
  434. package/dist/tests/validator/debug-other-configs.js +0 -1
  435. package/dist/tests/validator/debug-references.d.ts +0 -0
  436. package/dist/tests/validator/debug-references.js +0 -1
  437. package/dist/tests/validator/unispec-validator.test.d.ts +0 -1
  438. package/dist/tests/validator/unispec-validator.test.js +0 -98
  439. package/dist/tests/validator/utils.d.ts +0 -6
  440. package/dist/tests/validator/utils.js +0 -20
@@ -1,140 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.optimizeDocument = optimizeDocument;
4
- exports.generateOptimizationReport = generateOptimizationReport;
5
- const schemas_1 = require("../schemas/index.js");
6
- const optimization_functions_1 = require("./optimization-functions.js");
7
- /**
8
- * Optimize a UniSpec document with various optimization strategies.
9
- *
10
- * @param doc - The UniSpec document to optimize
11
- * @param options - Optimization options
12
- * @returns Optimization result with statistics and changes
13
- */
14
- function optimizeDocument(doc, options = {}) {
15
- const changes = [];
16
- const originalSchemaCount = Object.keys(doc.service?.schemas || {}).length;
17
- // Create a deep copy to avoid mutating the original
18
- const optimizedDoc = JSON.parse(JSON.stringify(doc));
19
- // Ensure service and schemas exist
20
- if (!optimizedDoc.service) {
21
- optimizedDoc.service = { name: "" };
22
- }
23
- if (!optimizedDoc.service.schemas) {
24
- optimizedDoc.service.schemas = {};
25
- }
26
- let deduplicatedCount = 0;
27
- // Apply optimizations in order
28
- if (options.dedupeSchemas !== false) {
29
- const dedupResult = (0, optimization_functions_1.deduplicateSchemas)(optimizedDoc);
30
- if (dedupResult.removedSchemas.length > 0) {
31
- changes.push(`Deduplicated ${dedupResult.removedSchemas.length} schemas: ${dedupResult.removedSchemas.join(", ")}`);
32
- changes.push(`Updated ${dedupResult.updatedReferences} schema references`);
33
- deduplicatedCount = dedupResult.removedSchemas.length;
34
- }
35
- }
36
- if (options.removeUnusedSchemas === true) {
37
- const removed = (0, optimization_functions_1.removeOrphanedSchemas)(optimizedDoc);
38
- if (removed.length > 0) {
39
- changes.push(`Removed ${removed.length} orphaned schemas: ${removed.join(", ")}`);
40
- }
41
- }
42
- if (options.sortSchemas !== false) {
43
- const sortedCount = (0, optimization_functions_1.sortSchemas)(optimizedDoc);
44
- if (sortedCount > 0) {
45
- changes.push(`Sorted ${sortedCount} schemas alphabetically`);
46
- }
47
- }
48
- if (options.compressReferences !== false) {
49
- const compressedCount = (0, optimization_functions_1.compressSchemaReferences)(optimizedDoc);
50
- if (compressedCount > 0) {
51
- changes.push(`Compressed ${compressedCount} schema references`);
52
- }
53
- }
54
- const finalSchemaCount = Object.keys(optimizedDoc.service.schemas).length;
55
- return {
56
- document: optimizedDoc,
57
- statistics: {
58
- originalSchemas: originalSchemaCount,
59
- optimizedSchemas: finalSchemaCount,
60
- removedSchemas: originalSchemaCount - finalSchemaCount,
61
- deduplicatedSchemas: deduplicatedCount,
62
- },
63
- changes,
64
- };
65
- }
66
- /**
67
- * Generate optimization report for a UniSpec document.
68
- *
69
- * @param doc - The UniSpec document to analyze
70
- * @returns Optimization recommendations
71
- */
72
- function generateOptimizationReport(doc) {
73
- const recommendations = [];
74
- // Create copies for analysis to avoid mutating original
75
- const docForDedup = JSON.parse(JSON.stringify(doc));
76
- const _docForOrphaned = JSON.parse(JSON.stringify(doc));
77
- // First find duplicates
78
- const dedupResult = (0, optimization_functions_1.deduplicateSchemas)(docForDedup);
79
- // Find orphaned schemas that are NOT duplicates
80
- const allSchemas = Object.keys(doc.service?.schemas || {});
81
- const duplicateNames = new Set(dedupResult.removedSchemas);
82
- // Find referenced schemas
83
- const referencedSchemas = new Set();
84
- function findReferences(obj) {
85
- if (!obj || typeof obj !== "object")
86
- return;
87
- for (const [key, value] of Object.entries(obj)) {
88
- if (key === "schemaRef" && typeof value === "string") {
89
- const schemaName = (0, schemas_1.normalizeSchemaRef)(value);
90
- if (schemaName)
91
- referencedSchemas.add(schemaName);
92
- }
93
- else if (typeof value === "object" && value !== null) {
94
- findReferences(value);
95
- }
96
- }
97
- }
98
- findReferences(doc);
99
- // Find orphaned schemas that are not duplicates
100
- const orphaned = allSchemas.filter((name) => !referencedSchemas.has(name) && !duplicateNames.has(name));
101
- if (orphaned.length > 0) {
102
- recommendations.push(`Remove ${orphaned.length} orphaned schemas to reduce document size`);
103
- }
104
- if (dedupResult.removedSchemas.length > 0) {
105
- recommendations.push(`Deduplicate ${dedupResult.removedSchemas.length} identical schemas`);
106
- }
107
- const totalSchemas = Object.keys(doc.service?.schemas || {}).length;
108
- const potentialReduction = orphaned.length + dedupResult.removedSchemas.length;
109
- // Calculate reference compression savings only if there are schema references
110
- let referenceCompression = 0;
111
- if (totalSchemas > 0) {
112
- // Count actual schema references to estimate compression savings
113
- let referenceCount = 0;
114
- function countReferences(obj) {
115
- if (!obj || typeof obj !== "object")
116
- return;
117
- for (const [key, value] of Object.entries(obj)) {
118
- if (key === "schemaRef" && typeof value === "string") {
119
- referenceCount++;
120
- }
121
- else if (typeof value === "object" && value !== null) {
122
- countReferences(value);
123
- }
124
- }
125
- }
126
- countReferences(doc);
127
- // Only estimate compression if there are references to compress
128
- if (referenceCount > 1) {
129
- referenceCompression = Math.min(referenceCount * 0.1, totalSchemas * 0.1);
130
- }
131
- }
132
- const result = {
133
- recommendations,
134
- potentialSavings: {
135
- schemaReduction: potentialReduction,
136
- referenceCompression,
137
- },
138
- };
139
- return result;
140
- }
@@ -1,17 +0,0 @@
1
- "use strict";
2
- // Export types
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.compressReference = exports.sortSchemas = exports.removeOrphanedSchemas = exports.deduplicateSchemas = exports.compressSchemaReferences = exports.optimizeDocument = exports.generateOptimizationReport = void 0;
5
- // Export core functions
6
- var core_1 = require("./core.js");
7
- Object.defineProperty(exports, "generateOptimizationReport", { enumerable: true, get: function () { return core_1.generateOptimizationReport; } });
8
- Object.defineProperty(exports, "optimizeDocument", { enumerable: true, get: function () { return core_1.optimizeDocument; } });
9
- // Export optimization functions
10
- var optimization_functions_1 = require("./optimization-functions.js");
11
- Object.defineProperty(exports, "compressSchemaReferences", { enumerable: true, get: function () { return optimization_functions_1.compressSchemaReferences; } });
12
- Object.defineProperty(exports, "deduplicateSchemas", { enumerable: true, get: function () { return optimization_functions_1.deduplicateSchemas; } });
13
- Object.defineProperty(exports, "removeOrphanedSchemas", { enumerable: true, get: function () { return optimization_functions_1.removeOrphanedSchemas; } });
14
- Object.defineProperty(exports, "sortSchemas", { enumerable: true, get: function () { return optimization_functions_1.sortSchemas; } });
15
- // Export utilities
16
- var utils_1 = require("./utils.js");
17
- Object.defineProperty(exports, "compressReference", { enumerable: true, get: function () { return utils_1.compressReference; } });
@@ -1,185 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deduplicateSchemas = deduplicateSchemas;
4
- exports.removeOrphanedSchemas = removeOrphanedSchemas;
5
- exports.sortSchemas = sortSchemas;
6
- exports.compressSchemaReferences = compressSchemaReferences;
7
- const schemas_1 = require("../schemas/index.js");
8
- const utils_1 = require("./utils.js");
9
- /**
10
- * Remove duplicate schemas from a UniSpec document.
11
- * Duplicates are identified by identical JSON Schema content.
12
- * Updates all schema references to point to the retained schema.
13
- *
14
- * @param doc - The UniSpec document to deduplicate
15
- * @returns Object with deduplication statistics
16
- */
17
- function deduplicateSchemas(doc) {
18
- if (!doc.service?.schemas) {
19
- return { removedSchemas: [], updatedReferences: 0 };
20
- }
21
- // First, find all referenced schemas
22
- const referencedSchemas = new Set();
23
- function findReferences(obj) {
24
- if (!obj || typeof obj !== "object")
25
- return;
26
- for (const [key, value] of Object.entries(obj)) {
27
- if (key === "schemaRef" && typeof value === "string") {
28
- const schemaName = (0, schemas_1.normalizeSchemaRef)(value);
29
- if (schemaName)
30
- referencedSchemas.add(schemaName);
31
- }
32
- else if (typeof value === "object" && value !== null) {
33
- findReferences(value);
34
- }
35
- }
36
- }
37
- findReferences(doc);
38
- const names = Object.keys(doc.service.schemas);
39
- const hashToName = new Map();
40
- const renameMap = {};
41
- const removedSchemas = [];
42
- for (const name of names) {
43
- const schema = doc.service.schemas[name];
44
- // Only hash the jsonSchema content, not the name field
45
- const hash = (0, schemas_1.stableStringify)(schema?.jsonSchema ?? null);
46
- const existing = hashToName.get(hash);
47
- if (!existing) {
48
- hashToName.set(hash, name);
49
- continue;
50
- }
51
- // Found duplicate - prefer referenced schema over unreferenced one
52
- const existingIsReferenced = referencedSchemas.has(existing);
53
- const currentIsReferenced = referencedSchemas.has(name);
54
- if (existingIsReferenced && !currentIsReferenced) {
55
- // Keep existing, remove current
56
- renameMap[name] = existing;
57
- removedSchemas.push(name);
58
- }
59
- else if (!existingIsReferenced && currentIsReferenced) {
60
- // Keep current, remove existing
61
- renameMap[existing] = name;
62
- removedSchemas.push(existing);
63
- hashToName.set(hash, name); // Update to current as preferred
64
- }
65
- else {
66
- // Both referenced or both unreferenced - keep first encountered
67
- renameMap[name] = existing;
68
- removedSchemas.push(name);
69
- }
70
- }
71
- if (removedSchemas.length === 0) {
72
- return { removedSchemas: [], updatedReferences: 0 };
73
- }
74
- // Update all schema references
75
- let updatedReferences = 0;
76
- function updateReferences(obj, path = "") {
77
- if (!obj || typeof obj !== "object")
78
- return;
79
- const objRecord = obj;
80
- for (const [key, value] of Object.entries(objRecord)) {
81
- const currentPath = path ? `${path}.${key}` : key;
82
- if (key === "schemaRef" && typeof value === "string") {
83
- const schemaName = (0, schemas_1.normalizeSchemaRef)(value);
84
- if (renameMap[schemaName]) {
85
- objRecord[key] = renameMap[schemaName];
86
- updatedReferences++;
87
- }
88
- }
89
- else if (typeof value === "object" && value !== null) {
90
- updateReferences(value, currentPath);
91
- }
92
- }
93
- }
94
- updateReferences(doc);
95
- // Remove duplicate schemas
96
- for (const dup of removedSchemas) {
97
- delete doc.service.schemas[dup];
98
- }
99
- return { removedSchemas, updatedReferences };
100
- }
101
- /**
102
- * Remove orphaned schemas (not referenced anywhere).
103
- *
104
- * @param doc - The UniSpec document to optimize
105
- * @returns Array of removed schema names
106
- */
107
- function removeOrphanedSchemas(doc) {
108
- if (!doc.service?.schemas)
109
- return [];
110
- const referencedSchemas = new Set();
111
- // Find all referenced schemas
112
- function findReferences(obj) {
113
- if (!obj || typeof obj !== "object")
114
- return;
115
- for (const [key, value] of Object.entries(obj)) {
116
- if (key === "schemaRef" && typeof value === "string") {
117
- const schemaName = (0, schemas_1.normalizeSchemaRef)(value);
118
- if (schemaName)
119
- referencedSchemas.add(schemaName);
120
- }
121
- else if (typeof value === "object" && value !== null) {
122
- findReferences(value);
123
- }
124
- }
125
- }
126
- findReferences(doc);
127
- // Remove orphaned schemas
128
- const allSchemas = Object.keys(doc.service.schemas);
129
- const orphaned = allSchemas.filter((schema) => !referencedSchemas.has(schema));
130
- for (const orphan of orphaned) {
131
- delete doc.service.schemas[orphan];
132
- }
133
- return orphaned;
134
- }
135
- /**
136
- * Sort schemas alphabetically by name for consistent output.
137
- *
138
- * @param doc - The UniSpec document to optimize
139
- * @returns Number of schemas sorted
140
- */
141
- function sortSchemas(doc) {
142
- if (!doc.service?.schemas)
143
- return 0;
144
- const schemaNames = Object.keys(doc.service.schemas);
145
- if (schemaNames.length === 0)
146
- return 0;
147
- const sortedSchemas = {};
148
- schemaNames.sort().forEach((name) => {
149
- const schema = doc.service?.schemas?.[name];
150
- if (schema) {
151
- sortedSchemas[name] = schema;
152
- }
153
- });
154
- doc.service.schemas = sortedSchemas;
155
- return schemaNames.length;
156
- }
157
- /**
158
- * Compress schema references by using shortest possible format.
159
- *
160
- * @param doc - The UniSpec document to optimize
161
- * @returns Number of references compressed
162
- */
163
- function compressSchemaReferences(doc) {
164
- let compressedCount = 0;
165
- function compressReferences(obj) {
166
- if (!obj || typeof obj !== "object")
167
- return;
168
- const objRecord = obj;
169
- for (const [key, value] of Object.entries(objRecord)) {
170
- if (key === "schemaRef" && typeof value === "string") {
171
- const original = value;
172
- const compressed = (0, utils_1.compressReference)(original);
173
- if (compressed !== original) {
174
- objRecord[key] = compressed;
175
- compressedCount++;
176
- }
177
- }
178
- else if (typeof value === "object" && value !== null) {
179
- compressReferences(value);
180
- }
181
- }
182
- }
183
- compressReferences(doc);
184
- return compressedCount;
185
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.compressReference = compressReference;
4
- /**
5
- * Compress a single schema reference to its shortest form.
6
- *
7
- * @param ref - The schema reference to compress
8
- * @returns Compressed reference
9
- */
10
- function compressReference(ref) {
11
- const trimmed = ref.trim();
12
- if (trimmed.length === 0)
13
- return "";
14
- // If it's already a simple name, keep it
15
- if (!trimmed.startsWith("#") && !trimmed.includes("/")) {
16
- return trimmed;
17
- }
18
- // Convert JSON Pointer to simple name
19
- if (trimmed.startsWith("#/service/schemas/")) {
20
- const parts = trimmed.split("/");
21
- return parts[parts.length - 1];
22
- }
23
- // Convert hash format to simple name
24
- if (trimmed.startsWith("#")) {
25
- const withoutHash = trimmed.slice(1);
26
- const parts = withoutHash.split("/").filter(Boolean);
27
- return parts.length > 0 ? parts[parts.length - 1] : withoutHash;
28
- }
29
- // Convert path format to simple name
30
- const parts = trimmed.split("/").filter(Boolean);
31
- return parts.length > 0 ? parts[parts.length - 1] : trimmed;
32
- }
@@ -1,113 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.dedupeSchemas = dedupeSchemas;
4
- const utils_1 = require("./utils.js");
5
- function updateSchemaRefs(doc, mapping) {
6
- const rest = doc.service?.protocols?.rest;
7
- const websocket = doc.service?.protocols?.websocket;
8
- if (rest?.routes) {
9
- for (const route of rest.routes) {
10
- for (const params of [
11
- route.pathParams,
12
- route.queryParams,
13
- route.headers,
14
- ]) {
15
- if (!params)
16
- continue;
17
- for (const p of params) {
18
- if (!p.schemaRef)
19
- continue;
20
- const key = (0, utils_1.normalizeSchemaRef)(p.schemaRef);
21
- const next = mapping[key];
22
- if (next && next !== key)
23
- p.schemaRef = next;
24
- }
25
- }
26
- const requestContent = route.requestBody?.content;
27
- if (requestContent) {
28
- for (const media of Object.values(requestContent)) {
29
- if (!media.schemaRef)
30
- continue;
31
- const key = (0, utils_1.normalizeSchemaRef)(media.schemaRef);
32
- const next = mapping[key];
33
- if (next && next !== key)
34
- media.schemaRef = next;
35
- }
36
- }
37
- const responses = route.responses;
38
- if (responses) {
39
- for (const resp of Object.values(responses)) {
40
- const respContent = resp.content;
41
- if (!respContent)
42
- continue;
43
- for (const media of Object.values(respContent)) {
44
- if (!media.schemaRef)
45
- continue;
46
- const key = (0, utils_1.normalizeSchemaRef)(media.schemaRef);
47
- const next = mapping[key];
48
- if (next && next !== key)
49
- media.schemaRef = next;
50
- }
51
- }
52
- }
53
- }
54
- }
55
- if (websocket?.channels) {
56
- for (const channel of websocket.channels) {
57
- if (!channel.messages)
58
- continue;
59
- for (const message of channel.messages) {
60
- if (!message.schemaRef)
61
- continue;
62
- const key = (0, utils_1.normalizeSchemaRef)(message.schemaRef);
63
- const next = mapping[key];
64
- if (next && next !== key)
65
- message.schemaRef = next;
66
- }
67
- }
68
- }
69
- }
70
- /**
71
- * Remove duplicate schemas from a UniSpec document.
72
- * Duplicates are identified by identical JSON Schema content.
73
- * Updates all schema references to point to the retained schema.
74
- *
75
- * @param doc - The UniSpec document to deduplicate
76
- */
77
- function dedupeSchemas(doc) {
78
- if (!doc?.service?.schemas || typeof doc.service.schemas !== "object")
79
- return;
80
- const schemas = doc.service.schemas;
81
- const hashToName = new Map();
82
- const toDelete = [];
83
- // Find duplicates
84
- for (const name of Object.keys(schemas)) {
85
- const schema = schemas[name];
86
- const hash = (0, utils_1.stableStringify)(schema?.jsonSchema ?? null);
87
- const existing = hashToName.get(hash);
88
- if (!existing) {
89
- hashToName.set(hash, name);
90
- }
91
- else {
92
- // Mark for deletion - keep the first one encountered
93
- toDelete.push(name);
94
- }
95
- }
96
- // Update references before deleting
97
- if (toDelete.length > 0) {
98
- const renameMap = {};
99
- for (const dup of toDelete) {
100
- const schema = schemas[dup];
101
- const hash = (0, utils_1.stableStringify)(schema?.jsonSchema ?? null);
102
- const existing = hashToName.get(hash);
103
- if (existing) {
104
- renameMap[dup] = existing;
105
- }
106
- }
107
- updateSchemaRefs(doc, renameMap);
108
- // Delete duplicates
109
- for (const dup of toDelete) {
110
- delete schemas[dup];
111
- }
112
- }
113
- }
@@ -1,14 +0,0 @@
1
- "use strict";
2
- // Export utility functions
3
- Object.defineProperty(exports, "__esModule", { value: true });
4
- exports.stableStringify = exports.normalizeSchemaRef = exports.resolveSchemaRef = exports.registerSchema = exports.dedupeSchemas = void 0;
5
- // Export deduplication functions
6
- var dedupe_1 = require("./dedupe.js");
7
- Object.defineProperty(exports, "dedupeSchemas", { enumerable: true, get: function () { return dedupe_1.dedupeSchemas; } });
8
- // Export resolver functions
9
- var resolver_1 = require("./resolver.js");
10
- Object.defineProperty(exports, "registerSchema", { enumerable: true, get: function () { return resolver_1.registerSchema; } });
11
- Object.defineProperty(exports, "resolveSchemaRef", { enumerable: true, get: function () { return resolver_1.resolveSchemaRef; } });
12
- var utils_1 = require("./utils.js");
13
- Object.defineProperty(exports, "normalizeSchemaRef", { enumerable: true, get: function () { return utils_1.normalizeSchemaRef; } });
14
- Object.defineProperty(exports, "stableStringify", { enumerable: true, get: function () { return utils_1.stableStringify; } });
@@ -1,42 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.resolveSchemaRef = resolveSchemaRef;
4
- exports.registerSchema = registerSchema;
5
- const utils_1 = require("./utils.js");
6
- /**
7
- * Resolve a schema reference to its definition in a UniSpec document.
8
- *
9
- * @param doc - The UniSpec document containing schemas
10
- * @param ref - The schema reference to resolve
11
- * @returns The schema definition or undefined if not found
12
- */
13
- function resolveSchemaRef(doc, ref) {
14
- if (!doc)
15
- return undefined;
16
- const name = (0, utils_1.normalizeSchemaRef)(ref);
17
- if (!name)
18
- return undefined;
19
- return doc.service?.schemas?.[name];
20
- }
21
- /**
22
- * Register a new schema definition in a UniSpec document.
23
- * Creates the schemas container if it doesn't exist.
24
- *
25
- * @param doc - The UniSpec document to modify
26
- * @param name - The schema name
27
- * @param jsonSchema - The JSON Schema definition
28
- * @returns The created schema definition
29
- */
30
- function registerSchema(doc, name, jsonSchema) {
31
- if (!doc.service) {
32
- doc.service = { name: "" };
33
- }
34
- if (!doc.service.schemas) {
35
- doc.service.schemas = {};
36
- }
37
- const definition = {
38
- jsonSchema,
39
- };
40
- doc.service.schemas[name] = definition;
41
- return definition;
42
- }
@@ -1,53 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.normalizeSchemaRef = normalizeSchemaRef;
4
- exports.stableStringify = stableStringify;
5
- /**
6
- * Normalize a schema reference to extract the schema name.
7
- * Supports multiple formats:
8
- * - Simple name: "User"
9
- * - JSON Pointer: "#/service/schemas/User"
10
- * - Hash format: "#User"
11
- * - Path format: "path/to/User"
12
- *
13
- * @param ref - The schema reference to normalize
14
- * @returns The normalized schema name
15
- */
16
- function normalizeSchemaRef(ref) {
17
- const trimmed = ref.trim();
18
- if (trimmed.length === 0)
19
- return "";
20
- // Handle JSON Pointer format: #/service/schemas/SchemaName
21
- if (trimmed.startsWith("#/service/schemas/")) {
22
- const parts = trimmed.split("/");
23
- return parts[parts.length - 1];
24
- }
25
- // Handle simple name format: SchemaName
26
- const withoutHash = trimmed.startsWith("#") ? trimmed.slice(1) : trimmed;
27
- const parts = withoutHash.split("/").filter(Boolean);
28
- return parts.length > 0 ? parts[parts.length - 1] : withoutHash;
29
- }
30
- /**
31
- * Create a stable string representation of a value for comparison.
32
- * Used for schema deduplication by creating consistent JSON strings.
33
- *
34
- * @param value - The value to stringify
35
- * @returns A stable JSON string representation
36
- */
37
- function stableStringify(value) {
38
- if (value === null)
39
- return "null";
40
- const t = typeof value;
41
- if (t === "number" || t === "boolean")
42
- return JSON.stringify(value);
43
- if (t === "string")
44
- return JSON.stringify(value);
45
- if (Array.isArray(value))
46
- return `[${value.map(stableStringify).join(",")}]`;
47
- if (t !== "object")
48
- return JSON.stringify(value);
49
- const obj = value;
50
- const keys = Object.keys(obj).sort();
51
- const entries = keys.map((k) => `${JSON.stringify(k)}:${stableStringify(obj[k])}`);
52
- return `{${entries.join(",")}}`;
53
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });