@superblocksteam/vite-plugin-file-sync 2.0.55 → 2.0.56-next.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 (369) hide show
  1. package/dist/ai-service/agent/prompts/build-base-system-prompt.d.ts.map +1 -1
  2. package/dist/ai-service/agent/prompts/build-base-system-prompt.js +394 -2303
  3. package/dist/ai-service/agent/prompts/build-base-system-prompt.js.map +1 -1
  4. package/dist/ai-service/agent/subagents/apis/examples.d.ts.map +1 -1
  5. package/dist/ai-service/agent/subagents/apis/examples.js +34 -35
  6. package/dist/ai-service/agent/subagents/apis/examples.js.map +1 -1
  7. package/dist/ai-service/agent/subagents/apis/generate-api-source.d.ts +2 -8
  8. package/dist/ai-service/agent/subagents/apis/generate-api-source.d.ts.map +1 -1
  9. package/dist/ai-service/agent/subagents/apis/generate-api-source.js +17 -46
  10. package/dist/ai-service/agent/subagents/apis/generate-api-source.js.map +1 -1
  11. package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts +0 -1
  12. package/dist/ai-service/agent/subagents/apis/prompt-builder.d.ts.map +1 -1
  13. package/dist/ai-service/agent/subagents/apis/prompt-builder.js +4 -25
  14. package/dist/ai-service/agent/subagents/apis/prompt-builder.js.map +1 -1
  15. package/dist/ai-service/agent/subagents/apis/state.js +1 -1
  16. package/dist/ai-service/agent/subagents/apis/state.js.map +1 -1
  17. package/dist/ai-service/agent/subagents/apis/system-prompt.d.ts +1 -1
  18. package/dist/ai-service/agent/subagents/apis/system-prompt.d.ts.map +1 -1
  19. package/dist/ai-service/agent/subagents/apis/system-prompt.js +134 -173
  20. package/dist/ai-service/agent/subagents/apis/system-prompt.js.map +1 -1
  21. package/dist/ai-service/agent/subagents/apis/types.d.ts +1 -4
  22. package/dist/ai-service/agent/subagents/apis/types.d.ts.map +1 -1
  23. package/dist/ai-service/agent/tool-message-utils.d.ts.map +1 -1
  24. package/dist/ai-service/agent/tool-message-utils.js +14 -31
  25. package/dist/ai-service/agent/tool-message-utils.js.map +1 -1
  26. package/dist/ai-service/agent/tools/apis/build-api.d.ts +1 -6
  27. package/dist/ai-service/agent/tools/apis/build-api.d.ts.map +1 -1
  28. package/dist/ai-service/agent/tools/apis/build-api.js +12 -21
  29. package/dist/ai-service/agent/tools/apis/build-api.js.map +1 -1
  30. package/dist/ai-service/agent/tools/apis/finalize-api.d.ts +2 -6
  31. package/dist/ai-service/agent/tools/apis/finalize-api.d.ts.map +1 -1
  32. package/dist/ai-service/agent/tools/apis/finalize-api.js +29 -20
  33. package/dist/ai-service/agent/tools/apis/finalize-api.js.map +1 -1
  34. package/dist/ai-service/agent/tools/build-edit-file.d.ts.map +1 -1
  35. package/dist/ai-service/agent/tools/build-edit-file.js +4 -9
  36. package/dist/ai-service/agent/tools/build-edit-file.js.map +1 -1
  37. package/dist/ai-service/agent/tools/build-install-packages.d.ts +7 -1
  38. package/dist/ai-service/agent/tools/build-install-packages.d.ts.map +1 -1
  39. package/dist/ai-service/agent/tools/build-install-packages.js +43 -8
  40. package/dist/ai-service/agent/tools/build-install-packages.js.map +1 -1
  41. package/dist/ai-service/agent/tools/build-manage-checklist.d.ts +1 -1
  42. package/dist/ai-service/agent/tools/build-multi-edit-file.d.ts.map +1 -1
  43. package/dist/ai-service/agent/tools/build-multi-edit-file.js +7 -9
  44. package/dist/ai-service/agent/tools/build-multi-edit-file.js.map +1 -1
  45. package/dist/ai-service/agent/tools/build-read-files.d.ts +2 -0
  46. package/dist/ai-service/agent/tools/build-read-files.d.ts.map +1 -1
  47. package/dist/ai-service/agent/tools/build-read-files.js +18 -18
  48. package/dist/ai-service/agent/tools/build-read-files.js.map +1 -1
  49. package/dist/ai-service/agent/tools/build-rename-file.d.ts +11 -0
  50. package/dist/ai-service/agent/tools/build-rename-file.d.ts.map +1 -0
  51. package/dist/ai-service/agent/tools/build-rename-file.js +103 -0
  52. package/dist/ai-service/agent/tools/build-rename-file.js.map +1 -0
  53. package/dist/ai-service/agent/tools/build-validate-icons.d.ts +0 -1
  54. package/dist/ai-service/agent/tools/build-validate-icons.d.ts.map +1 -1
  55. package/dist/ai-service/agent/tools/build-validate-icons.js +0 -6
  56. package/dist/ai-service/agent/tools/build-validate-icons.js.map +1 -1
  57. package/dist/ai-service/agent/tools/build-write-file.d.ts.map +1 -1
  58. package/dist/ai-service/agent/tools/build-write-file.js +5 -6
  59. package/dist/ai-service/agent/tools/build-write-file.js.map +1 -1
  60. package/dist/ai-service/agent/tools/index.d.ts +0 -10
  61. package/dist/ai-service/agent/tools/index.d.ts.map +1 -1
  62. package/dist/ai-service/agent/tools/index.js +0 -10
  63. package/dist/ai-service/agent/tools/index.js.map +1 -1
  64. package/dist/ai-service/agent/tools/shared-helpers.d.ts +1 -7
  65. package/dist/ai-service/agent/tools/shared-helpers.d.ts.map +1 -1
  66. package/dist/ai-service/agent/tools/shared-helpers.js +9 -29
  67. package/dist/ai-service/agent/tools/shared-helpers.js.map +1 -1
  68. package/dist/ai-service/agent/tools.d.ts.map +1 -1
  69. package/dist/ai-service/agent/tools.js +5 -11
  70. package/dist/ai-service/agent/tools.js.map +1 -1
  71. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts +1 -2
  72. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.d.ts.map +1 -1
  73. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js +89 -67
  74. package/dist/ai-service/agent/tools2/tools/exit-plan-mode.js.map +1 -1
  75. package/dist/ai-service/agent/tools2/tools/explain-code-finalize.d.ts +4 -0
  76. package/dist/ai-service/agent/tools2/tools/explain-code-finalize.d.ts.map +1 -0
  77. package/dist/ai-service/agent/tools2/tools/explain-code-finalize.js +19 -0
  78. package/dist/ai-service/agent/tools2/tools/explain-code-finalize.js.map +1 -0
  79. package/dist/ai-service/agent/tools2/tools/glob.d.ts.map +1 -1
  80. package/dist/ai-service/agent/tools2/tools/glob.js +15 -6
  81. package/dist/ai-service/agent/tools2/tools/glob.js.map +1 -1
  82. package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts +13 -0
  83. package/dist/ai-service/agent/tools2/tools/grep-metadata.d.ts.map +1 -1
  84. package/dist/ai-service/agent/tools2/tools/grep-metadata.js +21 -0
  85. package/dist/ai-service/agent/tools2/tools/grep-metadata.js.map +1 -1
  86. package/dist/ai-service/agent/tools2/tools/index.d.ts +1 -0
  87. package/dist/ai-service/agent/tools2/tools/index.d.ts.map +1 -1
  88. package/dist/ai-service/agent/tools2/tools/index.js +1 -0
  89. package/dist/ai-service/agent/tools2/tools/index.js.map +1 -1
  90. package/dist/ai-service/agent/tools2/tools/ls.d.ts +10 -0
  91. package/dist/ai-service/agent/tools2/tools/ls.d.ts.map +1 -0
  92. package/dist/ai-service/agent/tools2/tools/ls.js +71 -0
  93. package/dist/ai-service/agent/tools2/tools/ls.js.map +1 -0
  94. package/dist/ai-service/agent/utils.d.ts +0 -35
  95. package/dist/ai-service/agent/utils.d.ts.map +1 -1
  96. package/dist/ai-service/agent/utils.js +0 -132
  97. package/dist/ai-service/agent/utils.js.map +1 -1
  98. package/dist/ai-service/app-interface/file-system-interface.d.ts +1 -1
  99. package/dist/ai-service/app-interface/file-system-interface.d.ts.map +1 -1
  100. package/dist/ai-service/app-interface/file-system-interface.js +2 -2
  101. package/dist/ai-service/app-interface/file-system-interface.js.map +1 -1
  102. package/dist/ai-service/app-interface/shell.d.ts +5 -0
  103. package/dist/ai-service/app-interface/shell.d.ts.map +1 -1
  104. package/dist/ai-service/app-interface/shell.js +60 -0
  105. package/dist/ai-service/app-interface/shell.js.map +1 -1
  106. package/dist/ai-service/chat/chat-session-store.d.ts.map +1 -1
  107. package/dist/ai-service/chat/chat-session-store.js +8 -1
  108. package/dist/ai-service/chat/chat-session-store.js.map +1 -1
  109. package/dist/ai-service/clark-provider/clark-chat-settings.d.ts +2 -1
  110. package/dist/ai-service/clark-provider/clark-chat-settings.d.ts.map +1 -1
  111. package/dist/ai-service/clark-provider/clark-chat-settings.js +1 -0
  112. package/dist/ai-service/clark-provider/clark-chat-settings.js.map +1 -1
  113. package/dist/ai-service/const.d.ts +3 -7
  114. package/dist/ai-service/const.d.ts.map +1 -1
  115. package/dist/ai-service/const.js +2 -6
  116. package/dist/ai-service/const.js.map +1 -1
  117. package/dist/ai-service/context/app-context.d.ts +2 -1
  118. package/dist/ai-service/context/app-context.d.ts.map +1 -1
  119. package/dist/ai-service/context/app-context.js +9 -15
  120. package/dist/ai-service/context/app-context.js.map +1 -1
  121. package/dist/ai-service/index.d.ts +4 -4
  122. package/dist/ai-service/index.d.ts.map +1 -1
  123. package/dist/ai-service/index.js +168 -16
  124. package/dist/ai-service/index.js.map +1 -1
  125. package/dist/ai-service/llm/impl/anthropic.d.ts.map +1 -1
  126. package/dist/ai-service/llm/impl/anthropic.js +1 -0
  127. package/dist/ai-service/llm/impl/anthropic.js.map +1 -1
  128. package/dist/ai-service/llm/impl/clark.d.ts.map +1 -1
  129. package/dist/ai-service/llm/impl/clark.js +1 -0
  130. package/dist/ai-service/llm/impl/clark.js.map +1 -1
  131. package/dist/ai-service/llm/provider.d.ts.map +1 -1
  132. package/dist/ai-service/llm/provider.js +1 -0
  133. package/dist/ai-service/llm/provider.js.map +1 -1
  134. package/dist/ai-service/llm/types.d.ts +1 -1
  135. package/dist/ai-service/llm/types.d.ts.map +1 -1
  136. package/dist/ai-service/prompt-builder-service/types.d.ts +0 -2
  137. package/dist/ai-service/prompt-builder-service/types.d.ts.map +1 -1
  138. package/dist/ai-service/prompt-builder-service/types.js.map +1 -1
  139. package/dist/ai-service/prompts/explain-code.d.ts +7 -0
  140. package/dist/ai-service/prompts/explain-code.d.ts.map +1 -0
  141. package/dist/ai-service/prompts/explain-code.js +23 -0
  142. package/dist/ai-service/prompts/explain-code.js.map +1 -0
  143. package/dist/ai-service/state-machine/clark-fsm.d.ts +0 -2
  144. package/dist/ai-service/state-machine/clark-fsm.d.ts.map +1 -1
  145. package/dist/ai-service/state-machine/clark-fsm.js.map +1 -1
  146. package/dist/ai-service/state-machine/handlers/agent-planning.js +16 -16
  147. package/dist/ai-service/state-machine/handlers/agent-planning.js.map +1 -1
  148. package/dist/ai-service/state-machine/handlers/llm-generating.d.ts.map +1 -1
  149. package/dist/ai-service/state-machine/handlers/llm-generating.js +39 -4
  150. package/dist/ai-service/state-machine/handlers/llm-generating.js.map +1 -1
  151. package/dist/ai-service/state-machine/mocks.d.ts.map +1 -1
  152. package/dist/ai-service/state-machine/mocks.js +1 -0
  153. package/dist/ai-service/state-machine/mocks.js.map +1 -1
  154. package/dist/ai-service/test-utils/app-generation-mocks/orders-app.d.ts +1 -1
  155. package/dist/ai-service/test-utils/app-generation-mocks/orders-app.d.ts.map +1 -1
  156. package/dist/ai-service/test-utils/app-generation-mocks/orders-app.js +0 -7
  157. package/dist/ai-service/test-utils/app-generation-mocks/orders-app.js.map +1 -1
  158. package/dist/ai-service/test-utils/app-generation-mocks/smoketest.d.ts +1 -1
  159. package/dist/ai-service/test-utils/app-generation-mocks/smoketest.d.ts.map +1 -1
  160. package/dist/ai-service/test-utils/app-generation-mocks/smoketest.js +0 -8
  161. package/dist/ai-service/test-utils/app-generation-mocks/smoketest.js.map +1 -1
  162. package/dist/ai-service/transform/api-builder/to-sdk-transformer.d.ts.map +1 -1
  163. package/dist/ai-service/transform/api-builder/to-sdk-transformer.js +0 -15
  164. package/dist/ai-service/transform/api-builder/to-sdk-transformer.js.map +1 -1
  165. package/dist/ai-service/transform/api-builder/to-yaml-transformer.d.ts.map +1 -1
  166. package/dist/ai-service/transform/api-builder/to-yaml-transformer.js +0 -13
  167. package/dist/ai-service/transform/api-builder/to-yaml-transformer.js.map +1 -1
  168. package/dist/ai-service/types.d.ts +2 -2
  169. package/dist/ai-service/types.d.ts.map +1 -1
  170. package/dist/ai-service/util/json-stream-parser.d.ts +20 -0
  171. package/dist/ai-service/util/json-stream-parser.d.ts.map +1 -0
  172. package/dist/ai-service/util/json-stream-parser.js +139 -0
  173. package/dist/ai-service/util/json-stream-parser.js.map +1 -0
  174. package/dist/binding-extraction/extract-identifiers.d.ts +1 -5
  175. package/dist/binding-extraction/extract-identifiers.d.ts.map +1 -1
  176. package/dist/binding-extraction/extract-identifiers.js +78 -15
  177. package/dist/binding-extraction/extract-identifiers.js.map +1 -1
  178. package/dist/binding-extraction/index.d.ts +1 -1
  179. package/dist/binding-extraction/index.d.ts.map +1 -1
  180. package/dist/binding-extraction/index.js +1 -1
  181. package/dist/binding-extraction/index.js.map +1 -1
  182. package/dist/binding-extraction/{extract-js-identifiers.d.ts → js-identifiers.d.ts} +2 -1
  183. package/dist/binding-extraction/js-identifiers.d.ts.map +1 -0
  184. package/dist/binding-extraction/{extract-js-identifiers.js → js-identifiers.js} +81 -1
  185. package/dist/binding-extraction/js-identifiers.js.map +1 -0
  186. package/dist/binding-extraction/python-identifiers.d.ts +13 -0
  187. package/dist/binding-extraction/python-identifiers.d.ts.map +1 -0
  188. package/dist/binding-extraction/{extract-py-identifiers.js → python-identifiers.js} +155 -1
  189. package/dist/binding-extraction/python-identifiers.js.map +1 -0
  190. package/dist/codegen.d.ts.map +1 -1
  191. package/dist/codegen.js +9 -15
  192. package/dist/codegen.js.map +1 -1
  193. package/dist/components-manager.d.ts +12 -13
  194. package/dist/components-manager.d.ts.map +1 -1
  195. package/dist/components-manager.js +78 -139
  196. package/dist/components-manager.js.map +1 -1
  197. package/dist/file-sync-vite-plugin.d.ts +1 -1
  198. package/dist/file-sync-vite-plugin.d.ts.map +1 -1
  199. package/dist/file-sync-vite-plugin.js +164 -326
  200. package/dist/file-sync-vite-plugin.js.map +1 -1
  201. package/dist/file-system-helpers.d.ts +2 -2
  202. package/dist/file-system-helpers.d.ts.map +1 -1
  203. package/dist/file-system-helpers.js +6 -4
  204. package/dist/file-system-helpers.js.map +1 -1
  205. package/dist/file-system-manager.d.ts +7 -33
  206. package/dist/file-system-manager.d.ts.map +1 -1
  207. package/dist/file-system-manager.js +185 -594
  208. package/dist/file-system-manager.js.map +1 -1
  209. package/dist/index.d.ts +1 -1
  210. package/dist/index.d.ts.map +1 -1
  211. package/dist/index.js +0 -1
  212. package/dist/index.js.map +1 -1
  213. package/dist/inject-no-select.d.ts +15 -0
  214. package/dist/inject-no-select.d.ts.map +1 -0
  215. package/dist/inject-no-select.js +173 -0
  216. package/dist/inject-no-select.js.map +1 -0
  217. package/dist/injected-index.d.ts +0 -1
  218. package/dist/injected-index.d.ts.map +1 -1
  219. package/dist/injected-index.js +0 -1
  220. package/dist/injected-index.js.map +1 -1
  221. package/dist/lock-service/activity-tracker.d.ts.map +1 -1
  222. package/dist/lock-service/activity-tracker.js +4 -1
  223. package/dist/lock-service/activity-tracker.js.map +1 -1
  224. package/dist/parsing/entity/to-code-entity.d.ts.map +1 -1
  225. package/dist/parsing/entity/to-code-entity.js +3 -4
  226. package/dist/parsing/entity/to-code-entity.js.map +1 -1
  227. package/dist/parsing/entity/to-value-entity.d.ts.map +1 -1
  228. package/dist/parsing/entity/to-value-entity.js +19 -13
  229. package/dist/parsing/entity/to-value-entity.js.map +1 -1
  230. package/dist/parsing/ids.d.ts +0 -1
  231. package/dist/parsing/ids.d.ts.map +1 -1
  232. package/dist/parsing/ids.js +3 -4
  233. package/dist/parsing/ids.js.map +1 -1
  234. package/dist/parsing/imports.d.ts.map +1 -1
  235. package/dist/parsing/imports.js +0 -10
  236. package/dist/parsing/imports.js.map +1 -1
  237. package/dist/parsing/index.d.ts +0 -1
  238. package/dist/parsing/index.d.ts.map +1 -1
  239. package/dist/parsing/index.js +0 -1
  240. package/dist/parsing/index.js.map +1 -1
  241. package/dist/parsing/jsx.d.ts.map +1 -1
  242. package/dist/parsing/jsx.js +50 -22
  243. package/dist/parsing/jsx.js.map +1 -1
  244. package/dist/parsing/page.d.ts +0 -1
  245. package/dist/parsing/page.d.ts.map +1 -1
  246. package/dist/parsing/page.js +55 -32
  247. package/dist/parsing/page.js.map +1 -1
  248. package/dist/parsing/properties.d.ts.map +1 -1
  249. package/dist/parsing/properties.js +45 -15
  250. package/dist/parsing/properties.js.map +1 -1
  251. package/dist/parsing/template/index.js +1 -1
  252. package/dist/parsing/template/index.js.map +1 -1
  253. package/dist/parsing/template/to-code-template.d.ts +1 -2
  254. package/dist/parsing/template/to-code-template.d.ts.map +1 -1
  255. package/dist/parsing/template/to-code-template.js +2 -3
  256. package/dist/parsing/template/to-code-template.js.map +1 -1
  257. package/dist/parsing/type-parsing-registry.d.ts +0 -1
  258. package/dist/parsing/type-parsing-registry.d.ts.map +1 -1
  259. package/dist/parsing/type-parsing-registry.js +0 -2
  260. package/dist/parsing/type-parsing-registry.js.map +1 -1
  261. package/dist/parsing/util.d.ts.map +1 -1
  262. package/dist/parsing/util.js +22 -5
  263. package/dist/parsing/util.js.map +1 -1
  264. package/dist/plugin-options.d.ts +8 -1
  265. package/dist/plugin-options.d.ts.map +1 -1
  266. package/dist/plugin-options.js.map +1 -1
  267. package/dist/refactor/javascript.js +1 -1
  268. package/dist/refactor/javascript.js.map +1 -1
  269. package/dist/rename-manager.d.ts.map +1 -1
  270. package/dist/rename-manager.js +1 -2
  271. package/dist/rename-manager.js.map +1 -1
  272. package/dist/router-parser.d.ts +35 -0
  273. package/dist/router-parser.d.ts.map +1 -0
  274. package/dist/router-parser.js +490 -0
  275. package/dist/router-parser.js.map +1 -0
  276. package/dist/socket-manager.d.ts +3 -3
  277. package/dist/socket-manager.d.ts.map +1 -1
  278. package/dist/socket-manager.js +14 -15
  279. package/dist/socket-manager.js.map +1 -1
  280. package/dist/source-tracker.d.ts +9 -77
  281. package/dist/source-tracker.d.ts.map +1 -1
  282. package/dist/source-tracker.js +83 -374
  283. package/dist/source-tracker.js.map +1 -1
  284. package/dist/util/operation-queue.d.ts +3 -0
  285. package/dist/util/operation-queue.d.ts.map +1 -1
  286. package/dist/util/operation-queue.js +5 -0
  287. package/dist/util/operation-queue.js.map +1 -1
  288. package/dist/util.d.ts +13 -1
  289. package/dist/util.d.ts.map +1 -1
  290. package/dist/util.js +49 -28
  291. package/dist/util.js.map +1 -1
  292. package/dist/vite-plugin-yaml-types.d.ts +9 -0
  293. package/dist/vite-plugin-yaml-types.d.ts.map +1 -0
  294. package/dist/vite-plugin-yaml-types.js +114 -0
  295. package/dist/vite-plugin-yaml-types.js.map +1 -0
  296. package/package.json +8 -7
  297. package/dist/ai-service/agent/tools/build-add-event.d.ts +0 -14
  298. package/dist/ai-service/agent/tools/build-add-event.d.ts.map +0 -1
  299. package/dist/ai-service/agent/tools/build-add-event.js +0 -44
  300. package/dist/ai-service/agent/tools/build-add-event.js.map +0 -1
  301. package/dist/ai-service/agent/tools/build-add-state-var.d.ts +0 -16
  302. package/dist/ai-service/agent/tools/build-add-state-var.d.ts.map +0 -1
  303. package/dist/ai-service/agent/tools/build-add-state-var.js +0 -62
  304. package/dist/ai-service/agent/tools/build-add-state-var.js.map +0 -1
  305. package/dist/ai-service/agent/tools/build-add-timer.d.ts +0 -16
  306. package/dist/ai-service/agent/tools/build-add-timer.d.ts.map +0 -1
  307. package/dist/ai-service/agent/tools/build-add-timer.js +0 -46
  308. package/dist/ai-service/agent/tools/build-add-timer.js.map +0 -1
  309. package/dist/ai-service/agent/tools/build-create-page.d.ts +0 -10
  310. package/dist/ai-service/agent/tools/build-create-page.d.ts.map +0 -1
  311. package/dist/ai-service/agent/tools/build-create-page.js +0 -57
  312. package/dist/ai-service/agent/tools/build-create-page.js.map +0 -1
  313. package/dist/ai-service/agent/tools/build-list-available-components.d.ts +0 -9
  314. package/dist/ai-service/agent/tools/build-list-available-components.d.ts.map +0 -1
  315. package/dist/ai-service/agent/tools/build-list-available-components.js +0 -55
  316. package/dist/ai-service/agent/tools/build-list-available-components.js.map +0 -1
  317. package/dist/ai-service/agent/tools/build-register-component-name.d.ts +0 -9
  318. package/dist/ai-service/agent/tools/build-register-component-name.d.ts.map +0 -1
  319. package/dist/ai-service/agent/tools/build-register-component-name.js +0 -53
  320. package/dist/ai-service/agent/tools/build-register-component-name.js.map +0 -1
  321. package/dist/ai-service/agent/tools/build-rename-page.d.ts +0 -9
  322. package/dist/ai-service/agent/tools/build-rename-page.d.ts.map +0 -1
  323. package/dist/ai-service/agent/tools/build-rename-page.js +0 -50
  324. package/dist/ai-service/agent/tools/build-rename-page.js.map +0 -1
  325. package/dist/ai-service/agent/tools/build-set-api-triggers.d.ts +0 -25
  326. package/dist/ai-service/agent/tools/build-set-api-triggers.d.ts.map +0 -1
  327. package/dist/ai-service/agent/tools/build-set-api-triggers.js +0 -266
  328. package/dist/ai-service/agent/tools/build-set-api-triggers.js.map +0 -1
  329. package/dist/ai-service/agent/tools/build-update-state-var.d.ts +0 -16
  330. package/dist/ai-service/agent/tools/build-update-state-var.d.ts.map +0 -1
  331. package/dist/ai-service/agent/tools/build-update-state-var.js +0 -67
  332. package/dist/ai-service/agent/tools/build-update-state-var.js.map +0 -1
  333. package/dist/ai-service/agent/tools/study-current-app-state.d.ts +0 -20
  334. package/dist/ai-service/agent/tools/study-current-app-state.d.ts.map +0 -1
  335. package/dist/ai-service/agent/tools/study-current-app-state.js +0 -20
  336. package/dist/ai-service/agent/tools/study-current-app-state.js.map +0 -1
  337. package/dist/binding-extraction/extract-js-identifiers.d.ts.map +0 -1
  338. package/dist/binding-extraction/extract-js-identifiers.js.map +0 -1
  339. package/dist/binding-extraction/extract-py-identifiers.d.ts +0 -4
  340. package/dist/binding-extraction/extract-py-identifiers.d.ts.map +0 -1
  341. package/dist/binding-extraction/extract-py-identifiers.js.map +0 -1
  342. package/dist/component-docs-service/index.d.ts +0 -37
  343. package/dist/component-docs-service/index.d.ts.map +0 -1
  344. package/dist/component-docs-service/index.js +0 -118
  345. package/dist/component-docs-service/index.js.map +0 -1
  346. package/dist/parsing/events/index.d.ts +0 -5
  347. package/dist/parsing/events/index.d.ts.map +0 -1
  348. package/dist/parsing/events/index.js +0 -7
  349. package/dist/parsing/events/index.js.map +0 -1
  350. package/dist/parsing/events/to-code-events.d.ts +0 -3
  351. package/dist/parsing/events/to-code-events.d.ts.map +0 -1
  352. package/dist/parsing/events/to-code-events.js +0 -147
  353. package/dist/parsing/events/to-code-events.js.map +0 -1
  354. package/dist/parsing/events/to-value-events.d.ts +0 -10
  355. package/dist/parsing/events/to-value-events.d.ts.map +0 -1
  356. package/dist/parsing/events/to-value-events.js +0 -473
  357. package/dist/parsing/events/to-value-events.js.map +0 -1
  358. package/dist/parsing/scope.d.ts +0 -103
  359. package/dist/parsing/scope.d.ts.map +0 -1
  360. package/dist/parsing/scope.js +0 -902
  361. package/dist/parsing/scope.js.map +0 -1
  362. package/dist/routing.d.ts +0 -6
  363. package/dist/routing.d.ts.map +0 -1
  364. package/dist/routing.js +0 -169
  365. package/dist/routing.js.map +0 -1
  366. package/dist/sb-scope-manager.d.ts +0 -121
  367. package/dist/sb-scope-manager.d.ts.map +0 -1
  368. package/dist/sb-scope-manager.js +0 -678
  369. package/dist/sb-scope-manager.js.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import fs from "fs/promises";
2
2
  import path from "node:path";
3
3
  import * as t from "@babel/types";
4
- import { getClientApiId, PROCESSED_TRANSACTIONS_ATTRIBUTE, ROOT_WIDGET_ATTRIBUTE, SOURCE_ID_ATTRIBUTE, WIDGET_DISABLE_DND, } from "@superblocksteam/library-shared";
4
+ import { PROCESSED_TRANSACTIONS_ATTRIBUTE, ROOT_WIDGET_ATTRIBUTE, SOURCE_ID_ATTRIBUTE, WIDGET_DISABLE_DND, } from "@superblocksteam/library-shared";
5
5
  import { addTracingToMethods, TracedEventEmitter, } from "@superblocksteam/shared";
6
6
  import { readAppApiYamlFile, writeApiFiles, } from "@superblocksteam/util";
7
7
  import { glob } from "glob";
@@ -11,22 +11,25 @@ import { generateJSXAttribute } from "./codegen.js";
11
11
  import { ComponentsManager } from "./components-manager.js";
12
12
  import { addLegacyCustomComponentVariables, modifyLegacyCustomComponentElements, modifyLegacyCustomComponentImports, } from "./custom-components.js";
13
13
  import { applyErrorHandling, } from "./errors/error-handler.js";
14
- import { getApiFilePath, getPageFolder, isPageFilePath, PAGES_DIRECTORY, ROUTES_FILE, SCOPE_FILE, } from "./file-system-helpers.js";
14
+ import { getApiFilePath, isPageFilePath, PAGES_DIRECTORY, SCOPE_FILE, } from "./file-system-helpers.js";
15
15
  import { generate } from "./generate.js";
16
- import { OperationProcessor } from "./operations/operation-processor.js";
17
16
  import { doesNodePathHaveBinding } from "./parsing/bindings.js";
18
17
  import { getSbElementId } from "./parsing/ids.js";
19
18
  import { makeJSXAttribute } from "./parsing/jsx.js";
20
19
  import { getRootNodes } from "./parsing/page.js";
21
- import { getScope } from "./parsing/scope.js";
22
20
  import { getLegacyComponentsFolder, isCustomBuildEnabled, } from "./plugin-options.js";
23
21
  import { RenameManager } from "./rename-manager.js";
24
22
  import { getFullImportPath } from "./resolver.js";
23
+ import { findRouterFile } from "./router-parser.js";
25
24
  import { SourceTracker } from "./source-tracker.js";
26
25
  import { traverse } from "./traverse.js";
27
26
  import { getErrorMeta, getLogger } from "./util/logger.js";
28
- import { getPageName } from "./util.js";
27
+ import { getScopeIdFromName, getScopeNameFromPath } from "./util.js";
29
28
  const SUPPORTED_FILETYPES = [
29
+ {
30
+ type: "ts",
31
+ extension: ".ts",
32
+ },
30
33
  {
31
34
  type: "tsx",
32
35
  extension: ".tsx",
@@ -58,11 +61,10 @@ export class FileSystemManager extends TracedEventEmitter {
58
61
  apiFiles = {};
59
62
  sourceTracker;
60
63
  fsOperationQueue;
61
- operationProcessor;
62
64
  generationNumberSequence;
63
- routes = {};
64
65
  routeChangesQueue = [];
65
66
  pageAdditionQueue = new Set();
67
+ routerFilePath = null;
66
68
  watcher;
67
69
  registeredComponentPaths = {};
68
70
  renameManager = new RenameManager();
@@ -76,15 +78,8 @@ export class FileSystemManager extends TracedEventEmitter {
76
78
  this.fsOperationQueue = fsOperationQueue;
77
79
  this.generationNumberSequence = generationNumberSequence;
78
80
  this._tracer = tracer;
79
- // intentionally a new queue here, we don't want to share the queue with the fsOperationQueue
80
- this.operationProcessor = new OperationProcessor({
81
- batchWindowMs: 50,
82
- maxBatchSize: 100,
83
- });
84
- this.operationProcessor.disable();
85
81
  applyErrorHandling(this, {
86
82
  watch: { operation: "editing from code" },
87
- handleCreatePage: { operation: "creating a page" },
88
83
  handleReparent: { operation: "moving a component" },
89
84
  handleCreateComponent: { operation: "creating a component" },
90
85
  handleDeleteComponents: { operation: "deleting components" },
@@ -95,13 +90,9 @@ export class FileSystemManager extends TracedEventEmitter {
95
90
  handleUpdateApi: { operation: "updating an API" },
96
91
  handleDeleteApi: { operation: "deleting an API" },
97
92
  handleRenameApi: { operation: "renaming an API" },
98
- handleAddEntity: { operation: "adding an entity" },
99
- handleUpdateEntity: { operation: "updating an entity" },
100
- handleDeleteEntity: { operation: "deleting an entity" },
101
93
  handleRenameElement: { operation: "renaming an element" },
102
94
  });
103
95
  const methods = [
104
- "handleCreatePage",
105
96
  "handleReparent",
106
97
  "handleCreateComponent",
107
98
  "handleDeleteComponents",
@@ -112,9 +103,6 @@ export class FileSystemManager extends TracedEventEmitter {
112
103
  "handleUpdateApi",
113
104
  "handleDeleteApi",
114
105
  "handleRenameApi",
115
- "handleAddEntity",
116
- "handleUpdateEntity",
117
- "handleDeleteEntity",
118
106
  "handleRenameElement",
119
107
  ];
120
108
  addTracingToMethods(this, methods, tracer);
@@ -141,11 +129,8 @@ export class FileSystemManager extends TracedEventEmitter {
141
129
  // this reads all files excluding ignore list in the root path. Should we read all files in pages and add root.tsx and App.tsx instead?
142
130
  const tsxFiles = fileNames.filter((f) => f.endsWith(".tsx") && !f.includes(`${getLegacyComponentsFolder()}/`));
143
131
  const yamlFiles = fileNames.filter((f) => f.endsWith(".yaml"));
144
- const scopeFiles = fileNames.filter((f) => f.endsWith(SCOPE_FILE));
145
132
  logger.info(`scanning ${tsxFiles.length} code files`);
146
133
  logger.info(`scanning ${yamlFiles.length} api files`);
147
- logger.info(`scanning app theme file`);
148
- logger.info(`scanning ${scopeFiles.length} scope files`);
149
134
  const allFiles = [
150
135
  ...tsxFiles.map((f) => {
151
136
  return {
@@ -154,13 +139,6 @@ export class FileSystemManager extends TracedEventEmitter {
154
139
  content: readFile(f),
155
140
  };
156
141
  }),
157
- ...scopeFiles.map((f) => {
158
- return {
159
- type: "ts",
160
- path: f,
161
- content: readFile(f),
162
- };
163
- }),
164
142
  ...yamlFiles.map((f) => {
165
143
  return {
166
144
  type: "api",
@@ -188,20 +166,6 @@ export class FileSystemManager extends TracedEventEmitter {
188
166
  this.tsFiles[path] = content;
189
167
  }
190
168
  });
191
- // And routes are in the root
192
- const routePath = path.join(rootPath, ROUTES_FILE);
193
- const routeFile = await readFile(routePath);
194
- if (routeFile) {
195
- try {
196
- this.routes = JSON.parse(routeFile);
197
- }
198
- catch (e) {
199
- logger.error("Error parsing routes file", getErrorMeta({
200
- error: e,
201
- routeFile,
202
- }));
203
- }
204
- }
205
169
  try {
206
170
  this.initializeSourceTracker();
207
171
  }
@@ -224,6 +188,15 @@ export class FileSystemManager extends TracedEventEmitter {
224
188
  this.updateInternalApiData(content, path);
225
189
  }
226
190
  });
191
+ // Find and store the router file path for watching
192
+ try {
193
+ this.routerFilePath = await findRouterFile(rootPath);
194
+ logger.info(`Router file found at: ${this.routerFilePath}`);
195
+ }
196
+ catch (e) {
197
+ logger.error("No router file found", getErrorMeta(e));
198
+ this.routerFilePath = null;
199
+ }
227
200
  watcher.on("all", (event, filePath) => {
228
201
  void this.handleFileChange(event, filePath);
229
202
  });
@@ -240,6 +213,59 @@ export class FileSystemManager extends TracedEventEmitter {
240
213
  }
241
214
  return this.sourceTracker.handleNonVisualChangeByDeletingIds(path, content);
242
215
  }
216
+ async getPropertyCode(itemId, propertyName) {
217
+ const logger = getLogger();
218
+ if (!this.sourceTracker) {
219
+ throw new Error("Source tracker not initialized");
220
+ }
221
+ try {
222
+ // Get the element location (cast itemId to SbElement type)
223
+ const element = this.sourceTracker.getElementToLocation(itemId);
224
+ if (!element) {
225
+ logger.warn(`Element not found: ${itemId}`);
226
+ return null;
227
+ }
228
+ // Get the JSX opening element
229
+ let openingElement = null;
230
+ if (element.isJSXElement()) {
231
+ openingElement = element.get("openingElement");
232
+ }
233
+ else if (element.isJSXOpeningElement()) {
234
+ openingElement = element;
235
+ }
236
+ if (!openingElement) {
237
+ logger.warn(`Could not find opening element for: ${itemId}`);
238
+ return null;
239
+ }
240
+ // Find the attribute with the specified property name
241
+ const attributes = openingElement.get("attributes");
242
+ for (const attr of attributes) {
243
+ if (attr.isJSXAttribute()) {
244
+ const attrName = attr.get("name");
245
+ if (attrName.isJSXIdentifier() &&
246
+ attrName.node.name === propertyName) {
247
+ const value = attr.get("value");
248
+ // Handle different value types
249
+ if (value.isStringLiteral()) {
250
+ return value.node.value;
251
+ }
252
+ else if (value.isJSXExpressionContainer()) {
253
+ const expression = value.get("expression");
254
+ // Generate code from the expression
255
+ const code = generate(expression.node).code;
256
+ return code;
257
+ }
258
+ }
259
+ }
260
+ }
261
+ logger.warn(`Property ${propertyName} not found on element ${itemId}`);
262
+ return null;
263
+ }
264
+ catch (error) {
265
+ logger.error(`Error getting property code for ${itemId}.${propertyName}`, getErrorMeta(error));
266
+ return null;
267
+ }
268
+ }
243
269
  async getFileWithIds(filePath) {
244
270
  const logger = getLogger();
245
271
  if (!this.sourceTracker) {
@@ -389,15 +415,6 @@ export class FileSystemManager extends TracedEventEmitter {
389
415
  return null;
390
416
  }
391
417
  }
392
- enableOperationsQueue() {
393
- this.operationProcessor.enable();
394
- }
395
- disableOperationsQueue() {
396
- this.operationProcessor.disable();
397
- }
398
- async flushOperations() {
399
- await this.operationProcessor.flush();
400
- }
401
418
  // MARK: file change handling
402
419
  handleFileChange = async (event, filePath) => {
403
420
  const logger = getLogger();
@@ -410,7 +427,6 @@ export class FileSystemManager extends TracedEventEmitter {
410
427
  if (event === "addDir" || event === "unlinkDir") {
411
428
  return;
412
429
  }
413
- const routePath = path.join(rootPath, ROUTES_FILE);
414
430
  const fileType = SUPPORTED_FILETYPES.find((f) => filePath.endsWith(f.extension));
415
431
  // Only handle files we care about and that are in our root path
416
432
  if (!fileType || !filePath.startsWith(rootPath)) {
@@ -422,140 +438,84 @@ export class FileSystemManager extends TracedEventEmitter {
422
438
  const data = await readFile(filePath);
423
439
  if (typeof data !== "string")
424
440
  return;
425
- const isPage = isPageFilePath(filePath);
426
- if (isPage) {
427
- void this.operationProcessor.addOperation({
428
- metadata: {
429
- filePath,
430
- },
431
- execute: async () => {
432
- const file = await readFile(filePath);
433
- if (!file) {
434
- logger.error(`Failed to read file: ${filePath}`);
435
- return;
436
- }
437
- if (!(filePath in this.tsFiles)) {
438
- this.tsFiles[filePath] = file;
439
- await this.handleNonVisualChangeByDeletingIds(filePath, file);
440
- this.emit("addPage", filePath);
441
- }
442
- },
443
- });
444
- }
445
- else {
446
- void this.operationProcessor.addOperation({
447
- metadata: {
448
- filePath,
449
- },
450
- execute: async () => {
451
- switch (fileType.type) {
452
- case "api":
453
- case "python-api-step":
454
- case "js-api-step": {
455
- await this.processApiFileUpdates(filePath, fileType);
456
- break;
457
- }
458
- }
459
- },
460
- });
441
+ switch (fileType.type) {
442
+ case "api":
443
+ case "python-api-step":
444
+ case "js-api-step": {
445
+ await this.processApiFileUpdates(filePath, fileType);
446
+ }
461
447
  }
462
448
  break;
463
449
  }
464
450
  case "change": {
465
- if (filePath === routePath) {
466
- void this.operationProcessor.addOperation({
467
- metadata: {
468
- filePath,
469
- },
470
- priority: true,
471
- execute: async () => {
472
- try {
473
- const data = JSON.parse((await readFile(filePath)) ?? "{}");
474
- if (!isEqual(this.routes, data))
475
- this.routes = data;
476
- // this.addRoute assigns this.routes itself, causing this.routes === data
477
- // but we still want to emit the event to HMR root.tsx
478
- this.emit("routesChanged", this.routes);
479
- }
480
- catch (e) {
481
- logger.error("Error parsing routes file", getErrorMeta(e));
482
- }
483
- },
484
- });
451
+ const fileType = SUPPORTED_FILETYPES.find((f) => filePath.endsWith(f.extension));
452
+ if (!fileType || !filePath.startsWith(rootPath)) {
485
453
  return;
486
454
  }
487
- else {
488
- void this.operationProcessor.addOperation({
489
- metadata: {
490
- filePath,
491
- },
492
- execute: async () => {
493
- const fileType = SUPPORTED_FILETYPES.find((f) => filePath.endsWith(f.extension));
494
- if (!fileType || !filePath.startsWith(rootPath)) {
455
+ const data = await readFile(filePath);
456
+ if (typeof data !== "string")
457
+ return;
458
+ // Handle router file changes
459
+ if (this.routerFilePath && filePath === this.routerFilePath) {
460
+ logger.info("Router file changed, emitting routerChange event");
461
+ this.emit("routerChange", filePath);
462
+ return;
463
+ }
464
+ switch (fileType.type) {
465
+ case "ts":
466
+ case "tsx":
467
+ case "scope":
468
+ {
469
+ // We do not want to trigger ANY side effects for page additions, we want to control these
470
+ // in the addPage handler itself so we can control the order of events
471
+ if (this.pageAdditionQueue.has(filePath)) {
472
+ logger.info(`File changed: ${filePath} is a page addition, skipping side effects`);
473
+ this.pageAdditionQueue.delete(filePath);
495
474
  return;
496
475
  }
497
- const data = await readFile(filePath);
498
- if (typeof data !== "string")
499
- return;
500
- switch (fileType.type) {
501
- case "tsx":
502
- case "scope":
503
- {
504
- // We do not want to trigger ANY side effects for page additions, we want to control these
505
- // in the addPage handler itself so we can control the order of events
506
- if (this.pageAdditionQueue.has(filePath)) {
507
- logger.info(`File changed: ${filePath} is a page addition, skipping side effects`);
508
- this.pageAdditionQueue.delete(filePath);
509
- return;
510
- }
511
- if (!(filePath in this.tsFiles &&
512
- this.tsFiles[filePath] === data)) {
513
- logger.info(`File changed: ${filePath} updating AST tracker`);
514
- this.tsFiles[filePath] = data;
515
- // only update the source tracker if the file is different
516
- await this.handleNonVisualChangeByDeletingIds(filePath, data);
517
- this.emit("fileChanged", filePath, data, true);
518
- }
519
- else {
520
- logger.info(`File unchanged from last tracked state: ${filePath}`);
521
- this.emit("fileChanged", filePath, data, false);
522
- this.sourceTracker?.updateFileContents(filePath, data);
523
- }
524
- }
525
- break;
526
- case "api":
527
- case "python-api-step":
528
- case "js-api-step":
529
- {
530
- await this.processApiFileUpdates(filePath, fileType);
531
- }
532
- break;
476
+ if (!(filePath in this.tsFiles && this.tsFiles[filePath] === data)) {
477
+ logger.info(`File changed: ${filePath} updating AST tracker`);
478
+ this.tsFiles[filePath] = data;
479
+ // only update the source tracker if the file is different
480
+ await this.handleNonVisualChangeByDeletingIds(filePath, data);
481
+ this.emit("fileChanged", filePath, data, true);
482
+ }
483
+ else {
484
+ logger.info(`File unchanged from last tracked state: ${filePath}`);
485
+ this.emit("fileChanged", filePath, data, false);
486
+ this.sourceTracker?.updateFileContents(filePath, data);
533
487
  }
534
- },
535
- });
488
+ }
489
+ break;
490
+ case "api":
491
+ case "python-api-step":
492
+ case "js-api-step":
493
+ {
494
+ await this.processApiFileUpdates(filePath, fileType);
495
+ }
496
+ break;
536
497
  }
537
498
  break;
538
499
  }
539
500
  case "unlink": {
540
501
  if (filePath in this.tsFiles) {
541
- void this.operationProcessor.addOperation({
542
- metadata: {
543
- filePath,
544
- },
545
- execute: async () => {
546
- await this.deleteTsFile(filePath);
547
- },
548
- });
502
+ await this.deleteTsFile(filePath);
503
+ if (this.routerFilePath && filePath === this.routerFilePath) {
504
+ logger.warn("Router file was deleted, attempting to find new router file");
505
+ try {
506
+ this.routerFilePath = await findRouterFile(rootPath);
507
+ logger.info(`New router file found at: ${this.routerFilePath}`);
508
+ this.emit("routerChange", this.routerFilePath);
509
+ }
510
+ catch {
511
+ this.routerFilePath = null;
512
+ const error = new Error("Router file was deleted and no replacement could be found.");
513
+ logger.error("Router file missing", getErrorMeta(error));
514
+ }
515
+ }
549
516
  }
550
517
  else if (filePath in this.apiFiles) {
551
- void this.operationProcessor.addOperation({
552
- metadata: {
553
- filePath,
554
- },
555
- execute: async () => {
556
- await this.removeApiData(filePath);
557
- },
558
- });
518
+ await this.removeApiData(filePath);
559
519
  }
560
520
  break;
561
521
  }
@@ -620,21 +580,6 @@ export class FileSystemManager extends TracedEventEmitter {
620
580
  readFile(path) {
621
581
  return this.tsFiles[path];
622
582
  }
623
- async addRoute(route, filePath) {
624
- if (!this.rootDir) {
625
- throw new Error("Root directory not set");
626
- }
627
- this.routes[route] = { file: this.getRelativeRoutePath(filePath) };
628
- await this.writeFile(path.join(this.rootDir, ROUTES_FILE), JSON.stringify(this.routes, null, 2));
629
- }
630
- async removeRoute(filePath) {
631
- if (!this.rootDir) {
632
- throw new Error("Root directory not set");
633
- }
634
- const relativeFilePath = this.getRelativeRoutePath(filePath);
635
- this.routes = Object.fromEntries(Object.entries(this.routes).filter(([_, value]) => value.file !== relativeFilePath));
636
- await this.writeFile(path.join(this.rootDir, ROUTES_FILE), JSON.stringify(this.routes, null, 2));
637
- }
638
583
  async writeChanges(changes, callback) {
639
584
  return Promise.all(changes.map(async ({ fileName, source, kind }) => {
640
585
  await this.writeFile(fileName, source, kind);
@@ -733,26 +678,24 @@ export class FileSystemManager extends TracedEventEmitter {
733
678
  const roots = getRootNodes(filePath, currentFile);
734
679
  return [...roots, ...importedRoots];
735
680
  }
736
- getScope(filePath) {
737
- // get the scope.ts file in the same directory as path
738
- const scopeFilePath = path.join(path.dirname(filePath), SCOPE_FILE);
739
- const currentFile = this.sourceTracker?.getCurrentFiles()[scopeFilePath];
740
- if (!currentFile) {
741
- console.log("File not found", scopeFilePath);
742
- return null;
743
- }
744
- const scope = getScope(scopeFilePath, currentFile);
745
- return scope;
746
- }
747
- getRoutes() {
748
- const routes = [];
749
- for (const [path, { file }] of Object.entries(this.routes)) {
750
- routes.push({
751
- path,
752
- component: file,
753
- });
681
+ getScope(filePath, fallback) {
682
+ // Since we no longer use scope.ts files, generate scope info from file path. Pages retain page scope, everything else is App.
683
+ const scopeName = getScopeNameFromPath(filePath);
684
+ if (!scopeName) {
685
+ if (fallback) {
686
+ return {
687
+ entities: {},
688
+ scopeName: "App",
689
+ scopeId: getScopeIdFromName("App"),
690
+ };
691
+ }
692
+ return undefined;
754
693
  }
755
- return routes;
694
+ return {
695
+ entities: {},
696
+ scopeName,
697
+ scopeId: getScopeIdFromName(scopeName),
698
+ };
756
699
  }
757
700
  // MARK: transaction handling
758
701
  flushTransactions = () => {
@@ -774,80 +717,6 @@ export class FileSystemManager extends TracedEventEmitter {
774
717
  return this.processedTransactions.concat(nonce);
775
718
  }
776
719
  // MARK: editor operations
777
- handleCreatePage = async (payload) => {
778
- this.trackTransaction(payload.transaction?.id);
779
- const { name, route, navigateToRoute } = payload;
780
- if (!this.rootDir) {
781
- throw new Error("Root directory not set");
782
- }
783
- if (!route) {
784
- throw new Error("Route is required when creating a page");
785
- }
786
- const pagePath = getPageFolder(this.rootDir, name);
787
- const pageIndexPath = path.join(pagePath, "index.tsx");
788
- const scopePath = path.join(pagePath, "scope.ts");
789
- const pageContent = /*js*/ `import { Page, Dim, registerPage } from "@superblocksteam/library";
790
- import Stack from "@/components/ui/stack/index";
791
- import { ${name}, ${name}Scope } from "./scope";
792
-
793
- function PageContent() {
794
- const {} = ${name};
795
- return (
796
- <Page name="${name}" height={Dim.fill()} width={Dim.fill()}>
797
- <Stack
798
- height={Dim.fill()}
799
- width={Dim.fill()}
800
- layout="vertical"
801
- verticalAlign="top"
802
- horizontalAlign="center"
803
- shouldScrollContents
804
- ></Stack>
805
- </Page>
806
- );
807
- }
808
-
809
- export default registerPage(PageContent, ${name}Scope);
810
- `;
811
- const scopeContent = /*js*/ `/* eslint-disable @typescript-eslint/no-unused-vars */
812
- /* eslint-disable no-empty-pattern */
813
- import { createScope, computed, Global } from "@superblocksteam/library";
814
- import { App } from "@/scope";
815
- import { toast } from "sonner";
816
-
817
- export const ${name}Scope = createScope<{}>(({ entities }) => ({}), {
818
- name: "${name}",
819
- });
820
-
821
- export const ${name} = ${name}Scope.entities;
822
- `;
823
- this.watcher?.unwatch(pagePath);
824
- await fs.mkdir(pagePath, { recursive: true });
825
- await this.writeFile(pageIndexPath, pageContent, "ts");
826
- await this.writeFile(scopePath, scopeContent, "ts");
827
- await this.handleNonVisualChangeByDeletingIds(pageIndexPath, pageContent);
828
- await this.handleNonVisualChangeByDeletingIds(scopePath, scopeContent);
829
- this.pageAdditionQueue.add(pageIndexPath);
830
- this.pageAdditionQueue.add(scopePath);
831
- this.watcher?.add(pagePath);
832
- await this.addRoute(route, pageIndexPath);
833
- this.emit("addPage", pageIndexPath, navigateToRoute ? route : undefined);
834
- };
835
- handleDeletePage = async (payload) => {
836
- const { name, transaction } = payload;
837
- this.trackTransaction(transaction?.id);
838
- if (Object.values(this.routes).length === 1) {
839
- throw new Error("You can't delete the last page");
840
- }
841
- if (!this.rootDir) {
842
- throw new Error("Root directory not set");
843
- }
844
- const pagePath = getPageFolder(this.rootDir, name);
845
- const pageIndexPath = path.join(pagePath, "index.tsx");
846
- this.watcher?.unwatch(pagePath);
847
- await this.removeRoute(pageIndexPath);
848
- await fs.rm(pagePath, { recursive: true, force: true });
849
- this.emit("deletePage", pagePath);
850
- };
851
720
  get routeChange() {
852
721
  return this.routeChangesQueue.shift();
853
722
  }
@@ -973,70 +842,18 @@ export const ${name} = ${name}Scope.entities;
973
842
  this.flushTransactions();
974
843
  return returnValues;
975
844
  };
976
- // MARK: entity operations
977
- handleAddEntity = async (payload) => {
978
- this.sourceTracker?.addEntity({
979
- scopeId: payload.scopeId,
980
- entity: {
981
- type: payload.type,
982
- name: payload.name,
983
- attributes: payload.attributes,
984
- },
985
- });
986
- const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
987
- await this.writeChanges(changes, (fileName) => {
988
- this.emit("addEntity", fileName, payload);
989
- });
990
- };
991
- handleUpdateEntity = async (payload) => {
992
- this.sourceTracker?.updateEntity({
993
- entityId: payload.entityId,
994
- updates: payload.updates,
995
- });
996
- const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
997
- await this.writeChanges(changes, (fileName) => {
998
- this.emit("updateEntity", fileName, payload);
999
- });
1000
- };
1001
- handleDeleteEntity = async (payload) => {
1002
- const deletedEntityName = this.sourceTracker?.deleteEntity({
1003
- entityId: payload.entityId,
1004
- });
1005
- const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
1006
- await this.writeChanges(changes, (fileName) => {
1007
- if (deletedEntityName) {
1008
- this.emit("deleteEntity", fileName, deletedEntityName);
1009
- }
1010
- });
1011
- };
1012
- handleAddComponentNameToScope = async (payload) => {
1013
- const { scopeName, componentName } = payload;
1014
- this.sourceTracker?.addScopeComponent({
1015
- scopeName,
1016
- componentName,
1017
- });
1018
- const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
1019
- await this.writeChanges(changes);
1020
- };
1021
845
  // MARK: rename operations
1022
846
  handleRenameElement = async (payload) => {
1023
847
  if (payload.kind === "component") {
1024
848
  return this.handleRenameComponent(payload);
1025
849
  }
1026
- else if (payload.kind === "entity") {
1027
- return this.handleRenameEntity(payload);
1028
- }
1029
- else if (payload.kind === "page") {
1030
- return this.handleRenamePage(payload);
1031
- }
1032
850
  };
1033
851
  handleRenameComponent = async (payload) => {
1034
- const { elementId, newName, oldName, scopeName, renameInAst } = payload;
852
+ const { elementId, newName, oldName, renameInAst } = payload;
1035
853
  await this.sourceTracker?.renameComponent({
1036
854
  widgetSourceId: elementId,
1037
855
  oldName,
1038
856
  newName,
1039
- scopeName,
1040
857
  renameInAst,
1041
858
  });
1042
859
  await this.renameIdentifierInApis({
@@ -1049,183 +866,6 @@ export const ${name} = ${name}Scope.entities;
1049
866
  this.emit("renameComponent", fileName);
1050
867
  });
1051
868
  };
1052
- handleRenameEntity = async (payload) => {
1053
- const { elementId, newName, oldName, scopeName } = payload;
1054
- this.sourceTracker?.renameEntity({
1055
- entityId: elementId,
1056
- oldName,
1057
- newName,
1058
- scopeName,
1059
- });
1060
- await this.renameIdentifierInApis(payload);
1061
- const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
1062
- await this.writeChanges(changes, (fileName) => {
1063
- this.emit("renameEntity", fileName);
1064
- });
1065
- };
1066
- handleRenamePage = async (payload) => {
1067
- const { newName, oldName } = payload;
1068
- if (!this.rootDir) {
1069
- throw new Error("Root directory not set");
1070
- }
1071
- try {
1072
- await this.performRenamePageTransaction(oldName, newName);
1073
- this.emit("renamePage", newName);
1074
- }
1075
- catch (error) {
1076
- getLogger().error("Error renaming page", getErrorMeta(error));
1077
- throw error;
1078
- }
1079
- };
1080
- /**
1081
- * As much as possible, we want to perform the rename page transaction as an operation we can roll back if it fails.
1082
- */
1083
- async performRenamePageTransaction(oldName, newName) {
1084
- let snapshot;
1085
- let changes;
1086
- try {
1087
- if (!this.rootDir) {
1088
- throw new Error("Root directory not set");
1089
- }
1090
- const newPageFolder = getPageFolder(this.rootDir, newName);
1091
- const oldPageFolder = getPageFolder(this.rootDir, oldName);
1092
- const newIndexFilePath = path.join(newPageFolder, "index.tsx");
1093
- const oldIndexFilePath = path.join(oldPageFolder, "index.tsx");
1094
- const oldScopeFilePath = path.join(oldPageFolder, SCOPE_FILE);
1095
- const newScopeFilePath = path.join(newPageFolder, SCOPE_FILE);
1096
- // Early validations
1097
- const doesFileExist = await fs.stat(newIndexFilePath).catch(() => false);
1098
- if (doesFileExist) {
1099
- throw new Error(`Page ${newName} already exists`);
1100
- }
1101
- const existingRoute = Object.keys(this.routes).find((route) => this.routes[route]?.file ===
1102
- this.getRelativeRoutePath(oldIndexFilePath));
1103
- if (!existingRoute) {
1104
- throw new Error(`Route for ${oldName} not found`);
1105
- }
1106
- const oldScope = this.sourceTracker?.getScopeDefinitionForPage(oldName);
1107
- if (!oldScope) {
1108
- throw new Error(`Scope definition not found for old page, ${oldName}`);
1109
- }
1110
- snapshot = {
1111
- tsFiles: { ...this.tsFiles },
1112
- apiFiles: { ...this.apiFiles },
1113
- routes: { ...this.routes },
1114
- };
1115
- changes = {
1116
- newPageFolder,
1117
- oldPageFolder,
1118
- newIndexFilePath,
1119
- oldIndexFilePath,
1120
- newScopeFilePath,
1121
- oldScopeFilePath,
1122
- oldScope,
1123
- existingRoute,
1124
- };
1125
- await this.commitRenamePageChanges(oldName, newName, changes);
1126
- }
1127
- catch (error) {
1128
- if (snapshot && changes) {
1129
- await this.rollbackRenamePageChanges(snapshot, changes);
1130
- }
1131
- throw error;
1132
- }
1133
- }
1134
- async commitRenamePageChanges(oldName, newName, changes) {
1135
- const { newPageFolder, oldPageFolder, newIndexFilePath, oldIndexFilePath, newScopeFilePath, oldScopeFilePath, existingRoute, } = changes;
1136
- // we don't want to trigger fs events during the operation
1137
- this.watcher?.unwatch(newPageFolder);
1138
- this.watcher?.unwatch(oldPageFolder);
1139
- await fs.cp(oldPageFolder, newPageFolder, { recursive: true });
1140
- const newIndexFile = await readFile(newIndexFilePath);
1141
- if (!newIndexFile) {
1142
- throw new Error(`New index file ${newIndexFilePath} not found`);
1143
- }
1144
- const newScopeFile = await readFile(newScopeFilePath);
1145
- if (!newScopeFile) {
1146
- throw new Error(`New scope file ${newScopeFilePath} not found`);
1147
- }
1148
- delete this.tsFiles[oldIndexFilePath];
1149
- delete this.tsFiles[oldScopeFilePath];
1150
- // lets setup all the ast stuff for the new files
1151
- await this.handleNonVisualChangeByDeletingIds(newScopeFilePath, newScopeFile);
1152
- await this.handleNonVisualChangeByDeletingIds(newIndexFilePath, newIndexFile);
1153
- Object.entries(this.tsFiles).forEach(([key, value]) => {
1154
- if (key.startsWith(oldPageFolder)) {
1155
- this.tsFiles[key.replace(oldPageFolder, newPageFolder)] = value;
1156
- delete this.tsFiles[key];
1157
- }
1158
- });
1159
- // perform the page rename in source tracker now that we have the ast stuff setup
1160
- this.sourceTracker?.renamePage({
1161
- oldName,
1162
- newName,
1163
- scopeFilePath: newScopeFilePath,
1164
- pageFilePath: newIndexFilePath,
1165
- });
1166
- const newScope = this.sourceTracker?.getScopeDefinitionForPage(newName);
1167
- if (!newScope) {
1168
- throw new Error(`Scope definition not found for new page, ${newName}`);
1169
- }
1170
- // our apis need the new scope id info, otherwise ui loses track
1171
- Object.entries(this.apiFiles).forEach(([key, value]) => {
1172
- if (key.startsWith(oldPageFolder)) {
1173
- this.apiFiles[key.replace(oldPageFolder, newPageFolder)] = {
1174
- ...value,
1175
- apiPb: {
1176
- ...value.apiPb,
1177
- trigger: {
1178
- ...value.apiPb.trigger,
1179
- pageName: newName,
1180
- pageId: newScope.id,
1181
- },
1182
- },
1183
- scopeId: newScope.id,
1184
- pageName: newName,
1185
- };
1186
- delete this.apiFiles[key];
1187
- }
1188
- });
1189
- await this.removeRoute(oldIndexFilePath);
1190
- await this.addRoute(existingRoute, newIndexFilePath);
1191
- await this.sourceTracker?.removeFile(oldIndexFilePath);
1192
- await this.sourceTracker?.removeFile(oldScopeFilePath);
1193
- // write all changes
1194
- const sourceChanges = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
1195
- await this.writeChanges(sourceChanges);
1196
- this.watcher?.add(newPageFolder);
1197
- // should be safe to delete the old page folder now
1198
- await fs.rm(oldPageFolder, { recursive: true });
1199
- }
1200
- async rollbackRenamePageChanges(snapshot, changes) {
1201
- const { newPageFolder, oldPageFolder, oldScopeFilePath, oldIndexFilePath } = changes;
1202
- try {
1203
- this.tsFiles = snapshot.tsFiles;
1204
- this.apiFiles = snapshot.apiFiles;
1205
- this.routes = snapshot.routes;
1206
- // clean up the folders that were created
1207
- await fs.rm(newPageFolder, { recursive: true }).catch((error) => {
1208
- getLogger().warn(`Failed to delete new page folder ${newPageFolder} during rollback. Error: ${error}`);
1209
- });
1210
- const oldScopeFile = await readFile(oldScopeFilePath).catch(() => null);
1211
- if (oldScopeFile) {
1212
- await this.handleNonVisualChangeByDeletingIds(oldScopeFilePath, oldScopeFile);
1213
- }
1214
- const oldIndexFile = await readFile(oldIndexFilePath).catch(() => null);
1215
- if (oldIndexFile) {
1216
- await this.handleNonVisualChangeByDeletingIds(oldIndexFilePath, oldIndexFile);
1217
- }
1218
- // ensure we have the the correct routes on disk
1219
- if (this.rootDir) {
1220
- await this.writeFile(path.join(this.rootDir, ROUTES_FILE), JSON.stringify(snapshot.routes, null, 2));
1221
- }
1222
- // resume watching the original folder
1223
- this.watcher?.add(oldPageFolder);
1224
- }
1225
- catch (rollbackError) {
1226
- getLogger().error("Error during transaction rollback", getErrorMeta(rollbackError));
1227
- }
1228
- }
1229
869
  getRelativeRoutePath(filePath) {
1230
870
  if (!this.rootDir) {
1231
871
  throw new Error("Root directory not set");
@@ -1242,14 +882,11 @@ export const ${name} = ${name}Scope.entities;
1242
882
  if (!this.rootDir) {
1243
883
  throw new Error("Root directory not set");
1244
884
  }
1245
- if (!api.pageName) {
1246
- throw new Error("API page name is not set");
1247
- }
1248
885
  const apiName = api.apiPb.metadata.name;
1249
886
  if (!apiName) {
1250
887
  throw new Error("API name is not set");
1251
888
  }
1252
- const apiFilePath = getApiFilePath(this.rootDir, api.pageName, apiName);
889
+ const apiFilePath = getApiFilePath(this.rootDir, apiName);
1253
890
  const apiDir = path.dirname(apiFilePath);
1254
891
  const isNewApi = !this.getApiFiles()[apiFilePath];
1255
892
  try {
@@ -1263,14 +900,10 @@ export const ${name} = ${name}Scope.entities;
1263
900
  }
1264
901
  await this.writeFile(apiFilePath, yaml.stringify(api.apiPb), "api");
1265
902
  const generationNumber = this.generationNumberSequence.next();
903
+ const scopeId = getScopeIdFromName("App");
1266
904
  const apiDef = this.createClientApi(api);
1267
- let scopeId = "";
1268
905
  if (isNewApi) {
1269
- scopeId = await this.addApiToScope(api);
1270
- }
1271
- else {
1272
- const scopeDef = this.sourceTracker.getScopeDefinitionForPage(api.pageName);
1273
- scopeId = scopeDef?.id ?? "";
906
+ await this.addApiToScope(api);
1274
907
  }
1275
908
  this.emit("apiUpdate", { api: apiDef, scopeId });
1276
909
  return { api: apiDef, scopeId, generationNumber };
@@ -1283,8 +916,8 @@ export const ${name} = ${name}Scope.entities;
1283
916
  }
1284
917
  const rootDir = this.rootDir;
1285
918
  const deletedApis = [];
1286
- for (const { apiName, pageName } of apis) {
1287
- const apiFilePath = getApiFilePath(rootDir, pageName, apiName);
919
+ for (const { apiName } of apis) {
920
+ const apiFilePath = getApiFilePath(rootDir, apiName);
1288
921
  const api = this.apiFiles[apiFilePath];
1289
922
  if (!api || !this.sourceTracker) {
1290
923
  continue;
@@ -1297,12 +930,10 @@ export const ${name} = ${name}Scope.entities;
1297
930
  }
1298
931
  delete this.apiFiles[apiFilePath];
1299
932
  const scopeId = this.sourceTracker.deleteApi({
1300
- pageName,
1301
933
  apiName,
1302
934
  });
1303
935
  deletedApis.push({
1304
936
  apiName,
1305
- pageName,
1306
937
  scopeId,
1307
938
  });
1308
939
  }
@@ -1318,25 +949,19 @@ export const ${name} = ${name}Scope.entities;
1318
949
  return { deletedApis };
1319
950
  };
1320
951
  handleRenameApi = async (payload) => {
1321
- const { oldName, newName, pageName } = payload;
952
+ const { oldName, newName } = payload;
1322
953
  if (!this.rootDir) {
1323
954
  throw new Error("Root directory not set");
1324
955
  }
1325
- const pagePath = getPageFolder(this.rootDir, pageName);
1326
- const existingApiFolder = path.join(this.rootDir, "pages", pageName, "apis", oldName);
1327
- const newApiFolder = path.join(this.rootDir, "pages", pageName, "apis", newName);
1328
- const files = this.sourceTracker?.getCurrentFiles();
1329
- const file = files?.[path.join(pagePath, "index.tsx")];
1330
- if (!file || !file.ast) {
1331
- throw new Error(`Page ${pageName} not found`);
1332
- }
956
+ const existingApiFolder = path.join(this.rootDir, "apis", oldName);
957
+ const newApiFolder = path.join(this.rootDir, "apis", newName);
1333
958
  const apiFilePath = path.join(existingApiFolder, "api.yaml");
1334
959
  const apiDef = this.apiFiles[apiFilePath];
1335
960
  if (!apiDef) {
1336
961
  throw new Error(`API ${oldName} not found`);
1337
962
  }
1338
- const otherPageAPIs = structuredClone(Object.keys(this.apiFiles)
1339
- .filter((path) => path.startsWith(pagePath) && path !== apiFilePath)
963
+ const otherAPIs = structuredClone(Object.keys(this.apiFiles)
964
+ .filter((path) => path !== apiFilePath)
1340
965
  .map((path) => ({
1341
966
  api: { apiPb: this.apiFiles[path]?.apiPb },
1342
967
  filePath: path,
@@ -1350,15 +975,7 @@ export const ${name} = ${name}Scope.entities;
1350
975
  this.watcher?.unwatch(newApiFolder);
1351
976
  apiDef.apiPb.metadata.name = newName;
1352
977
  await fs.rename(existingApiFolder, newApiFolder);
1353
- const scopeDef = this.sourceTracker?.getScopeDefinitionForPage(pageName);
1354
- if (!scopeDef) {
1355
- throw new Error(`Scope definition not found for API`);
1356
- }
1357
- this.sourceTracker?.renameEntity({
1358
- oldName,
1359
- newName,
1360
- entityId: scopeDef.scopeNameToEntityId[oldName],
1361
- });
978
+ const scopeId = getScopeIdFromName("App");
1362
979
  delete this.apiFiles[apiFilePath];
1363
980
  // not waiting because we are queueing the write further down
1364
981
  void this.writeFile(path.join(newApiFolder, "api.yaml"), yaml.stringify(apiDef.apiPb), "api");
@@ -1369,26 +986,23 @@ export const ${name} = ${name}Scope.entities;
1369
986
  this.emit("apiManualUpdate", {
1370
987
  api: this.createClientApi(apiDef),
1371
988
  oldName,
1372
- pageName,
1373
- scopeId: scopeDef?.id ?? "",
989
+ scopeId,
1374
990
  }, true);
1375
991
  await this.renameManager.renameEntityInApis({
1376
992
  oldName,
1377
993
  newName,
1378
- apis: otherPageAPIs,
994
+ apis: otherAPIs,
1379
995
  });
1380
996
  // only save the APIs that have changed
1381
- await Promise.all(otherPageAPIs.map(async ({ api, filePath }) => {
997
+ await Promise.all(otherAPIs.map(async ({ api, filePath }) => {
1382
998
  if (isEqual(api?.apiPb, this.apiFiles[filePath]?.apiPb)) {
1383
999
  return Promise.resolve();
1384
1000
  }
1385
1001
  await this.writeFile(filePath, yaml.stringify(api?.apiPb), "api");
1386
1002
  this.emit("apiManualUpdate", {
1387
1003
  api: this.createClientApi(api),
1388
- pageName,
1389
- scopeId: scopeDef?.id ?? "",
1004
+ scopeId,
1390
1005
  }, true);
1391
- // TODO: Should I delete here?
1392
1006
  }));
1393
1007
  };
1394
1008
  async removeApiData(filePath) {
@@ -1398,18 +1012,15 @@ export const ${name} = ${name}Scope.entities;
1398
1012
  }
1399
1013
  delete this.apiFiles[filePath];
1400
1014
  this.sourceTracker?.deleteApi({
1401
- pageName: api.pageName,
1402
1015
  apiName: api.apiPb.metadata.name,
1403
1016
  });
1404
1017
  const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
1405
1018
  await this.writeChanges(changes);
1406
- const scopeId = this.sourceTracker?.getScopeDefinitionForPage(api.pageName)?.id;
1019
+ const scopeId = getScopeIdFromName("App");
1407
1020
  this.emit("apiManualDelete", {
1408
1021
  api: {
1409
- id: getClientApiId(api.apiPb.metadata.name, api.pageName),
1022
+ id: api.apiPb.metadata.name,
1410
1023
  apiName: api.apiPb.metadata.name,
1411
- // TODO(saksham): get pagename more defensively
1412
- pageName: getPageName(filePath),
1413
1024
  scopeId,
1414
1025
  },
1415
1026
  });
@@ -1428,7 +1039,7 @@ export const ${name} = ${name}Scope.entities;
1428
1039
  }
1429
1040
  // Utilities for converting server API format to Client API format
1430
1041
  // We internally save the API as the server does, but we return should always return it
1431
- // to the client with an id generated as PageName_ApiName
1042
+ // to the client with an id equal to the API name
1432
1043
  createClientApi(api) {
1433
1044
  return {
1434
1045
  pageName: api.pageName,
@@ -1436,7 +1047,7 @@ export const ${name} = ${name}Scope.entities;
1436
1047
  ...api.apiPb,
1437
1048
  metadata: {
1438
1049
  ...api.apiPb.metadata,
1439
- id: getClientApiId(api.apiPb.metadata.name, api.pageName),
1050
+ id: api.apiPb.metadata.name,
1440
1051
  },
1441
1052
  },
1442
1053
  };
@@ -1448,7 +1059,6 @@ export const ${name} = ${name}Scope.entities;
1448
1059
  // We want to add the API entity to our scope, but we do not want to emit entity events, because
1449
1060
  // the API update event handles this particular side effect.
1450
1061
  const scopeId = await this.sourceTracker.addApi({
1451
- pageName: api.pageName,
1452
1062
  apiName: api.apiPb.metadata.name,
1453
1063
  });
1454
1064
  const changes = (await this.sourceTracker?.getAndFlushChanges()) ?? [];
@@ -1473,23 +1083,15 @@ export const ${name} = ${name}Scope.entities;
1473
1083
  const parsedData = { apiPb: apiContent?.api };
1474
1084
  if (!(yamlPath in this.apiFiles &&
1475
1085
  isEqual(this.apiFiles[yamlPath]?.apiPb, parsedData.apiPb))) {
1476
- const { updatedApi, pageName, isNewApi } = this.updateInternalApiData({
1086
+ const { updatedApi, isNewApi } = this.updateInternalApiData({
1477
1087
  api: parsedData.apiPb,
1478
1088
  stepPathMap: apiContent.stepPathMap,
1479
1089
  }, yamlPath);
1480
1090
  logger.info(`API changed: ${yamlPath}`);
1481
- const scopeDef = this.sourceTracker?.getScopeDefinitionForPage(pageName);
1482
- if (!scopeDef) {
1483
- logger.error(`Scope definition not found for API`);
1484
- return;
1485
- }
1486
- if (isNewApi) {
1487
- await this.addApiToScope(updatedApi);
1488
- }
1091
+ const scopeId = getScopeIdFromName("App");
1489
1092
  this.emit("apiManualUpdate", {
1490
1093
  api: this.createClientApi(updatedApi),
1491
- pageName,
1492
- scopeId: scopeDef.id,
1094
+ scopeId,
1493
1095
  }, isNewApi);
1494
1096
  }
1495
1097
  else {
@@ -1505,21 +1107,15 @@ export const ${name} = ${name}Scope.entities;
1505
1107
  throw new Error("Root directory not set");
1506
1108
  }
1507
1109
  const { api: apiContents, stepPathMap } = content;
1508
- const pageName = getPageName(path);
1509
- let scopeId = this.sourceTracker?.getScopeDefinitionForPage(pageName)?.id;
1510
- if (!scopeId) {
1511
- console.warn("Scope ID not found for API", apiContents.metadata.name);
1512
- scopeId = "";
1513
- }
1110
+ const scopeId = getScopeIdFromName("App");
1514
1111
  const updatedApi = {
1515
1112
  apiPb: yaml.parse(JSON.stringify(apiContents)),
1516
- pageName,
1517
1113
  stepPathMap,
1518
1114
  scopeId,
1519
1115
  };
1520
1116
  const isNewApi = !this.apiFiles[path];
1521
1117
  this.apiFiles[path] = updatedApi;
1522
- return { updatedApi, pageName, isNewApi };
1118
+ return { updatedApi, isNewApi };
1523
1119
  };
1524
1120
  renameIdentifierInApis = async ({ elementId, oldName, newName, parentBinding, }) => {
1525
1121
  const apisInScope = structuredClone(this.getApisInScope(elementId));
@@ -1537,15 +1133,12 @@ export const ${name} = ${name}Scope.entities;
1537
1133
  return this.writeFile(filePath, yaml.stringify(api?.apiPb), "api");
1538
1134
  }));
1539
1135
  };
1540
- getApisInScope = (elementId) => {
1541
- const filePath = this.sourceTracker?.getElementToFilePath(elementId);
1542
- if (!filePath) {
1543
- return [];
1544
- }
1545
- const pagePath = path.dirname(filePath);
1546
- return Object.entries(this.apiFiles)
1547
- .filter(([filePath]) => filePath.includes(pagePath))
1548
- .map(([filePath, api]) => ({ api, filePath }));
1136
+ getApisInScope = (_elementId) => {
1137
+ // All APIs are now at app-level scope
1138
+ return Object.entries(this.apiFiles).map(([filePath, api]) => ({
1139
+ api,
1140
+ filePath,
1141
+ }));
1549
1142
  };
1550
1143
  }
1551
1144
  // Add new mock implementation
@@ -1563,10 +1156,8 @@ export class MockFileSyncManager extends FileSystemManager {
1563
1156
  else {
1564
1157
  this.apiFiles[path] = {
1565
1158
  apiPb: yaml.parse(content),
1566
- pageName: getPageName(path),
1567
1159
  stepPathMap: {},
1568
- // TODO: generate a scope ID for tests
1569
- scopeId: "",
1160
+ scopeId: getScopeIdFromName("App"),
1570
1161
  };
1571
1162
  }
1572
1163
  // Notify subscribers
@@ -1585,16 +1176,16 @@ export class MockFileSyncManager extends FileSystemManager {
1585
1176
  stepPathMap: {},
1586
1177
  scopeId: payload.scopeId,
1587
1178
  };
1588
- const scopeDef = this.sourceTracker?.getScopeDefinitionForPage(payload.api.pageName);
1179
+ const scopeId = getScopeIdFromName("App");
1589
1180
  const generationNumber = this.generationNumberSequence.next();
1590
1181
  this.emit("apiUpdate", {
1591
1182
  api: payload.api,
1592
- scopeId: scopeDef?.id ?? "",
1183
+ scopeId,
1593
1184
  });
1594
1185
  return {
1595
1186
  api: payload.api,
1596
1187
  generationNumber,
1597
- scopeId: scopeDef?.id ?? "",
1188
+ scopeId,
1598
1189
  };
1599
1190
  };
1600
1191
  }