@autoview/cli 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (297) hide show
  1. package/LICENSE +661 -0
  2. package/README.md +407 -0
  3. package/lib/AutoViewAgent.d.ts +109 -0
  4. package/lib/AutoViewAgent.js +123 -0
  5. package/lib/AutoViewAgent.js.map +1 -0
  6. package/lib/agent/emitMcpServer.d.ts +15 -0
  7. package/lib/agent/emitMcpServer.js +157 -0
  8. package/lib/agent/emitMcpServer.js.map +1 -0
  9. package/lib/agent/emitReport.d.ts +14 -0
  10. package/lib/agent/emitReport.js +85 -0
  11. package/lib/agent/emitReport.js.map +1 -0
  12. package/lib/agent/toolSurface.d.ts +130 -0
  13. package/lib/agent/toolSurface.js +342 -0
  14. package/lib/agent/toolSurface.js.map +1 -0
  15. package/lib/agent/verifyAgentTasks.d.ts +87 -0
  16. package/lib/agent/verifyAgentTasks.js +126 -0
  17. package/lib/agent/verifyAgentTasks.js.map +1 -0
  18. package/lib/cli/main.d.ts +2 -0
  19. package/lib/cli/main.js +295 -0
  20. package/lib/cli/main.js.map +1 -0
  21. package/lib/compiler/AutoViewInterfaceCompiler.d.ts +27 -0
  22. package/lib/compiler/AutoViewInterfaceCompiler.js +68 -0
  23. package/lib/compiler/AutoViewInterfaceCompiler.js.map +1 -0
  24. package/lib/constants/AutoViewFrontendTemplate.d.ts +1 -0
  25. package/lib/constants/AutoViewFrontendTemplate.js +46 -0
  26. package/lib/constants/AutoViewFrontendTemplate.js.map +1 -0
  27. package/lib/constants/AutoViewSystemPromptConstant.d.ts +5 -0
  28. package/lib/constants/AutoViewSystemPromptConstant.js +4 -0
  29. package/lib/constants/AutoViewSystemPromptConstant.js.map +1 -0
  30. package/lib/context/IAutoViewAgentContext.d.ts +60 -0
  31. package/lib/context/IAutoViewAgentContext.js +3 -0
  32. package/lib/context/IAutoViewAgentContext.js.map +1 -0
  33. package/lib/fromSwagger.d.ts +53 -0
  34. package/lib/fromSwagger.js +513 -0
  35. package/lib/fromSwagger.js.map +1 -0
  36. package/lib/generateDeterministic.d.ts +26 -0
  37. package/lib/generateDeterministic.js +75 -0
  38. package/lib/generateDeterministic.js.map +1 -0
  39. package/lib/index.d.ts +15 -0
  40. package/lib/index.js +41 -0
  41. package/lib/index.js.map +1 -0
  42. package/lib/orchestrate/orchestrateAutoView.d.ts +17 -0
  43. package/lib/orchestrate/orchestrateAutoView.js +491 -0
  44. package/lib/orchestrate/orchestrateAutoView.js.map +1 -0
  45. package/lib/orchestrate/orchestrateAutoViewProductPlan.d.ts +37 -0
  46. package/lib/orchestrate/orchestrateAutoViewProductPlan.js +109 -0
  47. package/lib/orchestrate/orchestrateAutoViewProductPlan.js.map +1 -0
  48. package/lib/orchestrate/orchestrateAutoViewRender.d.ts +133 -0
  49. package/lib/orchestrate/orchestrateAutoViewRender.js +943 -0
  50. package/lib/orchestrate/orchestrateAutoViewRender.js.map +1 -0
  51. package/lib/orchestrate/orchestrateAutoViewRenderDeterministic.d.ts +24 -0
  52. package/lib/orchestrate/orchestrateAutoViewRenderDeterministic.js +92 -0
  53. package/lib/orchestrate/orchestrateAutoViewRenderDeterministic.js.map +1 -0
  54. package/lib/orchestrate/orchestrateAutoViewReview.d.ts +48 -0
  55. package/lib/orchestrate/orchestrateAutoViewReview.js +328 -0
  56. package/lib/orchestrate/orchestrateAutoViewReview.js.map +1 -0
  57. package/lib/orchestrate/orchestrateAutoViewScaffold.d.ts +45 -0
  58. package/lib/orchestrate/orchestrateAutoViewScaffold.js +586 -0
  59. package/lib/orchestrate/orchestrateAutoViewScaffold.js.map +1 -0
  60. package/lib/orchestrate/orchestrateAutoViewSdkStudy.d.ts +26 -0
  61. package/lib/orchestrate/orchestrateAutoViewSdkStudy.js +85 -0
  62. package/lib/orchestrate/orchestrateAutoViewSdkStudy.js.map +1 -0
  63. package/lib/orchestrate/structures/IAutoViewProductPlan.d.ts +96 -0
  64. package/lib/orchestrate/structures/IAutoViewProductPlan.js +3 -0
  65. package/lib/orchestrate/structures/IAutoViewProductPlan.js.map +1 -0
  66. package/lib/orchestrate/structures/IAutoViewProductPlanApplication.d.ts +38 -0
  67. package/lib/orchestrate/structures/IAutoViewProductPlanApplication.js +3 -0
  68. package/lib/orchestrate/structures/IAutoViewProductPlanApplication.js.map +1 -0
  69. package/lib/orchestrate/structures/IAutoViewRenderApplication.d.ts +38 -0
  70. package/lib/orchestrate/structures/IAutoViewRenderApplication.js +3 -0
  71. package/lib/orchestrate/structures/IAutoViewRenderApplication.js.map +1 -0
  72. package/lib/orchestrate/structures/IAutoViewReviewApplication.d.ts +40 -0
  73. package/lib/orchestrate/structures/IAutoViewReviewApplication.js +3 -0
  74. package/lib/orchestrate/structures/IAutoViewReviewApplication.js.map +1 -0
  75. package/lib/orchestrate/structures/IAutoViewSdkMap.d.ts +63 -0
  76. package/lib/orchestrate/structures/IAutoViewSdkMap.js +3 -0
  77. package/lib/orchestrate/structures/IAutoViewSdkMap.js.map +1 -0
  78. package/lib/orchestrate/structures/IAutoViewSdkStudyApplication.d.ts +37 -0
  79. package/lib/orchestrate/structures/IAutoViewSdkStudyApplication.js +3 -0
  80. package/lib/orchestrate/structures/IAutoViewSdkStudyApplication.js.map +1 -0
  81. package/lib/orchestrate/utils/HistoryMessage.d.ts +10 -0
  82. package/lib/orchestrate/utils/HistoryMessage.js +25 -0
  83. package/lib/orchestrate/utils/HistoryMessage.js.map +1 -0
  84. package/lib/orchestrate/utils/auditFrontendRuntime.d.ts +53 -0
  85. package/lib/orchestrate/utils/auditFrontendRuntime.js +362 -0
  86. package/lib/orchestrate/utils/auditFrontendRuntime.js.map +1 -0
  87. package/lib/orchestrate/utils/buildDeterministicPlan.d.ts +4 -0
  88. package/lib/orchestrate/utils/buildDeterministicPlan.js +233 -0
  89. package/lib/orchestrate/utils/buildDeterministicPlan.js.map +1 -0
  90. package/lib/orchestrate/utils/buildDeterministicSdkMap.d.ts +22 -0
  91. package/lib/orchestrate/utils/buildDeterministicSdkMap.js +154 -0
  92. package/lib/orchestrate/utils/buildDeterministicSdkMap.js.map +1 -0
  93. package/lib/orchestrate/utils/cacheNodeModules.d.ts +31 -0
  94. package/lib/orchestrate/utils/cacheNodeModules.js +134 -0
  95. package/lib/orchestrate/utils/cacheNodeModules.js.map +1 -0
  96. package/lib/orchestrate/utils/describeEndpointPropsShape.d.ts +37 -0
  97. package/lib/orchestrate/utils/describeEndpointPropsShape.js +192 -0
  98. package/lib/orchestrate/utils/describeEndpointPropsShape.js.map +1 -0
  99. package/lib/orchestrate/utils/describeEndpointRequestBodyShape.d.ts +22 -0
  100. package/lib/orchestrate/utils/describeEndpointRequestBodyShape.js +29 -0
  101. package/lib/orchestrate/utils/describeEndpointRequestBodyShape.js.map +1 -0
  102. package/lib/orchestrate/utils/describeEndpointResponseShape.d.ts +19 -0
  103. package/lib/orchestrate/utils/describeEndpointResponseShape.js +30 -0
  104. package/lib/orchestrate/utils/describeEndpointResponseShape.js.map +1 -0
  105. package/lib/orchestrate/utils/executeCachedBatch.d.ts +22 -0
  106. package/lib/orchestrate/utils/executeCachedBatch.js +64 -0
  107. package/lib/orchestrate/utils/executeCachedBatch.js.map +1 -0
  108. package/lib/orchestrate/utils/loadShoppingFixture.d.ts +33 -0
  109. package/lib/orchestrate/utils/loadShoppingFixture.js +17 -0
  110. package/lib/orchestrate/utils/loadShoppingFixture.js.map +1 -0
  111. package/lib/orchestrate/utils/normalizeProductPlanPaths.d.ts +24 -0
  112. package/lib/orchestrate/utils/normalizeProductPlanPaths.js +77 -0
  113. package/lib/orchestrate/utils/normalizeProductPlanPaths.js.map +1 -0
  114. package/lib/orchestrate/utils/renderJsonSchema.d.ts +23 -0
  115. package/lib/orchestrate/utils/renderJsonSchema.js +122 -0
  116. package/lib/orchestrate/utils/renderJsonSchema.js.map +1 -0
  117. package/lib/orchestrate/utils/renderResourcePage.d.ts +36 -0
  118. package/lib/orchestrate/utils/renderResourcePage.js +1415 -0
  119. package/lib/orchestrate/utils/renderResourcePage.js.map +1 -0
  120. package/lib/orchestrate/utils/validateFrontendTypecheck.d.ts +109 -0
  121. package/lib/orchestrate/utils/validateFrontendTypecheck.js +274 -0
  122. package/lib/orchestrate/utils/validateFrontendTypecheck.js.map +1 -0
  123. package/lib/preview/renderPreview.d.ts +22 -0
  124. package/lib/preview/renderPreview.js +198 -0
  125. package/lib/preview/renderPreview.js.map +1 -0
  126. package/lib/typings/compiler.d.ts +39 -0
  127. package/lib/typings/compiler.js +3 -0
  128. package/lib/typings/compiler.js.map +1 -0
  129. package/lib/typings/events.d.ts +106 -0
  130. package/lib/typings/events.js +3 -0
  131. package/lib/typings/events.js.map +1 -0
  132. package/lib/typings/index.d.ts +10 -0
  133. package/lib/typings/index.js +27 -0
  134. package/lib/typings/index.js.map +1 -0
  135. package/lib/typings/misc.d.ts +78 -0
  136. package/lib/typings/misc.js +3 -0
  137. package/lib/typings/misc.js.map +1 -0
  138. package/lib/utils/ArrayUtil.d.ts +8 -0
  139. package/lib/utils/ArrayUtil.js +30 -0
  140. package/lib/utils/ArrayUtil.js.map +1 -0
  141. package/lib/utils/StringUtil.d.ts +11 -0
  142. package/lib/utils/StringUtil.js +28 -0
  143. package/lib/utils/StringUtil.js.map +1 -0
  144. package/lib/utils/classifyEndpoints.d.ts +62 -0
  145. package/lib/utils/classifyEndpoints.js +216 -0
  146. package/lib/utils/classifyEndpoints.js.map +1 -0
  147. package/lib/utils/endpointFilter.d.ts +26 -0
  148. package/lib/utils/endpointFilter.js +0 -0
  149. package/lib/utils/endpointFilter.js.map +1 -0
  150. package/lib/utils/extractFields.d.ts +85 -0
  151. package/lib/utils/extractFields.js +231 -0
  152. package/lib/utils/extractFields.js.map +1 -0
  153. package/lib/utils/index.d.ts +13 -0
  154. package/lib/utils/index.js +30 -0
  155. package/lib/utils/index.js.map +1 -0
  156. package/lib/utils/normalizeForNestia.d.ts +34 -0
  157. package/lib/utils/normalizeForNestia.js +133 -0
  158. package/lib/utils/normalizeForNestia.js.map +1 -0
  159. package/lib/utils/resourcePlan.d.ts +39 -0
  160. package/lib/utils/resourcePlan.js +95 -0
  161. package/lib/utils/resourcePlan.js.map +1 -0
  162. package/lib/utils/sliceDocument.d.ts +17 -0
  163. package/lib/utils/sliceDocument.js +114 -0
  164. package/lib/utils/sliceDocument.js.map +1 -0
  165. package/lib/utils/toEndpoints.d.ts +90 -0
  166. package/lib/utils/toEndpoints.js +227 -0
  167. package/lib/utils/toEndpoints.js.map +1 -0
  168. package/lib/verify/runWorkflows.d.ts +25 -0
  169. package/lib/verify/runWorkflows.js +366 -0
  170. package/lib/verify/runWorkflows.js.map +1 -0
  171. package/lib/verify/workflows.d.ts +53 -0
  172. package/lib/verify/workflows.js +107 -0
  173. package/lib/verify/workflows.js.map +1 -0
  174. package/package.json +82 -0
  175. package/prompts/AUTOVIEW_RENDER.md +398 -0
  176. package/prompts/AUTOVIEW_REVIEW.md +60 -0
  177. package/prompts/AUTOVIEW_SDK_STUDY.md +89 -0
  178. package/src/AutoViewAgent.ts +222 -0
  179. package/src/agent/emitMcpServer.integration.test.ts +168 -0
  180. package/src/agent/emitMcpServer.test.ts +51 -0
  181. package/src/agent/emitMcpServer.ts +178 -0
  182. package/src/agent/emitReport.ts +117 -0
  183. package/src/agent/toolSurface.test.ts +243 -0
  184. package/src/agent/toolSurface.ts +501 -0
  185. package/src/agent/verifyAgentTasks.test.ts +106 -0
  186. package/src/agent/verifyAgentTasks.ts +171 -0
  187. package/src/cli/main.ts +363 -0
  188. package/src/compiler/AutoViewInterfaceCompiler.ts +69 -0
  189. package/src/constants/AutoViewFrontendTemplate.ts +42 -0
  190. package/src/constants/AutoViewSystemPromptConstant.ts +6 -0
  191. package/src/context/IAutoViewAgentContext.ts +84 -0
  192. package/src/fromSwagger.test.ts +269 -0
  193. package/src/fromSwagger.ts +500 -0
  194. package/src/generateDeterministic.test.ts +39 -0
  195. package/src/generateDeterministic.ts +77 -0
  196. package/src/index.ts +30 -0
  197. package/src/orchestrate/orchestrateAutoView.ts +590 -0
  198. package/src/orchestrate/orchestrateAutoViewProductPlan.ts +121 -0
  199. package/src/orchestrate/orchestrateAutoViewRender.ts +1117 -0
  200. package/src/orchestrate/orchestrateAutoViewRenderDeterministic.ts +101 -0
  201. package/src/orchestrate/orchestrateAutoViewReview.ts +272 -0
  202. package/src/orchestrate/orchestrateAutoViewScaffold.ts +627 -0
  203. package/src/orchestrate/orchestrateAutoViewSdkStudy.ts +90 -0
  204. package/src/orchestrate/renderNavTs.test.ts +74 -0
  205. package/src/orchestrate/structures/IAutoViewProductPlan.ts +119 -0
  206. package/src/orchestrate/structures/IAutoViewProductPlanApplication.ts +41 -0
  207. package/src/orchestrate/structures/IAutoViewRenderApplication.ts +40 -0
  208. package/src/orchestrate/structures/IAutoViewReviewApplication.ts +42 -0
  209. package/src/orchestrate/structures/IAutoViewSdkMap.ts +72 -0
  210. package/src/orchestrate/structures/IAutoViewSdkStudyApplication.ts +40 -0
  211. package/src/orchestrate/utils/HistoryMessage.ts +41 -0
  212. package/src/orchestrate/utils/auditFrontendRuntime.test.ts +18 -0
  213. package/src/orchestrate/utils/auditFrontendRuntime.ts +454 -0
  214. package/src/orchestrate/utils/buildDeterministicPlan.test.ts +170 -0
  215. package/src/orchestrate/utils/buildDeterministicPlan.ts +289 -0
  216. package/src/orchestrate/utils/buildDeterministicSdkMap.test.ts +90 -0
  217. package/src/orchestrate/utils/buildDeterministicSdkMap.ts +169 -0
  218. package/src/orchestrate/utils/cacheNodeModules.ts +136 -0
  219. package/src/orchestrate/utils/describeEndpointPropsShape.test.ts +86 -0
  220. package/src/orchestrate/utils/describeEndpointPropsShape.ts +202 -0
  221. package/src/orchestrate/utils/describeEndpointRequestBodyShape.test.ts +87 -0
  222. package/src/orchestrate/utils/describeEndpointRequestBodyShape.ts +31 -0
  223. package/src/orchestrate/utils/describeEndpointResponseShape.test.ts +70 -0
  224. package/src/orchestrate/utils/describeEndpointResponseShape.ts +32 -0
  225. package/src/orchestrate/utils/executeCachedBatch.ts +59 -0
  226. package/src/orchestrate/utils/loadShoppingFixture.ts +52 -0
  227. package/src/orchestrate/utils/normalizeProductPlanPaths.ts +92 -0
  228. package/src/orchestrate/utils/renderJsonSchema.test.ts +162 -0
  229. package/src/orchestrate/utils/renderJsonSchema.ts +133 -0
  230. package/src/orchestrate/utils/renderResourcePage.test.ts +468 -0
  231. package/src/orchestrate/utils/renderResourcePage.ts +1624 -0
  232. package/src/orchestrate/utils/validateFrontendTypecheck.test.ts +32 -0
  233. package/src/orchestrate/utils/validateFrontendTypecheck.ts +335 -0
  234. package/src/preview/renderPreview.ts +273 -0
  235. package/src/typings/compiler.ts +47 -0
  236. package/src/typings/events.ts +155 -0
  237. package/src/typings/index.ts +10 -0
  238. package/src/typings/misc.ts +93 -0
  239. package/src/utils/ArrayUtil.ts +16 -0
  240. package/src/utils/StringUtil.ts +29 -0
  241. package/src/utils/classifyEndpoints.test.ts +86 -0
  242. package/src/utils/classifyEndpoints.ts +291 -0
  243. package/src/utils/endpointFilter.test.ts +50 -0
  244. package/src/utils/endpointFilter.ts +0 -0
  245. package/src/utils/extractFields.test.ts +82 -0
  246. package/src/utils/extractFields.ts +306 -0
  247. package/src/utils/index.ts +13 -0
  248. package/src/utils/normalizeForNestia.test.ts +93 -0
  249. package/src/utils/normalizeForNestia.ts +139 -0
  250. package/src/utils/resourcePlan.test.ts +104 -0
  251. package/src/utils/resourcePlan.ts +180 -0
  252. package/src/utils/sliceDocument.test.ts +85 -0
  253. package/src/utils/sliceDocument.ts +119 -0
  254. package/src/utils/toEndpoints.test.ts +251 -0
  255. package/src/utils/toEndpoints.ts +343 -0
  256. package/src/verify/runWorkflows.ts +403 -0
  257. package/src/verify/workflows.test.ts +117 -0
  258. package/src/verify/workflows.ts +154 -0
  259. package/template/CLAUDE.md +140 -0
  260. package/template/Dockerfile +31 -0
  261. package/template/PROMPT.md +80 -0
  262. package/template/SANDBOX.md +70 -0
  263. package/template/app/api/health/route.ts +10 -0
  264. package/template/app/globals.css +97 -0
  265. package/template/app/layout.tsx +30 -0
  266. package/template/app/page.tsx +19 -0
  267. package/template/components/AppShell.tsx +114 -0
  268. package/template/components/auto/CatalogGrid.tsx +159 -0
  269. package/template/components/auto/ConfirmButton.tsx +67 -0
  270. package/template/components/auto/EmbeddedCollection.tsx +144 -0
  271. package/template/components/auto/ResourceDashboard.tsx +104 -0
  272. package/template/components/auto/ResourceDetail.tsx +93 -0
  273. package/template/components/auto/ResourceForm.tsx +235 -0
  274. package/template/components/auto/ResourceIcon.tsx +88 -0
  275. package/template/components/auto/ResourceLanding.tsx +155 -0
  276. package/template/components/auto/ResourceTable.tsx +223 -0
  277. package/template/components/auto/formatValue.tsx +186 -0
  278. package/template/components/auto/types.ts +42 -0
  279. package/template/components/ui/badge.tsx +40 -0
  280. package/template/components/ui/button.tsx +57 -0
  281. package/template/components/ui/card.tsx +86 -0
  282. package/template/components/ui/dialog.tsx +119 -0
  283. package/template/components/ui/input.tsx +23 -0
  284. package/template/components/ui/label.tsx +24 -0
  285. package/template/components/ui/pagination.tsx +117 -0
  286. package/template/components/ui/select.tsx +92 -0
  287. package/template/components/ui/sheet.tsx +135 -0
  288. package/template/components/ui/skeleton.tsx +15 -0
  289. package/template/components/ui/table.tsx +120 -0
  290. package/template/components/ui/tabs.tsx +55 -0
  291. package/template/lib/utils.ts +35 -0
  292. package/template/next.config.mjs +52 -0
  293. package/template/package.json +46 -0
  294. package/template/postcss.config.js +6 -0
  295. package/template/scripts/start-shopping-backend.sh +56 -0
  296. package/template/tailwind.config.ts +96 -0
  297. package/template/tsconfig.json +29 -0
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.describeEndpointResponseShape = describeEndpointResponseShape;
4
+ const renderJsonSchema_1 = require("./renderJsonSchema");
5
+ /**
6
+ * Render the response body type of a single AutoBE operation as a readable,
7
+ * multi-line TypeScript-shaped string. Used by the Render phase to spoon-feed
8
+ * the LLM the exact field names + nesting of every endpoint's return value —
9
+ * otherwise the model invents plausible-sounding properties (e.g. `auth.member`
10
+ * on `IAuthorized` when the real shape is `{ id, created_at, token }`), which
11
+ * then fails TypeScript when the user runs `npm run typecheck` against the
12
+ * generated frontend.
13
+ *
14
+ * Returns `void` when the operation has no response body, so callers can
15
+ * pass-through to `Promise<void>` in the rendered signature. Delegates the
16
+ * actual schema walk to {@link renderJsonSchema} so request and response
17
+ * descriptions stay shape-compatible.
18
+ *
19
+ * Pure. Does not mutate the document.
20
+ */
21
+ function describeEndpointResponseShape(op, doc) {
22
+ if (op.responseBody === null)
23
+ return "void";
24
+ const shape = (0, renderJsonSchema_1.renderNamedSchema)(op.responseBody.typeName, doc);
25
+ // A list endpoint responds with an array of the element type. Make the
26
+ // array explicit so the Render phase builds a table/list off the element
27
+ // fields, not a single-record view.
28
+ return op.responseBody.isArray ? `${shape}[]` : shape;
29
+ }
30
+ //# sourceMappingURL=describeEndpointResponseShape.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describeEndpointResponseShape.js","sourceRoot":"","sources":["../../../src/orchestrate/utils/describeEndpointResponseShape.ts"],"names":[],"mappings":";;AAqBA,sEAUC;AA5BD,yDAAuD;AAEvD;;;;;;;;;;;;;;;GAeG;AACH,SAAgB,6BAA6B,CAC3C,EAAqB,EACrB,GAAsB;IAEtB,IAAI,EAAE,CAAC,YAAY,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IAC5C,MAAM,KAAK,GAAG,IAAA,oCAAiB,EAAC,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC;IAC/D,uEAAuE;IACvE,yEAAyE;IACzE,oCAAoC;IACpC,OAAO,EAAE,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC;AACxD,CAAC"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Executes a task list with semaphore-controlled parallelization.
3
+ *
4
+ * All tasks are dispatched immediately into a worker pool, with concurrency
5
+ * limited by `semaphore` to prevent overwhelming LLM APIs. Results are returned
6
+ * in original order. On the first task failure the remaining queue is aborted
7
+ * and the original error is rethrown.
8
+ *
9
+ * Standalone copy of `@autobe/agent`'s `executeCachedBatch` that takes the
10
+ * concurrency cap directly as a number — the autoview package does not need the
11
+ * full `AutoBeContext` shape just to read `ctx.vendor.semaphore`.
12
+ *
13
+ * @param semaphore Concurrency cap (1–N parallel tasks at any one time).
14
+ * @param taskList List of async tasks to execute, each receiving the cache key
15
+ * as its argument.
16
+ * @param promptCacheKey Optional cache key (generates a UUID if omitted) — used
17
+ * as the user-message body so the LLM provider can reuse a cached system
18
+ * prompt across calls.
19
+ */
20
+ export declare const executeCachedBatch: <T>(semaphore: number, taskList: Task<T>[], promptCacheKey?: string) => Promise<T[]>;
21
+ type Task<T> = (user: string) => Promise<T>;
22
+ export {};
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.executeCachedBatch = void 0;
13
+ const tstl_1 = require("tstl");
14
+ const uuid_1 = require("uuid");
15
+ /**
16
+ * Executes a task list with semaphore-controlled parallelization.
17
+ *
18
+ * All tasks are dispatched immediately into a worker pool, with concurrency
19
+ * limited by `semaphore` to prevent overwhelming LLM APIs. Results are returned
20
+ * in original order. On the first task failure the remaining queue is aborted
21
+ * and the original error is rethrown.
22
+ *
23
+ * Standalone copy of `@autobe/agent`'s `executeCachedBatch` that takes the
24
+ * concurrency cap directly as a number — the autoview package does not need the
25
+ * full `AutoBeContext` shape just to read `ctx.vendor.semaphore`.
26
+ *
27
+ * @param semaphore Concurrency cap (1–N parallel tasks at any one time).
28
+ * @param taskList List of async tasks to execute, each receiving the cache key
29
+ * as its argument.
30
+ * @param promptCacheKey Optional cache key (generates a UUID if omitted) — used
31
+ * as the user-message body so the LLM provider can reuse a cached system
32
+ * prompt across calls.
33
+ */
34
+ const executeCachedBatch = (semaphore, taskList, promptCacheKey) => __awaiter(void 0, void 0, void 0, function* () {
35
+ if (taskList.length === 0)
36
+ return [];
37
+ promptCacheKey !== null && promptCacheKey !== void 0 ? promptCacheKey : (promptCacheKey = (0, uuid_1.v7)());
38
+ const queue = taskList.map((task, index) => new tstl_1.Pair(task, index));
39
+ const results = [];
40
+ let aborted = false;
41
+ let firstError = null;
42
+ yield Promise.allSettled(new Array(Math.min(semaphore, queue.length)).fill(0).map(() => __awaiter(void 0, void 0, void 0, function* () {
43
+ while (queue.length !== 0 && !aborted) {
44
+ const item = queue.splice(0, 1)[0];
45
+ try {
46
+ const result = yield item.first(promptCacheKey);
47
+ if (!aborted)
48
+ results.push(new tstl_1.Pair(result, item.second));
49
+ }
50
+ catch (error) {
51
+ if (!aborted) {
52
+ aborted = true;
53
+ queue.length = 0;
54
+ firstError = error;
55
+ }
56
+ }
57
+ }
58
+ })));
59
+ if (firstError !== null)
60
+ throw firstError;
61
+ return results.sort((x, y) => x.second - y.second).map((p) => p.first);
62
+ });
63
+ exports.executeCachedBatch = executeCachedBatch;
64
+ //# sourceMappingURL=executeCachedBatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"executeCachedBatch.js","sourceRoot":"","sources":["../../../src/orchestrate/utils/executeCachedBatch.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+BAA4B;AAC5B,+BAA0B;AAE1B;;;;;;;;;;;;;;;;;;GAkBG;AACI,MAAM,kBAAkB,GAAG,CAChC,SAAiB,EACjB,QAAm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C,CACH,CAAC;IACF,IAAI,UAAU,KAAK,IAAI;QAAE,MAAM,UAAU,CAAC;IAC1C,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACzE,CAAC,CAAA,CAAC;AAlCW,QAAA,kBAAkB,sBAkC7B"}
@@ -0,0 +1,33 @@
1
+ import { OpenApi } from "@typia/interface";
2
+ /**
3
+ * Lazy-load `@samchon/shopping-api/swagger.json` and convert it to an
4
+ * {@link OpenApi.IDocument} so AutoView can run against a stable reference
5
+ * SDK without depending on the live `interface` phase.
6
+ *
7
+ * Also surfaces the swagger's first declared server URL — the bundled
8
+ * `@samchon/shopping-api` swagger lists `https://shopping-be.wrtn.ai` so the
9
+ * generated frontend can hit a real backend (and render real product names like
10
+ * "Apple Watch") instead of typia-random mock gibberish. The Scaffold phase
11
+ * uses this URL to seed the default `IConnection.host`.
12
+ *
13
+ * The swagger payload is ~700 KB, so the result is memoized on the first call.
14
+ * The conversion reuses the same `invertOpenApiDocument` helper the live
15
+ * interface compiler relies on, which means the rest of the AutoView pipeline
16
+ * cannot tell the document came from a fixture instead of a freshly generated
17
+ * session.
18
+ *
19
+ * The shopping-api package ships an OpenAPI 3.x document — its shape is
20
+ * structurally identical to typia's `OpenApi.IDocument`, so we cast through
21
+ * `unknown` rather than dragging in another normalization library. The
22
+ * downstream invert helper validates the relevant fields itself; an
23
+ * incompatible document would surface there.
24
+ */
25
+ export interface IShoppingFixture {
26
+ document: OpenApi.IDocument;
27
+ /**
28
+ * First entry from `swagger.servers[]`. `null` when the swagger omits
29
+ * `servers` (the SDK would then have to rely on simulate-only mocks).
30
+ */
31
+ serverUrl: string | null;
32
+ }
33
+ export declare function loadShoppingFixture(): IShoppingFixture;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loadShoppingFixture = loadShoppingFixture;
4
+ const utils_1 = require("@typia/utils");
5
+ let cached = null;
6
+ function loadShoppingFixture() {
7
+ var _a, _b, _c;
8
+ if (cached !== null)
9
+ return cached;
10
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
11
+ const swagger = require("@samchon/shopping-api/swagger.json");
12
+ const document = utils_1.OpenApiConverter.upgradeDocument(swagger);
13
+ const serverUrl = (_c = (_b = (_a = swagger.servers) === null || _a === void 0 ? void 0 : _a.find((s) => typeof (s === null || s === void 0 ? void 0 : s.url) === "string" && s.url.length > 0)) === null || _b === void 0 ? void 0 : _b.url) !== null && _c !== void 0 ? _c : null;
14
+ cached = { document, serverUrl: serverUrl !== null && serverUrl !== void 0 ? serverUrl : null };
15
+ return cached;
16
+ }
17
+ //# sourceMappingURL=loadShoppingFixture.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loadShoppingFixture.js","sourceRoot":"","sources":["../../../src/orchestrate/utils/loadShoppingFixture.ts"],"names":[],"mappings":";;AAqCA,kDAcC;AAlDD,wCAAgD;AAkChD,IAAI,MAAM,GAA4B,IAAI,CAAC;AAE3C,SAAgB,mBAAmB;;IACjC,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,MAAM,CAAC;IACnC,iEAAiE;IACjE,MAAM,OAAO,GAAG,OAAO,CAAC,oCAAoC,CAE3D,CAAC;IACF,MAAM,QAAQ,GAAG,wBAAgB,CAAC,eAAe,CAC/C,OAA4E,CAC7E,CAAC;IACF,MAAM,SAAS,GACb,MAAA,MAAA,MAAA,OAAO,CAAC,OAAO,0CAAE,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,GAAG,CAAA,KAAK,QAAQ,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,0CACxE,GAAG,mCAAI,IAAI,CAAC;IAClB,MAAM,GAAG,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,aAAT,SAAS,cAAT,SAAS,GAAI,IAAI,EAAE,CAAC;IACpD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { IAutoViewProductPlan } from "../structures/IAutoViewProductPlan";
2
+ /**
3
+ * Normalize Next.js dynamic-segment names inside a product plan so the
4
+ * generated app router does not blow up with the `"You cannot use different
5
+ * slug names for the same dynamic path"` error.
6
+ *
7
+ * Background: the Product Plan phase routinely emits sibling routes such as
8
+ * `/sales/[id]` and `/sales/[saleId]/questions`. Next.js refuses to start when
9
+ * two routes under the same parent disagree on the dynamic-segment name. Rather
10
+ * than re-running the planner just to fix the slugs, we rewrite every dynamic
11
+ * segment in place so the first name we saw at a given parent prefix wins.
12
+ *
13
+ * The rewrite touches three places that all need to stay in sync:
14
+ *
15
+ * - `screens[].path` (and the screens are returned in the same order so the
16
+ * Render phase still maps the right TSX to the right route).
17
+ * - `navigation[].primary` / `navigation[].secondary` (path arrays referencing
18
+ * the screens above).
19
+ * - That's it — `IOmission.target` is a free-form label, not a path, so the
20
+ * function leaves it alone.
21
+ *
22
+ * Pure. Does not mutate the input.
23
+ */
24
+ export declare function normalizeProductPlanPaths(plan: IAutoViewProductPlan): IAutoViewProductPlan;
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeProductPlanPaths = normalizeProductPlanPaths;
4
+ /**
5
+ * Normalize Next.js dynamic-segment names inside a product plan so the
6
+ * generated app router does not blow up with the `"You cannot use different
7
+ * slug names for the same dynamic path"` error.
8
+ *
9
+ * Background: the Product Plan phase routinely emits sibling routes such as
10
+ * `/sales/[id]` and `/sales/[saleId]/questions`. Next.js refuses to start when
11
+ * two routes under the same parent disagree on the dynamic-segment name. Rather
12
+ * than re-running the planner just to fix the slugs, we rewrite every dynamic
13
+ * segment in place so the first name we saw at a given parent prefix wins.
14
+ *
15
+ * The rewrite touches three places that all need to stay in sync:
16
+ *
17
+ * - `screens[].path` (and the screens are returned in the same order so the
18
+ * Render phase still maps the right TSX to the right route).
19
+ * - `navigation[].primary` / `navigation[].secondary` (path arrays referencing
20
+ * the screens above).
21
+ * - That's it — `IOmission.target` is a free-form label, not a path, so the
22
+ * function leaves it alone.
23
+ *
24
+ * Pure. Does not mutate the input.
25
+ */
26
+ function normalizeProductPlanPaths(plan) {
27
+ const canonical = new Map(); // parentPrefix -> slug name
28
+ const rewrites = new Map(); // original → normalized
29
+ const normalize = (path) => {
30
+ const cached = rewrites.get(path);
31
+ if (cached !== undefined)
32
+ return cached;
33
+ const result = normalizeSinglePath(path, canonical);
34
+ rewrites.set(path, result);
35
+ return result;
36
+ };
37
+ // First pass: build the canonical map by walking screens in order.
38
+ // The first screen that introduces a dynamic segment at a given
39
+ // parent wins, which matches the operator's mental model when they
40
+ // scan the plan top-to-bottom.
41
+ const screens = plan.screens.map((screen) => (Object.assign(Object.assign({}, screen), { path: normalize(screen.path) })));
42
+ // Second pass: rewrite nav references through the same map.
43
+ const navigation = plan.navigation.map((nav) => (Object.assign(Object.assign({}, nav), { primary: nav.primary.map(normalize), secondary: nav.secondary.map(normalize) })));
44
+ return {
45
+ screens,
46
+ navigation,
47
+ intentionalOmissions: plan.intentionalOmissions,
48
+ };
49
+ }
50
+ function normalizeSinglePath(path, canonical) {
51
+ const segments = path.replace(/^\/+/, "").split("/");
52
+ if (segments.length === 0 || segments[0] === "")
53
+ return path;
54
+ let prefix = "";
55
+ const out = [];
56
+ for (const seg of segments) {
57
+ const dynamic = /^\[(.+)\]$/.exec(seg);
58
+ if (dynamic === null) {
59
+ out.push(seg);
60
+ prefix = `${prefix}/${seg}`;
61
+ continue;
62
+ }
63
+ const known = canonical.get(prefix);
64
+ if (known === undefined) {
65
+ canonical.set(prefix, dynamic[1]);
66
+ out.push(seg);
67
+ prefix = `${prefix}/${seg}`;
68
+ }
69
+ else {
70
+ const normalized = `[${known}]`;
71
+ out.push(normalized);
72
+ prefix = `${prefix}/${normalized}`;
73
+ }
74
+ }
75
+ return `/${out.join("/")}`;
76
+ }
77
+ //# sourceMappingURL=normalizeProductPlanPaths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalizeProductPlanPaths.js","sourceRoot":"","sources":["../../../src/orchestrate/utils/normalizeProductPlanPaths.ts"],"names":[],"mappings":";;AAwBA,8DAsCC;AA5DD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,SAAgB,yBAAyB,CACvC,IAA0B;IAE1B,MAAM,SAAS,GAAG,IAAI,GAAG,EAAkB,CAAC,CAAC,4BAA4B;IACzE,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAkB,CAAC,CAAC,wBAAwB;IACpE,MAAM,SAAS,GAAG,CAAC,IAAY,EAAU,EAAE;QACzC,MAAM,MAAM,GAAG,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,MAAM,KAAK,SAAS;YAAE,OAAO,MAAM,CAAC;QACxC,MAAM,MAAM,GAAG,mBAAmB,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;QACpD,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;QAC3B,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC;IAEF,mEAAmE;IACnE,gEAAgE;IAChE,mEAAmE;IACnE,+BAA+B;IAC/B,MAAM,OAAO,GAAmC,IAAI,CAAC,OAAO,CAAC,GAAG,CAC9D,CAAC,MAAM,EAAE,EAAE,CAAC,iCACP,MAAM,KACT,IAAI,EAAE,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAC5B,CACH,CAAC;IAEF,4DAA4D;IAC5D,MAAM,UAAU,GAAuC,IAAI,CAAC,UAAU,CAAC,GAAG,CACxE,CAAC,GAAG,EAAE,EAAE,CAAC,iCACJ,GAAG,KACN,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,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AG,GAAG,MAAM,IAAI,UAAU,EAAE,CAAC;QACrC,CAAC;IACH,CAAC;IACD,OAAO,IAAI,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC;AAC7B,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { OpenApi } from "@typia/interface";
2
+ /**
3
+ * Render an OpenAPI schema (or a named schema reference) as a readable,
4
+ * multi-line TypeScript-shaped string. The output is intended for inclusion in
5
+ * an LLM prompt where the model has to write a TSX page against an SDK type —
6
+ * raw OpenAPI JSON forces the model to mentally translate schema indirection
7
+ * back into TypeScript and it routinely improvises instead of doing the work.
8
+ *
9
+ * Nested `$ref` targets are inlined up to a fixed depth so the LLM does not
10
+ * have to chase indirection. Beyond that depth the bare type name is emitted so
11
+ * cycles stay finite. Properties are kept in declaration order; optional fields
12
+ * are suffixed with `?`. String formats (`uuid`, `date-time`, ...) are appended
13
+ * as a trailing comment so the LLM can still see the semantic when it matters.
14
+ *
15
+ * Pure. Does not mutate the document.
16
+ */
17
+ export declare function renderJsonSchema(schema: OpenApi.IJsonSchema, doc: OpenApi.IDocument): string;
18
+ /**
19
+ * Look up a schema by its component name and render it. Returns the bare type
20
+ * name when the schema is missing from `(doc.components?.schemas ?? {})` so callers can
21
+ * still surface something useful when the document is incomplete.
22
+ */
23
+ export declare function renderNamedSchema(typeName: string, doc: OpenApi.IDocument): string;
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.renderJsonSchema = renderJsonSchema;
4
+ exports.renderNamedSchema = renderNamedSchema;
5
+ /**
6
+ * Render an OpenAPI schema (or a named schema reference) as a readable,
7
+ * multi-line TypeScript-shaped string. The output is intended for inclusion in
8
+ * an LLM prompt where the model has to write a TSX page against an SDK type —
9
+ * raw OpenAPI JSON forces the model to mentally translate schema indirection
10
+ * back into TypeScript and it routinely improvises instead of doing the work.
11
+ *
12
+ * Nested `$ref` targets are inlined up to a fixed depth so the LLM does not
13
+ * have to chase indirection. Beyond that depth the bare type name is emitted so
14
+ * cycles stay finite. Properties are kept in declaration order; optional fields
15
+ * are suffixed with `?`. String formats (`uuid`, `date-time`, ...) are appended
16
+ * as a trailing comment so the LLM can still see the semantic when it matters.
17
+ *
18
+ * Pure. Does not mutate the document.
19
+ */
20
+ function renderJsonSchema(schema, doc) {
21
+ return renderSchema(schema, doc, 0);
22
+ }
23
+ /**
24
+ * Look up a schema by its component name and render it. Returns the bare type
25
+ * name when the schema is missing from `(doc.components?.schemas ?? {})` so callers can
26
+ * still surface something useful when the document is incomplete.
27
+ */
28
+ function renderNamedSchema(typeName, doc) {
29
+ var _a, _b;
30
+ const schema = ((_b = (_a = doc.components) === null || _a === void 0 ? void 0 : _a.schemas) !== null && _b !== void 0 ? _b : {})[typeName];
31
+ if (schema === undefined)
32
+ return typeName;
33
+ return renderJsonSchema(schema, doc);
34
+ }
35
+ const MAX_DEPTH = 3;
36
+ const INDENT = " ";
37
+ function renderSchema(schema, doc, depth) {
38
+ var _a, _b;
39
+ if ("$ref" in schema && typeof schema.$ref === "string") {
40
+ const name = schema.$ref.replace(/^#\/components\/schemas\//, "");
41
+ if (depth >= MAX_DEPTH)
42
+ return name;
43
+ const target = ((_b = (_a = doc.components) === null || _a === void 0 ? void 0 : _a.schemas) !== null && _b !== void 0 ? _b : {})[name];
44
+ if (target === undefined)
45
+ return name;
46
+ return renderSchema(target, doc, depth);
47
+ }
48
+ if ("oneOf" in schema) {
49
+ const parts = schema.oneOf.map((branch) => renderSchema(branch, doc, depth));
50
+ return parts.length > 0 ? parts.join(" | ") : "unknown";
51
+ }
52
+ if ("const" in schema) {
53
+ return JSON.stringify(schema.const);
54
+ }
55
+ if (!("type" in schema))
56
+ return "unknown";
57
+ switch (schema.type) {
58
+ case "boolean":
59
+ return "boolean";
60
+ case "integer":
61
+ case "number":
62
+ return "number";
63
+ case "string": {
64
+ const tagged = formatStringTag(schema);
65
+ return tagged === null ? "string" : `string /* ${tagged} */`;
66
+ }
67
+ case "null":
68
+ return "null";
69
+ case "array": {
70
+ // OpenAPI arrays are `IArray | ITuple`; only `IArray` carries `items`.
71
+ // Real-world swaggers (Stripe) also ship array schemas with no `items`
72
+ // at all — degrade to `unknown[]` instead of recursing into `undefined`.
73
+ if (!("items" in schema) || schema.items == null) {
74
+ return "unknown[]";
75
+ }
76
+ const item = renderSchema(schema.items, doc, depth);
77
+ return needsArrayWrap(item) ? `Array<${item}>` : `${item}[]`;
78
+ }
79
+ case "object":
80
+ return renderObject(schema, doc, depth);
81
+ }
82
+ return "unknown";
83
+ }
84
+ function renderObject(schema, doc, depth) {
85
+ var _a;
86
+ // `properties` is nominally required by the schema type, but real-world
87
+ // swaggers (Stripe) ship `type: "object"` schemas with no `properties`
88
+ // key — typically a free-form map declared only via
89
+ // `additionalProperties`. `Object.entries(undefined)` throws, so guard
90
+ // to a `Record<string, unknown>`-ish placeholder instead of crashing
91
+ // the whole Render phase.
92
+ if (schema.properties === undefined || schema.properties === null) {
93
+ return "{ [key: string]: unknown }";
94
+ }
95
+ const entries = Object.entries(schema.properties);
96
+ if (entries.length === 0)
97
+ return "{}";
98
+ if (depth >= MAX_DEPTH)
99
+ return "{ ... }";
100
+ const required = new Set((_a = schema.required) !== null && _a !== void 0 ? _a : []);
101
+ const pad = INDENT.repeat(depth + 1);
102
+ const closePad = INDENT.repeat(depth);
103
+ const lines = entries.map(([name, prop]) => {
104
+ const rendered = renderSchema(prop, doc, depth + 1);
105
+ const optional = required.has(name) ? "" : "?";
106
+ return `${pad}${name}${optional}: ${rendered};`;
107
+ });
108
+ return `{\n${lines.join("\n")}\n${closePad}}`;
109
+ }
110
+ function needsArrayWrap(rendered) {
111
+ if (rendered.includes(" | "))
112
+ return true;
113
+ if (rendered.startsWith("{"))
114
+ return true;
115
+ return false;
116
+ }
117
+ function formatStringTag(schema) {
118
+ if (typeof schema.format === "string")
119
+ return schema.format;
120
+ return null;
121
+ }
122
+ //# sourceMappingURL=renderJsonSchema.js.map
@@ -0,0 +1 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C,OAAO,GAAG,GAAG,GAAG,IAAI,GAAG,QAAQ,KAAK,QAAQ,GAAG,CAAC;IAClD,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,QAAQ,GAAG,CAAC;AAChD,CAAC;AAED,SAAS,cAAc,CAAC,QAAgB;IACtC,IAAI,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1C,IAAI,QAAQ,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1C,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,eAAe,CACtB,MAAmC;IAEnC,IAAI,OAAO,MAAM,CAAC,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,MAAM,CAAC;IAC5D,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { OpenApi } from "@typia/interface";
2
+ import { IFieldSpec } from "../../utils/extractFields";
3
+ import { IAutoViewEndpoint } from "../../utils/toEndpoints";
4
+ import { IAutoViewProductPlan } from "../structures/IAutoViewProductPlan";
5
+ /**
6
+ * Deterministic page generator — the replacement for the LLM Render phase.
7
+ *
8
+ * Given one planned screen and the operations it composes, emit a complete,
9
+ * runnable `page.tsx` that wires the typed SDK call to one of the universal
10
+ * `Resource*` components (table / detail / form / landing). The component set is
11
+ * static (shipped in the template); this only produces the thin per-route page:
12
+ *
13
+ * - column / field metadata baked from {@link extractFields} (every property of
14
+ * the row / response / request type → one column / row / input — dense and
15
+ * complete by construction, never an LLM-chosen subset),
16
+ * - a typed SDK call whose `props` argument is cast to
17
+ * `Parameters<typeof api.functional.X.method>[1]` so the generated project
18
+ * typechecks against Nestia's exact generated types without this generator
19
+ * needing to import them.
20
+ *
21
+ * Same swagger → same pages, every run. No LLM, no retries, no typecheck
22
+ * roulette.
23
+ */
24
+ export declare function renderResourcePage(screen: IAutoViewProductPlan.IScreen, endpoints: IAutoViewEndpoint[], document: OpenApi.IDocument, allScreens: IAutoViewProductPlan.IScreen[]): string;
25
+ /**
26
+ * The browsable ROW collection a response carries, or `null` for a single object
27
+ * / void. Shared by the screen classifier (list vs detail) and the table
28
+ * renderer so they never disagree. Recognizes a bare array, a generically named
29
+ * wrapper (`data`/`entries`), a wrapper named after the resource
30
+ * (`{ droplets: [...] }`, DigitalOcean), and an element that is a `$ref` type OR
31
+ * an INLINE object (DO's droplet shape is inline).
32
+ */
33
+ export declare function responseCollection(op: IAutoViewEndpoint, doc: OpenApi.IDocument): {
34
+ field: string | null;
35
+ columns: IFieldSpec[];
36
+ } | null;