@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,171 @@
1
+ import { SdkQuickstartPrompts } from '../../prompts/sdk/quickstart.js';
2
+ import { ActionResult } from '../action-result.js';
3
+ import { UrlPath } from '../../types/file/urlPath.js';
4
+ import { LoginAction } from '../auth/login.js';
5
+ import { getAuthInfo } from '../../client-utils/auth-manager.js';
6
+ import { withDirPath } from '../../infrastructure/tmp-extensions.js';
7
+ import { FilePath } from '../../types/file/filePath.js';
8
+ import { SpecContext } from '../../types/spec-context.js';
9
+ import { ValidateAction } from '../api/validate.js';
10
+ import { FileDownloadService } from '../../infrastructure/services/file-download-service.js';
11
+ import { FileService } from '../../infrastructure/file-service.js';
12
+ import { GenerateAction } from './generate.js';
13
+ import { LauncherService } from '../../infrastructure/launcher-service.js';
14
+ import { ZipService } from '../../infrastructure/zip-service.js';
15
+ import { FileName } from '../../types/file/fileName.js';
16
+ import { ValidationService } from '../../infrastructure/services/validation-service.js';
17
+ export class SdkQuickstartAction {
18
+ constructor(configDir, commandMetadata) {
19
+ this.configDir = configDir;
20
+ this.commandMetadata = commandMetadata;
21
+ this.prompts = new SdkQuickstartPrompts();
22
+ this.fileDownloadService = new FileDownloadService();
23
+ this.fileService = new FileService();
24
+ this.launcherService = new LauncherService();
25
+ this.zipService = new ZipService();
26
+ this.validationService = new ValidationService(this.configDir);
27
+ this.metadataFileUrl = new UrlPath(`https://raw.githubusercontent.com/apimatic/sample-docs-as-code-portal/refs/heads/master/src/spec/APIMATIC-META.json`);
28
+ this.defaultSpecUrl = new UrlPath(`https://raw.githubusercontent.com/apimatic/sample-docs-as-code-portal/refs/heads/master/src/spec/openapi.json`);
29
+ this.execute = async () => {
30
+ const storedAuth = await getAuthInfo(this.configDir.toString());
31
+ if (!(storedAuth === null || storedAuth === void 0 ? void 0 : storedAuth.authKey)) {
32
+ const loginResult = await new LoginAction(this.configDir, this.commandMetadata).execute();
33
+ if (loginResult.isFailed()) {
34
+ return ActionResult.failed();
35
+ }
36
+ }
37
+ return await withDirPath(async (tempDirectory) => {
38
+ var _a;
39
+ // Step 1/4
40
+ this.prompts.importSpecStep();
41
+ let specPath;
42
+ while (!specPath) {
43
+ const inputPath = await this.prompts.specPathPrompt(this.defaultSpecUrl);
44
+ if (!inputPath) {
45
+ this.prompts.noSpecSpecified();
46
+ return ActionResult.cancelled();
47
+ }
48
+ if (inputPath instanceof UrlPath) {
49
+ const downloadFileResult = await this.prompts.downloadSpecFile(this.fileDownloadService.downloadFile(inputPath));
50
+ if (downloadFileResult.isErr()) {
51
+ this.prompts.serviceError(downloadFileResult.error);
52
+ }
53
+ else {
54
+ const specContext = new SpecContext(tempDirectory);
55
+ specPath = await specContext.save(downloadFileResult.value.stream, downloadFileResult.value.filename);
56
+ }
57
+ }
58
+ else {
59
+ const fileExists = await this.fileService.fileExists(inputPath);
60
+ if (!fileExists) {
61
+ this.prompts.specFileDoesNotExist();
62
+ }
63
+ else {
64
+ specPath = inputPath;
65
+ }
66
+ }
67
+ }
68
+ // Step 2/4
69
+ this.prompts.validateSpecStep();
70
+ const validateAction = new ValidateAction(this.configDir, this.commandMetadata);
71
+ const validationResult = await validateAction.execute(specPath, false);
72
+ if (validationResult.isFailed()) {
73
+ this.prompts.specValidationFailed();
74
+ if (!(await this.prompts.useDefaultSpecPrompt())) {
75
+ this.prompts.fixYourSpec();
76
+ return ActionResult.cancelled();
77
+ }
78
+ const downloadFileResult = await this.prompts.downloadSpecFile(this.fileDownloadService.downloadFile(this.defaultSpecUrl));
79
+ if (downloadFileResult.isErr()) {
80
+ this.prompts.serviceError(downloadFileResult.error);
81
+ }
82
+ else {
83
+ const specContext = new SpecContext(tempDirectory);
84
+ specPath = await specContext.save(downloadFileResult.value.stream, downloadFileResult.value.filename);
85
+ }
86
+ }
87
+ if (validationResult.isSuccess()) {
88
+ const unallowed = validationResult.getValue();
89
+ if (unallowed && (((_a = unallowed.Features) === null || _a === void 0 ? void 0 : _a.length) > 0 || unallowed.EndpointCount > unallowed.EndpointLimit)) {
90
+ const config = {
91
+ features: unallowed.Features.filter((name) => !!name),
92
+ endpointsToKeep: unallowed.EndpointLimit
93
+ };
94
+ const stripUnallowedFeaturesResult = await this.validationService.stripUnallowedFeatures(specPath, config);
95
+ if (stripUnallowedFeaturesResult.isErr()) {
96
+ this.prompts.splitSpecDetected(unallowed);
97
+ return ActionResult.failed();
98
+ }
99
+ else {
100
+ this.prompts.stripUnallowedFeaturesStep(unallowed);
101
+ const specContext = new SpecContext(tempDirectory);
102
+ specPath = await specContext.save(stripUnallowedFeaturesResult.value, new FileName('pruned-spec.zip'));
103
+ }
104
+ }
105
+ }
106
+ // Step 3/4
107
+ this.prompts.selectLanguageStep();
108
+ const language = await this.prompts.selectLanguagePrompt();
109
+ if (!language) {
110
+ this.prompts.noLanguageSelected();
111
+ return ActionResult.cancelled();
112
+ }
113
+ // Step 4/4
114
+ this.prompts.selectInputDirectoryStep();
115
+ let inputDirectory;
116
+ while (true) {
117
+ inputDirectory = await this.prompts.inputDirectoryPathPrompt();
118
+ if (!inputDirectory) {
119
+ this.prompts.noInputDirectoryProvided();
120
+ return ActionResult.cancelled();
121
+ }
122
+ if (!(await this.fileService.directoryExists(inputDirectory))) {
123
+ this.prompts.inputDirectoryPathDoesNotExist(inputDirectory);
124
+ // TODO: Prompt user if he wants to create the directory
125
+ continue;
126
+ }
127
+ if (!(await this.fileService.directoryEmpty(inputDirectory))) {
128
+ this.prompts.inputDirectoryNotEmpty(inputDirectory);
129
+ continue;
130
+ }
131
+ break;
132
+ }
133
+ // Setup source directory with the spec folder
134
+ const apimaticMetaFile = await this.prompts.downloadMetadataFile(this.fileDownloadService.downloadFile(this.metadataFileUrl));
135
+ if (apimaticMetaFile.isErr()) {
136
+ this.prompts.serviceError(apimaticMetaFile.error);
137
+ return ActionResult.failed();
138
+ }
139
+ const tempSpecDirectory = tempDirectory.join('spec');
140
+ await this.fileService.createDirectoryIfNotExists(tempSpecDirectory);
141
+ const metadataFilePath = new FilePath(tempSpecDirectory, apimaticMetaFile.value.filename);
142
+ await this.fileService.writeFile(metadataFilePath, apimaticMetaFile.value.stream);
143
+ if (await this.fileService.isZipFile(specPath)) {
144
+ await this.zipService.unArchive(specPath, tempSpecDirectory);
145
+ }
146
+ else {
147
+ await this.fileService.copyToDir(specPath, tempSpecDirectory);
148
+ }
149
+ const sourceDirectory = inputDirectory.join('src');
150
+ const specDirectory = sourceDirectory.join('spec');
151
+ await this.fileService.copyDirectoryContents(tempSpecDirectory, specDirectory);
152
+ const srcDirectoryStructure = await this.fileService.getDirectory(sourceDirectory);
153
+ this.prompts.printDirectoryStructure(inputDirectory, srcDirectoryStructure);
154
+ const sdkDirectory = inputDirectory.join('sdk');
155
+ const sdkGenerateAction = new GenerateAction(this.configDir, this.commandMetadata);
156
+ const result = await sdkGenerateAction.execute(sourceDirectory, sdkDirectory, language, true, false);
157
+ if (result.isFailed()) {
158
+ return ActionResult.failed();
159
+ }
160
+ const languageDirectory = sdkDirectory.join(language);
161
+ const readmeFilePath = new FilePath(languageDirectory, new FileName('README.md'));
162
+ if (await this.launcherService.openFolderInIde(languageDirectory, readmeFilePath)) {
163
+ this.prompts.sdkOpenedInEditor();
164
+ }
165
+ this.prompts.nextSteps(language, inputDirectory);
166
+ return ActionResult.success();
167
+ });
168
+ };
169
+ }
170
+ }
171
+ //# sourceMappingURL=quickstart.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"quickstart.js","sourceRoot":"","sources":["../../../src/actions/sdk/quickstart.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AACvE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,OAAO,EAAE,WAAW,EAAE,MAAM,oCAAoC,CAAC;AACjE,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,M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AC,eAAe,EAAE,YAAY,EAAE,QAAoB,EAAE,IAAI,EAAE,KAAK,CAAC,CAAC;gBACjH,IAAI,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;oBACtB,OAAO,YAAY,CAAC,MAAM,EAAE,CAAC;gBAC/B,CAAC;gBAED,MAAM,iBAAiB,GAAG,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;gBACtD,MAAM,cAAc,GAAG,IAAI,QAAQ,CAAC,iBAAiB,EAAE,IAAI,QAAQ,CAAC,WAAW,CAAC,CAAC,CAAC;gBAClF,IAAI,MAAM,IAAI,CAAC,eAAe,CAAC,eAAe,CAAC,iBAAiB,EAAE,cAAc,CAAC,EAAE,CAAC;oBAClF,IAAI,CAAC,OAAO,CAAC,iBAAiB,EAAE,CAAC;gBACnC,CAAC;gBAED,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC;gBACjD,OAAO,YAAY,CAAC,OAAO,EAAE,CAAC;YAChC,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;IAjKyG,CAAC;CAkK7G"}
@@ -0,0 +1,8 @@
1
+ import { SerializableRecipe } from "../../../types/recipe/recipe.js";
2
+ export declare class PortalRecipe {
3
+ private readonly recipe;
4
+ constructor(name: string);
5
+ addContentStep(key: string, content: string): void;
6
+ addEndpointStep(key: string, description: string, endpointGroupName: string, endpointName: string): void;
7
+ toSerializableRecipe(): SerializableRecipe;
8
+ }
@@ -0,0 +1,33 @@
1
+ import { StepType } from "../../../types/recipe/recipe.js";
2
+ export class PortalRecipe {
3
+ constructor(name) {
4
+ this.recipe = {
5
+ name,
6
+ steps: []
7
+ };
8
+ }
9
+ addContentStep(key, content) {
10
+ this.recipe.steps.push({
11
+ key,
12
+ name: key, //TODO: Check if key is required
13
+ type: StepType.Content,
14
+ config: { content }
15
+ });
16
+ }
17
+ addEndpointStep(key, description, endpointGroupName, endpointName) {
18
+ const endpointPermalink = `$e/${[endpointGroupName, endpointName].map(encodeURIComponent).join("/")}`;
19
+ this.recipe.steps.push({
20
+ key,
21
+ name: key, //TODO: Check if key is required
22
+ type: StepType.Endpoint,
23
+ config: {
24
+ description,
25
+ endpointPermalink
26
+ }
27
+ });
28
+ }
29
+ toSerializableRecipe() {
30
+ return this.recipe;
31
+ }
32
+ }
33
+ //# sourceMappingURL=portal-recipe.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"portal-recipe.js","sourceRoot":"","sources":["../../../../src/application/portal/recipe/portal-recipe.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE/E,MAAM,OAAO,YAAY;IAGvB,YAAY,IAAY;QACtB,IAAI,CAAC,MAAM,GAAG;YACZ,IAAI;YACJ,KAAK,EAAE,EAAE;SACV,CAAC;IACJ,CAAC;IAED,cAAc,CAAC,GAAW,EAAE,OAAe;QACzC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;YACrB,GAAG;YACH,IAAI,EAAE,GAAG,EAAE,gCAAgC;YAC3C,IAAI,EAAE,QAAQ,CAAC,OAAO;YACtB,MAAM,EAAE,EAAE,OAAO,EAAE;SACpB,CAAC,CAAC;IACL,CAAC;IAED,eAAe,CAAC,GAAW,EAAE,WAAmB,EAAE,iBAAyB,EAAE,YAAoB;QAC/F,MAAM,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;QACtG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC;YACrB,GAAG;YACH,IAAI,EAAE,GAAG,EAAE,gCAAgC;YAC3C,IAAI,EAAE,QAAQ,CAAC,QAAQ;YACvB,MAAM,EAAE;gBACN,WAAW;gBACX,iBAAiB;aAClB;SACF,CAAC,CAAC;IACL,CAAC;IAED,oBAAoB;QAClB,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF"}
@@ -0,0 +1,21 @@
1
+ import { SerializableRecipe } from "../../../types/recipe/recipe.js";
2
+ import { DirectoryPath } from "../../../types/file/directoryPath.js";
3
+ import { Toc } from "../../../types/toc/toc.js";
4
+ import { FilePath } from "../../../types/file/filePath.js";
5
+ import { FileName } from "../../../types/file/fileName.js";
6
+ import { BuildContext } from "../../../types/build-context.js";
7
+ export declare class PortalRecipeGenerator {
8
+ private readonly fileService;
9
+ createRecipe(recipe: SerializableRecipe, tocFileContent: Toc, tocFilePath: FilePath, recipeName: string, recipeScriptFileName: FileName, recipeMarkdownFileName: FileName, buildContext: BuildContext, buildDirectory: DirectoryPath): Promise<void>;
10
+ private addRecipeToToc;
11
+ private registerRecipeInBuildConfigFile;
12
+ private createMarkdownFile;
13
+ private createScriptFromRecipe;
14
+ private saveGeneratedRecipeScriptToBuildDirectory;
15
+ private generateVerifyFunction;
16
+ private addContentStepToScript;
17
+ private addEndpointStepToScript;
18
+ private getMarkdownFileContent;
19
+ private formatScript;
20
+ private toPascalCase;
21
+ }
@@ -0,0 +1,145 @@
1
+ import prettier from "prettier";
2
+ import { stringify } from "yaml";
3
+ import { FileService } from "../../../infrastructure/file-service.js";
4
+ import { FilePath } from "../../../types/file/filePath.js";
5
+ export class PortalRecipeGenerator {
6
+ constructor() {
7
+ //TODO: Replace tocFileContent any type with concrete type.
8
+ this.fileService = new FileService();
9
+ }
10
+ async createRecipe(recipe, tocFileContent, tocFilePath, recipeName, recipeScriptFileName, recipeMarkdownFileName, buildContext, buildDirectory) {
11
+ await this.addRecipeToToc(tocFileContent, tocFilePath, recipeName, recipeMarkdownFileName);
12
+ await this.registerRecipeInBuildConfigFile(buildContext, recipeName, recipeScriptFileName);
13
+ await this.createMarkdownFile(recipeMarkdownFileName, buildDirectory.join("content"));
14
+ const generatedRecipeScript = await this.createScriptFromRecipe(recipe);
15
+ const generatedRecipeScriptsDirectoryPath = buildDirectory.join("static", "scripts", "recipes");
16
+ await this.saveGeneratedRecipeScriptToBuildDirectory(generatedRecipeScript, generatedRecipeScriptsDirectoryPath, recipeScriptFileName);
17
+ }
18
+ async addRecipeToToc(tocData, tocFilePath, recipeName, recipeMarkdownFileName) {
19
+ let toc = tocData.toc;
20
+ let apiRecipesGroup = toc.find((item) => item.group === "API Recipes");
21
+ if (!apiRecipesGroup) {
22
+ // If the group doesn't exist, create and insert it after the last group
23
+ apiRecipesGroup = {
24
+ group: "API Recipes",
25
+ items: []
26
+ };
27
+ // Insert after the last group section, before generate sections
28
+ let lastGroupIdx = -1;
29
+ for (let i = 0; i < toc.length; i++) {
30
+ if (toc[i].group)
31
+ lastGroupIdx = i;
32
+ }
33
+ toc.splice(lastGroupIdx + 1, 0, apiRecipesGroup);
34
+ }
35
+ // Only add the recipe if it doesn't already exist
36
+ const existingRecipe = apiRecipesGroup.items.find((item) => item.page === recipeName || item.file === `recipes/${recipeMarkdownFileName}`);
37
+ if (!existingRecipe) {
38
+ apiRecipesGroup.items.push({
39
+ page: recipeName,
40
+ file: `recipes/${recipeMarkdownFileName}`
41
+ });
42
+ await this.fileService.writeContents(tocFilePath, stringify(tocData));
43
+ }
44
+ }
45
+ async registerRecipeInBuildConfigFile(buildContext, recipeName, recipeScriptFileName) {
46
+ const buildConfig = await buildContext.getBuildFileContents();
47
+ if (!buildConfig.recipes) {
48
+ buildConfig.recipes = {};
49
+ }
50
+ const recipesConfig = buildConfig.recipes;
51
+ if (!recipesConfig.workflows) {
52
+ recipesConfig.workflows = [];
53
+ }
54
+ const existingIndex = recipesConfig.workflows.findIndex((workflow) => workflow.permalink === `page:recipes/${this.toPascalCase(recipeName)}`);
55
+ const newWorkflow = {
56
+ name: recipeName,
57
+ permalink: `page:recipes/${this.toPascalCase(recipeName)}`,
58
+ functionName: this.toPascalCase(recipeName),
59
+ scriptPath: `./static/scripts/recipes/${recipeScriptFileName}`
60
+ };
61
+ if (existingIndex !== -1) {
62
+ // Replace the existing workflow
63
+ recipesConfig.workflows[existingIndex] = newWorkflow;
64
+ }
65
+ else {
66
+ // Add as new workflow
67
+ recipesConfig.workflows.push(newWorkflow);
68
+ }
69
+ await buildContext.updateBuildFileContents(buildConfig);
70
+ }
71
+ async createMarkdownFile(recipeMarkdownFileName, contentFolder) {
72
+ const directory = contentFolder.join("recipes");
73
+ const markdownFileContent = this.getMarkdownFileContent();
74
+ await this.fileService.createDirectoryIfNotExists(directory);
75
+ await this.fileService.writeContents(new FilePath(directory, recipeMarkdownFileName), markdownFileContent);
76
+ }
77
+ async createScriptFromRecipe(recipe) {
78
+ let script = `export default function ${this.toPascalCase(recipe.name)}(workflowCtx, portal) {`;
79
+ script += "return {";
80
+ recipe.steps.forEach((step, index) => {
81
+ script += `"${step.key}": {`;
82
+ script += `name: "${step.name}",`;
83
+ script += "stepCallback: async () => {";
84
+ if (step.type === "content") {
85
+ script += this.addContentStepToScript(step.config);
86
+ }
87
+ else if (step.type === "endpoint") {
88
+ script += this.addEndpointStepToScript(step.config);
89
+ }
90
+ script += "},";
91
+ script += "}";
92
+ if (index < recipe.steps.length - 1) {
93
+ script += ",";
94
+ }
95
+ });
96
+ script += "};";
97
+ script += "}";
98
+ return script;
99
+ }
100
+ async saveGeneratedRecipeScriptToBuildDirectory(generatedRecipeScript, generatedRecipeScriptsDirectoryPath, recipeScriptFileName, format = false) {
101
+ if (format) {
102
+ generatedRecipeScript = await this.formatScript(generatedRecipeScript);
103
+ }
104
+ await this.fileService.createDirectoryIfNotExists(generatedRecipeScriptsDirectoryPath);
105
+ await this.fileService.writeContents(new FilePath(generatedRecipeScriptsDirectoryPath, recipeScriptFileName), generatedRecipeScript);
106
+ }
107
+ generateVerifyFunction() {
108
+ return `if (response.StatusCode == 200) { return true; } else { setError("API Call wasn't able to get a valid response. Please try again."); return false; }`;
109
+ }
110
+ addContentStepToScript(contentConfig) {
111
+ return `return workflowCtx.showContent(${JSON.stringify(contentConfig.content)});`;
112
+ }
113
+ addEndpointStepToScript(endpointConfig) {
114
+ let script = "return workflowCtx.showEndpoint({";
115
+ if (endpointConfig.description !== "") {
116
+ script += `description: ${JSON.stringify(endpointConfig.description)},`;
117
+ }
118
+ script += `endpointPermalink: "${endpointConfig.endpointPermalink}",`;
119
+ script += "verify: (response, setError) => {";
120
+ script += this.generateVerifyFunction();
121
+ script += "},";
122
+ script += "});";
123
+ return script;
124
+ }
125
+ getMarkdownFileContent() {
126
+ return `# This is a Guided Walkthrough File
127
+ This is the starter content`;
128
+ }
129
+ async formatScript(code) {
130
+ return prettier.format(code, {
131
+ parser: "babel",
132
+ semi: true,
133
+ singleQuote: false,
134
+ tabWidth: 2,
135
+ trailingComma: "es5"
136
+ });
137
+ }
138
+ toPascalCase(str) {
139
+ return str
140
+ .split(" ")
141
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1).toLowerCase())
142
+ .join("");
143
+ }
144
+ }
145
+ //# sourceMappingURL=recipe-generator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"recipe-generator.js","sourceRoot":"","sources":["../../../../src/application/portal/recipe/recipe-generator.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,SAAS,EAAE,MAAM,MAAM,CAAC;AAGjC,OAAO,EAAE,WAAW,EAAE,MAAM,yCAAyC,CAAC;AAEtE,OAAO,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAI3D,MAAM,OAAO,qBAAqB;IAAlC;QACE,2DAA2D;QAC1C,gBAAW,GAAgB,IAAI,WAAW,EAAE,CAAC;IAiMhE,CAAC;IA/LQ,KAAK,CAAC,YAAY,CACvB,MAA0B,EAC1B,cAAmB,EACnB,WAAqB,EACrB,UAAkB,EAClB,oBAA8B,EAC9B,sBAAgC,EAChC,YAA0B,EAC1B,cAA6B;QAE7B,MAAM,IAAI,CAAC,cAAc,CAAC,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,sBAAsB,CAAC,CAAC;QAC3F,MAAM,IAAI,CAAC,+BAA+B,CAAC,YA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,IAAI,CAAC;QACtE,MAAM,IAAI,mCAAmC,CAAC;QAC9C,MAAM,IAAI,IAAI,CAAC,sBAAsB,EAAE,CAAC;QACxC,MAAM,IAAI,IAAI,CAAC;QACf,MAAM,IAAI,KAAK,CAAC;QAChB,OAAO,MAAM,CAAC;IAChB,CAAC;IAEO,sBAAsB;QAC5B,OAAO;4BACiB,CAAC;IAC3B,CAAC;IAEO,KAAK,CAAC,YAAY,CAAC,IAAY;QACrC,OAAO,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE;YAC3B,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,IAAI;YACV,WAAW,EAAE,KAAK;YAClB,QAAQ,EAAE,CAAC;YACX,aAAa,EAAE,KAAK;SACrB,CAAC,CAAC;IACL,CAAC;IAEO,YAAY,CAAC,GAAW;QAC9B,OAAO,GAAG;aACP,KAAK,CAAC,GAAG,CAAC;aACV,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;aACzE,IAAI,CAAC,EAAE,CAAC,CAAC;IACd,CAAC;CACF"}
@@ -1,4 +1,4 @@
1
- import { TocGroup } from "../../../types/toc/toc";
1
+ import { TocGroup } from "../../../types/toc/toc.js";
2
2
  export declare class TocContentParser {
3
3
  parseContentFolder(contentFolderPath: string, workingDirectory: string): Promise<TocGroup[]>;
4
4
  private normalizePath;
@@ -1,9 +1,6 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TocContentParser = void 0;
4
- const path = require("path");
5
- const fs = require("fs-extra");
6
- class TocContentParser {
1
+ import * as path from "path";
2
+ import * as fs from "fs/promises";
3
+ export class TocContentParser {
7
4
  async parseContentFolder(contentFolderPath, workingDirectory) {
8
5
  const items = await fs.readdir(contentFolderPath);
9
6
  const contentItems = [];
@@ -33,14 +30,15 @@ class TocContentParser {
33
30
  return [];
34
31
  }
35
32
  // Wrap everything under a "Custom Content" group
36
- return [{
33
+ return [
34
+ {
37
35
  group: "Custom Content",
38
36
  items: contentItems
39
- }];
37
+ }
38
+ ];
40
39
  }
41
40
  normalizePath(path) {
42
- return path.replace(/\\/g, '/');
41
+ return path.replace(/\\/g, "/");
43
42
  }
44
43
  }
45
- exports.TocContentParser = TocContentParser;
46
- //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidG9jLWNvbnRlbnQtcGFyc2VyLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vLi4vc3JjL2FwcGxpY2F0aW9uL3BvcnRhbC90b2MvdG9jLWNvbnRlbnQtcGFyc2VyLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBLDZCQUE2QjtBQUM3QiwrQkFBK0I7QUFHL0IsTUFBYSxnQkFBZ0I7SUFDM0IsS0FBSyxDQUFDLGtCQUFrQixDQUFDLGlCQUF5QixFQUFFLGdCQUF3QjtRQUMxRSxNQUFNLEtBQUssR0FBRyxNQUFNLEVBQUUsQ0FBQyxPQUFPLENBQUMsaUJBQWlCLENBQUMsQ0FBQztRQUNsRCxNQUFNLFlBQVksR0FBaUMsRUFBRSxDQUFDO1FBRXRELEtBQUssTUFBTSxJQUFJLElBQUksS0FBSyxFQUFFLENBQUM7WUFDekIsTUFBTSxRQUFRLEdBQUcsSUFBSSxDQUFDLElBQUksQ0FBQyxpQkFBaUIsRUFBRSxJQUFJLENBQUMsQ0FBQztZQUNwRCxNQUFNLEtBQUssR0FBRyxNQUFNLEVBQUUsQ0FBQyxJQUFJLENBQUMsUUFBUSxDQUFDLENBQUM7WUFFdEMsSUFBSSxLQUFLLENBQUMsV0FBVyxFQUFFLEVBQUUsQ0FBQztnQkFDeEIsTUFBTSxRQUFRLEdBQUcsTUFBTSxJQUFJLENBQUMsa0JBQWtCLENBQUMsUUF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sT0FBTyxDQUFDLEtBQUssRUFBRSxHQUFHLENBQUMsQ0FBQztJQUNsQyxDQUFDO0NBQ0Y7QUEzQ0QsNENBMkNDIn0=
44
+ //# sourceMappingURL=toc-content-parser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toc-content-parser.js","sourceRoot":"","sources":["../../../../src/application/portal/toc/toc-content-parser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,aAAa,CAAC;AAGlC,MAAM,OAAO,gBAAgB;IAC3B,KAAK,CAAC,kBAAkB,CAAC,iBAAyB,EAAE,gBAAwB;QAC1E,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAC;QAClD,MAAM,YAAY,GAAiC,EAAE,CAAC;QAEtD,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,iBAAiB,EAAE,IAAI,CAAC,CAAC;YACpD,MAAM,KAAK,GAAG,MAAM,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;YAEtC,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;gBACxB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,QAAQ,EAAE,gBAAgB,CAAC,CAAC;gBAC3E,IAAI,QAAQ,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;oBACxB,YAAY,CAAC,IAAI,CAAC;wBAChB,KAAK,EAAE,IAAI;wBACX,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,2CAA2C;qBACrE,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;iBAAM,IAAI,KAAK,CAAC,MAAM,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;gBAClD,MAAM,YAAY,GAAG,IAAI,CAAC,QAAQ,CAAC,gBAAgB,EAAE,QAAQ,CAAC,CAAC;gBAC/D,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;gBAE5C,YAAY,CAAC,IAAI,CAAC;oBAChB,IAAI,EAAE,QAAQ;oBACd,IAAI,EAAE,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC;iBACvC,CAAC,CAAC;YACL,CAAC;QACH,CAAC;QAED,qDAAqD;QACrD,IAAI,YAAY,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC9B,OAAO,EAAE,CAAC;QACZ,CAAC;QAED,iDAAiD;QACjD,OAAO;YACL;gBACE,KAAK,EAAE,gBAAgB;gBACvB,KAAK,EAAE,YAAY;aACpB;SACF,CAAC;IACJ,CAAC;IAEO,aAAa,CAAC,IAAY;QAChC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;IAClC,CAAC;CACF"}
@@ -1,6 +1,27 @@
1
- import { Toc, TocGroup, TocEndpoint, TocModel } from "../../../types/toc/toc";
1
+ import { Toc, TocGroup, TocModelPage, TocCallbackPage, TocWebhookPage, TocEndpoint } from '../../../types/toc/toc.js';
2
+ type Endpoints = {
3
+ data: Map<string, TocEndpoint[]>;
4
+ expand: boolean;
5
+ };
6
+ type Webhooks = {
7
+ data: Map<string, TocWebhookPage[]>;
8
+ expand: boolean;
9
+ };
10
+ type Callbacks = {
11
+ data: Map<string, TocCallbackPage[]>;
12
+ expand: boolean;
13
+ };
14
+ type Models = {
15
+ data: TocModelPage[];
16
+ expand: boolean;
17
+ };
2
18
  export declare class TocStructureGenerator {
3
- createTocStructure(endpointGroups: Map<string, TocEndpoint[]>, models: TocModel[], expandEndpoints?: boolean, expandModels?: boolean, contentGroups?: TocGroup[]): Toc;
19
+ createTocStructure(endpoints: Endpoints, models: Models, webhooks: Webhooks, callbacks: Callbacks, contentGroups?: TocGroup[]): Toc;
4
20
  transformToYaml(toc: Toc): string;
21
+ private getEndpointsSection;
22
+ private getCallbacksSection;
23
+ private getWebhooksSection;
24
+ private getModelsSection;
5
25
  private transformKeys;
6
26
  }
27
+ export {};