@apimatic/cli 1.1.0-alpha.9 → 1.1.0-beta.10

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 (341) hide show
  1. package/README.md +443 -374
  2. package/bin/run.js +5 -0
  3. package/lib/actions/action-result.d.ts +19 -0
  4. package/lib/actions/action-result.js +70 -0
  5. package/lib/actions/action-result.js.map +1 -0
  6. package/lib/actions/api/transform.d.ts +15 -0
  7. package/lib/actions/api/transform.js +48 -0
  8. package/lib/actions/api/transform.js.map +1 -0
  9. package/lib/actions/api/validate.d.ts +14 -0
  10. package/lib/actions/api/validate.js +52 -0
  11. package/lib/actions/api/validate.js.map +1 -0
  12. package/lib/actions/auth/login.d.ts +13 -0
  13. package/lib/actions/auth/login.js +55 -0
  14. package/lib/actions/auth/login.js.map +1 -0
  15. package/lib/actions/auth/logout.d.ts +8 -0
  16. package/lib/actions/auth/logout.js +15 -0
  17. package/lib/actions/auth/logout.js.map +1 -0
  18. package/lib/actions/auth/status.d.ts +11 -0
  19. package/lib/actions/auth/status.js +26 -0
  20. package/lib/actions/auth/status.js.map +1 -0
  21. package/lib/actions/portal/copilot.d.ts +16 -0
  22. package/lib/actions/portal/copilot.js +89 -0
  23. package/lib/actions/portal/copilot.js.map +1 -0
  24. package/lib/actions/portal/generate.d.ts +11 -5
  25. package/lib/actions/portal/generate.js +60 -55
  26. package/lib/actions/portal/generate.js.map +1 -0
  27. package/lib/actions/portal/quickstart.d.ts +17 -0
  28. package/lib/actions/portal/quickstart.js +169 -0
  29. package/lib/actions/portal/quickstart.js.map +1 -0
  30. package/lib/actions/portal/recipe/new-recipe.d.ts +15 -0
  31. package/lib/actions/portal/recipe/new-recipe.js +177 -0
  32. package/lib/actions/portal/recipe/new-recipe.js.map +1 -0
  33. package/lib/actions/portal/serve.d.ts +15 -0
  34. package/lib/actions/portal/serve.js +104 -0
  35. package/lib/actions/portal/serve.js.map +1 -0
  36. package/lib/actions/portal/toc/new-toc.d.ts +17 -13
  37. package/lib/actions/portal/toc/new-toc.js +85 -123
  38. package/lib/actions/portal/toc/new-toc.js.map +1 -0
  39. package/lib/actions/quickstart.d.ts +10 -0
  40. package/lib/actions/quickstart.js +30 -0
  41. package/lib/actions/quickstart.js.map +1 -0
  42. package/lib/actions/sdk/generate.d.ts +13 -0
  43. package/lib/actions/sdk/generate.js +77 -0
  44. package/lib/actions/sdk/generate.js.map +1 -0
  45. package/lib/actions/sdk/quickstart.d.ts +17 -0
  46. package/lib/actions/sdk/quickstart.js +171 -0
  47. package/lib/actions/sdk/quickstart.js.map +1 -0
  48. package/lib/application/portal/recipe/portal-recipe.d.ts +8 -0
  49. package/lib/application/portal/recipe/portal-recipe.js +33 -0
  50. package/lib/application/portal/recipe/portal-recipe.js.map +1 -0
  51. package/lib/application/portal/recipe/recipe-generator.d.ts +21 -0
  52. package/lib/application/portal/recipe/recipe-generator.js +145 -0
  53. package/lib/application/portal/recipe/recipe-generator.js.map +1 -0
  54. package/lib/application/portal/toc/toc-content-parser.d.ts +1 -1
  55. package/lib/application/portal/toc/toc-content-parser.js +9 -11
  56. package/lib/application/portal/toc/toc-content-parser.js.map +1 -0
  57. package/lib/application/portal/toc/toc-structure-generator.d.ts +23 -2
  58. package/lib/application/portal/toc/toc-structure-generator.js +133 -66
  59. package/lib/application/portal/toc/toc-structure-generator.js.map +1 -0
  60. package/lib/client-utils/auth-manager.d.ts +7 -2
  61. package/lib/client-utils/auth-manager.js +26 -14
  62. package/lib/client-utils/auth-manager.js.map +1 -0
  63. package/lib/commands/api/transform.d.ts +10 -7
  64. package/lib/commands/api/transform.js +51 -111
  65. package/lib/commands/api/transform.js.map +1 -0
  66. package/lib/commands/api/validate.d.ts +7 -4
  67. package/lib/commands/api/validate.js +31 -74
  68. package/lib/commands/api/validate.js.map +1 -0
  69. package/lib/commands/auth/login.d.ts +3 -1
  70. package/lib/commands/auth/login.js +26 -68
  71. package/lib/commands/auth/login.js.map +1 -0
  72. package/lib/commands/auth/logout.d.ts +3 -1
  73. package/lib/commands/auth/logout.js +14 -21
  74. package/lib/commands/auth/logout.js.map +1 -0
  75. package/lib/commands/auth/status.d.ts +1 -0
  76. package/lib/commands/auth/status.js +18 -21
  77. package/lib/commands/auth/status.js.map +1 -0
  78. package/lib/commands/portal/copilot.d.ts +13 -0
  79. package/lib/commands/portal/copilot.js +34 -0
  80. package/lib/commands/portal/copilot.js.map +1 -0
  81. package/lib/commands/portal/generate.d.ts +7 -11
  82. package/lib/commands/portal/generate.js +26 -89
  83. package/lib/commands/portal/generate.js.map +1 -0
  84. package/lib/commands/portal/recipe/new.d.ts +12 -0
  85. package/lib/commands/portal/recipe/new.js +45 -0
  86. package/lib/commands/portal/recipe/new.js.map +1 -0
  87. package/lib/commands/portal/serve.d.ts +8 -8
  88. package/lib/commands/portal/serve.js +41 -125
  89. package/lib/commands/portal/serve.js.map +1 -0
  90. package/lib/commands/portal/toc/new.d.ts +8 -7
  91. package/lib/commands/portal/toc/new.js +52 -49
  92. package/lib/commands/portal/toc/new.js.map +1 -0
  93. package/lib/commands/quickstart.d.ts +9 -0
  94. package/lib/commands/quickstart.js +37 -0
  95. package/lib/commands/quickstart.js.map +1 -0
  96. package/lib/commands/sdk/generate.d.ts +10 -8
  97. package/lib/commands/sdk/generate.js +46 -131
  98. package/lib/commands/sdk/generate.js.map +1 -0
  99. package/lib/config/axios-config.js +4 -6
  100. package/lib/config/axios-config.js.map +1 -0
  101. package/lib/hooks/not-found.d.ts +3 -0
  102. package/lib/hooks/not-found.js +52 -0
  103. package/lib/hooks/not-found.js.map +1 -0
  104. package/lib/hooks/utils.d.ts +5 -0
  105. package/lib/hooks/utils.js +51 -0
  106. package/lib/hooks/utils.js.map +1 -0
  107. package/lib/index.js +2 -5
  108. package/lib/index.js.map +1 -0
  109. package/lib/infrastructure/debounce-service.d.ts +10 -0
  110. package/lib/infrastructure/debounce-service.js +55 -0
  111. package/lib/infrastructure/debounce-service.js.map +1 -0
  112. package/lib/infrastructure/env-info.d.ts +12 -0
  113. package/lib/infrastructure/env-info.js +58 -0
  114. package/lib/infrastructure/env-info.js.map +1 -0
  115. package/lib/infrastructure/file-service.d.ts +25 -0
  116. package/lib/infrastructure/file-service.js +131 -0
  117. package/lib/infrastructure/file-service.js.map +1 -0
  118. package/lib/infrastructure/launcher-service.d.ts +9 -0
  119. package/lib/infrastructure/launcher-service.js +72 -0
  120. package/lib/infrastructure/launcher-service.js.map +1 -0
  121. package/lib/infrastructure/network-service.d.ts +3 -0
  122. package/lib/infrastructure/network-service.js +7 -0
  123. package/lib/infrastructure/network-service.js.map +1 -0
  124. package/lib/infrastructure/service-error.d.ts +16 -0
  125. package/lib/infrastructure/service-error.js +49 -0
  126. package/lib/infrastructure/service-error.js.map +1 -0
  127. package/lib/infrastructure/services/api-client-factory.d.ts +6 -0
  128. package/lib/infrastructure/services/api-client-factory.js +20 -0
  129. package/lib/infrastructure/services/api-client-factory.js.map +1 -0
  130. package/lib/infrastructure/services/api-service.d.ts +13 -0
  131. package/lib/infrastructure/services/api-service.js +103 -0
  132. package/lib/infrastructure/services/api-service.js.map +1 -0
  133. package/lib/infrastructure/services/auth-service.d.ts +11 -0
  134. package/lib/infrastructure/services/auth-service.js +37 -0
  135. package/lib/infrastructure/services/auth-service.js.map +1 -0
  136. package/lib/infrastructure/services/file-download-service.d.ts +15 -0
  137. package/lib/infrastructure/services/file-download-service.js +104 -0
  138. package/lib/infrastructure/services/file-download-service.js.map +1 -0
  139. package/lib/infrastructure/services/portal-service.d.ts +15 -12
  140. package/lib/infrastructure/services/portal-service.js +152 -99
  141. package/lib/infrastructure/services/portal-service.js.map +1 -0
  142. package/lib/infrastructure/services/telemetry-service.d.ts +9 -0
  143. package/lib/infrastructure/services/telemetry-service.js +38 -0
  144. package/lib/infrastructure/services/telemetry-service.js.map +1 -0
  145. package/lib/infrastructure/services/transformation-service.d.ts +23 -0
  146. package/lib/infrastructure/services/transformation-service.js +56 -0
  147. package/lib/infrastructure/services/transformation-service.js.map +1 -0
  148. package/lib/infrastructure/services/validation-service.d.ts +43 -0
  149. package/lib/infrastructure/services/validation-service.js +142 -0
  150. package/lib/infrastructure/services/validation-service.js.map +1 -0
  151. package/lib/infrastructure/tmp-extensions.d.ts +2 -0
  152. package/lib/infrastructure/tmp-extensions.js +6 -0
  153. package/lib/infrastructure/tmp-extensions.js.map +1 -0
  154. package/lib/infrastructure/zip-service.d.ts +6 -0
  155. package/lib/infrastructure/zip-service.js +39 -0
  156. package/lib/infrastructure/zip-service.js.map +1 -0
  157. package/lib/prompts/api/transform.d.ts +11 -0
  158. package/lib/prompts/api/transform.js +29 -0
  159. package/lib/prompts/api/transform.js.map +1 -0
  160. package/lib/prompts/api/validate.d.ts +15 -0
  161. package/lib/prompts/api/validate.js +76 -0
  162. package/lib/prompts/api/validate.js.map +1 -0
  163. package/lib/prompts/auth/login.d.ts +10 -0
  164. package/lib/prompts/auth/login.js +22 -0
  165. package/lib/prompts/auth/login.js.map +1 -0
  166. package/lib/prompts/auth/logout.d.ts +3 -0
  167. package/lib/prompts/auth/logout.js +7 -0
  168. package/lib/prompts/auth/logout.js.map +1 -0
  169. package/lib/prompts/auth/status.d.ts +8 -0
  170. package/lib/prompts/auth/status.js +22 -0
  171. package/lib/prompts/auth/status.js.map +1 -0
  172. package/lib/prompts/format.d.ts +31 -0
  173. package/lib/prompts/format.js +89 -0
  174. package/lib/prompts/format.js.map +1 -0
  175. package/lib/prompts/portal/copilot.d.ts +18 -0
  176. package/lib/prompts/portal/copilot.js +82 -0
  177. package/lib/prompts/portal/copilot.js.map +1 -0
  178. package/lib/prompts/portal/generate.d.ts +13 -8
  179. package/lib/prompts/portal/generate.js +36 -53
  180. package/lib/prompts/portal/generate.js.map +1 -0
  181. package/lib/prompts/portal/quickstart.d.ts +31 -29
  182. package/lib/prompts/portal/quickstart.js +139 -185
  183. package/lib/prompts/portal/quickstart.js.map +1 -0
  184. package/lib/prompts/portal/recipe/new-recipe.d.ts +29 -0
  185. package/lib/prompts/portal/recipe/new-recipe.js +165 -0
  186. package/lib/prompts/portal/recipe/new-recipe.js.map +1 -0
  187. package/lib/prompts/portal/serve.d.ts +9 -5
  188. package/lib/prompts/portal/serve.js +29 -19
  189. package/lib/prompts/portal/serve.js.map +1 -0
  190. package/lib/prompts/portal/toc/new-toc.d.ts +13 -8
  191. package/lib/prompts/portal/toc/new-toc.js +36 -36
  192. package/lib/prompts/portal/toc/new-toc.js.map +1 -0
  193. package/lib/prompts/prompt.d.ts +3 -0
  194. package/lib/prompts/prompt.js +37 -0
  195. package/lib/prompts/prompt.js.map +1 -0
  196. package/lib/prompts/quickstart.d.ts +6 -0
  197. package/lib/prompts/quickstart.js +25 -0
  198. package/lib/prompts/quickstart.js.map +1 -0
  199. package/lib/prompts/sdk/generate.d.ts +16 -0
  200. package/lib/prompts/sdk/generate.js +57 -0
  201. package/lib/prompts/sdk/generate.js.map +1 -0
  202. package/lib/prompts/sdk/quickstart.d.ts +35 -0
  203. package/lib/prompts/sdk/quickstart.js +177 -0
  204. package/lib/prompts/sdk/quickstart.js.map +1 -0
  205. package/lib/types/api/account.d.ts +10 -0
  206. package/lib/types/api/account.js +2 -0
  207. package/lib/types/api/account.js.map +1 -0
  208. package/lib/types/api/transform.d.ts +14 -25
  209. package/lib/types/api/transform.js +20 -23
  210. package/lib/types/api/transform.js.map +1 -0
  211. package/lib/types/build/build.d.ts +22 -0
  212. package/lib/types/build/build.js +7 -0
  213. package/lib/types/build/build.js.map +1 -0
  214. package/lib/types/build-context.d.ts +13 -0
  215. package/lib/types/build-context.js +33 -0
  216. package/lib/types/build-context.js.map +1 -0
  217. package/lib/types/common/command-metadata.d.ts +4 -0
  218. package/lib/types/common/command-metadata.js +2 -0
  219. package/lib/types/common/command-metadata.js.map +1 -0
  220. package/lib/types/events/domain-event.d.ts +8 -0
  221. package/lib/types/events/domain-event.js +11 -0
  222. package/lib/types/events/domain-event.js.map +1 -0
  223. package/lib/types/events/quickstart-completed.d.ts +7 -0
  224. package/lib/types/events/quickstart-completed.js +10 -0
  225. package/lib/types/events/quickstart-completed.js.map +1 -0
  226. package/lib/types/events/quickstart-initiated.d.ts +7 -0
  227. package/lib/types/events/quickstart-initiated.js +10 -0
  228. package/lib/types/events/quickstart-initiated.js.map +1 -0
  229. package/lib/types/events/recipe-creation-failed.d.ts +5 -0
  230. package/lib/types/events/recipe-creation-failed.js +8 -0
  231. package/lib/types/events/recipe-creation-failed.js.map +1 -0
  232. package/lib/types/events/toc-creation-failed.d.ts +5 -0
  233. package/lib/types/events/toc-creation-failed.js +8 -0
  234. package/lib/types/events/toc-creation-failed.js.map +1 -0
  235. package/lib/types/file/directory.d.ts +17 -0
  236. package/lib/types/file/directory.js +87 -0
  237. package/lib/types/file/directory.js.map +1 -0
  238. package/lib/types/file/directoryPath.d.ts +10 -0
  239. package/lib/types/file/directoryPath.js +26 -0
  240. package/lib/types/file/directoryPath.js.map +1 -0
  241. package/lib/types/file/fileName.d.ts +7 -0
  242. package/lib/types/file/fileName.js +21 -0
  243. package/lib/types/file/fileName.js.map +1 -0
  244. package/lib/types/file/filePath.d.ts +10 -0
  245. package/lib/types/file/filePath.js +32 -0
  246. package/lib/types/file/filePath.js.map +1 -0
  247. package/lib/types/file/resource-input.d.ts +5 -0
  248. package/lib/types/file/resource-input.js +42 -0
  249. package/lib/types/file/resource-input.js.map +1 -0
  250. package/lib/types/file/urlPath.d.ts +6 -0
  251. package/lib/types/file/urlPath.js +22 -0
  252. package/lib/types/file/urlPath.js.map +1 -0
  253. package/lib/types/flags-provider.d.ts +15 -0
  254. package/lib/types/flags-provider.js +34 -0
  255. package/lib/types/flags-provider.js.map +1 -0
  256. package/lib/types/portal-context.d.ts +13 -0
  257. package/lib/types/portal-context.js +38 -0
  258. package/lib/types/portal-context.js.map +1 -0
  259. package/lib/types/recipe/recipe.d.ts +22 -0
  260. package/lib/types/recipe/recipe.js +6 -0
  261. package/lib/types/recipe/recipe.js.map +1 -0
  262. package/lib/types/recipe-context.d.ts +9 -0
  263. package/lib/types/recipe-context.js +26 -0
  264. package/lib/types/recipe-context.js.map +1 -0
  265. package/lib/types/resource-context.d.ts +12 -0
  266. package/lib/types/resource-context.js +30 -0
  267. package/lib/types/resource-context.js.map +1 -0
  268. package/lib/types/sdk/generate.d.ts +9 -22
  269. package/lib/types/sdk/generate.js +25 -14
  270. package/lib/types/sdk/generate.js.map +1 -0
  271. package/lib/types/sdk-context.d.ts +14 -0
  272. package/lib/types/sdk-context.js +32 -0
  273. package/lib/types/sdk-context.js.map +1 -0
  274. package/lib/types/sdl/sdl.d.ts +27 -0
  275. package/lib/types/sdl/sdl.js +145 -3
  276. package/lib/types/sdl/sdl.js.map +1 -0
  277. package/lib/types/spec-context.d.ts +12 -0
  278. package/lib/types/spec-context.js +29 -0
  279. package/lib/types/spec-context.js.map +1 -0
  280. package/lib/types/temp-context.d.ts +11 -0
  281. package/lib/types/temp-context.js +27 -0
  282. package/lib/types/temp-context.js.map +1 -0
  283. package/lib/types/toc/toc.d.ts +31 -6
  284. package/lib/types/toc/toc.js +2 -10
  285. package/lib/types/toc/toc.js.map +1 -0
  286. package/lib/types/toc-context.d.ts +12 -0
  287. package/lib/types/toc-context.js +26 -0
  288. package/lib/types/toc-context.js.map +1 -0
  289. package/lib/types/transform-context.d.ts +13 -0
  290. package/lib/types/transform-context.js +30 -0
  291. package/lib/types/transform-context.js.map +1 -0
  292. package/lib/types/utils.d.ts +0 -9
  293. package/lib/types/utils.js +2 -3
  294. package/lib/types/utils.js.map +1 -0
  295. package/lib/types/versioned-build-context.d.ts +15 -0
  296. package/lib/types/versioned-build-context.js +28 -0
  297. package/lib/types/versioned-build-context.js.map +1 -0
  298. package/lib/utils/string-utils.d.ts +3 -0
  299. package/lib/utils/string-utils.js +79 -0
  300. package/lib/utils/string-utils.js.map +1 -0
  301. package/lib/utils/utils.d.ts +2 -44
  302. package/lib/utils/utils.js +14 -366
  303. package/lib/utils/utils.js.map +1 -0
  304. package/package.json +50 -31
  305. package/bin/run +0 -9
  306. package/lib/application/portal/toc/sdl-parser.d.ts +0 -13
  307. package/lib/application/portal/toc/sdl-parser.js +0 -53
  308. package/lib/client-utils/sdk-client.d.ts +0 -23
  309. package/lib/client-utils/sdk-client.js +0 -124
  310. package/lib/commands/portal/quickstart.d.ts +0 -10
  311. package/lib/commands/portal/quickstart.js +0 -79
  312. package/lib/config/env.d.ts +0 -27
  313. package/lib/config/env.js +0 -31
  314. package/lib/controllers/api/transform.d.ts +0 -5
  315. package/lib/controllers/api/transform.js +0 -56
  316. package/lib/controllers/api/validate.d.ts +0 -3
  317. package/lib/controllers/api/validate.js +0 -33
  318. package/lib/controllers/portal/generate.d.ts +0 -3
  319. package/lib/controllers/portal/generate.js +0 -110
  320. package/lib/controllers/portal/quickstart.d.ts +0 -14
  321. package/lib/controllers/portal/quickstart.js +0 -258
  322. package/lib/controllers/portal/serve.d.ts +0 -3
  323. package/lib/controllers/portal/serve.js +0 -138
  324. package/lib/controllers/sdk/generate.d.ts +0 -4
  325. package/lib/controllers/sdk/generate.js +0 -66
  326. package/lib/services/portal/server.d.ts +0 -14
  327. package/lib/services/portal/server.js +0 -101
  328. package/lib/types/api/validate.d.ts +0 -12
  329. package/lib/types/api/validate.js +0 -3
  330. package/lib/types/common/result.d.ts +0 -17
  331. package/lib/types/common/result.js +0 -36
  332. package/lib/types/portal/generate.d.ts +0 -26
  333. package/lib/types/portal/generate.js +0 -4
  334. package/lib/types/portal/quickstart.d.ts +0 -17
  335. package/lib/types/portal/quickstart.js +0 -3
  336. package/lib/validators/common/directoryValidator.d.ts +0 -9
  337. package/lib/validators/common/directoryValidator.js +0 -53
  338. package/lib/validators/common/portValidator.d.ts +0 -5
  339. package/lib/validators/common/portValidator.js +0 -20
  340. package/lib/validators/portal/serveValidator.d.ts +0 -6
  341. package/lib/validators/portal/serveValidator.js +0 -21
@@ -0,0 +1,29 @@
1
+ import { FileService } from "../infrastructure/file-service.js";
2
+ import { FilePath } from "./file/filePath.js";
3
+ import { FileName } from "./file/fileName.js";
4
+ import { ZipService } from "../infrastructure/zip-service.js";
5
+ export class SpecContext {
6
+ constructor(specDirectory) {
7
+ this.fileService = new FileService();
8
+ this.zipService = new ZipService();
9
+ this.specDirectory = specDirectory;
10
+ }
11
+ async validate() {
12
+ return !(await this.fileService.directoryEmpty(this.specDirectory));
13
+ }
14
+ async replaceDefaultSpec(specPath) {
15
+ await this.fileService.deleteFile(new FilePath(this.specDirectory, new FileName("openapi.json")));
16
+ if (await this.fileService.isZipFile(specPath)) {
17
+ await this.zipService.unArchive(specPath, this.specDirectory);
18
+ }
19
+ else {
20
+ await this.fileService.copy(specPath, specPath.replaceDirectory(this.specDirectory));
21
+ }
22
+ }
23
+ async save(stream, fileName) {
24
+ const filePath = new FilePath(this.specDirectory, fileName);
25
+ await this.fileService.writeFile(filePath, stream);
26
+ return filePath;
27
+ }
28
+ }
29
+ //# sourceMappingURL=spec-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spec-context.js","sourceRoot":"","sources":["../../src/types/spec-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,MAAM,OAAO,WAAW;IAKtB,YAAY,aAA4B;QAJvB,gBAAW,GAAG,IAAI,WAAW,EAAE,CAAC;QAChC,eAAU,GAAG,IAAI,UAAU,EAAE,CAAC;QAI7C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;IAEM,KAAK,CAAC,QAAQ;QACnB,OAAO,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,cAAc,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;IACtE,CAAC;IAEM,KAAK,CAAC,kBAAkB,CAAC,QAAkB;QAChD,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;QAClG,IAAI,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QAChE,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;QACvF,CAAC;IACH,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAA6B,EAAE,QAAkB;QACjE,MAAM,QAAQ,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC,CAAC;QAC5D,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACnD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
@@ -0,0 +1,11 @@
1
+ import { DirectoryPath } from "./file/directoryPath.js";
2
+ import { FilePath } from "./file/filePath.js";
3
+ export declare class TempContext {
4
+ private readonly tempDirectory;
5
+ private readonly fileService;
6
+ private readonly zipService;
7
+ constructor(tempDirectory: DirectoryPath);
8
+ private get getTempFileName();
9
+ zip(buildDirectory: DirectoryPath): Promise<FilePath>;
10
+ save(portalStream: NodeJS.ReadableStream): Promise<FilePath>;
11
+ }
@@ -0,0 +1,27 @@
1
+ import { FileService } from "../infrastructure/file-service.js";
2
+ import { ZipService } from "../infrastructure/zip-service.js";
3
+ import { FilePath } from "./file/filePath.js";
4
+ import { FileName } from "./file/fileName.js";
5
+ import { randomUUID } from "crypto";
6
+ export class TempContext {
7
+ constructor(tempDirectory) {
8
+ this.tempDirectory = tempDirectory;
9
+ this.fileService = new FileService();
10
+ this.zipService = new ZipService();
11
+ }
12
+ get getTempFileName() {
13
+ const uuid = randomUUID();
14
+ return new FilePath(this.tempDirectory, new FileName(`${uuid}`));
15
+ }
16
+ async zip(buildDirectory) {
17
+ const tempFile = this.getTempFileName;
18
+ await this.zipService.archive(buildDirectory, tempFile);
19
+ return tempFile;
20
+ }
21
+ async save(portalStream) {
22
+ const tempFile = this.getTempFileName;
23
+ await this.fileService.writeFile(tempFile, portalStream);
24
+ return tempFile;
25
+ }
26
+ }
27
+ //# sourceMappingURL=temp-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"temp-context.js","sourceRoot":"","sources":["../../src/types/temp-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,kCAAkC,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAEpC,MAAM,OAAO,WAAW;IAItB,YAA6B,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;QAHxC,gBAAW,GAAG,IAAI,WAAW,EAAE,CAAC;QAChC,eAAU,GAAG,IAAI,UAAU,EAAE,CAAC;IAEa,CAAC;IAE7D,IAAY,eAAe;QACzB,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;QAC1B,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,aAAa,EAAE,IAAI,QAAQ,CAAC,GAAG,IAAI,EAAE,CAAC,CAAC,CAAC;IACnE,CAAC;IAEM,KAAK,CAAC,GAAG,CAAC,cAA6B;QAC5C,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC;QACtC,MAAM,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QACxD,OAAO,QAAQ,CAAC;IAClB,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,YAAmC;QACnD,MAAM,QAAQ,GAAG,IAAI,CAAC,eAAe,CAAC;QACtC,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;QACzD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF"}
@@ -3,28 +3,53 @@ export interface Toc {
3
3
  }
4
4
  export interface TocGroup {
5
5
  readonly group: string;
6
- readonly items: Array<TocGroup | TocGenerated | TocEndpoint | TocEndpointGroupOverview | TocModel | TocCustomPage>;
6
+ readonly items: Array<TocGroup | TocGenerated | TocEndpointPage | TocWebhookPage | TocCallbackPage | TocModelPage | TocCustomPage>;
7
7
  }
8
8
  export interface TocGenerated {
9
- readonly generate: string;
9
+ readonly generate: string | null;
10
10
  readonly from: string;
11
11
  }
12
+ export type TocEndpointPage = TocEndpoint | TocEndpointGroupOverview;
13
+ export type TocWebhookPage = TocWebhook | TocWebhookOverview;
14
+ export type TocCallbackPage = TocCallback | TocCallbackOverview;
12
15
  export interface TocEndpointGroupOverview {
13
16
  readonly generate: null;
14
- readonly from: "endpoint-group-overview";
17
+ readonly from: 'endpoint-group-overview';
15
18
  readonly endpointGroup: string;
16
19
  }
17
20
  export interface TocEndpoint {
18
21
  readonly generate: null;
19
- readonly from: "endpoint";
22
+ readonly from: 'endpoint';
20
23
  readonly endpointName: string;
21
24
  readonly endpointGroup: string;
22
25
  }
23
- export interface TocModel {
26
+ export interface TocModelPage {
24
27
  readonly generate: null;
25
- readonly from: "model";
28
+ readonly from: 'model';
26
29
  readonly modelName: string;
27
30
  }
31
+ export interface TocWebhookOverview {
32
+ readonly generate: null;
33
+ readonly from: 'webhook-group-overview';
34
+ readonly webhookGroup: string | null;
35
+ }
36
+ export interface TocWebhook {
37
+ readonly generate: null;
38
+ readonly from: 'webhook';
39
+ readonly webhookName: string;
40
+ readonly webhookGroup: string | null;
41
+ }
42
+ export interface TocCallbackOverview {
43
+ readonly generate: null;
44
+ readonly from: 'callback-group-overview';
45
+ readonly callbackGroup: string | null;
46
+ }
47
+ export interface TocCallback {
48
+ readonly generate: null;
49
+ readonly from: 'callback';
50
+ readonly callbackName: string;
51
+ readonly callbackGroup: string | null;
52
+ }
28
53
  export interface TocCustomPage {
29
54
  readonly page: string;
30
55
  readonly file: string;
@@ -1,10 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- ;
4
- ;
5
- ;
6
- ;
7
- ;
8
- ;
9
- ;
10
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9jLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL3R5cGVzL3RvYy90b2MudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFFQyxDQUFDO0FBS0QsQ0FBQztBQUtELENBQUM7QUFNRCxDQUFDO0FBT0QsQ0FBQztBQU1ELENBQUM7QUFLRCxDQUFDIn0=
1
+ export {};
2
+ //# sourceMappingURL=toc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toc.js","sourceRoot":"","sources":["../../../src/types/toc/toc.ts"],"names":[],"mappings":""}
@@ -0,0 +1,12 @@
1
+ import { DirectoryPath } from "./file/directoryPath.js";
2
+ import { FilePath } from "./file/filePath.js";
3
+ import { Toc } from "./toc/toc.js";
4
+ export declare class TocContext {
5
+ private readonly fileService;
6
+ private readonly tocFilePath;
7
+ constructor(tocDirectory: DirectoryPath);
8
+ get tocPath(): FilePath;
9
+ exists(): Promise<boolean>;
10
+ parseTocData(): Promise<Toc>;
11
+ save(contents: string): Promise<FilePath>;
12
+ }
@@ -0,0 +1,26 @@
1
+ import { FileService } from "../infrastructure/file-service.js";
2
+ import { FilePath } from "./file/filePath.js";
3
+ import { FileName } from "./file/fileName.js";
4
+ import { parse } from "yaml";
5
+ export class TocContext {
6
+ constructor(tocDirectory) {
7
+ this.fileService = new FileService();
8
+ this.tocFilePath = new FilePath(tocDirectory, new FileName("toc.yml"));
9
+ }
10
+ get tocPath() {
11
+ return this.tocFilePath;
12
+ }
13
+ async exists() {
14
+ return await this.fileService.fileExists(this.tocFilePath);
15
+ }
16
+ async parseTocData() {
17
+ const tocContent = await this.fileService.getContents(this.tocFilePath);
18
+ return parse(tocContent);
19
+ }
20
+ async save(contents) {
21
+ await this.fileService.ensurePathExists(this.tocFilePath);
22
+ await this.fileService.writeContents(this.tocFilePath, contents);
23
+ return this.tocPath;
24
+ }
25
+ }
26
+ //# sourceMappingURL=toc-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toc-context.js","sourceRoot":"","sources":["../../src/types/toc-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAEhE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAE7B,MAAM,OAAO,UAAU;IAIrB,YAAY,YAA2B;QAHtB,gBAAW,GAAG,IAAI,WAAW,EAAE,CAAC;QAI/C,IAAI,CAAC,WAAW,GAAG,IAAI,QAAQ,CAAC,YAAY,EAAE,IAAI,QAAQ,CAAC,SAAS,CAAC,CAAC,CAAC;IACzE,CAAC;IAED,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAEM,KAAK,CAAC,MAAM;QACjB,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAC7D,CAAC;IAEM,KAAK,CAAC,YAAY;QACvB,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QACxE,OAAO,KAAK,CAAC,UAAU,CAAQ,CAAC;IAClC,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,QAAgB;QAChC,MAAM,IAAI,CAAC,WAAW,CAAC,gBAAgB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAC1D,MAAM,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;QACjE,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ import { ExportFormats } from "@apimatic/sdk";
2
+ import { DirectoryPath } from "./file/directoryPath.js";
3
+ import { FilePath } from "./file/filePath.js";
4
+ export declare class TransformContext {
5
+ private readonly destinationDirectory;
6
+ private readonly fileService;
7
+ private readonly transformedApi;
8
+ constructor(specFilePath: FilePath, format: ExportFormats, destinationDirectory: DirectoryPath);
9
+ private get specPath();
10
+ exists(): Promise<boolean>;
11
+ save(stream: NodeJS.ReadableStream): Promise<FilePath>;
12
+ private parseFileName;
13
+ }
@@ -0,0 +1,30 @@
1
+ import { FileService } from "../infrastructure/file-service.js";
2
+ import { getFileNameFromPath } from "../utils/utils.js";
3
+ import { DestinationFormats } from "./api/transform.js";
4
+ import { FileName } from "./file/fileName.js";
5
+ import { FilePath } from "./file/filePath.js";
6
+ export class TransformContext {
7
+ constructor(specFilePath, format, destinationDirectory) {
8
+ this.destinationDirectory = destinationDirectory;
9
+ this.fileService = new FileService();
10
+ this.transformedApi = this.parseFileName(format, specFilePath);
11
+ }
12
+ get specPath() {
13
+ return new FilePath(this.destinationDirectory, this.transformedApi);
14
+ }
15
+ async exists() {
16
+ const transformedApiPath = new FilePath(this.destinationDirectory, this.transformedApi);
17
+ return await this.fileService.fileExists(transformedApiPath);
18
+ }
19
+ async save(stream) {
20
+ await this.fileService.createDirectoryIfNotExists(this.destinationDirectory);
21
+ await this.fileService.writeFile(this.specPath, stream);
22
+ return this.specPath;
23
+ }
24
+ parseFileName(format, file) {
25
+ const destinationFileExt = DestinationFormats[format];
26
+ const destinationFilePrefix = getFileNameFromPath(file.toString());
27
+ return new FileName(`${destinationFilePrefix}_${format}.${destinationFileExt}`);
28
+ }
29
+ }
30
+ //# sourceMappingURL=transform-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform-context.js","sourceRoot":"","sources":["../../src/types/transform-context.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAChE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,MAAM,OAAO,gBAAgB;IAK3B,YAAY,YAAsB,EACtB,MAAqB,EACJ,oBAAmC;QAAnC,yBAAoB,GAApB,oBAAoB,CAAe;QAN/C,gBAAW,GAAG,IAAI,WAAW,EAAE,CAAC;QAO/C,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACjE,CAAC;IAED,IAAY,QAAQ;QAClB,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;IACtE,CAAC;IAEM,KAAK,CAAC,MAAM;QACjB,MAAM,kBAAkB,GAAG,IAAI,QAAQ,CAAC,IAAI,CAAC,oBAAoB,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC;QACxF,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,kBAAkB,CAAC,CAAC;IAE/D,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,MAA6B;QAC7C,MAAM,IAAI,CAAC,WAAW,CAAC,0BAA0B,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC7E,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxD,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAEO,aAAa,CAAC,MAAc,EAAE,IAAc;QAClD,MAAM,kBAAkB,GAAW,kBAAkB,CAAC,MAAyC,CAAC,CAAC;QACjG,MAAM,qBAAqB,GAAG,mBAAmB,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC;QACnE,OAAO,IAAI,QAAQ,CAAC,GAAG,qBAAqB,IAAI,MAAM,IAAI,kBAAkB,EAAE,CAAC,CAAC;IAClF,CAAC;CACF"}
@@ -3,12 +3,3 @@ export type ValidationMessages = {
3
3
  warnings: string[];
4
4
  errors: string[];
5
5
  };
6
- export type loggers = {
7
- log: (message: string) => void;
8
- warn: (message: string) => void;
9
- error: (message: string) => void;
10
- };
11
- export type AuthenticationError = {
12
- statusCode: number;
13
- body: string;
14
- };
@@ -1,3 +1,2 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidXRpbHMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdHlwZXMvdXRpbHMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
1
+ export {};
2
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/types/utils.ts"],"names":[],"mappings":""}
@@ -0,0 +1,15 @@
1
+ import { DirectoryPath } from "./file/directoryPath.js";
2
+ type VersionedBuildValidateResult = {
3
+ isValid: false;
4
+ } | {
5
+ isValid: true;
6
+ versionsDirectory: DirectoryPath;
7
+ versions: string[];
8
+ };
9
+ export declare class VersionedBuildContext {
10
+ private readonly fileService;
11
+ private readonly buildDirectory;
12
+ constructor(buildDirectory: DirectoryPath);
13
+ validate(): Promise<VersionedBuildValidateResult>;
14
+ }
15
+ export {};
@@ -0,0 +1,28 @@
1
+ import { FileService } from "../infrastructure/file-service.js";
2
+ import { BuildContext } from "./build-context.js";
3
+ export class VersionedBuildContext {
4
+ constructor(buildDirectory) {
5
+ this.fileService = new FileService();
6
+ this.buildDirectory = buildDirectory;
7
+ }
8
+ async validate() {
9
+ var _a;
10
+ const buildContext = new BuildContext(this.buildDirectory);
11
+ if (!(await buildContext.validate())) {
12
+ return { isValid: false };
13
+ }
14
+ const config = await buildContext.getBuildFileContents();
15
+ if (!("generateVersionedPortal" in config)) {
16
+ return { isValid: false };
17
+ }
18
+ const versionsPath = (_a = config.versionsPath) !== null && _a !== void 0 ? _a : "versioned_docs";
19
+ const versionsDirectory = this.buildDirectory.join(versionsPath);
20
+ if (!(await this.fileService.directoryExists(versionsDirectory))) {
21
+ return { isValid: false };
22
+ }
23
+ const versionsDirs = await this.fileService.getSubDirectoriesPaths(versionsDirectory);
24
+ const versions = versionsDirs.map((dir) => dir.leafName());
25
+ return { isValid: true, versionsDirectory, versions };
26
+ }
27
+ }
28
+ //# sourceMappingURL=versioned-build-context.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"versioned-build-context.js","sourceRoot":"","sources":["../../src/types/versioned-build-context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mCAAmC,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAQlD,MAAM,OAAO,qBAAqB;IAIhC,YAAY,cAA6B;QAHxB,gBAAW,GAAG,IAAI,WAAW,EAAE,CAAC;QAI/C,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAEM,KAAK,CAAC,QAAQ;;QACnB,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC;QAC3D,IAAI,CAAC,CAAC,MAAM,YAAY,CAAC,QAAQ,EAAE,CAAC,EAAE,CAAC;YACrC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAC5B,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,YAAY,CAAC,oBAAoB,EAAE,CAAC;QACzD,IAAI,CAAC,CAAC,yBAAyB,IAAI,MAAM,CAAC,EAAE,CAAC;YAC3C,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAC5B,CAAC;QACD,MAAM,YAAY,GAAG,MAAC,MAAM,CAAC,YAAuB,mCAAI,gBAAgB,CAAC;QACzE,MAAM,iBAAiB,GAAG,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QACjE,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,iBAAiB,CAAC,CAAC,EAAE,CAAC;YACjE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;QAC5B,CAAC;QACD,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;QACtF,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC;QAC3D,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,iBAAiB,EAAE,QAAQ,EAAE,CAAC;IACxD,CAAC;CACF"}
@@ -0,0 +1,3 @@
1
+ export declare const removeQuotes: (input: string) => string;
2
+ export declare function stripAnsi(str: string): string;
3
+ export declare function toTitleCase(str: string): string;
@@ -0,0 +1,79 @@
1
+ export const removeQuotes = (input) => {
2
+ const quotes = ['"', "'"];
3
+ for (const quote of quotes) {
4
+ if (input.startsWith(quote) && input.endsWith(quote) && input.length > 1) {
5
+ return removeQuotes(input.slice(1, -1)); // Recursive call
6
+ }
7
+ }
8
+ return input;
9
+ };
10
+ export function stripAnsi(str) {
11
+ let result = '';
12
+ let i = 0;
13
+ while (i < str.length) {
14
+ const char = str[i];
15
+ // Detect ESC (0x1B)
16
+ if (char === '\x1B' && str[i + 1] === '[') {
17
+ // We’re at the start of an ANSI sequence. Skip until 'm' or end.
18
+ i += 2; // skip ESC[
19
+ while (i < str.length && str[i] !== 'm') {
20
+ i++;
21
+ }
22
+ // Skip the 'm' itself
23
+ i++;
24
+ }
25
+ else if (char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127) {
26
+ // Skip other control chars (optional)
27
+ i++;
28
+ }
29
+ else {
30
+ // Normal printable char — keep it
31
+ result += char;
32
+ i++;
33
+ }
34
+ }
35
+ return result;
36
+ }
37
+ export function toTitleCase(str) {
38
+ if (str === '') {
39
+ return '';
40
+ }
41
+ let result = '';
42
+ let shouldCapitalizeNext = true;
43
+ for (let i = 0; i < str.length; i++) {
44
+ const char = str[i];
45
+ const prevChar = i > 0 ? str[i - 1] : '';
46
+ if (isLowercase(char)) {
47
+ result += shouldCapitalizeNext ? ' ' + char.toUpperCase() : char;
48
+ shouldCapitalizeNext = false;
49
+ }
50
+ else if (isUppercase(char)) {
51
+ if (prevChar && !isUppercase(prevChar)) {
52
+ result += ' ';
53
+ }
54
+ result += char;
55
+ shouldCapitalizeNext = false;
56
+ }
57
+ else if (isDigit(char)) {
58
+ if (prevChar && !isDigit(prevChar)) {
59
+ result += ' ';
60
+ }
61
+ result += char;
62
+ shouldCapitalizeNext = true;
63
+ }
64
+ else {
65
+ shouldCapitalizeNext = true;
66
+ }
67
+ }
68
+ return result.trim();
69
+ }
70
+ function isLowercase(char) {
71
+ return char >= 'a' && char <= 'z';
72
+ }
73
+ function isUppercase(char) {
74
+ return char >= 'A' && char <= 'Z';
75
+ }
76
+ function isDigit(char) {
77
+ return char.length === 1 && char >= '0' && char <= '9';
78
+ }
79
+ //# sourceMappingURL=string-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"string-utils.js","sourceRoot":"","sources":["../../src/utils/string-utils.ts"],"names":[],"mappings":"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"}
@@ -1,46 +1,4 @@
1
- import { loggers, ValidationMessages } from "../types/utils";
2
- import { ApiValidationSummary } from "@apimatic/sdk";
3
- export declare const unzipFile: (stream: NodeJS.ReadableStream, destination: string) => Promise<unknown>;
4
- export declare const createTempDirectory: () => Promise<string>;
5
- export declare const clearDirectory: (folderPath: string) => Promise<void>;
6
- export declare const validationMessagesToJson: (validationMessages: ApiValidationSummary) => object;
7
- interface DirectoryNode {
8
- [key: string]: DirectoryNode | string | null | undefined;
9
- }
10
- export declare const directoryToJson: (dirPath: string, parentPath?: string) => DirectoryNode;
11
- export declare const isValidUrl: (input: string) => boolean;
12
- export declare const deleteFile: (filePath: string) => Promise<void>;
13
- export declare const writeFileUsingReadableStream: (stream: NodeJS.ReadableStream, destinationPath: string) => Promise<unknown>;
14
- export declare const zipDirectoryToStream: (sourcePath: string) => Promise<NodeJS.ReadableStream>;
15
- /**
16
- * Packages local files into a ZIP archive
17
- *
18
- * @param {docsPortalFolderPath} path to portal directory.
19
- * @param {destinationZipPath} path to generated zip
20
- * return {string}
21
- */
22
- export declare const zipDirectory: (sourcePath: string, destinationPath: string) => Promise<string>;
23
1
  export declare const replaceHTML: (string: string) => string;
24
- export declare const isJSONParsable: (json: string) => boolean;
25
- export declare const getGeneratedFilesPaths: (sourceDirectoryPath: string, generatedPortalArtifactsDirectoryPath: string) => string[];
26
2
  export declare const getFileNameFromPath: (filePath: string) => string;
27
- export declare const printValidationMessages: ({ warnings, errors, messages }: ValidationMessages, { log, warn, error }: loggers) => void;
28
- /**
29
- * Extracts a ZIP file to a specified destination directory.
30
- *
31
- * @param zipFilePath Path to the ZIP file.
32
- * @param destinationDir Path to the destination directory where files will be extracted.
33
- */
34
- export declare function extractZipFile(zipFilePath: string, destinationDir: string): Promise<void>;
35
- export declare function validateAndZipPortalSource(sourceDir: string, outputPath: string, ignoredPaths?: string[]): Promise<string>;
36
- export declare function cleanUpGeneratedPortalFiles(sourceDir: string): Promise<void>;
37
- export declare function isPortInUse(port: number): Promise<boolean>;
38
- export declare function parseStreamBodyToJson(body: NodeJS.ReadableStream): Promise<any>;
39
- export declare const getNonHiddenItemsFromDirectory: (directoryPath: string) => string[];
40
- export declare const getMessageInOrangeColor: (message: string) => string;
41
- export declare const getMessageInBlueColor: (message: string) => string;
42
- export declare const getMessageInCyanColor: (message: string) => string;
43
- export declare const getMessageInGreenColor: (message: string) => string;
44
- export declare const getMessageInMagentaColor: (message: string) => string;
45
- export declare const getMessageInRedColor: (message: string) => string;
46
- export {};
3
+ export declare function parseStreamBodyToJson(body: NodeJS.ReadableStream): Promise<unknown>;
4
+ export declare const toPascalCase: (str: string) => string;