@unispechq/unispec-core 0.3.0 → 0.3.2

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 (306) hide show
  1. package/dist/cjs/diff/annotators.js +36 -9
  2. package/dist/cjs/src/cache/cache-factory.js +72 -0
  3. package/dist/cjs/src/cache/cache-manager.js +128 -0
  4. package/dist/cjs/src/cache/constants.js +25 -0
  5. package/dist/cjs/src/cache/hash-utils.js +19 -0
  6. package/dist/cjs/src/cache/hashing.js +230 -0
  7. package/dist/cjs/src/cache/index.js +24 -0
  8. package/dist/cjs/src/cache/lru-cache.js +144 -0
  9. package/dist/cjs/src/cache/types.js +5 -0
  10. package/dist/cjs/src/diff/annotators.js +160 -0
  11. package/dist/cjs/src/diff/change-reports.js +369 -0
  12. package/dist/cjs/src/diff/core.js +158 -0
  13. package/dist/cjs/src/diff/enhanced-diff.js +65 -0
  14. package/dist/cjs/src/diff/impact-strategies-refactored.js +230 -0
  15. package/dist/cjs/src/diff/impact-strategies.js +219 -0
  16. package/dist/cjs/src/diff/index.js +27 -0
  17. package/dist/cjs/src/diff/metrics-calculator.js +69 -0
  18. package/dist/cjs/src/diff/risk-calculator.js +58 -0
  19. package/dist/cjs/src/diff/suggestion-generator.js +78 -0
  20. package/dist/cjs/src/diff/types.js +11 -0
  21. package/dist/cjs/src/errors/base-error.js +33 -0
  22. package/dist/cjs/src/errors/config-error.js +11 -0
  23. package/dist/cjs/src/errors/error-factory.js +48 -0
  24. package/dist/cjs/src/errors/index.js +19 -0
  25. package/dist/cjs/src/errors/loader-error.js +11 -0
  26. package/dist/cjs/src/errors/reference-error.js +11 -0
  27. package/dist/cjs/src/errors/schema-error.js +11 -0
  28. package/dist/cjs/src/errors/security-error.js +11 -0
  29. package/dist/cjs/src/errors/semantic-error.js +11 -0
  30. package/dist/cjs/src/generated-schemas.js +2100 -0
  31. package/dist/cjs/src/index.js +59 -0
  32. package/dist/cjs/src/loader/index.js +13 -0
  33. package/dist/cjs/src/loader/security-validator.js +53 -0
  34. package/dist/cjs/src/loader/types.js +11 -0
  35. package/dist/cjs/src/loader/unispec-loader.js +84 -0
  36. package/dist/cjs/src/loader/yaml-loader.js +76 -0
  37. package/dist/cjs/src/normalizer/core.js +37 -0
  38. package/dist/cjs/src/normalizer/graphql-normalizer.js +67 -0
  39. package/dist/cjs/src/normalizer/index.js +7 -0
  40. package/dist/cjs/src/normalizer/rest-normalizer.js +51 -0
  41. package/dist/cjs/src/normalizer/types.js +2 -0
  42. package/dist/cjs/src/normalizer/utils.js +49 -0
  43. package/dist/cjs/src/normalizer/websocket-normalizer.js +81 -0
  44. package/dist/cjs/src/optimizer/core.js +140 -0
  45. package/dist/cjs/src/optimizer/index.js +17 -0
  46. package/dist/cjs/src/optimizer/optimization-functions.js +185 -0
  47. package/dist/cjs/src/optimizer/types.js +2 -0
  48. package/dist/cjs/src/optimizer/utils.js +32 -0
  49. package/dist/cjs/src/schemas/dedupe.js +113 -0
  50. package/dist/cjs/src/schemas/index.js +14 -0
  51. package/dist/cjs/src/schemas/resolver.js +42 -0
  52. package/dist/cjs/src/schemas/utils.js +53 -0
  53. package/dist/cjs/src/types/index.js +2 -0
  54. package/dist/cjs/src/validator/ajv-validator.js +82 -0
  55. package/dist/cjs/src/validator/config-validator-main.js +34 -0
  56. package/dist/cjs/src/validator/config-validator.js +17 -0
  57. package/dist/cjs/src/validator/index.js +23 -0
  58. package/dist/cjs/src/validator/object-traversal.js +112 -0
  59. package/dist/cjs/src/validator/reference-validator.js +233 -0
  60. package/dist/cjs/src/validator/schema-references.js +116 -0
  61. package/dist/cjs/src/validator/semantic-validator.js +328 -0
  62. package/dist/cjs/src/validator/tests-validator.js +16 -0
  63. package/dist/cjs/src/validator/types.js +2 -0
  64. package/dist/cjs/src/validator/unispec-validator.js +80 -0
  65. package/dist/cjs/src/validator/validator-factory.js +77 -0
  66. package/dist/cjs/src/versions.js +147 -0
  67. package/dist/cjs/tests/cache/cache.test.js +274 -0
  68. package/dist/cjs/tests/cache/utils.js +32 -0
  69. package/dist/cjs/tests/concurrency-normalizer-optimizer.test.js +1 -0
  70. package/dist/cjs/tests/diff/diff-annotators.test.js +280 -0
  71. package/dist/cjs/tests/diff/diff-comprehensive.test.js +262 -0
  72. package/dist/cjs/tests/diff/diff-extended.test.js +235 -0
  73. package/dist/cjs/tests/diff/diff.test.js +189 -0
  74. package/dist/cjs/tests/diff/utils.js +8 -0
  75. package/dist/cjs/tests/errors/errors-integration.test.js +173 -0
  76. package/dist/cjs/tests/errors/errors.test.js +280 -0
  77. package/dist/cjs/tests/errors/utils.js +7 -0
  78. package/dist/cjs/tests/loader/integration.test.js +216 -0
  79. package/dist/cjs/tests/loader/loader.test.js +341 -0
  80. package/dist/cjs/tests/normalizer/normalizer-comprehensive.test.js +648 -0
  81. package/dist/cjs/tests/normalizer/normalizer-invalid.test.js +258 -0
  82. package/dist/cjs/tests/normalizer/normalizer-valid.test.js +238 -0
  83. package/dist/cjs/tests/normalizer/utils.js +47 -0
  84. package/dist/cjs/tests/optimizer/compress-references.test.js +304 -0
  85. package/dist/cjs/tests/optimizer/deduplication.test.js +132 -0
  86. package/dist/cjs/tests/optimizer/integration.test.js +131 -0
  87. package/dist/cjs/tests/optimizer/optimization-report.test.js +222 -0
  88. package/dist/cjs/tests/optimizer/optimize-document.test.js +187 -0
  89. package/dist/cjs/tests/optimizer/orphaned-schemas.test.js +194 -0
  90. package/dist/cjs/tests/optimizer/sort-schemas.test.js +131 -0
  91. package/dist/cjs/tests/optimizer/utils.js +209 -0
  92. package/dist/cjs/tests/schemas/schemas-edge-cases.test.js +223 -0
  93. package/dist/cjs/tests/schemas/schemas.test.js +400 -0
  94. package/dist/cjs/tests/schemas/utils.js +7 -0
  95. package/dist/cjs/tests/utils.js +131 -0
  96. package/dist/cjs/tests/validator/config-validator.test.js +78 -0
  97. package/dist/cjs/tests/validator/debug-config.js +1 -0
  98. package/dist/cjs/tests/validator/debug-missing-service.js +1 -0
  99. package/dist/cjs/tests/validator/debug-other-configs.js +1 -0
  100. package/dist/cjs/tests/validator/debug-references.js +1 -0
  101. package/dist/cjs/tests/validator/unispec-validator.test.js +103 -0
  102. package/dist/cjs/tests/validator/utils.js +25 -0
  103. package/dist/diff/annotators.js +36 -9
  104. package/dist/src/cache/cache-factory.d.ts +31 -0
  105. package/dist/src/cache/cache-factory.js +65 -0
  106. package/dist/src/cache/cache-manager.d.ts +62 -0
  107. package/dist/src/cache/cache-manager.js +124 -0
  108. package/dist/src/cache/constants.d.ts +21 -0
  109. package/dist/src/cache/constants.js +22 -0
  110. package/dist/src/cache/hash-utils.d.ts +11 -0
  111. package/dist/src/cache/hash-utils.js +15 -0
  112. package/dist/src/cache/hashing.d.ts +28 -0
  113. package/dist/src/cache/hashing.js +193 -0
  114. package/dist/src/cache/index.d.ts +6 -0
  115. package/dist/src/cache/index.js +10 -0
  116. package/dist/src/cache/lru-cache.d.ts +44 -0
  117. package/dist/src/cache/lru-cache.js +140 -0
  118. package/dist/src/cache/types.d.ts +24 -0
  119. package/dist/src/cache/types.js +4 -0
  120. package/dist/src/diff/annotators.d.ts +4 -0
  121. package/dist/src/diff/annotators.js +155 -0
  122. package/dist/src/diff/change-reports.d.ts +37 -0
  123. package/dist/src/diff/change-reports.js +366 -0
  124. package/dist/src/diff/core.d.ts +26 -0
  125. package/dist/src/diff/core.js +155 -0
  126. package/dist/src/diff/enhanced-diff.d.ts +51 -0
  127. package/dist/src/diff/enhanced-diff.js +62 -0
  128. package/dist/src/diff/impact-strategies-refactored.d.ts +69 -0
  129. package/dist/src/diff/impact-strategies-refactored.js +223 -0
  130. package/dist/src/diff/impact-strategies.d.ts +41 -0
  131. package/dist/src/diff/impact-strategies.js +212 -0
  132. package/dist/src/diff/index.d.ts +8 -0
  133. package/dist/src/diff/index.js +11 -0
  134. package/dist/src/diff/metrics-calculator.d.ts +23 -0
  135. package/dist/src/diff/metrics-calculator.js +65 -0
  136. package/dist/src/diff/risk-calculator.d.ts +23 -0
  137. package/dist/src/diff/risk-calculator.js +55 -0
  138. package/dist/src/diff/suggestion-generator.d.ts +18 -0
  139. package/dist/src/diff/suggestion-generator.js +74 -0
  140. package/dist/src/diff/types.d.ts +24 -0
  141. package/dist/src/diff/types.js +8 -0
  142. package/dist/src/errors/base-error.d.ts +20 -0
  143. package/dist/src/errors/base-error.js +29 -0
  144. package/dist/src/errors/config-error.d.ts +4 -0
  145. package/dist/src/errors/config-error.js +7 -0
  146. package/dist/src/errors/error-factory.d.ts +22 -0
  147. package/dist/src/errors/error-factory.js +45 -0
  148. package/dist/src/errors/index.d.ts +8 -0
  149. package/dist/src/errors/index.js +8 -0
  150. package/dist/src/errors/loader-error.d.ts +4 -0
  151. package/dist/src/errors/loader-error.js +7 -0
  152. package/dist/src/errors/reference-error.d.ts +4 -0
  153. package/dist/src/errors/reference-error.js +7 -0
  154. package/dist/src/errors/schema-error.d.ts +4 -0
  155. package/dist/src/errors/schema-error.js +7 -0
  156. package/dist/src/errors/security-error.d.ts +4 -0
  157. package/dist/src/errors/security-error.js +7 -0
  158. package/dist/src/errors/semantic-error.d.ts +4 -0
  159. package/dist/src/errors/semantic-error.js +7 -0
  160. package/dist/src/generated-schemas.d.ts +2073 -0
  161. package/dist/src/generated-schemas.js +2097 -0
  162. package/dist/src/index.d.ts +13 -0
  163. package/dist/src/index.js +43 -0
  164. package/dist/src/loader/index.d.ts +5 -0
  165. package/dist/src/loader/index.js +5 -0
  166. package/dist/src/loader/security-validator.d.ts +5 -0
  167. package/dist/src/loader/security-validator.js +50 -0
  168. package/dist/src/loader/types.d.ts +30 -0
  169. package/dist/src/loader/types.js +8 -0
  170. package/dist/src/loader/unispec-loader.d.ts +10 -0
  171. package/dist/src/loader/unispec-loader.js +81 -0
  172. package/dist/src/loader/yaml-loader.d.ts +10 -0
  173. package/dist/src/loader/yaml-loader.js +39 -0
  174. package/dist/src/normalizer/core.d.ts +24 -0
  175. package/dist/src/normalizer/core.js +34 -0
  176. package/dist/src/normalizer/graphql-normalizer.d.ts +8 -0
  177. package/dist/src/normalizer/graphql-normalizer.js +64 -0
  178. package/dist/src/normalizer/index.d.ts +2 -0
  179. package/dist/src/normalizer/index.js +3 -0
  180. package/dist/src/normalizer/rest-normalizer.d.ts +8 -0
  181. package/dist/src/normalizer/rest-normalizer.js +48 -0
  182. package/dist/src/normalizer/types.d.ts +7 -0
  183. package/dist/src/normalizer/types.js +1 -0
  184. package/dist/src/normalizer/utils.d.ts +17 -0
  185. package/dist/src/normalizer/utils.js +45 -0
  186. package/dist/src/normalizer/websocket-normalizer.d.ts +8 -0
  187. package/dist/src/normalizer/websocket-normalizer.js +78 -0
  188. package/dist/src/optimizer/core.d.ts +17 -0
  189. package/dist/src/optimizer/core.js +136 -0
  190. package/dist/src/optimizer/index.d.ts +4 -0
  191. package/dist/src/optimizer/index.js +7 -0
  192. package/dist/src/optimizer/optimization-functions.d.ts +32 -0
  193. package/dist/src/optimizer/optimization-functions.js +179 -0
  194. package/dist/src/optimizer/types.d.ts +28 -0
  195. package/dist/src/optimizer/types.js +1 -0
  196. package/dist/src/optimizer/utils.d.ts +7 -0
  197. package/dist/src/optimizer/utils.js +29 -0
  198. package/dist/src/schemas/dedupe.d.ts +9 -0
  199. package/dist/src/schemas/dedupe.js +110 -0
  200. package/dist/src/schemas/index.d.ts +3 -0
  201. package/dist/src/schemas/index.js +6 -0
  202. package/dist/src/schemas/resolver.d.ts +19 -0
  203. package/dist/src/schemas/resolver.js +38 -0
  204. package/dist/src/schemas/utils.d.ts +20 -0
  205. package/dist/src/schemas/utils.js +49 -0
  206. package/dist/src/types/index.d.ts +434 -0
  207. package/dist/src/types/index.js +1 -0
  208. package/dist/src/validator/ajv-validator.d.ts +15 -0
  209. package/dist/src/validator/ajv-validator.js +75 -0
  210. package/dist/src/validator/config-validator-main.d.ts +10 -0
  211. package/dist/src/validator/config-validator-main.js +31 -0
  212. package/dist/src/validator/config-validator.d.ts +5 -0
  213. package/dist/src/validator/config-validator.js +14 -0
  214. package/dist/src/validator/index.d.ts +10 -0
  215. package/dist/src/validator/index.js +11 -0
  216. package/dist/src/validator/object-traversal.d.ts +52 -0
  217. package/dist/src/validator/object-traversal.js +104 -0
  218. package/dist/src/validator/reference-validator.d.ts +31 -0
  219. package/dist/src/validator/reference-validator.js +230 -0
  220. package/dist/src/validator/schema-references.d.ts +23 -0
  221. package/dist/src/validator/schema-references.js +111 -0
  222. package/dist/src/validator/semantic-validator.d.ts +26 -0
  223. package/dist/src/validator/semantic-validator.js +325 -0
  224. package/dist/src/validator/tests-validator.d.ts +9 -0
  225. package/dist/src/validator/tests-validator.js +13 -0
  226. package/dist/src/validator/types.d.ts +29 -0
  227. package/dist/src/validator/types.js +1 -0
  228. package/dist/src/validator/unispec-validator.d.ts +15 -0
  229. package/dist/src/validator/unispec-validator.js +77 -0
  230. package/dist/src/validator/validator-factory.d.ts +10 -0
  231. package/dist/src/validator/validator-factory.js +73 -0
  232. package/dist/src/versions.d.ts +10 -0
  233. package/dist/src/versions.js +143 -0
  234. package/dist/tests/cache/cache.test.d.ts +1 -0
  235. package/dist/tests/cache/cache.test.js +269 -0
  236. package/dist/tests/cache/utils.d.ts +4 -0
  237. package/dist/tests/cache/utils.js +24 -0
  238. package/dist/tests/concurrency-normalizer-optimizer.test.d.ts +0 -0
  239. package/dist/tests/concurrency-normalizer-optimizer.test.js +1 -0
  240. package/dist/tests/diff/diff-annotators.test.d.ts +1 -0
  241. package/dist/tests/diff/diff-annotators.test.js +275 -0
  242. package/dist/tests/diff/diff-comprehensive.test.d.ts +1 -0
  243. package/dist/tests/diff/diff-comprehensive.test.js +257 -0
  244. package/dist/tests/diff/diff-extended.test.d.ts +1 -0
  245. package/dist/tests/diff/diff-extended.test.js +230 -0
  246. package/dist/tests/diff/diff.test.d.ts +1 -0
  247. package/dist/tests/diff/diff.test.js +184 -0
  248. package/dist/tests/diff/utils.d.ts +2 -0
  249. package/dist/tests/diff/utils.js +3 -0
  250. package/dist/tests/errors/errors-integration.test.d.ts +1 -0
  251. package/dist/tests/errors/errors-integration.test.js +168 -0
  252. package/dist/tests/errors/errors.test.d.ts +1 -0
  253. package/dist/tests/errors/errors.test.js +275 -0
  254. package/dist/tests/errors/utils.d.ts +2 -0
  255. package/dist/tests/errors/utils.js +3 -0
  256. package/dist/tests/loader/integration.test.d.ts +1 -0
  257. package/dist/tests/loader/integration.test.js +211 -0
  258. package/dist/tests/loader/loader.test.d.ts +1 -0
  259. package/dist/tests/loader/loader.test.js +336 -0
  260. package/dist/tests/normalizer/normalizer-comprehensive.test.d.ts +1 -0
  261. package/dist/tests/normalizer/normalizer-comprehensive.test.js +643 -0
  262. package/dist/tests/normalizer/normalizer-invalid.test.d.ts +1 -0
  263. package/dist/tests/normalizer/normalizer-invalid.test.js +253 -0
  264. package/dist/tests/normalizer/normalizer-valid.test.d.ts +1 -0
  265. package/dist/tests/normalizer/normalizer-valid.test.js +233 -0
  266. package/dist/tests/normalizer/utils.d.ts +18 -0
  267. package/dist/tests/normalizer/utils.js +36 -0
  268. package/dist/tests/optimizer/compress-references.test.d.ts +1 -0
  269. package/dist/tests/optimizer/compress-references.test.js +299 -0
  270. package/dist/tests/optimizer/deduplication.test.d.ts +1 -0
  271. package/dist/tests/optimizer/deduplication.test.js +127 -0
  272. package/dist/tests/optimizer/integration.test.d.ts +1 -0
  273. package/dist/tests/optimizer/integration.test.js +126 -0
  274. package/dist/tests/optimizer/optimization-report.test.d.ts +1 -0
  275. package/dist/tests/optimizer/optimization-report.test.js +217 -0
  276. package/dist/tests/optimizer/optimize-document.test.d.ts +1 -0
  277. package/dist/tests/optimizer/optimize-document.test.js +182 -0
  278. package/dist/tests/optimizer/orphaned-schemas.test.d.ts +1 -0
  279. package/dist/tests/optimizer/orphaned-schemas.test.js +189 -0
  280. package/dist/tests/optimizer/sort-schemas.test.d.ts +1 -0
  281. package/dist/tests/optimizer/sort-schemas.test.js +126 -0
  282. package/dist/tests/optimizer/utils.d.ts +8 -0
  283. package/dist/tests/optimizer/utils.js +199 -0
  284. package/dist/tests/schemas/schemas-edge-cases.test.d.ts +1 -0
  285. package/dist/tests/schemas/schemas-edge-cases.test.js +218 -0
  286. package/dist/tests/schemas/schemas.test.d.ts +1 -0
  287. package/dist/tests/schemas/schemas.test.js +395 -0
  288. package/dist/tests/schemas/utils.d.ts +2 -0
  289. package/dist/tests/schemas/utils.js +3 -0
  290. package/dist/tests/utils.d.ts +10 -0
  291. package/dist/tests/utils.js +118 -0
  292. package/dist/tests/validator/config-validator.test.d.ts +1 -0
  293. package/dist/tests/validator/config-validator.test.js +73 -0
  294. package/dist/tests/validator/debug-config.d.ts +0 -0
  295. package/dist/tests/validator/debug-config.js +1 -0
  296. package/dist/tests/validator/debug-missing-service.d.ts +0 -0
  297. package/dist/tests/validator/debug-missing-service.js +1 -0
  298. package/dist/tests/validator/debug-other-configs.d.ts +0 -0
  299. package/dist/tests/validator/debug-other-configs.js +1 -0
  300. package/dist/tests/validator/debug-references.d.ts +0 -0
  301. package/dist/tests/validator/debug-references.js +1 -0
  302. package/dist/tests/validator/unispec-validator.test.d.ts +1 -0
  303. package/dist/tests/validator/unispec-validator.test.js +98 -0
  304. package/dist/tests/validator/utils.d.ts +6 -0
  305. package/dist/tests/validator/utils.js +20 -0
  306. package/package.json +4 -3
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ // Export types
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
16
+ };
17
+ Object.defineProperty(exports, "__esModule", { value: true });
18
+ __exportStar(require("./change-reports.js"), exports);
19
+ // Export core functionality
20
+ __exportStar(require("./core.js"), exports);
21
+ // Export enhanced functionality
22
+ __exportStar(require("./enhanced-diff.js"), exports);
23
+ __exportStar(require("./impact-strategies-refactored.js"), exports);
24
+ __exportStar(require("./metrics-calculator.js"), exports);
25
+ __exportStar(require("./risk-calculator.js"), exports);
26
+ __exportStar(require("./suggestion-generator.js"), exports);
27
+ __exportStar(require("./types.js"), exports);
@@ -0,0 +1,69 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.MetricsCalculatorService = void 0;
4
+ /**
5
+ * Service for calculating compatibility metrics from enhanced changes.
6
+ */
7
+ class MetricsCalculatorService {
8
+ /**
9
+ * Calculate compatibility metrics from enhanced changes.
10
+ */
11
+ calculateMetrics(changes) {
12
+ const breakingChanges = this.filterBreakingChanges(changes);
13
+ const nonBreakingChanges = this.filterNonBreakingChanges(changes);
14
+ const totalChanges = changes.length;
15
+ const breakingScore = this.calculateBreakingScore(breakingChanges.length, totalChanges);
16
+ const overallCompatibility = Math.max(0, 100 - breakingScore);
17
+ const clientScore = this.calculateClientCompatibilityScore(changes);
18
+ const serverScore = this.calculateServerCompatibilityScore(changes);
19
+ const migrationEffort = this.determineMigrationEffort(breakingChanges, nonBreakingChanges);
20
+ return {
21
+ overallCompatibility: Math.round(overallCompatibility),
22
+ breakingChangesCount: breakingChanges.length,
23
+ nonBreakingChangesCount: nonBreakingChanges.length,
24
+ clientCompatibilityScore: Math.round(clientScore),
25
+ serverCompatibilityScore: Math.round(serverScore),
26
+ migrationEffort,
27
+ };
28
+ }
29
+ filterBreakingChanges(changes) {
30
+ return changes.filter((c) => c.impact.backwardCompatibility === "incompatible");
31
+ }
32
+ filterNonBreakingChanges(changes) {
33
+ return changes.filter((c) => c.impact.backwardCompatibility === "compatible");
34
+ }
35
+ calculateBreakingScore(breakingCount, totalChanges) {
36
+ return totalChanges > 0 ? (breakingCount / totalChanges) * 100 : 0;
37
+ }
38
+ calculateClientCompatibilityScore(changes) {
39
+ const totalChanges = changes.length;
40
+ if (totalChanges === 0)
41
+ return 100;
42
+ const highClientImpact = changes.filter((c) => c.impact.clientImpact === "high").length;
43
+ const mediumClientImpact = changes.filter((c) => c.impact.clientImpact === "medium").length;
44
+ return (100 - (highClientImpact * 50 + mediumClientImpact * 25) / totalChanges);
45
+ }
46
+ calculateServerCompatibilityScore(changes) {
47
+ const totalChanges = changes.length;
48
+ if (totalChanges === 0)
49
+ return 100;
50
+ const highServerImpact = changes.filter((c) => c.impact.serverImpact === "high").length;
51
+ const mediumServerImpact = changes.filter((c) => c.impact.serverImpact === "medium").length;
52
+ return (100 - (highServerImpact * 30 + mediumServerImpact * 15) / totalChanges);
53
+ }
54
+ determineMigrationEffort(breakingChanges, _nonBreakingChanges) {
55
+ const complexMigrations = breakingChanges.filter((c) => c.impact.migrationComplexity === "complex").length;
56
+ const moderateMigrations = breakingChanges.filter((c) => c.impact.migrationComplexity === "moderate").length;
57
+ if (complexMigrations > 0) {
58
+ return "major";
59
+ }
60
+ else if (moderateMigrations > 2) {
61
+ return "significant";
62
+ }
63
+ else if (moderateMigrations > 0 || breakingChanges.length > 3) {
64
+ return "moderate";
65
+ }
66
+ return "minimal";
67
+ }
68
+ }
69
+ exports.MetricsCalculatorService = MetricsCalculatorService;
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.RiskLevelCalculator = void 0;
4
+ /**
5
+ * Calculator for determining risk levels based on change impact.
6
+ */
7
+ exports.RiskLevelCalculator = {
8
+ /**
9
+ * Calculate risk level based on impact.
10
+ */
11
+ calculate(impact) {
12
+ // Critical: Breaking changes with high client impact
13
+ if (impact.backwardCompatibility === "incompatible" &&
14
+ impact.clientImpact === "high") {
15
+ return "critical";
16
+ }
17
+ // High: Any breaking change
18
+ if (impact.backwardCompatibility === "incompatible") {
19
+ return "high";
20
+ }
21
+ // Medium: Medium impact on client or server
22
+ if (impact.clientImpact === "medium" || impact.serverImpact === "medium") {
23
+ return "medium";
24
+ }
25
+ // Low: Everything else
26
+ return "low";
27
+ },
28
+ /**
29
+ * Get risk level weight for sorting.
30
+ */
31
+ getWeight(riskLevel) {
32
+ const weights = {
33
+ critical: 4,
34
+ high: 3,
35
+ medium: 2,
36
+ low: 1,
37
+ };
38
+ return weights[riskLevel];
39
+ },
40
+ /**
41
+ * Check if risk level requires immediate attention.
42
+ */
43
+ requiresImmediateAttention(riskLevel) {
44
+ return riskLevel === "critical" || riskLevel === "high";
45
+ },
46
+ /**
47
+ * Get risk level description.
48
+ */
49
+ getDescription(riskLevel) {
50
+ const descriptions = {
51
+ critical: "Critical breaking change requiring immediate action",
52
+ high: "Breaking change that requires attention",
53
+ medium: "Moderate change with some impact",
54
+ low: "Minor change with minimal impact",
55
+ };
56
+ return descriptions[riskLevel];
57
+ },
58
+ };
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SuggestionGeneratorService = void 0;
4
+ /**
5
+ * Service for generating migration suggestions based on change impact.
6
+ */
7
+ class SuggestionGeneratorService {
8
+ /**
9
+ * Generate migration suggestions based on change impact.
10
+ */
11
+ generateSuggestions(change, impact) {
12
+ const suggestions = [];
13
+ this.addBreakingChangeSuggestions(suggestions, change, impact);
14
+ this.addClientImpactSuggestions(suggestions, impact);
15
+ this.addServerImpactSuggestions(suggestions, impact);
16
+ this.addMigrationComplexitySuggestions(suggestions, impact);
17
+ return suggestions;
18
+ }
19
+ addBreakingChangeSuggestions(suggestions, change, impact) {
20
+ if (impact.backwardCompatibility !== "incompatible")
21
+ return;
22
+ suggestions.push("This is a breaking change that requires client updates");
23
+ if (change.protocol === "rest") {
24
+ this.addRestBreakingSuggestions(suggestions, change);
25
+ }
26
+ else if (change.protocol === "graphql") {
27
+ this.addGraphQLBreakingSuggestions(suggestions, change);
28
+ }
29
+ else if (change.protocol === "websocket") {
30
+ this.addWebSocketBreakingSuggestions(suggestions, change);
31
+ }
32
+ }
33
+ addRestBreakingSuggestions(suggestions, change) {
34
+ if (change.kind?.includes("route.removed")) {
35
+ suggestions.push("Consider deprecating the route before removal");
36
+ suggestions.push("Provide alternative endpoint if functionality is still needed");
37
+ }
38
+ if (change.path.includes("/path")) {
39
+ suggestions.push("Maintain backward compatibility by supporting old path");
40
+ suggestions.push("Document migration path for clients");
41
+ }
42
+ }
43
+ addGraphQLBreakingSuggestions(suggestions, change) {
44
+ if (change.kind?.includes("operation.removed")) {
45
+ suggestions.push("Mark operation as @deprecated before removal");
46
+ suggestions.push("Provide alternative query/mutation if possible");
47
+ }
48
+ if (change.path.includes("/returnType")) {
49
+ suggestions.push("Consider adding new field instead of changing return type");
50
+ suggestions.push("Use union types for multiple possible return types");
51
+ }
52
+ }
53
+ addWebSocketBreakingSuggestions(suggestions, change) {
54
+ if (change.kind?.includes("channel.removed")) {
55
+ suggestions.push("Notify clients before closing channel");
56
+ suggestions.push("Provide grace period for migration");
57
+ }
58
+ }
59
+ addClientImpactSuggestions(suggestions, impact) {
60
+ if (impact.clientImpact === "high") {
61
+ suggestions.push("Client code changes are required");
62
+ suggestions.push("Update client documentation");
63
+ }
64
+ }
65
+ addServerImpactSuggestions(suggestions, impact) {
66
+ if (impact.serverImpact === "medium" || impact.serverImpact === "high") {
67
+ suggestions.push("Server implementation changes required");
68
+ suggestions.push("Update server-side documentation");
69
+ }
70
+ }
71
+ addMigrationComplexitySuggestions(suggestions, impact) {
72
+ if (impact.migrationComplexity === "complex") {
73
+ suggestions.push("Plan migration in phases");
74
+ suggestions.push("Consider feature flags for gradual rollout");
75
+ }
76
+ }
77
+ }
78
+ exports.SuggestionGeneratorService = SuggestionGeneratorService;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_NAMED_COLLECTION_PATHS = void 0;
4
+ // Default named collection paths for UniSpec
5
+ exports.DEFAULT_NAMED_COLLECTION_PATHS = [
6
+ "/service/protocols/rest/routes",
7
+ "/service/protocols/websocket/channels",
8
+ "/service/protocols/graphql/queries",
9
+ "/service/protocols/graphql/mutations",
10
+ "/service/protocols/graphql/subscriptions",
11
+ ];
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /**
3
+ * Base validation error class for UniSpec validation.
4
+ * Provides better error context and handling.
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.UniSpecValidationError = void 0;
8
+ class UniSpecValidationError extends Error {
9
+ constructor(message, code, path = "", severity = "error", details) {
10
+ super(message);
11
+ this.name = "UniSpecValidationError";
12
+ this.code = code;
13
+ this.path = path;
14
+ this.severity = severity;
15
+ this.details = details;
16
+ // Maintains proper stack trace for where our error was thrown (only available on V8)
17
+ if (Error.captureStackTrace) {
18
+ Error.captureStackTrace(this, UniSpecValidationError);
19
+ }
20
+ }
21
+ toJSON() {
22
+ return {
23
+ name: this.name,
24
+ message: this.message,
25
+ code: this.code,
26
+ path: this.path,
27
+ severity: this.severity,
28
+ details: this.details,
29
+ stack: this.stack,
30
+ };
31
+ }
32
+ }
33
+ exports.UniSpecValidationError = UniSpecValidationError;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UniSpecConfigError = void 0;
4
+ const base_error_1 = require("./base-error.js");
5
+ class UniSpecConfigError extends base_error_1.UniSpecValidationError {
6
+ constructor(message, path = "", details) {
7
+ super(message, "config_error", path, "error", details);
8
+ this.name = "UniSpecConfigError";
9
+ }
10
+ }
11
+ exports.UniSpecConfigError = UniSpecConfigError;
@@ -0,0 +1,48 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ErrorFactory = void 0;
4
+ const base_error_1 = require("./base-error.js");
5
+ const config_error_1 = require("./config-error.js");
6
+ const loader_error_1 = require("./loader-error.js");
7
+ const reference_error_1 = require("./reference-error.js");
8
+ const schema_error_1 = require("./schema-error.js");
9
+ const security_error_1 = require("./security-error.js");
10
+ const semantic_error_1 = require("./semantic-error.js");
11
+ /**
12
+ * Error factory for creating specific error types.
13
+ */
14
+ exports.ErrorFactory = {
15
+ createSchemaError(message, path, details) {
16
+ return new schema_error_1.UniSpecSchemaError(message, path, details);
17
+ },
18
+ createSemanticError(message, path, details) {
19
+ return new semantic_error_1.UniSpecSemanticError(message, path, details);
20
+ },
21
+ createReferenceError(message, path, details) {
22
+ return new reference_error_1.UniSpecReferenceError(message, path, details);
23
+ },
24
+ createConfigError(message, path, details) {
25
+ return new config_error_1.UniSpecConfigError(message, path, details);
26
+ },
27
+ createSecurityError(message, path, details) {
28
+ return new security_error_1.UniSpecSecurityError(message, path, details);
29
+ },
30
+ createLoaderError(message, path, details) {
31
+ return new loader_error_1.UniSpecLoaderError(message, path, details);
32
+ },
33
+ /**
34
+ * Convert generic error to UniSpecValidationError
35
+ */
36
+ fromError(error, defaultCode = "validation_error") {
37
+ if (error instanceof base_error_1.UniSpecValidationError) {
38
+ return error;
39
+ }
40
+ if (error instanceof Error) {
41
+ return new base_error_1.UniSpecValidationError(error.message, defaultCode, "", "error", { originalError: error.name, stack: error.stack });
42
+ }
43
+ if (typeof error === "string") {
44
+ return new base_error_1.UniSpecValidationError(error, defaultCode);
45
+ }
46
+ return new base_error_1.UniSpecValidationError(`Unknown validation error: ${String(error)}`, defaultCode, "", "error", { originalError: error });
47
+ },
48
+ };
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UniSpecSemanticError = exports.UniSpecSecurityError = exports.UniSpecSchemaError = exports.UniSpecReferenceError = exports.UniSpecLoaderError = exports.ErrorFactory = exports.UniSpecConfigError = exports.UniSpecValidationError = void 0;
4
+ var base_error_1 = require("./base-error.js");
5
+ Object.defineProperty(exports, "UniSpecValidationError", { enumerable: true, get: function () { return base_error_1.UniSpecValidationError; } });
6
+ var config_error_1 = require("./config-error.js");
7
+ Object.defineProperty(exports, "UniSpecConfigError", { enumerable: true, get: function () { return config_error_1.UniSpecConfigError; } });
8
+ var error_factory_1 = require("./error-factory.js");
9
+ Object.defineProperty(exports, "ErrorFactory", { enumerable: true, get: function () { return error_factory_1.ErrorFactory; } });
10
+ var loader_error_1 = require("./loader-error.js");
11
+ Object.defineProperty(exports, "UniSpecLoaderError", { enumerable: true, get: function () { return loader_error_1.UniSpecLoaderError; } });
12
+ var reference_error_1 = require("./reference-error.js");
13
+ Object.defineProperty(exports, "UniSpecReferenceError", { enumerable: true, get: function () { return reference_error_1.UniSpecReferenceError; } });
14
+ var schema_error_1 = require("./schema-error.js");
15
+ Object.defineProperty(exports, "UniSpecSchemaError", { enumerable: true, get: function () { return schema_error_1.UniSpecSchemaError; } });
16
+ var security_error_1 = require("./security-error.js");
17
+ Object.defineProperty(exports, "UniSpecSecurityError", { enumerable: true, get: function () { return security_error_1.UniSpecSecurityError; } });
18
+ var semantic_error_1 = require("./semantic-error.js");
19
+ Object.defineProperty(exports, "UniSpecSemanticError", { enumerable: true, get: function () { return semantic_error_1.UniSpecSemanticError; } });
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UniSpecLoaderError = void 0;
4
+ const base_error_1 = require("./base-error.js");
5
+ class UniSpecLoaderError extends base_error_1.UniSpecValidationError {
6
+ constructor(message, path = "", details) {
7
+ super(message, "loader_error", path, "error", details);
8
+ this.name = "UniSpecLoaderError";
9
+ }
10
+ }
11
+ exports.UniSpecLoaderError = UniSpecLoaderError;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UniSpecReferenceError = void 0;
4
+ const base_error_1 = require("./base-error.js");
5
+ class UniSpecReferenceError extends base_error_1.UniSpecValidationError {
6
+ constructor(message, path = "", details) {
7
+ super(message, "reference_error", path, "error", details);
8
+ this.name = "UniSpecReferenceError";
9
+ }
10
+ }
11
+ exports.UniSpecReferenceError = UniSpecReferenceError;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UniSpecSchemaError = void 0;
4
+ const base_error_1 = require("./base-error.js");
5
+ class UniSpecSchemaError extends base_error_1.UniSpecValidationError {
6
+ constructor(message, path = "", details) {
7
+ super(message, "schema_error", path, "error", details);
8
+ this.name = "UniSpecSchemaError";
9
+ }
10
+ }
11
+ exports.UniSpecSchemaError = UniSpecSchemaError;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UniSpecSecurityError = void 0;
4
+ const base_error_1 = require("./base-error.js");
5
+ class UniSpecSecurityError extends base_error_1.UniSpecValidationError {
6
+ constructor(message, path = "", details) {
7
+ super(message, "security_error", path, "error", details);
8
+ this.name = "UniSpecSecurityError";
9
+ }
10
+ }
11
+ exports.UniSpecSecurityError = UniSpecSecurityError;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UniSpecSemanticError = void 0;
4
+ const base_error_1 = require("./base-error.js");
5
+ class UniSpecSemanticError extends base_error_1.UniSpecValidationError {
6
+ constructor(message, path = "", details) {
7
+ super(message, "semantic_error", path, "error", details);
8
+ this.name = "UniSpecSemanticError";
9
+ }
10
+ }
11
+ exports.UniSpecSemanticError = UniSpecSemanticError;