@lovrabet/rabetbase-cli 2.5.13-beta.1 → 2.6.0-beta.1

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 (446) hide show
  1. package/README.md +42 -17
  2. package/lib/api/api-doc.js +3 -1
  3. package/lib/api/api-group.js +3 -1
  4. package/lib/api/fetch-model-list.js +1 -1
  5. package/lib/api/generate-api-file.js +8 -1
  6. package/lib/api/generate-sdk-config-file.js +1 -1
  7. package/lib/api/legacy-api-file.js +2 -1
  8. package/lib/api/model-registry-file.js +11 -1
  9. package/lib/api/model-registry-scaffold.js +2 -1
  10. package/lib/api/model-source.js +3 -1
  11. package/lib/auth/auth-server-ui.js +2 -1
  12. package/lib/auth/auth-server.js +5 -1
  13. package/lib/auth/constant.js +1 -1
  14. package/lib/auth/get-cookie.js +1 -1
  15. package/lib/auth/get-session-user.js +1 -1
  16. package/lib/auth/is-session-valid.js +1 -1
  17. package/lib/auth/login-success-html.js +3 -1
  18. package/lib/auth/logout.js +1 -1
  19. package/lib/cli-flags.js +1 -1
  20. package/lib/cli.js +5 -1
  21. package/lib/commands/api/generate.js +4 -1
  22. package/lib/commands/api/index.js +1 -1
  23. package/lib/commands/api/list.js +2 -1
  24. package/lib/commands/api/pull.js +10 -1
  25. package/lib/commands/api/shared.js +1 -1
  26. package/lib/commands/app/detail.js +1 -1
  27. package/lib/commands/app/index.js +1 -1
  28. package/lib/commands/app/list.js +5 -1
  29. package/lib/commands/app/members-list.js +1 -1
  30. package/lib/commands/app/remote-directory.js +1 -1
  31. package/lib/commands/app/shared.js +4 -1
  32. package/lib/commands/app-config/delete.js +2 -1
  33. package/lib/commands/app-config/get.js +2 -1
  34. package/lib/commands/app-config/index.js +1 -1
  35. package/lib/commands/app-config/list.js +2 -1
  36. package/lib/commands/app-config/set.js +3 -1
  37. package/lib/commands/app-config/shared.d.ts +9 -2
  38. package/lib/commands/app-config/shared.js +6 -1
  39. package/lib/commands/auth/index.js +1 -1
  40. package/lib/commands/bff/create.js +11 -1
  41. package/lib/commands/bff/delete.js +6 -1
  42. package/lib/commands/bff/detail.js +1 -1
  43. package/lib/commands/bff/index.js +1 -1
  44. package/lib/commands/bff/list.js +1 -1
  45. package/lib/commands/bff/logs.js +4 -1
  46. package/lib/commands/bff/pull.js +22 -1
  47. package/lib/commands/bff/push.js +16 -1
  48. package/lib/commands/bff/status.js +3 -1
  49. package/lib/commands/cli-skill/index.js +2 -1
  50. package/lib/commands/cli-update.js +7 -1
  51. package/lib/commands/codegen/index.js +1 -1
  52. package/lib/commands/codegen/sdk.js +1 -1
  53. package/lib/commands/codegen/sql.js +1 -1
  54. package/lib/commands/common/app-registry.js +4 -1
  55. package/lib/commands/common/app-selector.js +4 -1
  56. package/lib/commands/common/async-task.js +2 -1
  57. package/lib/commands/common/dry-run.js +1 -1
  58. package/lib/commands/common/flags.js +3 -1
  59. package/lib/commands/common/local-file.js +1 -1
  60. package/lib/commands/common/validate.js +1 -1
  61. package/lib/commands/config/delete.js +2 -1
  62. package/lib/commands/config/get.js +1 -1
  63. package/lib/commands/config/index.js +1 -1
  64. package/lib/commands/config/init.js +5 -1
  65. package/lib/commands/config/list.js +1 -1
  66. package/lib/commands/config/set.js +4 -1
  67. package/lib/commands/config/shared.js +2 -1
  68. package/lib/commands/dataset/batch-design.js +9 -1
  69. package/lib/commands/dataset/business-group-update.js +10 -1
  70. package/lib/commands/dataset/business-groups.js +1 -1
  71. package/lib/commands/dataset/capability.js +3 -1
  72. package/lib/commands/dataset/cross-relation-create.js +2 -1
  73. package/lib/commands/dataset/cross-relation-delete.js +1 -1
  74. package/lib/commands/dataset/cross-relation-list.js +2 -1
  75. package/lib/commands/dataset/cross-relation-shared.js +10 -1
  76. package/lib/commands/dataset/cross-relation-update.js +2 -1
  77. package/lib/commands/dataset/delete.js +6 -1
  78. package/lib/commands/dataset/design-context.js +1 -1
  79. package/lib/commands/dataset/design-start.js +1 -1
  80. package/lib/commands/dataset/design-status.js +1 -1
  81. package/lib/commands/dataset/design-sync-retry.js +1 -1
  82. package/lib/commands/dataset/design-sync-status.js +1 -1
  83. package/lib/commands/dataset/design-validate.js +1 -1
  84. package/lib/commands/dataset/detail.js +5 -1
  85. package/lib/commands/dataset/extend-update.js +7 -1
  86. package/lib/commands/dataset/field-restore.js +7 -1
  87. package/lib/commands/dataset/field-update.js +7 -1
  88. package/lib/commands/dataset/generate.js +19 -1
  89. package/lib/commands/dataset/index.js +3 -1
  90. package/lib/commands/dataset/list.js +2 -1
  91. package/lib/commands/dataset/operations.js +2 -1
  92. package/lib/commands/dataset/relation-audit.js +7 -1
  93. package/lib/commands/dataset/relation-create.js +3 -1
  94. package/lib/commands/dataset/relation-delete.js +3 -1
  95. package/lib/commands/dataset/relation-shared.js +21 -1
  96. package/lib/commands/dataset/relation-update.js +4 -1
  97. package/lib/commands/dataset/relations.js +7 -1
  98. package/lib/commands/dataset/rename.js +4 -1
  99. package/lib/commands/dataset/restore.js +7 -1
  100. package/lib/commands/dataset/user-deleted-field-list.js +3 -1
  101. package/lib/commands/db/analysis-batching.js +3 -1
  102. package/lib/commands/db/analyze-batch-plan.js +2 -1
  103. package/lib/commands/db/analyze-cancel.js +1 -1
  104. package/lib/commands/db/analyze-start.js +3 -1
  105. package/lib/commands/db/analyze-status.js +6 -1
  106. package/lib/commands/db/create.js +4 -1
  107. package/lib/commands/db/cross-db-analysis-shared.js +3 -1
  108. package/lib/commands/db/cross-db-analyze-latest.js +1 -1
  109. package/lib/commands/db/cross-db-analyze-start.js +2 -1
  110. package/lib/commands/db/cross-db-analyze-status.js +1 -1
  111. package/lib/commands/db/delete.js +3 -1
  112. package/lib/commands/db/detail.js +1 -1
  113. package/lib/commands/db/diff-refresh-start.js +1 -1
  114. package/lib/commands/db/diff-refresh-status.js +2 -1
  115. package/lib/commands/db/diff.js +3 -1
  116. package/lib/commands/db/index.js +2 -1
  117. package/lib/commands/db/list.js +2 -1
  118. package/lib/commands/db/shared.js +3 -1
  119. package/lib/commands/db/table-diff-shared.js +2 -1
  120. package/lib/commands/db/tables.js +2 -1
  121. package/lib/commands/db/test.js +2 -1
  122. package/lib/commands/db/update.js +4 -1
  123. package/lib/commands/deployment/index.js +1 -1
  124. package/lib/commands/deployment/sync-all.js +3 -1
  125. package/lib/commands/deployment/sync-jobs.js +2 -1
  126. package/lib/commands/deployment/sync-status.js +2 -1
  127. package/lib/commands/doctor.js +12 -1
  128. package/lib/commands/file/index.js +3 -1
  129. package/lib/commands/flow/create.js +2 -1
  130. package/lib/commands/flow/detail.js +3 -1
  131. package/lib/commands/flow/index.js +1 -1
  132. package/lib/commands/flow/list.js +2 -1
  133. package/lib/commands/flow/page-list.js +2 -1
  134. package/lib/commands/flow/publish.js +2 -1
  135. package/lib/commands/flow/runtime-resources-shared.js +3 -1
  136. package/lib/commands/flow/runtime-role-list.js +2 -1
  137. package/lib/commands/flow/runtime-role-user-list.js +2 -1
  138. package/lib/commands/flow/runtime-user-search.js +2 -1
  139. package/lib/commands/flow/shared.js +6 -1
  140. package/lib/commands/flow/update.js +4 -1
  141. package/lib/commands/flow/validate.js +2 -1
  142. package/lib/commands/instant-api-policy/current.js +1 -1
  143. package/lib/commands/instant-api-policy/index.js +1 -1
  144. package/lib/commands/instant-api-policy/init.js +2 -1
  145. package/lib/commands/instant-api-policy/publish.js +5 -1
  146. package/lib/commands/instant-api-policy/pull.js +2 -1
  147. package/lib/commands/instant-api-policy/revision.js +1 -1
  148. package/lib/commands/instant-api-policy/revisions.js +1 -1
  149. package/lib/commands/instant-api-policy/rollback.js +5 -1
  150. package/lib/commands/instant-api-policy/shared.js +5 -1
  151. package/lib/commands/instant-api-policy/validate.js +1 -1
  152. package/lib/commands/issue/context.js +1 -1
  153. package/lib/commands/issue/index.js +1 -1
  154. package/lib/commands/issue/nudge.js +2 -1
  155. package/lib/commands/issue/report.js +5 -1
  156. package/lib/commands/kb/create.js +5 -1
  157. package/lib/commands/kb/delete.js +5 -1
  158. package/lib/commands/kb/detail.js +1 -1
  159. package/lib/commands/kb/import-api.d.ts +3 -0
  160. package/lib/commands/kb/import-api.js +1 -0
  161. package/lib/commands/kb/import-resume.d.ts +2 -0
  162. package/lib/commands/kb/import-resume.js +2 -0
  163. package/lib/commands/kb/import-shared.d.ts +69 -0
  164. package/lib/commands/kb/import-shared.js +9 -0
  165. package/lib/commands/kb/import-status.d.ts +2 -0
  166. package/lib/commands/kb/import-status.js +1 -0
  167. package/lib/commands/kb/import.d.ts +2 -0
  168. package/lib/commands/kb/import.js +3 -0
  169. package/lib/commands/kb/index.js +1 -1
  170. package/lib/commands/kb/list.js +1 -1
  171. package/lib/commands/kb/search.js +3 -1
  172. package/lib/commands/kb/shared.js +9 -1
  173. package/lib/commands/kb/update.js +7 -1
  174. package/lib/commands/logs/index.js +2 -1
  175. package/lib/commands/menu/asset-update.js +8 -1
  176. package/lib/commands/menu/delete.js +15 -1
  177. package/lib/commands/menu/external-link-create.js +16 -1
  178. package/lib/commands/menu/external-link-update.js +10 -1
  179. package/lib/commands/menu/group-create.js +8 -1
  180. package/lib/commands/menu/group-update.js +6 -1
  181. package/lib/commands/menu/index.js +2 -1
  182. package/lib/commands/menu/list.js +1 -1
  183. package/lib/commands/menu/move.js +6 -1
  184. package/lib/commands/menu/regroup-start.js +11 -1
  185. package/lib/commands/menu/rename.js +9 -1
  186. package/lib/commands/menu/shared/compare-table.js +2 -1
  187. package/lib/commands/menu/shared/delete-plan.js +13 -1
  188. package/lib/commands/menu/shared/facts.js +5 -1
  189. package/lib/commands/menu/shared/index.js +1 -1
  190. package/lib/commands/menu/shared/inquirer.js +4 -1
  191. package/lib/commands/menu/shared/local-pages.js +5 -1
  192. package/lib/commands/menu/shared/logic.js +3 -1
  193. package/lib/commands/menu/shared/mutations.js +9 -1
  194. package/lib/commands/menu/shared/path.js +1 -1
  195. package/lib/commands/menu/shared/service.js +4 -1
  196. package/lib/commands/menu/shared/subapp-assets.js +4 -1
  197. package/lib/commands/menu/shared/sync-core.js +7 -1
  198. package/lib/commands/menu/shared/types.js +1 -1
  199. package/lib/commands/menu/shared/update-core.js +8 -1
  200. package/lib/commands/menu/shared/valid-url.js +1 -1
  201. package/lib/commands/menu/subapp-assets-status.js +1 -1
  202. package/lib/commands/menu/subapp-assets-update.js +7 -1
  203. package/lib/commands/menu/sync.js +7 -1
  204. package/lib/commands/menu/visibility-update.js +13 -1
  205. package/lib/commands/metric/contract.d.ts +8 -0
  206. package/lib/commands/metric/contract.js +5 -0
  207. package/lib/commands/metric/definition.d.ts +43 -0
  208. package/lib/commands/metric/definition.js +4 -0
  209. package/lib/commands/metric/delete.d.ts +2 -0
  210. package/lib/commands/metric/delete.js +3 -0
  211. package/lib/commands/metric/detail.d.ts +2 -0
  212. package/lib/commands/metric/detail.js +1 -0
  213. package/lib/commands/metric/example.d.ts +2 -0
  214. package/lib/commands/metric/example.js +1 -0
  215. package/lib/commands/metric/index.d.ts +2 -0
  216. package/lib/commands/metric/index.js +1 -0
  217. package/lib/commands/metric/list.d.ts +2 -0
  218. package/lib/commands/metric/list.js +2 -0
  219. package/lib/commands/metric/publication-diff.d.ts +8 -0
  220. package/lib/commands/metric/publication-diff.js +1 -0
  221. package/lib/commands/metric/publish.d.ts +2 -0
  222. package/lib/commands/metric/publish.js +4 -0
  223. package/lib/commands/metric/schema.d.ts +2 -0
  224. package/lib/commands/metric/schema.js +1 -0
  225. package/lib/commands/metric/shared.d.ts +14 -0
  226. package/lib/commands/metric/shared.js +2 -0
  227. package/lib/commands/metric/validate.d.ts +2 -0
  228. package/lib/commands/metric/validate.js +1 -0
  229. package/lib/commands/notification/config-create.js +4 -1
  230. package/lib/commands/notification/config-delete.js +4 -1
  231. package/lib/commands/notification/config-list.js +2 -1
  232. package/lib/commands/notification/config-update.js +4 -1
  233. package/lib/commands/notification/index.js +1 -1
  234. package/lib/commands/notification/shared.js +18 -1
  235. package/lib/commands/ocr/index.js +4 -1
  236. package/lib/commands/page/create.js +6 -1
  237. package/lib/commands/page/custom/detail.js +2 -1
  238. package/lib/commands/page/custom/list.js +2 -1
  239. package/lib/commands/page/custom/publish.js +3 -1
  240. package/lib/commands/page/custom/shared.js +3 -1
  241. package/lib/commands/page/custom/syntax.js +2 -1
  242. package/lib/commands/page/custom/update.js +3 -1
  243. package/lib/commands/page/data-list-status.js +2 -1
  244. package/lib/commands/page/generate-start.js +5 -1
  245. package/lib/commands/page/generate-status.js +4 -1
  246. package/lib/commands/page/index.js +2 -1
  247. package/lib/commands/page/pull.js +6 -1
  248. package/lib/commands/page/push.js +11 -1
  249. package/lib/commands/page/relation-audit.js +15 -1
  250. package/lib/commands/page/restore.js +5 -1
  251. package/lib/commands/page/shared.js +16 -1
  252. package/lib/commands/page/sync.js +2 -1
  253. package/lib/commands/project/api-architecture-upgrade.js +11 -1
  254. package/lib/commands/project/create/enhanced-guided-create.js +2 -1
  255. package/lib/commands/project/create/format-elapsed.js +1 -1
  256. package/lib/commands/project/create/main.js +13 -1
  257. package/lib/commands/project/create/materialize-project-template.js +12 -1
  258. package/lib/commands/project/create/project-name.js +1 -1
  259. package/lib/commands/project/create/project-template-archive.js +5 -1
  260. package/lib/commands/project/create/project-template-path.js +1 -1
  261. package/lib/commands/project/create/use-copy-project-template.js +2 -1
  262. package/lib/commands/project/create/use-format-code.js +1 -1
  263. package/lib/commands/project/create/use-install-dependencies.js +1 -1
  264. package/lib/commands/project/domain-routing-sync.js +1 -1
  265. package/lib/commands/project/index.js +4 -1
  266. package/lib/commands/project/upgrade.js +7 -1
  267. package/lib/commands/registry.js +10 -1
  268. package/lib/commands/role/delete.js +2 -1
  269. package/lib/commands/role/detail.js +1 -1
  270. package/lib/commands/role/index.js +1 -1
  271. package/lib/commands/role/list.js +2 -1
  272. package/lib/commands/role/shared.js +8 -1
  273. package/lib/commands/role/update.js +3 -1
  274. package/lib/commands/role/user-add.js +2 -1
  275. package/lib/commands/role/user-remove.js +2 -1
  276. package/lib/commands/role/user-resolve.js +1 -1
  277. package/lib/commands/rule/get.js +1 -1
  278. package/lib/commands/rule/index.js +1 -1
  279. package/lib/commands/rule/list.js +1 -1
  280. package/lib/commands/rule/set.js +7 -1
  281. package/lib/commands/rule/shared.js +4 -1
  282. package/lib/commands/run/index.js +5 -1
  283. package/lib/commands/schema.js +1 -1
  284. package/lib/commands/sql/create.js +7 -1
  285. package/lib/commands/sql/delete.js +4 -1
  286. package/lib/commands/sql/detail.js +1 -1
  287. package/lib/commands/sql/exec.js +1 -1
  288. package/lib/commands/sql/index.js +1 -1
  289. package/lib/commands/sql/list.js +2 -1
  290. package/lib/commands/sql/pull.js +10 -1
  291. package/lib/commands/sql/push.js +9 -1
  292. package/lib/commands/sql/shared.js +5 -1
  293. package/lib/commands/sql/status.js +3 -1
  294. package/lib/commands/sql/validate.js +5 -1
  295. package/lib/commands/task/index.js +1 -1
  296. package/lib/commands/task/status.js +2 -1
  297. package/lib/commands/tenant/index.js +1 -1
  298. package/lib/commands/tenant/members-list.js +2 -1
  299. package/lib/commands/tenant/shared.js +2 -1
  300. package/lib/commands/user-account/dingding-sandbox-bind.js +2 -1
  301. package/lib/commands/user-account/feishu-bind.js +2 -1
  302. package/lib/commands/user-account/index.js +1 -1
  303. package/lib/commands/workspace/add.js +1 -1
  304. package/lib/commands/workspace/index.js +7 -1
  305. package/lib/commands/workspace/remove.js +1 -1
  306. package/lib/config/domain-config.js +8 -1
  307. package/lib/config/project-domain-routing.js +3 -1
  308. package/lib/config/region-config.js +2 -1
  309. package/lib/config/schema.js +7 -1
  310. package/lib/constant/cdn.js +2 -1
  311. package/lib/constant/cli.js +8 -1
  312. package/lib/constant/defaults.js +1 -1
  313. package/lib/constant/domain.js +4 -1
  314. package/lib/constant/env.js +1 -1
  315. package/lib/constant/output.js +1 -1
  316. package/lib/constant/paths.js +1 -1
  317. package/lib/constant/region.js +1 -1
  318. package/lib/constant/risk.js +1 -1
  319. package/lib/constant/routing-profile.js +1 -1
  320. package/lib/context/app-resolver.js +7 -1
  321. package/lib/context/auth-resolver.js +1 -1
  322. package/lib/context/config-loader.js +7 -1
  323. package/lib/context.js +9 -1
  324. package/lib/core/alias-resolver.js +5 -1
  325. package/lib/core/api-client.d.ts +14 -7
  326. package/lib/core/api-client.js +69 -1
  327. package/lib/core/bff/config.js +1 -1
  328. package/lib/core/bff/file-system.js +6 -1
  329. package/lib/core/bff/hash.js +1 -1
  330. package/lib/core/bff/hook-directory.js +9 -1
  331. package/lib/core/bff/lock.js +2 -1
  332. package/lib/core/bff/types.js +1 -1
  333. package/lib/core/bff/utils.js +3 -1
  334. package/lib/core/cross-db-analysis.js +1 -1
  335. package/lib/core/cross-db-relation.js +1 -1
  336. package/lib/core/db-resolver.js +2 -1
  337. package/lib/core/flow-config.js +49 -1
  338. package/lib/core/instant-api-policy/config.js +7 -1
  339. package/lib/core/instant-api-policy/endpoints.js +1 -1
  340. package/lib/core/kb-management-client.d.ts +11 -0
  341. package/lib/core/kb-management-client.js +4 -1
  342. package/lib/core/kb-search-client.js +3 -1
  343. package/lib/core/page/file-system.js +2 -1
  344. package/lib/core/page/hash.js +1 -1
  345. package/lib/core/page/lock.js +2 -1
  346. package/lib/core/page/lr-smart-jsx.js +4 -1
  347. package/lib/core/page/types.js +1 -1
  348. package/lib/core/sql-index-auditor.js +14 -1
  349. package/lib/core/sql-sync/config.js +1 -1
  350. package/lib/core/sql-sync/file-system.js +3 -1
  351. package/lib/core/sql-sync/hash.js +1 -1
  352. package/lib/core/sql-sync/lock.js +2 -1
  353. package/lib/core/sql-sync/types.js +1 -1
  354. package/lib/core/sql-sync/utils.js +2 -1
  355. package/lib/core/sql-validator.js +15 -1
  356. package/lib/errors.js +3 -1
  357. package/lib/framework/build-all-flags.js +1 -1
  358. package/lib/framework/error-output.js +1 -1
  359. package/lib/framework/explicit-yes.js +1 -1
  360. package/lib/framework/flags.js +1 -1
  361. package/lib/framework/help.js +2 -1
  362. package/lib/framework/index.js +1 -1
  363. package/lib/framework/output.js +2 -1
  364. package/lib/framework/response.js +1 -1
  365. package/lib/framework/runner-alias.js +2 -1
  366. package/lib/framework/runner.js +9 -1
  367. package/lib/framework/schema-export.js +1 -1
  368. package/lib/framework/supported-flags.js +2 -1
  369. package/lib/framework/types.js +1 -1
  370. package/lib/generated/build-info.d.ts +4 -4
  371. package/lib/generated/build-info.js +1 -1
  372. package/lib/generated/official-routing.js +3 -1
  373. package/lib/generated/routing-contract.js +1 -1
  374. package/lib/help.js +1 -1
  375. package/lib/runtime/confirmation.js +2 -1
  376. package/lib/runtime/event.js +1 -1
  377. package/lib/runtime/index.js +4 -1
  378. package/lib/runtime/queue.js +1 -1
  379. package/lib/runtime/resolve.js +2 -1
  380. package/lib/runtime/types.js +1 -1
  381. package/lib/services/dataset-design/checkpoint.js +2 -1
  382. package/lib/services/dataset-design/commands.js +14 -1
  383. package/lib/services/dataset-design/contract.js +8 -1
  384. package/lib/skills/builtin-skill.js +8 -1
  385. package/lib/skills/install-updated-skill.d.ts +8 -0
  386. package/lib/skills/install-updated-skill.js +3 -0
  387. package/lib/skills/local-skills-installer.d.ts +2 -0
  388. package/lib/skills/local-skills-installer.js +1 -0
  389. package/lib/skills/main.js +2 -1
  390. package/lib/skills/npx-skills-add.d.ts +6 -6
  391. package/lib/skills/npx-skills-add.js +5 -1
  392. package/lib/skills/skill-presence.d.ts +1 -30
  393. package/lib/skills/skill-presence.js +2 -1
  394. package/lib/telemetry/cli-command-trace.js +2 -1
  395. package/lib/telemetry/cli-help-trace.js +1 -1
  396. package/lib/telemetry/ensure-cli-otel-config.js +1 -1
  397. package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
  398. package/lib/telemetry/send-cli-trace-log.js +1 -1
  399. package/lib/types/index.js +1 -1
  400. package/lib/utils/ai_config.js +3 -1
  401. package/lib/utils/apply-jq-filter.js +1 -1
  402. package/lib/utils/cdn-config.js +1 -1
  403. package/lib/utils/check-sdk-version.js +5 -1
  404. package/lib/utils/cli-version-check.js +4 -1
  405. package/lib/utils/cli-version-policy.js +3 -1
  406. package/lib/utils/config.js +1 -1
  407. package/lib/utils/entity-with-id.js +1 -1
  408. package/lib/utils/file-utils.js +1 -1
  409. package/lib/utils/guides-cdn.js +3 -1
  410. package/lib/utils/http-client.js +2 -1
  411. package/lib/utils/is-non-interactive.js +1 -1
  412. package/lib/utils/logger.js +3 -1
  413. package/lib/utils/params.js +1 -1
  414. package/lib/utils/platform.js +1 -1
  415. package/lib/utils/sleep.js +1 -1
  416. package/lib/utils/template-replacer.js +5 -1
  417. package/lib/utils/update-notice.js +3 -1
  418. package/lib/utils/version.js +1 -1
  419. package/lib/utils/with-active-cookie.js +1 -1
  420. package/lib/utils/write-cli-side-channel.js +1 -1
  421. package/package.json +10 -7
  422. package/skills/rabetbase/SKILL.md +11 -7
  423. package/skills/rabetbase/guides/backend-function.md +3 -1
  424. package/skills/rabetbase/guides/data-api-guidelines.md +1 -1
  425. package/skills/rabetbase/guides/frontend-development.md +1 -0
  426. package/skills/rabetbase/guides/metric-development.md +185 -0
  427. package/skills/rabetbase/references/rabetbase-app-config.md +4 -3
  428. package/skills/rabetbase/references/rabetbase-cli-skill-install.md +5 -5
  429. package/skills/rabetbase/references/rabetbase-dataset-design.md +1 -1
  430. package/skills/rabetbase/references/rabetbase-kb.md +16 -0
  431. package/skills/rabetbase/references/rabetbase-metric.md +119 -0
  432. package/skills/rabetbase/references/rabetbase-update.md +7 -5
  433. package/skills/rabetbase-dataset-generation/SKILL.md +1 -1
  434. package/skills/rabetbase-dataset-generation/references/workflow.md +1 -1
  435. package/skills/rabetbase-metrics-generation/SKILL.md +22 -0
  436. package/skills/rabetbase-metrics-generation/references/verification.md +19 -0
  437. package/skills/rabetbase-metrics-generation/references/workflow.md +41 -0
  438. package/skills/rabetbase-metrics-generation/templates/statistics-delivery.md +11 -0
  439. package/skills/rabetbase-page-generation/SKILL.md +1 -1
  440. package/skills/rabetbase-page-generation/references/generation.md +1 -1
  441. package/skills/rabetbase.manifest.json +5 -3
  442. package/templates/metrics/definition.json +78 -0
  443. package/templates/metrics/metric-definition.schema.json +136 -0
  444. package/lib/postinstall.d.ts +0 -3
  445. package/lib/postinstall.js +0 -1
  446. package/scripts/postinstall.mjs +0 -24
@@ -1 +1 @@
1
- const a41_0x28a77f=a41_0x48fa;(function(_0x79663b,_0x7d6fd8){const _0x5bca0d=a41_0x48fa,_0x57717e=_0x79663b();while(!![]){try{const _0xea9f94=-parseInt(_0x5bca0d(0x13e))/0x1*(parseInt(_0x5bca0d(0x14d))/0x2)+parseInt(_0x5bca0d(0x15a))/0x3*(-parseInt(_0x5bca0d(0x144))/0x4)+parseInt(_0x5bca0d(0x13f))/0x5+parseInt(_0x5bca0d(0x147))/0x6*(parseInt(_0x5bca0d(0x13c))/0x7)+-parseInt(_0x5bca0d(0x153))/0x8+parseInt(_0x5bca0d(0x155))/0x9*(-parseInt(_0x5bca0d(0x14b))/0xa)+parseInt(_0x5bca0d(0x13d))/0xb;if(_0xea9f94===_0x7d6fd8)break;else _0x57717e['push'](_0x57717e['shift']());}catch(_0x1a9d67){_0x57717e['push'](_0x57717e['shift']());}}}(a41_0x364b,0x4f269));function a41_0x48fa(_0x25a117,_0x41ba44){_0x25a117=_0x25a117-0x13c;const _0x364bde=a41_0x364b();let _0x48fa48=_0x364bde[_0x25a117];return _0x48fa48;}import{listBffScripts}from'../../core/api-client.js';export const bffList={'service':a41_0x28a77f(0x143),'command':'list','description':a41_0x28a77f(0x148),'risk':a41_0x28a77f(0x14a),'flags':[{'name':a41_0x28a77f(0x15b),'type':a41_0x28a77f(0x14e),'description':a41_0x28a77f(0x14f),'default':a41_0x28a77f(0x156),'enum':[a41_0x28a77f(0x156),a41_0x28a77f(0x14c)]},{'name':'name','type':a41_0x28a77f(0x14e),'description':a41_0x28a77f(0x141)},{'name':'verbose','type':'boolean','description':a41_0x28a77f(0x145)}],async 'execute'(_0x28a7c3){const _0x5daf9b=a41_0x28a77f,_0x32d6d5=await listBffScripts(_0x28a7c3[_0x5daf9b(0x150)],_0x28a7c3[_0x5daf9b(0x142)](_0x5daf9b(0x15b)),{'scriptName':_0x28a7c3[_0x5daf9b(0x142)](_0x5daf9b(0x152))||undefined}),_0x550cee=_0x28a7c3[_0x5daf9b(0x151)](_0x5daf9b(0x157));return{'ok':!![],'data':_0x550cee?_0x32d6d5:_0x32d6d5[_0x5daf9b(0x154)](_0x216e42=>({'id':_0x216e42['id'],'functionName':_0x216e42[_0x5daf9b(0x159)]??'','description':_0x216e42['description']||_0x5daf9b(0x158),'scriptType':_0x216e42[_0x5daf9b(0x146)]})),'message':_0x32d6d5[_0x5daf9b(0x140)]===0x0?_0x5daf9b(0x149):undefined};}};function a41_0x364b(){const _0x5d745b=['bff','33584fvwjeQ','Return\x20full\x20script\x20objects','scriptType','6fzOTUs','List\x20Backend\x20Function\x20scripts','No\x20Backend\x20Function\x20scripts\x20found.','read','270cYGCAr','COMMON','1828sEDACN','string','Script\x20type\x20filter','appCode','bool','name','4540544fAWYFE','map','98073KMWCye','ENDPOINT','verbose','(unnamed)','functionName','126nfqBbT','type','3987179YLuaCE','9131243HERTAi','169unpipD','1466880tScfBB','length','Filter\x20by\x20script\x20name','str'];a41_0x364b=function(){return _0x5d745b;};return a41_0x364b();}
1
+ import{listBffScripts}from"../../core/api-client.js";export const bffList={service:"bff",command:"list",description:"List Backend Function scripts",risk:"read",flags:[{name:"type",type:"string",description:"Script type filter",default:"ENDPOINT",enum:["ENDPOINT","COMMON"]},{name:"name",type:"string",description:"Filter by script name"},{name:"verbose",type:"boolean",description:"Return full script objects"}],async execute(ctx){const scripts=await listBffScripts(ctx.appCode,ctx.str("type"),{scriptName:ctx.str("name")||undefined});const verbose=ctx.bool("verbose");return{ok:true,data:verbose?scripts:scripts.map(s=>({id:s.id,functionName:s.functionName??"",description:s.description||"(unnamed)",scriptType:s.scriptType})),message:scripts.length===0?"No Backend Function scripts found.":undefined}}};
@@ -1 +1,4 @@
1
- const a42_0x3f649b=a42_0x48d6;(function(_0x2fe34c,_0x115d5f){const _0x52ad37=a42_0x48d6,_0xe588b8=_0x2fe34c();while(!![]){try{const _0x3fe11a=parseInt(_0x52ad37(0x1b2))/0x1+-parseInt(_0x52ad37(0x1a7))/0x2*(-parseInt(_0x52ad37(0x1b5))/0x3)+parseInt(_0x52ad37(0x1b3))/0x4+parseInt(_0x52ad37(0x1c5))/0x5*(-parseInt(_0x52ad37(0x1c7))/0x6)+-parseInt(_0x52ad37(0x19f))/0x7+-parseInt(_0x52ad37(0x1b7))/0x8*(parseInt(_0x52ad37(0x19e))/0x9)+parseInt(_0x52ad37(0x1b6))/0xa;if(_0x3fe11a===_0x115d5f)break;else _0xe588b8['push'](_0xe588b8['shift']());}catch(_0x21461f){_0xe588b8['push'](_0xe588b8['shift']());}}}(a42_0x2ebb,0xb0120));import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a42_0x48d6(_0xf9a73a,_0x598b6e){_0xf9a73a=_0xf9a73a-0x19d;const _0x2ebbae=a42_0x2ebb();let _0x48d624=_0x2ebbae[_0xf9a73a];return _0x48d624;}function a42_0x2ebb(){const _0x237283=['length','6kyjrnm','No\x20Backend\x20Function\x20logs\x20found\x20for\x20the\x20selected\x20range.','flag','number','225WZPcry','5302689POONDM','--start-time','bff','validation','DEBUG','logs','Query\x20recent\x20Backend\x20Function\x20runtime\x20logs\x20for\x20development\x20debugging','since','364912BQlCwc','--since','str','level','Found\x20','toUpperCase','--end-time','Maximum\x20log\x20lines\x20to\x20return\x20(1-','isSafeInteger','appCode','start-time','713062cclFsh','108628KHDYtb','\x20must\x20be\x20a\x20positive\x20integer.','3yardUa','25372720MbbEqJ','440488KyfRtx','INFO','\x20Backend\x20Function\x20log\x20line(s).','end-time','string','Query\x20end\x20time\x20as\x20a\x20Unix\x20timestamp\x20in\x20milliseconds\x20(default:\x20now)','Filter\x20by\x20log\x20level','num','trim','read','keyword','now','Minutes\x20before\x20the\x20end\x20time\x20to\x20query\x20(default:\x20','--limit\x20must\x20be\x20between\x201\x20and\x20','3023555AaOdlu'];a42_0x2ebb=function(){return _0x237283;};return a42_0x2ebb();}import{searchBffScriptLogs}from'../../core/api-client.js';import{CliErrors}from'../../errors.js';const DEFAULT_SINCE_MINUTES=0x1e,DEFAULT_LIMIT=0xc8,MAX_LIMIT=0x3e8,LOG_LEVELS=[a42_0x3f649b(0x1a3),a42_0x3f649b(0x1b8),'WARN','ERROR'];export function resolveBffLogQuery(_0x23c52c,_0x1d9eb9=Date[a42_0x3f649b(0x1c2)]()){const _0xd508d2=a42_0x3f649b,_0x16454b=_0x23c52c['flag'](_0xd508d2(0x1a6)),_0x45fe1b=_0x23c52c['flag']('start-time'),_0x2443aa=_0x23c52c[_0xd508d2(0x1c9)](_0xd508d2(0x1ba));if(_0x16454b!==undefined&&_0x45fe1b!==undefined)throw CliErrors['validation']('--since\x20cannot\x20be\x20combined\x20with\x20--start-time.');const _0x11afe3=_0x2443aa===undefined?_0x1d9eb9:readPositiveInteger(_0x23c52c[_0xd508d2(0x1be)](_0xd508d2(0x1ba)),_0xd508d2(0x1ad)),_0x4bf482=_0x45fe1b===undefined?_0x11afe3-readSinceMinutes(_0x23c52c)*0xea60:readPositiveInteger(_0x23c52c[_0xd508d2(0x1be)](_0xd508d2(0x1b1)),_0xd508d2(0x1a0));if(_0x4bf482<=0x0)throw CliErrors[_0xd508d2(0x1a2)]('The\x20resolved\x20log\x20start\x20time\x20must\x20be\x20greater\x20than\x200.');if(_0x4bf482>_0x11afe3)throw CliErrors[_0xd508d2(0x1a2)]('--start-time\x20must\x20be\x20less\x20than\x20or\x20equal\x20to\x20--end-time.');const _0xbbc05a=readPositiveInteger(_0x23c52c[_0xd508d2(0x1be)]('limit',DEFAULT_LIMIT),'--limit');if(_0xbbc05a>MAX_LIMIT)throw CliErrors[_0xd508d2(0x1a2)](_0xd508d2(0x1c4)+MAX_LIMIT+'.');const _0x3536c5=_0x23c52c['str'](_0xd508d2(0x1aa))[_0xd508d2(0x1bf)]()[_0xd508d2(0x1ac)]()||undefined,_0x2ece7b=_0x23c52c[_0xd508d2(0x1a9)](_0xd508d2(0x1c1))['trim']()||undefined;return{'appCode':_0x23c52c[_0xd508d2(0x1b0)],'startTime':_0x4bf482,'endTime':_0x11afe3,..._0x45fe1b===undefined?{'sinceMinutes':readSinceMinutes(_0x23c52c)}:{},..._0x3536c5?{'level':_0x3536c5}:{},..._0x2ece7b?{'keyword':_0x2ece7b}:{},'limit':_0xbbc05a};}function readSinceMinutes(_0xcc12ba){const _0x51e461=a42_0x3f649b;return readPositiveInteger(_0xcc12ba['num'](_0x51e461(0x1a6),DEFAULT_SINCE_MINUTES),_0x51e461(0x1a8));}function readPositiveInteger(_0x176f38,_0x5ce923){const _0x4c9635=a42_0x3f649b;if(!Number[_0x4c9635(0x1af)](_0x176f38)||_0x176f38<=0x0)throw CliErrors[_0x4c9635(0x1a2)](_0x5ce923+_0x4c9635(0x1b4));return _0x176f38;}export const bffLogs={'service':a42_0x3f649b(0x1a1),'command':a42_0x3f649b(0x1a4),'description':a42_0x3f649b(0x1a5),'risk':a42_0x3f649b(0x1c0),'structuredErrors':!![],'flags':[APPCODE_FLAG_OPTIONAL,{'name':a42_0x3f649b(0x1a6),'type':a42_0x3f649b(0x19d),'description':a42_0x3f649b(0x1c3)+DEFAULT_SINCE_MINUTES+')'},{'name':'start-time','type':a42_0x3f649b(0x19d),'description':'Query\x20start\x20time\x20as\x20a\x20Unix\x20timestamp\x20in\x20milliseconds'},{'name':a42_0x3f649b(0x1ba),'type':a42_0x3f649b(0x19d),'description':a42_0x3f649b(0x1bc)},{'name':'level','type':a42_0x3f649b(0x1bb),'description':a42_0x3f649b(0x1bd),'enum':LOG_LEVELS},{'name':a42_0x3f649b(0x1c1),'type':a42_0x3f649b(0x1bb),'description':'Filter\x20formatted\x20log\x20lines\x20by\x20keyword'},{'name':'limit','type':a42_0x3f649b(0x19d),'description':a42_0x3f649b(0x1ae)+MAX_LIMIT+')','default':DEFAULT_LIMIT}],async 'validate'(_0x93c784){resolveBffLogQuery(_0x93c784);},async 'execute'(_0x17a210){const _0x19c7cb=a42_0x3f649b,_0x542b9e=resolveBffLogQuery(_0x17a210),{sinceMinutes:_0x5f2d45,..._0x3482a2}=_0x542b9e,_0x7b64b8=await searchBffScriptLogs(_0x3482a2);return{'ok':!![],'data':{'query':_0x542b9e,'count':_0x7b64b8[_0x19c7cb(0x1c6)],'logs':_0x7b64b8},'message':_0x7b64b8[_0x19c7cb(0x1c6)]===0x0?_0x19c7cb(0x1c8):_0x19c7cb(0x1ab)+_0x7b64b8[_0x19c7cb(0x1c6)]+_0x19c7cb(0x1b9)};}};
1
+ import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{searchBffScriptLogs}from"../../core/api-client.js";import{CliErrors}from"../../errors.js";const DEFAULT_SINCE_MINUTES=30;const DEFAULT_LIMIT=200;const MAX_LIMIT=1e3;const LOG_LEVELS=["DEBUG","INFO","WARN","ERROR"];export function resolveBffLogQuery(ctx,now=Date.now()){const rawSince=ctx.flag("since");const rawStartTime=ctx.flag("start-time");const rawEndTime=ctx.flag("end-time");if(rawSince!==undefined&&rawStartTime!==undefined){throw CliErrors.validation("--since cannot be combined with --start-time.")}const endTime=rawEndTime===undefined?now:readPositiveInteger(ctx.num("end-time"),"--end-time");const startTime=rawStartTime===undefined?endTime-readSinceMinutes(ctx)*6e4:readPositiveInteger(ctx.num("start-time"),"--start-time");if(startTime<=0){throw CliErrors.validation("The resolved log start time must be greater than 0.")}if(startTime>endTime){
2
+ throw CliErrors.validation("--start-time must be less than or equal to --end-time.")}const limit=readPositiveInteger(ctx.num("limit",DEFAULT_LIMIT),"--limit");if(limit>MAX_LIMIT){throw CliErrors.validation(`--limit must be between 1 and ${MAX_LIMIT}.`)}const level=ctx.str("level").trim().toUpperCase()||undefined;const keyword=ctx.str("keyword").trim()||undefined;return{appCode:ctx.appCode,startTime:startTime,endTime:endTime,...rawStartTime===undefined?{sinceMinutes:readSinceMinutes(ctx)}:{},...level?{level:level}:{},...keyword?{keyword:keyword}:{},limit:limit}}function readSinceMinutes(ctx){return readPositiveInteger(ctx.num("since",DEFAULT_SINCE_MINUTES),"--since")}function readPositiveInteger(value,flag){if(!Number.isSafeInteger(value)||value<=0){throw CliErrors.validation(`${flag} must be a positive integer.`)}return value}export const bffLogs={service:"bff",command:"logs",description:"Query recent Backend Function runtime logs for development debugging",risk:"read",
3
+ structuredErrors:true,flags:[APPCODE_FLAG_OPTIONAL,{name:"since",type:"number",description:`Minutes before the end time to query (default: ${DEFAULT_SINCE_MINUTES})`},{name:"start-time",type:"number",description:"Query start time as a Unix timestamp in milliseconds"},{name:"end-time",type:"number",description:"Query end time as a Unix timestamp in milliseconds (default: now)"},{name:"level",type:"string",description:"Filter by log level",enum:LOG_LEVELS},{name:"keyword",type:"string",description:"Filter formatted log lines by keyword"},{name:"limit",type:"number",description:`Maximum log lines to return (1-${MAX_LIMIT})`,default:DEFAULT_LIMIT}],async validate(ctx){resolveBffLogQuery(ctx)},async execute(ctx){const query=resolveBffLogQuery(ctx);const{sinceMinutes:_sinceMinutes,...apiQuery}=query;const logs=await searchBffScriptLogs(apiQuery);return{ok:true,data:{query:query,count:logs.length,logs:logs},
4
+ message:logs.length===0?"No Backend Function logs found for the selected range.":`Found ${logs.length} Backend Function log line(s).`}}};
@@ -1 +1,22 @@
1
- const a43_0x15d1eb=a43_0x25d6;(function(_0x4a6172,_0x4efe1c){const _0xbc6226=a43_0x25d6,_0x6b1862=_0x4a6172();while(!![]){try{const _0x1fb7cd=-parseInt(_0xbc6226(0x8c))/0x1+parseInt(_0xbc6226(0xa4))/0x2+parseInt(_0xbc6226(0xbf))/0x3+-parseInt(_0xbc6226(0x96))/0x4*(parseInt(_0xbc6226(0xc4))/0x5)+-parseInt(_0xbc6226(0x8a))/0x6+parseInt(_0xbc6226(0x108))/0x7*(-parseInt(_0xbc6226(0xb5))/0x8)+parseInt(_0xbc6226(0xdc))/0x9;if(_0x1fb7cd===_0x4efe1c)break;else _0x6b1862['push'](_0x6b1862['shift']());}catch(_0x2994d0){_0x6b1862['push'](_0x6b1862['shift']());}}}(a43_0x3b53,0xd6e45));import{createInterface}from'node:readline';import{readFile,rename,stat,unlink,writeFile}from'node:fs/promises';import{randomUUID}from'node:crypto';function a43_0x3b53(){const _0x56a01b=['conflict','\x22\x20from\x20the\x20lock\x20file.','/api/management/library/scripts/list?appCode=','Force\x20overwrite\x20local\x20unsynced\x20changes','Remote\x20script\x20missing\x20id.','set','mergedCli','Lock\x20scope\x20for\x20app\x20\x22','Pull\x20remote\x20Backend\x20Function\x20scripts\x20to\x20local','2639232UyLTvQ','string','801516FtwhMl','newLockKey','require','toLowerCase','rollback','&currentPage=1&pageSize=','lockFilePath','Could\x20not\x20restore\x20local\x20script\x20\x22','Failed\x20to\x20write\x20the\x20Backend\x20Function\x20lock\x20file;\x20local\x20changes\x20could\x20not\x20be\x20completely\x20rolled\x20back.','oldDirectoryPath','1316FEHNzE','Could\x20not\x20restore\x20temporary\x20HOOK\x20directory\x20\x22','\x20skipped','scriptsRoot','cancelled','oldLockKey','utf8','content','HOOK/','oldDirectory','.hook-directory-migrate-','map','Failed\x20to\x20rename\x20HOOK\x20directory\x20\x22','functionNode','2505890FYpkIT','write','lastSync','\x22:\x20','validation','unresolvable\x20target\x20path','currentApp','hash','Force\x20pull\x20will\x20overwrite\x20local\x20unsynced\x20changes.\x20Continue?\x20[y/N]\x20','\x20remote\x20Backend\x20Function\x20script(s)\x20for\x20pull','\x22\x20from\x20\x22','hookLocation','newDirectory','existed','HOOK','defaultApp','all','24aWKWPG','filter','\x20pulled','Pull\x20complete:\x20','split','stdin','Remote\x20script\x20missing\x20content.','\x20--format\x20compress','sourceFilePathByNewLockKey','entry','1400544JTccrQ','code','Could\x20not\x20restore\x20HOOK\x20directory\x20\x22','\x22:\x20it\x20is\x20now\x20another\x20Dataset\x20alias\x20and\x20contains\x20untracked\x20scripts.\x20Resolve\x20the\x20directory\x20manually\x20before\x20retrying.','\x22:\x20its\x20target\x20directory\x20is\x20unsafe.','18185vPZgKN','join','requires','NFC','mode','bool','bff','rekey','remoteId','\x22\x20may\x20remain.','pull','functions','toISOString','COMMON','appCode','\x22\x20is\x20another\x20legacy\x20key\x20being\x20migrated.\x20Resolve\x20the\x20lock\x20entries\x20manually\x20before\x20retrying.','newDirectoryPath','has','ino','push_local','keyChanges','move','close','ENDPOINT','26664372PquotQ','alias','\x22:\x20its\x20target\x20\x22','Cannot\x20migrate\x20unsafe\x20HOOK\x20directory\x20\x22','get','reverse','\x22\x20and\x20\x22','&type=','message','\x22\x20to\x20\x22','apiDir','Failed\x20to\x20write\x20local\x20script\x20\x22','\x22:\x20the\x20target\x20directory\x20already\x20exists.\x20Resolve\x20the\x20directories\x20and\x20retry.','length','\x20failed','sourceDirectoryPathByNewDirectory','question','functionName','\x20resolution','GET','\x20conflict','datasetCode','projectedFunctions','delete','If\x20the\x20reviewed\x20local\x20script\x20should\x20win,\x20run\x20this\x20command\x20to\x20update\x20the\x20remote\x20script.\x20Do\x20not\x20use\x20--force\x20to\x20resolve\x20a\x20content\x20conflict.','Would\x20inspect\x20','filePath','No\x20remote\x20Backend\x20Function\x20scripts\x20found.','operationType','stringify','scriptsRootDir','push','entries','yes','ENOENT','Cannot\x20migrate\x20HOOK\x20directory\x20\x22','--type\x20must\x20be\x20COMMON,\x20ENDPOINT,\x20or\x20HOOK.','some','read','type','nonInteractive','force','\x20bff\x20push\x20--type\x20','includes','3183467AsyJii','flatMap','scriptType','\x22\x20not\x20found\x20after\x20ensureLockScope.','lockKey','\x22.\x20Resolve\x20the\x20lock\x20entries\x20manually\x20before\x20retrying.','parse','selectedAppName','migrations','str','\x22:\x20both\x20target\x20\x22','scriptContent','case-rename','Failed\x20to\x20migrate\x20HOOK\x20directories;\x20local\x20changes\x20could\x20not\x20be\x20completely\x20rolled\x20back.','Cannot\x20migrate\x20unsafe\x20HOOK\x20lock\x20key\x20\x22','stderr','apps','Cannot\x20migrate\x20HOOK\x20directories\x20\x22','would_pull','\x22:\x20target\x20lock\x20key\x20is\x20already\x20bound\x20to\x20another\x20script.','dev'];a43_0x3b53=function(){return _0x56a01b;};return a43_0x3b53();}import{dirname,join}from'node:path';import{BFF_LIST_PAGE_SIZE,listBffScripts,getBffScriptStatistics}from'../../core/api-client.js';import{loadAliasMap}from'../../core/alias-resolver.js';import{resolveApiModelSource}from'../../api/model-source.js';import{loadBffProjectConfig}from'../../core/bff/config.js';import{createHookLocationMap,directoryExists,ensureParentDirectory,fileExists,isSafeLockKeySegment,normalizeBffType,resolveLocalFilePathFromLockKey,resolveRemoteScriptTarget,scanLocalBffFunctions}from'../../core/bff/file-system.js';import{computeContentHash,computeFileHash}from'../../core/bff/hash.js';import{assertUnambiguousHookAliases}from'../../core/bff/hook-directory.js';import{createEmptyBffLock,ensureLockScope,readBffLockFile,writeBffLockFile}from'../../core/bff/lock.js';import{CliErrors}from'../../errors.js';function a43_0x25d6(_0x4de7f8,_0x13a8d0){_0x4de7f8=_0x4de7f8-0x83;const _0x3b53f2=a43_0x3b53();let _0x25d63e=_0x3b53f2[_0x4de7f8];return _0x25d63e;}import{CLI_BIN_NAME}from'../../constant/cli.js';export const bffPull={'service':a43_0x15d1eb(0xca),'command':a43_0x15d1eb(0xce),'description':a43_0x15d1eb(0x89),'risk':a43_0x15d1eb(0x102),'structuredErrors':!![],'flags':[{'name':a43_0x15d1eb(0x103),'type':a43_0x15d1eb(0x8b),'description':'Pull\x20only\x20this\x20script\x20type','enum':[a43_0x15d1eb(0xd1),a43_0x15d1eb(0xdb),a43_0x15d1eb(0xb2)]},{'name':'force','type':'boolean','description':a43_0x15d1eb(0x84)}],async 'dryRun'(_0x4815f8){const _0x7dc967=a43_0x15d1eb,_0x4d6a85=loadBffProjectConfig(_0x4815f8['appCode']),_0x34138e=await readBffLockFile(_0x4d6a85[_0x7dc967(0x92)]),{appLock:_0x242ec1}=ensureLockScope(_0x34138e??createEmptyBffLock(),_0x4815f8[_0x7dc967(0xd2)],_0x4d6a85[_0x7dc967(0x99)],_0x7dc967(0xce)),_0x1ed462=normalizeBffType(_0x4815f8[_0x7dc967(0x111)](_0x7dc967(0x103)))??undefined,[_0x5259c2,_0x378421]=await Promise[_0x7dc967(0xb4)]([listBffScripts(_0x4815f8[_0x7dc967(0xd2)],_0x1ed462),getBffScriptStatistics(_0x4815f8[_0x7dc967(0xd2)])]),_0xd3e1ec=_0x5259c2[_0x7dc967(0x101)](_0x2bb431=>normalizeBffType(_0x2bb431[_0x7dc967(0x10a)])===_0x7dc967(0xb2)),_0x22b051=_0xd3e1ec?buildDatasetCodeToAliasMap(_0x4815f8[_0x7dc967(0xe6)],_0x4815f8['appCode'],_0x4815f8[_0x7dc967(0x10f)]||_0x4815f8['mergedCli']?.[_0x7dc967(0xaa)]||_0x4815f8['mergedCli']?.[_0x7dc967(0xb3)]):new Map(),_0x1ad380=_0xd3e1ec?await planHookDirectoryMigration(_0x4d6a85,_0x242ec1,_0x22b051,await scanLocalBffFunctions(_0x4d6a85,'HOOK')):undefined,_0x1bb6fb=createHookLocationMap(_0x378421),_0x59db8e=[];for(const _0x24fcfd of _0x5259c2){const _0x5df754=resolveRemoteScriptTarget(_0x4d6a85,_0x24fcfd,_0x1bb6fb,_0x1ad380?.[_0x7dc967(0xf2)]??_0x242ec1[_0x7dc967(0xcf)],_0x22b051);if(!_0x5df754){_0x59db8e['push']({'scriptType':_0x24fcfd[_0x7dc967(0x10a)],'functionName':_0x24fcfd['functionName']??'','status':'skipped','reason':'unresolvable\x20target\x20path'});continue;}const _0x5ee64f=(_0x1ad380?.[_0x7dc967(0xf2)]??_0x242ec1[_0x7dc967(0xcf)])[_0x5df754['lockKey']],_0x50757a=_0x24fcfd['scriptContent']!=null?computeContentHash(_0x24fcfd[_0x7dc967(0x113)]):undefined,_0xd71a17=await hasUnsyncedLocalChanges(resolveMigratedSourceFilePath(_0x1ad380,_0x5df754)??_0x5df754[_0x7dc967(0xf6)],_0x5ee64f,_0x50757a),_0x44eee5=_0xd71a17?localUnsyncedConflict(_0x5df754,_0x24fcfd['id']):undefined;_0x59db8e[_0x7dc967(0xfb)]({'lockKey':_0x5df754[_0x7dc967(0x10c)],'filePath':_0x5df754[_0x7dc967(0xf6)],'remoteId':_0x24fcfd['id']??null,'status':_0x44eee5?_0x7dc967(0x11d):_0x7dc967(0x11a),..._0x44eee5?{'conflict':_0x44eee5}:{},..._0x5df754['hookLocation']?{'alias':_0x5df754[_0x7dc967(0xaf)][_0x7dc967(0xdd)]??null,'datasetCode':_0x5df754[_0x7dc967(0xaf)]['datasetCode'],'operationType':_0x5df754[_0x7dc967(0xaf)][_0x7dc967(0xf8)],'functionNode':_0x5df754[_0x7dc967(0xaf)][_0x7dc967(0xa3)]}:{}});}return{'method':_0x7dc967(0xef),'url':_0x7dc967(0x83)+_0x4815f8[_0x7dc967(0xd2)]+(_0x1ed462?_0x7dc967(0xe3)+_0x1ed462:'')+_0x7dc967(0x91)+BFF_LIST_PAGE_SIZE,'body':{'appCode':_0x4815f8[_0x7dc967(0xd2)],'filterType':_0x1ed462??null,..._0x1ad380&&_0x1ad380[_0x7dc967(0x110)][_0x7dc967(0xe9)]>0x0?{'hookDirectoryMigrations':_0x1ad380[_0x7dc967(0x110)][_0x7dc967(0xa1)](_0x5c361f=>({'from':_0x5c361f[_0x7dc967(0x9f)],'to':_0x5c361f[_0x7dc967(0xb0)]}))}:{},'files':_0x59db8e},'description':_0x7dc967(0xf5)+_0x59db8e[_0x7dc967(0xe9)]+_0x7dc967(0xad)};},async 'execute'(_0x4b65b7){const _0x45296e=a43_0x15d1eb,_0x1145b6=loadBffProjectConfig(_0x4b65b7[_0x45296e(0xd2)]),_0x390a44=await readBffLockFile(_0x1145b6[_0x45296e(0x92)]),{lockData:_0x38f8c3,appLock:_0x2d7676}=ensureLockScope(_0x390a44??createEmptyBffLock(),_0x4b65b7[_0x45296e(0xd2)],_0x1145b6['scriptsRoot'],_0x45296e(0xce)),_0x532f5d=normalizeBffType(_0x4b65b7[_0x45296e(0x111)](_0x45296e(0x103)))??undefined;if(_0x4b65b7[_0x45296e(0x111)](_0x45296e(0x103))&&!_0x532f5d)throw CliErrors[_0x45296e(0xa8)](_0x45296e(0x100));const [_0x1b5925,_0x245ba6]=await Promise['all']([listBffScripts(_0x4b65b7['appCode'],_0x532f5d),getBffScriptStatistics(_0x4b65b7['appCode'])]);if(_0x1b5925[_0x45296e(0xe9)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'conflicts':[],'failed':[]},'message':_0x45296e(0xf7)};const _0x1bf238=_0x4b65b7[_0x45296e(0xc9)](_0x45296e(0x105));if(_0x1bf238&&!_0x4b65b7[_0x45296e(0x104)]){const _0x12241b=await confirmForce();if(!_0x12241b)throw CliErrors[_0x45296e(0x9a)]('Force\x20pull\x20cancelled.');}if(_0x1bf238&&_0x4b65b7[_0x45296e(0x104)]){}const _0x4489e1=_0x1b5925[_0x45296e(0x101)](_0xa14946=>normalizeBffType(_0xa14946[_0x45296e(0x10a)])===_0x45296e(0xb2)),_0x20cedd=_0x4489e1?buildDatasetCodeToAliasMap(_0x4b65b7[_0x45296e(0xe6)],_0x4b65b7[_0x45296e(0xd2)],_0x4b65b7['selectedAppName']||_0x4b65b7[_0x45296e(0x87)]?.['currentApp']||_0x4b65b7[_0x45296e(0x87)]?.[_0x45296e(0xb3)]):new Map(),_0x3f31cc=createHookLocationMap(_0x245ba6),_0x2ec079=JSON[_0x45296e(0x10e)](JSON[_0x45296e(0xf9)](_0x38f8c3)),_0x1d4b25=_0x4b65b7['appCode'],_0x5129fc=_0x2ec079[_0x45296e(0x118)][_0x1d4b25];if(!_0x5129fc)throw new Error(_0x45296e(0x88)+_0x1d4b25+_0x45296e(0x10b));const _0x5e8b69=_0x4489e1?await applyHookDirectoryMigration(await planHookDirectoryMigration(_0x1145b6,_0x5129fc,_0x20cedd,await scanLocalBffFunctions(_0x1145b6,_0x45296e(0xb2))),_0x5129fc):undefined,_0x4890c3=createPullFileTransaction(),_0x45d29b=[],_0x354e2b=[],_0x3491c9=[],_0x453173=[];for(const _0x1ce597 of _0x1b5925){const _0x4fc4b6=resolveRemoteScriptTarget(_0x1145b6,_0x1ce597,_0x3f31cc,_0x5129fc['functions'],_0x20cedd);if(!_0x4fc4b6){_0x354e2b['push']({'lockKey':_0x1ce597[_0x45296e(0x10a)]+'/'+_0x1ce597[_0x45296e(0xed)],'reason':_0x45296e(0xa9)});continue;}const _0x54ce6a=_0x5129fc[_0x45296e(0xcf)][_0x4fc4b6[_0x45296e(0x10c)]];try{if(!_0x1ce597['id'])throw new Error(_0x45296e(0x85));if(_0x1ce597[_0x45296e(0x113)]==null)throw new Error(_0x45296e(0xbb));const _0x25d083=_0x1ce597[_0x45296e(0x113)],_0x3689f7=computeContentHash(_0x25d083);if(!_0x1bf238){const _0x5135aa=await hasUnsyncedLocalChanges(_0x4fc4b6[_0x45296e(0xf6)],_0x54ce6a,_0x3689f7);if(_0x5135aa){_0x3491c9['push'](localUnsyncedConflict(_0x4fc4b6,_0x1ce597['id']));continue;}}await _0x4890c3[_0x45296e(0xa5)](_0x4fc4b6[_0x45296e(0xf6)],_0x25d083);const _0x586d95={'hash':_0x3689f7,'remoteId':_0x1ce597['id'],'version':_0x1ce597['version']};_0x4fc4b6[_0x45296e(0x103)]==='HOOK'&&_0x4fc4b6[_0x45296e(0xaf)]&&(_0x586d95[_0x45296e(0xdd)]=_0x4fc4b6[_0x45296e(0xaf)]['alias'],_0x586d95[_0x45296e(0xf1)]=_0x4fc4b6[_0x45296e(0xaf)][_0x45296e(0xf1)],_0x586d95['operationType']=_0x4fc4b6[_0x45296e(0xaf)][_0x45296e(0xf8)],_0x586d95[_0x45296e(0xa3)]=_0x4fc4b6[_0x45296e(0xaf)][_0x45296e(0xa3)]),_0x5129fc[_0x45296e(0xcf)][_0x4fc4b6['lockKey']]=_0x586d95,_0x45d29b['push']({'lockKey':_0x4fc4b6[_0x45296e(0x10c)],'remoteId':_0x1ce597['id']});}catch(_0x2d971e){_0x453173[_0x45296e(0xfb)]({'lockKey':_0x4fc4b6[_0x45296e(0x10c)],'error':_0x2d971e instanceof Error?_0x2d971e[_0x45296e(0xe4)]:String(_0x2d971e)});}}_0x5129fc['lastSync']=new Date()[_0x45296e(0xd0)]();try{await writeBffLockFile(_0x1145b6[_0x45296e(0x92)],_0x2ec079);}catch(_0x53bee8){const _0x2a04a9=[...await _0x4890c3[_0x45296e(0x90)](),...await _0x5e8b69?.['rollback']()??[]];throw withRollbackErrors(_0x53bee8,_0x45296e(0x94),_0x2a04a9);}return{'ok':_0x453173[_0x45296e(0xe9)]===0x0,'data':{'pulled':_0x45d29b,'skipped':_0x354e2b,'conflicts':_0x3491c9,'failed':_0x453173},'message':formatPullMessage(_0x45d29b[_0x45296e(0xe9)],_0x354e2b[_0x45296e(0xe9)],_0x3491c9[_0x45296e(0xe9)],_0x453173['length'])};}};function localUnsyncedConflict(_0x1e5792,_0x1bf1d2){const _0xf54cc0=a43_0x15d1eb,_0x1aaae5=_0x1e5792['lockKey'][_0xf54cc0(0xb9)]('/')['at'](-0x1);return{'code':'BFF_LOCAL_UNSYNCED','lockKey':_0x1e5792[_0xf54cc0(0x10c)],'filePath':_0x1e5792[_0xf54cc0(0xf6)],..._0x1bf1d2!=null?{'remoteId':_0x1bf1d2}:{},'message':'Local\x20script\x20differs\x20from\x20the\x20last\x20pulled\x20version.\x20Review\x20it\x20before\x20choosing\x20the\x20source\x20of\x20truth.','nextAction':{'action':_0xf54cc0(0xd7),'command':CLI_BIN_NAME+_0xf54cc0(0x106)+_0x1e5792[_0xf54cc0(0x103)]+'\x20--name\x20'+_0x1aaae5+_0xf54cc0(0xbc),'requiresReview':!![],'message':_0xf54cc0(0xf4)}};}function formatPullMessage(_0x37c4e6,_0x37ab82,_0x27734b,_0x1e37f){const _0xdeaf7=a43_0x15d1eb,_0x24dc8a=[_0xdeaf7(0xb8)+_0x37c4e6+_0xdeaf7(0xb7),_0x37ab82+_0xdeaf7(0x98)];_0x27734b>0x0&&_0x24dc8a['push'](_0x27734b+_0xdeaf7(0xf0)+(_0x27734b===0x1?'':'s')+'\x20'+(_0x27734b===0x1?_0xdeaf7(0xc6):_0xdeaf7(0x8e))+_0xdeaf7(0xee));if(_0x1e37f>0x0)_0x24dc8a['push'](_0x1e37f+_0xdeaf7(0xea));return _0x24dc8a[_0xdeaf7(0xc5)](',\x20');}async function hasUnsyncedLocalChanges(_0x2db74f,_0x2f9336,_0x4f0332){const _0x13f946=a43_0x15d1eb;if(!await fileExists(_0x2db74f))return![];const _0x529b15=await computeFileHash(_0x2db74f);if(!_0x2f9336)return _0x4f0332?_0x529b15!==_0x4f0332:!![];return _0x529b15!==_0x2f9336[_0x13f946(0xab)];}function createPullFileTransaction(){const _0x2ceb3e=new Map(),_0x2a4bae=async(_0x16d4d0,_0x173689)=>{const _0x3164e9=a43_0x25d6;try{if(_0x173689[_0x3164e9(0xb1)])await ensureParentDirectory(_0x16d4d0),await writeFile(_0x16d4d0,_0x173689[_0x3164e9(0x9d)]);else try{await unlink(_0x16d4d0);}catch(_0x4cceb6){if(_0x4cceb6[_0x3164e9(0xc0)]!==_0x3164e9(0xfe))throw _0x4cceb6;}return undefined;}catch(_0x206b13){return _0x206b13 instanceof Error?_0x206b13:new Error(String(_0x206b13));}};return{async 'write'(_0x1afddb,_0xfa4d14){const _0x47d790=a43_0x25d6;if(!_0x2ceb3e[_0x47d790(0xd5)](_0x1afddb))try{_0x2ceb3e[_0x47d790(0x86)](_0x1afddb,{'existed':!![],'content':await readFile(_0x1afddb)});}catch(_0x2366c7){if(_0x2366c7[_0x47d790(0xc0)]!==_0x47d790(0xfe))throw _0x2366c7;_0x2ceb3e[_0x47d790(0x86)](_0x1afddb,{'existed':![]});}try{await ensureParentDirectory(_0x1afddb),await writeFile(_0x1afddb,_0xfa4d14,_0x47d790(0x9c));}catch(_0x41e99f){const _0x4e02ce=await _0x2a4bae(_0x1afddb,_0x2ceb3e['get'](_0x1afddb));if(!_0x4e02ce)_0x2ceb3e[_0x47d790(0xf3)](_0x1afddb);throw withRollbackErrors(_0x41e99f,_0x47d790(0xe7)+_0x1afddb+'\x22.',_0x4e02ce?[_0x4e02ce]:[]);}},async 'rollback'(){const _0x324338=a43_0x25d6,_0x14f72f=[];for(const [_0x18f4cb,_0x4c2e7b]of[..._0x2ceb3e['entries']()]['reverse']()){const _0x4f4dce=await _0x2a4bae(_0x18f4cb,_0x4c2e7b);_0x4f4dce&&_0x14f72f['push'](new Error(_0x324338(0x93)+_0x18f4cb+'\x22:\x20'+_0x4f4dce[_0x324338(0xe4)]));}return _0x14f72f;}};}function withRollbackErrors(_0x125139,_0x2e3d2a,_0x576586){const _0x3fdbe1=a43_0x15d1eb,_0x154380=_0x125139 instanceof Error?_0x125139:new Error(String(_0x125139));if(_0x576586[_0x3fdbe1(0xe9)]===0x0)return _0x154380;return new AggregateError([_0x154380,..._0x576586],_0x2e3d2a+'\x20Recovery\x20errors:\x20'+_0x576586[_0x3fdbe1(0xa1)](_0x3c991b=>_0x3c991b[_0x3fdbe1(0xe4)])[_0x3fdbe1(0xc5)](';\x20'));}function buildDatasetCodeToAliasMap(_0x4f97a2,_0x38a4ef,_0xbff0aa){const _0x3e49d5=a43_0x15d1eb,_0x32122c=resolveApiModelSource(_0x4f97a2,_0x38a4ef,_0xbff0aa),_0x10c2ff=loadAliasMap(_0x4f97a2,undefined,_0x32122c[_0x3e49d5(0xf6)],_0x32122c['profileName']);return assertUnambiguousHookAliases(_0x10c2ff),new Map(_0x10c2ff['map'](_0x44312e=>[_0x44312e[_0x3e49d5(0xf1)][_0x3e49d5(0x8f)](),_0x44312e['alias']]));}async function planHookDirectoryMigration(_0x1b69fe,_0x3f84fe,_0x5f1e18,_0x43922f){const _0x10c65f=a43_0x15d1eb,_0x5d2a21=new Map();for(const [_0x448621,_0x3b9494]of Object[_0x10c65f(0xfc)](_0x3f84fe['functions'])){const [_0x41c108,_0x18279a,_0x2b3be0,_0x456248,_0x59a011,..._0xbace85]=_0x448621[_0x10c65f(0xb9)]('/');if(_0x41c108!==_0x10c65f(0xb2)||!_0x18279a||!_0x2b3be0||!_0x456248||!_0x59a011||_0xbace85['length']>0x0||!_0x3b9494[_0x10c65f(0xf1)])continue;const _0x4c0277=_0x5f1e18[_0x10c65f(0xe0)](_0x3b9494['datasetCode'][_0x10c65f(0x8f)]()),_0xd81679=_0x4c0277??_0x3b9494[_0x10c65f(0xf1)];if(!isSafeHookDirectorySegment(_0x18279a))throw CliErrors[_0x10c65f(0xa8)](_0x10c65f(0xdf)+_0x18279a+_0x10c65f(0x11e));if(!isSafeHookDirectorySegment(_0xd81679))throw CliErrors[_0x10c65f(0xa8)](_0x10c65f(0xff)+_0x18279a+_0x10c65f(0xc3));if(_0x18279a===_0xd81679)continue;const _0x15343b=_0x5d2a21[_0x10c65f(0xe0)](_0x18279a)??{'datasetCode':_0x3b9494[_0x10c65f(0xf1)],'alias':_0x4c0277,'keyChanges':[]};if(_0x15343b['datasetCode']!==_0x3b9494[_0x10c65f(0xf1)])throw CliErrors[_0x10c65f(0xa8)](_0x10c65f(0xff)+_0x18279a+'\x22:\x20it\x20is\x20tracked\x20by\x20multiple\x20Datasets.');const _0x1cf846=_0x10c65f(0x9e)+_0xd81679+'/'+_0x2b3be0+'/'+_0x456248+'/'+_0x59a011;try{resolveLocalFilePathFromLockKey(_0x1b69fe,_0x448621),resolveLocalFilePathFromLockKey(_0x1b69fe,_0x1cf846);}catch(_0x2add80){throw CliErrors['validation'](_0x10c65f(0x116)+_0x448621+_0x10c65f(0xa7)+(_0x2add80 instanceof Error?_0x2add80['message']:String(_0x2add80)));}_0x15343b['keyChanges'][_0x10c65f(0xfb)]({'oldLockKey':_0x448621,'newLockKey':_0x1cf846,'entry':_0x3b9494}),_0x5d2a21['set'](_0x18279a,_0x15343b);}const _0x2402fb=new Set([..._0x5d2a21['values']()][_0x10c65f(0x109)](_0x3fbf31=>_0x3fbf31['keyChanges'][_0x10c65f(0xa1)](_0x198062=>_0x198062['oldLockKey']))),_0x539f59=new Map(),_0x47ea51=new Map();for(const [_0x1d1bdd,_0x4b43fe]of _0x5d2a21){const _0x5dfa04=_0x4b43fe[_0x10c65f(0xdd)]??_0x4b43fe[_0x10c65f(0xf1)],_0x21a734=hookDirectoryIdentity(_0x5dfa04),_0x3b5f6a=_0x539f59['get'](_0x21a734);if(_0x3b5f6a&&_0x3b5f6a!==_0x1d1bdd)throw CliErrors[_0x10c65f(0xa8)](_0x10c65f(0x119)+_0x3b5f6a+'\x22\x20and\x20\x22'+_0x1d1bdd+_0x10c65f(0x112)+_0x5dfa04+'\x22.\x20Resolve\x20the\x20directories\x20manually\x20before\x20retrying.');_0x539f59[_0x10c65f(0x86)](_0x21a734,_0x1d1bdd);for(const _0x43c3d1 of _0x4b43fe[_0x10c65f(0xd8)]){const _0x56c44b=_0x47ea51[_0x10c65f(0xe0)](_0x43c3d1[_0x10c65f(0x8d)]);if(_0x56c44b&&_0x56c44b!==_0x43c3d1[_0x10c65f(0x9b)])throw CliErrors[_0x10c65f(0xa8)]('Cannot\x20migrate\x20HOOK\x20lock\x20keys\x20\x22'+_0x56c44b+_0x10c65f(0xe2)+_0x43c3d1['oldLockKey']+_0x10c65f(0x112)+_0x43c3d1['newLockKey']+_0x10c65f(0x10d));if(_0x2402fb[_0x10c65f(0xd5)](_0x43c3d1['newLockKey']))throw CliErrors[_0x10c65f(0xa8)]('Cannot\x20migrate\x20HOOK\x20lock\x20key\x20\x22'+_0x43c3d1['oldLockKey']+_0x10c65f(0xde)+_0x43c3d1[_0x10c65f(0x8d)]+_0x10c65f(0xd3));_0x47ea51[_0x10c65f(0x86)](_0x43c3d1[_0x10c65f(0x8d)],_0x43c3d1[_0x10c65f(0x9b)]);}}const _0x2b24b4=new Map();for(const [_0x397a2f,_0x13b3b6]of _0x5f1e18){_0x2b24b4[_0x10c65f(0x86)](hookDirectoryIdentity(_0x13b3b6),_0x397a2f);}const _0x8333b0=[];for(const [_0x785ae8,_0x399b5e]of _0x5d2a21){const _0x544427=_0x399b5e['alias']??_0x399b5e[_0x10c65f(0xf1)],_0x14cd6f=join(_0x1b69fe[_0x10c65f(0xfa)],_0x10c65f(0xb2),_0x785ae8),_0x26e670=join(_0x1b69fe[_0x10c65f(0xfa)],_0x10c65f(0xb2),_0x544427),_0x1e3e87=await directoryExists(_0x14cd6f),_0x44fb5f=await directoryExists(_0x26e670),_0x591405=_0x1e3e87?_0x44fb5f?await sameDirectory(_0x14cd6f,_0x26e670)?'case-rename':undefined:_0x10c65f(0xd9):_0x10c65f(0xcb);if(!_0x591405)throw CliErrors[_0x10c65f(0xa8)]('Cannot\x20migrate\x20HOOK\x20directory\x20\x22'+_0x785ae8+_0x10c65f(0xe5)+_0x544427+_0x10c65f(0xe8));const _0x290672=_0x2b24b4['get'](hookDirectoryIdentity(_0x785ae8));if(_0x290672&&_0x290672!==_0x399b5e[_0x10c65f(0xf1)][_0x10c65f(0x8f)]()){const _0x2427f6=new Set(_0x399b5e['keyChanges'][_0x10c65f(0xa1)](_0x15b899=>_0x15b899[_0x10c65f(0x9b)])),_0x40ffe3=_0x43922f[_0x10c65f(0xb6)](_0x4e578c=>_0x4e578c[_0x10c65f(0x103)]===_0x10c65f(0xb2)&&_0x4e578c[_0x10c65f(0xdd)]!=null&&hookDirectoryIdentity(_0x4e578c[_0x10c65f(0xdd)])===hookDirectoryIdentity(_0x785ae8)&&!_0x2427f6[_0x10c65f(0xd5)](_0x4e578c[_0x10c65f(0x10c)]));if(_0x40ffe3[_0x10c65f(0xe9)]>0x0)throw CliErrors[_0x10c65f(0xa8)](_0x10c65f(0xff)+_0x785ae8+_0x10c65f(0xc2));}const _0x43bee7=_0x2b24b4[_0x10c65f(0xe0)](hookDirectoryIdentity(_0x544427));if(_0x43bee7&&_0x43bee7!==_0x399b5e[_0x10c65f(0xf1)][_0x10c65f(0x8f)]())throw CliErrors['validation'](_0x10c65f(0xff)+_0x785ae8+'\x22\x20to\x20\x22'+_0x544427+'\x22:\x20the\x20destination\x20is\x20another\x20Dataset\x20alias.\x20Resolve\x20the\x20directory\x20manually\x20before\x20retrying.');for(const _0x214ac5 of _0x399b5e['keyChanges']){const _0x37acda=_0x3f84fe[_0x10c65f(0xcf)][_0x214ac5[_0x10c65f(0x8d)]];if(_0x37acda&&!_0x2402fb[_0x10c65f(0xd5)](_0x214ac5[_0x10c65f(0x8d)])&&!sameHookIdentity(_0x214ac5[_0x10c65f(0xbe)],_0x37acda))throw CliErrors[_0x10c65f(0xa8)]('Cannot\x20migrate\x20HOOK\x20directory\x20\x22'+_0x785ae8+_0x10c65f(0xe5)+_0x544427+_0x10c65f(0x11b));}_0x8333b0['push']({'oldDirectory':_0x785ae8,'newDirectory':_0x544427,'oldDirectoryPath':_0x14cd6f,'newDirectoryPath':_0x26e670,'mode':_0x591405,'alias':_0x399b5e['alias'],'keyChanges':_0x399b5e[_0x10c65f(0xd8)]});}const _0x22bcca={..._0x3f84fe[_0x10c65f(0xcf)]},_0x56b970=new Map(),_0x49b451=new Map();for(const _0x4dc171 of _0x8333b0){const _0x2f93e5=_0x4dc171[_0x10c65f(0xc8)]!==_0x10c65f(0xcb);_0x2f93e5&&_0x49b451['set'](hookDirectoryIdentity(_0x4dc171[_0x10c65f(0xb0)]),_0x4dc171[_0x10c65f(0x95)]);for(const _0x55d754 of _0x4dc171[_0x10c65f(0xd8)]){const _0x33bf67=_0x22bcca[_0x55d754[_0x10c65f(0x8d)]],_0x4a2971=_0x2f93e5?_0x55d754[_0x10c65f(0xbe)]:_0x33bf67??_0x55d754[_0x10c65f(0xbe)];_0x22bcca[_0x55d754[_0x10c65f(0x8d)]]=canonicalizeHookEntry(_0x4a2971,_0x4dc171[_0x10c65f(0xdd)]),delete _0x22bcca[_0x55d754[_0x10c65f(0x9b)]],_0x2f93e5&&_0x56b970[_0x10c65f(0x86)](_0x55d754['newLockKey'],resolveLocalFilePathFromLockKey(_0x1b69fe,_0x55d754[_0x10c65f(0x9b)]));}}return{'migrations':_0x8333b0,'projectedFunctions':_0x22bcca,'sourceFilePathByNewLockKey':_0x56b970,'sourceDirectoryPathByNewDirectory':_0x49b451};}function resolveMigratedSourceFilePath(_0x5646c6,_0x50e8d6){const _0x44f365=a43_0x15d1eb;if(!_0x5646c6||!_0x50e8d6)return undefined;const _0x129789=_0x5646c6[_0x44f365(0xbd)][_0x44f365(0xe0)](_0x50e8d6[_0x44f365(0x10c)]);if(_0x129789)return _0x129789;if(_0x50e8d6[_0x44f365(0x103)]!==_0x44f365(0xb2))return undefined;const [,_0x55536b,..._0x258241]=_0x50e8d6[_0x44f365(0x10c)][_0x44f365(0xb9)]('/');if(!_0x55536b||_0x258241['length']===0x0)return undefined;const _0x15d452=_0x5646c6[_0x44f365(0xeb)][_0x44f365(0xe0)](hookDirectoryIdentity(_0x55536b));return _0x15d452?join(_0x15d452,..._0x258241)+'.js':undefined;}function sameHookIdentity(_0xd33040,_0x1bba77){const _0x2b4f6d=a43_0x15d1eb;return _0xd33040[_0x2b4f6d(0xcc)]===_0x1bba77[_0x2b4f6d(0xcc)]&&_0xd33040[_0x2b4f6d(0xf1)]===_0x1bba77[_0x2b4f6d(0xf1)]&&_0xd33040[_0x2b4f6d(0xf8)]===_0x1bba77[_0x2b4f6d(0xf8)]&&_0xd33040[_0x2b4f6d(0xa3)]===_0x1bba77[_0x2b4f6d(0xa3)];}function canonicalizeHookEntry(_0x5b475e,_0xea0700){const {alias:_0x44d77f,..._0x25ebac}=_0x5b475e;return _0xea0700?{..._0x25ebac,'alias':_0xea0700}:_0x25ebac;}function hookDirectoryIdentity(_0x4a02aa){const _0x41934a=a43_0x15d1eb;return _0x4a02aa['normalize'](_0x41934a(0xc7))[_0x41934a(0x8f)]();}function isSafeHookDirectorySegment(_0x2d9855){return isSafeLockKeySegment(_0x2d9855);}async function sameDirectory(_0x15b619,_0xd1ecf){const _0x2152c7=a43_0x15d1eb,[_0x2c6966,_0x1c91cd]=await Promise[_0x2152c7(0xb4)]([stat(_0x15b619),stat(_0xd1ecf)]);return _0x2c6966[_0x2152c7(0x11c)]===_0x1c91cd[_0x2152c7(0x11c)]&&_0x2c6966[_0x2152c7(0xd6)]===_0x1c91cd['ino'];}async function applyHookDirectoryMigration(_0x3677dd,_0x2c51d7){const _0x556347=a43_0x15d1eb,_0x17f430=_0x2c51d7[_0x556347(0xcf)],_0x17292d=_0x2c51d7[_0x556347(0xa6)],_0x46d88d=[],_0x482a63=async()=>{const _0x20d198=_0x556347,_0x48506f=[];_0x2c51d7[_0x20d198(0xcf)]=_0x17f430,_0x2c51d7[_0x20d198(0xa6)]=_0x17292d;for(const {migration:_0x68f1ba,temporaryPath:_0x847d86}of[..._0x46d88d][_0x20d198(0xe1)]()){try{_0x847d86?(await rename(_0x68f1ba[_0x20d198(0xd4)],_0x847d86),await rename(_0x847d86,_0x68f1ba[_0x20d198(0x95)])):await rename(_0x68f1ba[_0x20d198(0xd4)],_0x68f1ba[_0x20d198(0x95)]);}catch(_0x525dfd){_0x48506f['push'](new Error(_0x20d198(0xc1)+_0x68f1ba['oldDirectory']+_0x20d198(0xae)+_0x68f1ba['newDirectory']+_0x20d198(0xa7)+(_0x525dfd instanceof Error?_0x525dfd[_0x20d198(0xe4)]:String(_0x525dfd))));}}return _0x48506f;};try{for(const _0x55c77d of _0x3677dd[_0x556347(0x110)]){if(_0x55c77d['mode']===_0x556347(0xd9))await ensureParentDirectory(_0x55c77d['newDirectoryPath']),await rename(_0x55c77d[_0x556347(0x95)],_0x55c77d[_0x556347(0xd4)]),_0x46d88d['push']({'migration':_0x55c77d});else{if(_0x55c77d[_0x556347(0xc8)]===_0x556347(0x114)){const _0x54147c=join(dirname(_0x55c77d[_0x556347(0x95)]),_0x556347(0xa0)+randomUUID());await rename(_0x55c77d[_0x556347(0x95)],_0x54147c);try{await rename(_0x54147c,_0x55c77d[_0x556347(0xd4)]);}catch(_0x1c5d5f){try{await rename(_0x54147c,_0x55c77d[_0x556347(0x95)]);}catch(_0x2754a9){throw withRollbackErrors(_0x1c5d5f,_0x556347(0xa2)+_0x55c77d['oldDirectory']+_0x556347(0xe5)+_0x55c77d[_0x556347(0xb0)]+'\x22;\x20temporary\x20directory\x20\x22'+_0x54147c+_0x556347(0xcd),[new Error(_0x556347(0x97)+_0x54147c+_0x556347(0xe5)+_0x55c77d[_0x556347(0x9f)]+_0x556347(0xa7)+(_0x2754a9 instanceof Error?_0x2754a9[_0x556347(0xe4)]:String(_0x2754a9)))]);}throw _0x1c5d5f;}_0x46d88d[_0x556347(0xfb)]({'migration':_0x55c77d,'temporaryPath':_0x54147c});}}}return _0x2c51d7[_0x556347(0xcf)]=_0x3677dd[_0x556347(0xf2)],{'rollback':_0x482a63};}catch(_0x4f9d52){const _0x380dbb=await _0x482a63();throw withRollbackErrors(_0x4f9d52,_0x556347(0x115),_0x380dbb);}}async function confirmForce(){const _0x1f91d6=a43_0x15d1eb,_0x508fc4=createInterface({'input':process[_0x1f91d6(0xba)],'output':process[_0x1f91d6(0x117)]}),_0xcc4d0e=await new Promise(_0x269479=>{const _0x1ff9d3=_0x1f91d6;_0x508fc4[_0x1ff9d3(0xec)](_0x1ff9d3(0xac),_0x269479);});return _0x508fc4[_0x1f91d6(0xda)](),['y',_0x1f91d6(0xfd)][_0x1f91d6(0x107)](_0xcc4d0e['trim']()[_0x1f91d6(0x8f)]());}
1
+ import{createInterface}from"node:readline";import{readFile,rename,stat,unlink,writeFile}from"node:fs/promises";import{randomUUID}from"node:crypto";import{dirname,join}from"node:path";import{BFF_LIST_PAGE_SIZE,listBffScripts,getBffScriptStatistics}from"../../core/api-client.js";import{loadAliasMap}from"../../core/alias-resolver.js";import{resolveApiModelSource}from"../../api/model-source.js";import{loadBffProjectConfig}from"../../core/bff/config.js";import{createHookLocationMap,directoryExists,ensureParentDirectory,fileExists,isSafeLockKeySegment,normalizeBffType,resolveLocalFilePathFromLockKey,resolveRemoteScriptTarget,scanLocalBffFunctions}from"../../core/bff/file-system.js";import{computeContentHash,computeFileHash}from"../../core/bff/hash.js";import{assertUnambiguousHookAliases}from"../../core/bff/hook-directory.js";import{createEmptyBffLock,ensureLockScope,readBffLockFile,writeBffLockFile}from"../../core/bff/lock.js";import{CliErrors}from"../../errors.js"
2
+ ;import{CLI_BIN_NAME}from"../../constant/cli.js";export const bffPull={service:"bff",command:"pull",description:"Pull remote Backend Function scripts to local",risk:"read",structuredErrors:true,flags:[{name:"type",type:"string",description:"Pull only this script type",enum:["COMMON","ENDPOINT","HOOK"]},{name:"force",type:"boolean",description:"Force overwrite local unsynced changes"}],async dryRun(ctx){const config=loadBffProjectConfig(ctx.appCode);const rawLock=await readBffLockFile(config.lockFilePath);const{appLock:appLock}=ensureLockScope(rawLock??createEmptyBffLock(),ctx.appCode,config.scriptsRoot,"pull");const filterType=normalizeBffType(ctx.str("type"))??undefined;const[scripts,statistics]=await Promise.all([listBffScripts(ctx.appCode,filterType),getBffScriptStatistics(ctx.appCode)]);const hasHookScripts=scripts.some(script=>normalizeBffType(script.scriptType)==="HOOK")
3
+ ;const datasetCodeToAlias=hasHookScripts?buildDatasetCodeToAliasMap(ctx.apiDir,ctx.appCode,ctx.selectedAppName||ctx.mergedCli?.currentApp||ctx.mergedCli?.defaultApp):new Map;const hookMigrationPlan=hasHookScripts?await planHookDirectoryMigration(config,appLock,datasetCodeToAlias,await scanLocalBffFunctions(config,"HOOK")):undefined;const hookLocationMap=createHookLocationMap(statistics);const preview=[];for(const script of scripts){const target=resolveRemoteScriptTarget(config,script,hookLocationMap,hookMigrationPlan?.projectedFunctions??appLock.functions,datasetCodeToAlias);if(!target){preview.push({scriptType:script.scriptType,functionName:script.functionName??"",status:"skipped",reason:"unresolvable target path"});continue}const lockEntry=(hookMigrationPlan?.projectedFunctions??appLock.functions)[target.lockKey];const remoteHash=script.scriptContent!=null?computeContentHash(script.scriptContent):undefined
4
+ ;const hasConflict=await hasUnsyncedLocalChanges(resolveMigratedSourceFilePath(hookMigrationPlan,target)??target.filePath,lockEntry,remoteHash);const conflict=hasConflict?localUnsyncedConflict(target,script.id):undefined;preview.push({lockKey:target.lockKey,filePath:target.filePath,remoteId:script.id??null,status:conflict?"conflict":"would_pull",...conflict?{conflict:conflict}:{},...target.hookLocation?{alias:target.hookLocation.alias??null,datasetCode:target.hookLocation.datasetCode,operationType:target.hookLocation.operationType,functionNode:target.hookLocation.functionNode}:{}})}return{method:"GET",url:`/api/management/library/scripts/list?appCode=${ctx.appCode}${filterType?`&type=${filterType}`:""}&currentPage=1&pageSize=${BFF_LIST_PAGE_SIZE}`,body:{appCode:ctx.appCode,filterType:filterType??null,...hookMigrationPlan&&hookMigrationPlan.migrations.length>0?{hookDirectoryMigrations:hookMigrationPlan.migrations.map(migration=>({from:migration.oldDirectory,to:migration.newDirectory}))
5
+ }:{},files:preview},description:`Would inspect ${preview.length} remote Backend Function script(s) for pull`}},async execute(ctx){const config=loadBffProjectConfig(ctx.appCode);const rawLock=await readBffLockFile(config.lockFilePath);const{lockData:lockData,appLock:appLock}=ensureLockScope(rawLock??createEmptyBffLock(),ctx.appCode,config.scriptsRoot,"pull");const filterType=normalizeBffType(ctx.str("type"))??undefined;if(ctx.str("type")&&!filterType){throw CliErrors.validation("--type must be COMMON, ENDPOINT, or HOOK.")}const[scripts,statistics]=await Promise.all([listBffScripts(ctx.appCode,filterType),getBffScriptStatistics(ctx.appCode)]);if(scripts.length===0){return{ok:true,data:{pulled:[],skipped:[],conflicts:[],failed:[]},message:"No remote Backend Function scripts found."}}const force=ctx.bool("force");if(force&&!ctx.nonInteractive){const confirmed=await confirmForce();if(!confirmed){throw CliErrors.cancelled("Force pull cancelled.")}}if(force&&ctx.nonInteractive){}
6
+ const hasHookScripts=scripts.some(script=>normalizeBffType(script.scriptType)==="HOOK");const datasetCodeToAlias=hasHookScripts?buildDatasetCodeToAliasMap(ctx.apiDir,ctx.appCode,ctx.selectedAppName||ctx.mergedCli?.currentApp||ctx.mergedCli?.defaultApp):new Map;const hookLocationMap=createHookLocationMap(statistics);const nextLockData=JSON.parse(JSON.stringify(lockData));const currentAppCode=ctx.appCode;const nextAppLock=nextLockData.apps[currentAppCode];if(!nextAppLock){throw new Error(`Lock scope for app "${currentAppCode}" not found after ensureLockScope.`)}const hookMigration=hasHookScripts?await applyHookDirectoryMigration(await planHookDirectoryMigration(config,nextAppLock,datasetCodeToAlias,await scanLocalBffFunctions(config,"HOOK")),nextAppLock):undefined;const fileTransaction=createPullFileTransaction();const pulled=[];const skipped=[];const conflicts=[];const failed=[];for(const script of scripts){
7
+ const target=resolveRemoteScriptTarget(config,script,hookLocationMap,nextAppLock.functions,datasetCodeToAlias);if(!target){skipped.push({lockKey:`${script.scriptType}/${script.functionName}`,reason:"unresolvable target path"});continue}const lockEntry=nextAppLock.functions[target.lockKey];try{if(!script.id){throw new Error("Remote script missing id.")}if(script.scriptContent==null){throw new Error("Remote script missing content.")}const content=script.scriptContent;const remoteHash=computeContentHash(content);if(!force){const hasConflict=await hasUnsyncedLocalChanges(target.filePath,lockEntry,remoteHash);if(hasConflict){conflicts.push(localUnsyncedConflict(target,script.id));continue}}await fileTransaction.write(target.filePath,content);const nextEntry={hash:remoteHash,remoteId:script.id,version:script.version};if(target.type==="HOOK"&&target.hookLocation){nextEntry.alias=target.hookLocation.alias;nextEntry.datasetCode=target.hookLocation.datasetCode
8
+ ;nextEntry.operationType=target.hookLocation.operationType;nextEntry.functionNode=target.hookLocation.functionNode}nextAppLock.functions[target.lockKey]=nextEntry;pulled.push({lockKey:target.lockKey,remoteId:script.id})}catch(error){failed.push({lockKey:target.lockKey,error:error instanceof Error?error.message:String(error)})}}nextAppLock.lastSync=(new Date).toISOString();try{await writeBffLockFile(config.lockFilePath,nextLockData)}catch(error){const rollbackErrors=[...await fileTransaction.rollback(),...await(hookMigration?.rollback())??[]];throw withRollbackErrors(error,"Failed to write the Backend Function lock file; local changes could not be completely rolled back.",rollbackErrors)}return{ok:failed.length===0,data:{pulled:pulled,skipped:skipped,conflicts:conflicts,failed:failed},message:formatPullMessage(pulled.length,skipped.length,conflicts.length,failed.length)}}};function localUnsyncedConflict(target,remoteId){const functionName=target.lockKey.split("/").at(-1);return{
9
+ code:"BFF_LOCAL_UNSYNCED",lockKey:target.lockKey,filePath:target.filePath,...remoteId!=null?{remoteId:remoteId}:{},message:"Local script differs from the last pulled version. Review it before choosing the source of truth.",nextAction:{action:"push_local",command:`${CLI_BIN_NAME} bff push --type ${target.type} --name ${functionName} --format compress`,requiresReview:true,message:"If the reviewed local script should win, run this command to update the remote script. Do not use --force to resolve a content conflict."}}}function formatPullMessage(pulled,skipped,conflicts,failed){const parts=[`Pull complete: ${pulled} pulled`,`${skipped} skipped`];if(conflicts>0){parts.push(`${conflicts} conflict${conflicts===1?"":"s"} ${conflicts===1?"requires":"require"} resolution`)}if(failed>0)parts.push(`${failed} failed`);return parts.join(", ")}async function hasUnsyncedLocalChanges(filePath,lockEntry,remoteHash){if(!await fileExists(filePath))return false
10
+ ;const localHash=await computeFileHash(filePath);if(!lockEntry)return remoteHash?localHash!==remoteHash:true;return localHash!==lockEntry.hash}function createPullFileTransaction(){const snapshots=new Map;const restore=async(filePath,snapshot)=>{try{if(snapshot.existed){await ensureParentDirectory(filePath);await writeFile(filePath,snapshot.content)}else{try{await unlink(filePath)}catch(error){if(error.code!=="ENOENT")throw error}}return undefined}catch(error){return error instanceof Error?error:new Error(String(error))}};return{async write(filePath,content){if(!snapshots.has(filePath)){try{snapshots.set(filePath,{existed:true,content:await readFile(filePath)})}catch(error){if(error.code!=="ENOENT")throw error;snapshots.set(filePath,{existed:false})}}try{await ensureParentDirectory(filePath);await writeFile(filePath,content,"utf8")}catch(error){const rollbackError=await restore(filePath,snapshots.get(filePath));if(!rollbackError)snapshots.delete(filePath)
11
+ ;throw withRollbackErrors(error,`Failed to write local script "${filePath}".`,rollbackError?[rollbackError]:[])}},async rollback(){const errors=[];for(const[filePath,snapshot]of[...snapshots.entries()].reverse()){const error=await restore(filePath,snapshot);if(error){errors.push(new Error(`Could not restore local script "${filePath}": ${error.message}`))}}return errors}}}function withRollbackErrors(cause,message,rollbackErrors){const original=cause instanceof Error?cause:new Error(String(cause));if(rollbackErrors.length===0)return original;return new AggregateError([original,...rollbackErrors],`${message} Recovery errors: ${rollbackErrors.map(error=>error.message).join("; ")}`)}function buildDatasetCodeToAliasMap(apiDir,appCode,selectedAppName){const source=resolveApiModelSource(apiDir,appCode,selectedAppName);const entries=loadAliasMap(apiDir,undefined,source.filePath,source.profileName);assertUnambiguousHookAliases(entries)
12
+ ;return new Map(entries.map(entry=>[entry.datasetCode.toLowerCase(),entry.alias]))}async function planHookDirectoryMigration(config,appLock,datasetCodeToAlias,localHooks){const grouped=new Map;for(const[oldLockKey,entry]of Object.entries(appLock.functions)){const[type,directoryName,operationType,functionNode,functionName,...rest]=oldLockKey.split("/");if(type!=="HOOK"||!directoryName||!operationType||!functionNode||!functionName||rest.length>0||!entry.datasetCode)continue;const alias=datasetCodeToAlias.get(entry.datasetCode.toLowerCase());const newDirectory=alias??entry.datasetCode;if(!isSafeHookDirectorySegment(directoryName)){throw CliErrors.validation(`Cannot migrate unsafe HOOK directory "${directoryName}" from the lock file.`)}if(!isSafeHookDirectorySegment(newDirectory)){throw CliErrors.validation(`Cannot migrate HOOK directory "${directoryName}": its target directory is unsafe.`)}if(directoryName===newDirectory)continue;const group=grouped.get(directoryName)??{
13
+ datasetCode:entry.datasetCode,alias:alias,keyChanges:[]};if(group.datasetCode!==entry.datasetCode){throw CliErrors.validation(`Cannot migrate HOOK directory "${directoryName}": it is tracked by multiple Datasets.`)}const newLockKey=`HOOK/${newDirectory}/${operationType}/${functionNode}/${functionName}`;try{resolveLocalFilePathFromLockKey(config,oldLockKey);resolveLocalFilePathFromLockKey(config,newLockKey)}catch(error){throw CliErrors.validation(`Cannot migrate unsafe HOOK lock key "${oldLockKey}": ${error instanceof Error?error.message:String(error)}`)}group.keyChanges.push({oldLockKey:oldLockKey,newLockKey:newLockKey,entry:entry});grouped.set(directoryName,group)}const changingOldKeys=new Set([...grouped.values()].flatMap(group=>group.keyChanges.map(change=>change.oldLockKey)));const plannedDirectories=new Map;const plannedLockKeys=new Map;for(const[oldDirectory,group]of grouped){const newDirectory=group.alias??group.datasetCode;const directoryKey=hookDirectoryIdentity(newDirectory)
14
+ ;const existingDirectorySource=plannedDirectories.get(directoryKey);if(existingDirectorySource&&existingDirectorySource!==oldDirectory){throw CliErrors.validation(`Cannot migrate HOOK directories "${existingDirectorySource}" and "${oldDirectory}": both target "${newDirectory}". Resolve the directories manually before retrying.`)}plannedDirectories.set(directoryKey,oldDirectory);for(const change of group.keyChanges){const existingKeySource=plannedLockKeys.get(change.newLockKey);if(existingKeySource&&existingKeySource!==change.oldLockKey){throw CliErrors.validation(`Cannot migrate HOOK lock keys "${existingKeySource}" and "${change.oldLockKey}": both target "${change.newLockKey}". Resolve the lock entries manually before retrying.`)}if(changingOldKeys.has(change.newLockKey)){throw CliErrors.validation(`Cannot migrate HOOK lock key "${change.oldLockKey}": its target "${change.newLockKey}" is another legacy key being migrated. Resolve the lock entries manually before retrying.`)}
15
+ plannedLockKeys.set(change.newLockKey,change.oldLockKey)}}const currentAliasOwners=new Map;for(const[datasetCode,alias]of datasetCodeToAlias){currentAliasOwners.set(hookDirectoryIdentity(alias),datasetCode)}const migrations=[];for(const[oldDirectory,group]of grouped){const newDirectory=group.alias??group.datasetCode;const oldDirectoryPath=join(config.scriptsRootDir,"HOOK",oldDirectory);const newDirectoryPath=join(config.scriptsRootDir,"HOOK",newDirectory);const oldExists=await directoryExists(oldDirectoryPath);const newExists=await directoryExists(newDirectoryPath);const mode=oldExists?newExists?await sameDirectory(oldDirectoryPath,newDirectoryPath)?"case-rename":undefined:"move":"rekey";if(!mode){throw CliErrors.validation(`Cannot migrate HOOK directory "${oldDirectory}" to "${newDirectory}": the target directory already exists. Resolve the directories and retry.`)}const owner=currentAliasOwners.get(hookDirectoryIdentity(oldDirectory))
16
+ ;if(owner&&owner!==group.datasetCode.toLowerCase()){const trackedKeys=new Set(group.keyChanges.map(change=>change.oldLockKey));const unknownScripts=localHooks.filter(fn=>fn.type==="HOOK"&&fn.alias!=null&&hookDirectoryIdentity(fn.alias)===hookDirectoryIdentity(oldDirectory)&&!trackedKeys.has(fn.lockKey));if(unknownScripts.length>0){throw CliErrors.validation(`Cannot migrate HOOK directory "${oldDirectory}": it is now another Dataset alias and contains untracked scripts. Resolve the directory manually before retrying.`)}}const destinationOwner=currentAliasOwners.get(hookDirectoryIdentity(newDirectory));if(destinationOwner&&destinationOwner!==group.datasetCode.toLowerCase()){throw CliErrors.validation(`Cannot migrate HOOK directory "${oldDirectory}" to "${newDirectory}": the destination is another Dataset alias. Resolve the directory manually before retrying.`)}for(const change of group.keyChanges){const targetEntry=appLock.functions[change.newLockKey]
17
+ ;if(targetEntry&&!changingOldKeys.has(change.newLockKey)&&!sameHookIdentity(change.entry,targetEntry)){throw CliErrors.validation(`Cannot migrate HOOK directory "${oldDirectory}" to "${newDirectory}": target lock key is already bound to another script.`)}}migrations.push({oldDirectory:oldDirectory,newDirectory:newDirectory,oldDirectoryPath:oldDirectoryPath,newDirectoryPath:newDirectoryPath,mode:mode,alias:group.alias,keyChanges:group.keyChanges})}const projectedFunctions={...appLock.functions};const sourceFilePathByNewLockKey=new Map;const sourceDirectoryPathByNewDirectory=new Map;for(const migration of migrations){const sourceWins=migration.mode!=="rekey";if(sourceWins){sourceDirectoryPathByNewDirectory.set(hookDirectoryIdentity(migration.newDirectory),migration.oldDirectoryPath)}for(const change of migration.keyChanges){const targetEntry=projectedFunctions[change.newLockKey];const selected=sourceWins?change.entry:targetEntry??change.entry
18
+ ;projectedFunctions[change.newLockKey]=canonicalizeHookEntry(selected,migration.alias);delete projectedFunctions[change.oldLockKey];if(sourceWins){sourceFilePathByNewLockKey.set(change.newLockKey,resolveLocalFilePathFromLockKey(config,change.oldLockKey))}}}return{migrations:migrations,projectedFunctions:projectedFunctions,sourceFilePathByNewLockKey:sourceFilePathByNewLockKey,sourceDirectoryPathByNewDirectory:sourceDirectoryPathByNewDirectory}}function resolveMigratedSourceFilePath(plan,target){if(!plan||!target)return undefined;const trackedPath=plan.sourceFilePathByNewLockKey.get(target.lockKey);if(trackedPath)return trackedPath;if(target.type!=="HOOK")return undefined;const[,directoryName,...remainingSegments]=target.lockKey.split("/");if(!directoryName||remainingSegments.length===0)return undefined;const sourceDirectoryPath=plan.sourceDirectoryPathByNewDirectory.get(hookDirectoryIdentity(directoryName))
19
+ ;return sourceDirectoryPath?`${join(sourceDirectoryPath,...remainingSegments)}.js`:undefined}function sameHookIdentity(left,right){return left.remoteId===right.remoteId&&left.datasetCode===right.datasetCode&&left.operationType===right.operationType&&left.functionNode===right.functionNode}function canonicalizeHookEntry(entry,alias){const{alias:_oldAlias,...withoutAlias}=entry;return alias?{...withoutAlias,alias:alias}:withoutAlias}function hookDirectoryIdentity(directoryName){return directoryName.normalize("NFC").toLowerCase()}function isSafeHookDirectorySegment(value){return isSafeLockKeySegment(value)}async function sameDirectory(left,right){const[leftStat,rightStat]=await Promise.all([stat(left),stat(right)]);return leftStat.dev===rightStat.dev&&leftStat.ino===rightStat.ino}async function applyHookDirectoryMigration(plan,appLock){const originalFunctions=appLock.functions;const originalLastSync=appLock.lastSync;const completed=[];const rollback=async()=>{const errors=[]
20
+ ;appLock.functions=originalFunctions;appLock.lastSync=originalLastSync;for(const{migration:migration,temporaryPath:temporaryPath}of[...completed].reverse()){try{if(temporaryPath){await rename(migration.newDirectoryPath,temporaryPath);await rename(temporaryPath,migration.oldDirectoryPath)}else{await rename(migration.newDirectoryPath,migration.oldDirectoryPath)}}catch(error){errors.push(new Error(`Could not restore HOOK directory "${migration.oldDirectory}" from "${migration.newDirectory}": ${error instanceof Error?error.message:String(error)}`))}}return errors};try{for(const migration of plan.migrations){if(migration.mode==="move"){await ensureParentDirectory(migration.newDirectoryPath);await rename(migration.oldDirectoryPath,migration.newDirectoryPath);completed.push({migration:migration})}else if(migration.mode==="case-rename"){const temporaryPath=join(dirname(migration.oldDirectoryPath),`.hook-directory-migrate-${randomUUID()}`);await rename(migration.oldDirectoryPath,temporaryPath)
21
+ ;try{await rename(temporaryPath,migration.newDirectoryPath)}catch(error){try{await rename(temporaryPath,migration.oldDirectoryPath)}catch(rollbackError){throw withRollbackErrors(error,`Failed to rename HOOK directory "${migration.oldDirectory}" to "${migration.newDirectory}"; temporary directory "${temporaryPath}" may remain.`,[new Error(`Could not restore temporary HOOK directory "${temporaryPath}" to "${migration.oldDirectory}": ${rollbackError instanceof Error?rollbackError.message:String(rollbackError)}`)])}throw error}completed.push({migration:migration,temporaryPath:temporaryPath})}}appLock.functions=plan.projectedFunctions;return{rollback:rollback}}catch(error){const rollbackErrors=await rollback();throw withRollbackErrors(error,"Failed to migrate HOOK directories; local changes could not be completely rolled back.",rollbackErrors)}}async function confirmForce(){const rl=createInterface({input:process.stdin,output:process.stderr});const answer=await new Promise(resolve=>{
22
+ rl.question("Force pull will overwrite local unsynced changes. Continue? [y/N] ",resolve)});rl.close();return["y","yes"].includes(answer.trim().toLowerCase())}
@@ -1 +1,16 @@
1
- const a44_0xad0615=a44_0x3e85;(function(_0x1960fc,_0x6e2039){const _0x227280=a44_0x3e85,_0x29b8fd=_0x1960fc();while(!![]){try{const _0x32354c=-parseInt(_0x227280(0x1da))/0x1+parseInt(_0x227280(0x21f))/0x2+-parseInt(_0x227280(0x1f4))/0x3+-parseInt(_0x227280(0x206))/0x4*(parseInt(_0x227280(0x201))/0x5)+-parseInt(_0x227280(0x1e1))/0x6+parseInt(_0x227280(0x228))/0x7*(parseInt(_0x227280(0x219))/0x8)+parseInt(_0x227280(0x1bc))/0x9*(parseInt(_0x227280(0x208))/0xa);if(_0x32354c===_0x6e2039)break;else _0x29b8fd['push'](_0x29b8fd['shift']());}catch(_0x5a363c){_0x29b8fd['push'](_0x29b8fd['shift']());}}}(a44_0x3283,0x2ec7f));import{readFile}from'node:fs/promises';import{saveBffScript,getBffScriptInfo,getBffScriptStatistics,getPlatformErrorCode,listDatasets,clearBffScriptCache}from'../../core/api-client.js';import{loadAliasMap}from'../../core/alias-resolver.js';function a44_0x3e85(_0x521c7a,_0x3281db){_0x521c7a=_0x521c7a-0x1b7;const _0x328300=a44_0x3283();let _0x3e855c=_0x328300[_0x521c7a];return _0x3e855c;}import{resolveApiModelSource}from'../../api/model-source.js';import{loadBffProjectConfig}from'../../core/bff/config.js';import{normalizeBffType,scanLocalBffFunctions}from'../../core/bff/file-system.js';import{buildHookDirectoryIndexes,assertUnambiguousHookAliases,assertUnambiguousHookDirectoryMappings,preflightPushHookDirectories,trackedHookDirectoryMappings}from'../../core/bff/hook-directory.js';import{computeFileHash}from'../../core/bff/hash.js';import{createEmptyBffLock,ensureLockScope,readBffLockFile,writeBffLockFile}from'../../core/bff/lock.js';import{extractScriptDescription,snakeToCamel}from'../../core/bff/utils.js';import{sleep}from'../../utils/sleep.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{CliErrors}from'../../errors.js';const CACHE_CLEAR_ATTEMPTS=0x2,CACHE_CLEAR_INTERVAL_MS=0x12c;export const bffPush={'service':a44_0xad0615(0x20f),'command':a44_0xad0615(0x225),'description':'Push\x20local\x20Backend\x20Function\x20scripts\x20to\x20remote','risk':a44_0xad0615(0x21d),'structuredErrors':!![],'flags':[{'name':a44_0xad0615(0x22b),'type':a44_0xad0615(0x1cd),'description':a44_0xad0615(0x1cc),'enum':['COMMON','ENDPOINT',a44_0xad0615(0x21b)]},{'name':a44_0xad0615(0x1e8),'type':a44_0xad0615(0x1cd),'description':a44_0xad0615(0x1be)},{'name':a44_0xad0615(0x1f9),'type':'boolean','description':'Force\x20push\x20ignoring\x20hash\x20protection'}],async 'dryRun'(_0x1369e3){const _0x3dfc88=a44_0xad0615,_0x43fc33=loadBffProjectConfig(_0x1369e3[_0x3dfc88(0x1fd)]),_0x557633=await readBffLockFile(_0x43fc33['lockFilePath']),{appLock:_0x54a637}=ensureLockScope(_0x557633??createEmptyBffLock(),_0x1369e3[_0x3dfc88(0x1fd)],_0x43fc33[_0x3dfc88(0x1ec)],'push'),_0x4503df=await getTargetFunctions(_0x43fc33,_0x1369e3),_0x148e38=_0x4503df['some'](_0x3757e0=>_0x3757e0[_0x3dfc88(0x22b)]===_0x3dfc88(0x21b))?await scanLocalBffFunctions(_0x43fc33,_0x3dfc88(0x21b)):_0x4503df,_0x2cac38=await buildHookMaps(_0x1369e3[_0x3dfc88(0x1fd)],_0x1369e3[_0x3dfc88(0x1e7)],_0x148e38,_0x54a637,_0x1369e3[_0x3dfc88(0x202)]||_0x1369e3[_0x3dfc88(0x1c1)]?.['currentApp']||_0x1369e3[_0x3dfc88(0x1c1)]?.[_0x3dfc88(0x1db)]),_0x8452e9=_0x1369e3[_0x3dfc88(0x1f5)](_0x3dfc88(0x1f9)),_0x439961=[];for(const _0x290381 of _0x4503df){const _0x4d24b7=await computeFileHash(_0x290381['filePath']),_0xde73e5=_0x54a637['functions'][_0x290381[_0x3dfc88(0x1f3)]],_0x2cd334=!!_0xde73e5&&_0xde73e5[_0x3dfc88(0x220)]===_0x4d24b7,_0x5a30e4=_0x2cac38[_0x3dfc88(0x1c5)]['get'](_0x290381[_0x3dfc88(0x1f3)]),_0x4e2b6f=!!_0xde73e5?.[_0x3dfc88(0x1fa)]&&_0xde73e5[_0x3dfc88(0x1ef)]==null&&(_0x8452e9||!_0x2cd334),_0x5aee6c=_0x4e2b6f?missingRemoteVersionConflict(_0x290381,_0xde73e5):undefined,_0x15d3a6=_0x2cac38[_0x3dfc88(0x1d1)]['has'](_0x290381[_0x3dfc88(0x1f3)])?_0x3dfc88(0x217):!_0x8452e9&&_0x2cd334?_0x3dfc88(0x1d0):_0x5aee6c?_0x3dfc88(0x1fe):_0x3dfc88(0x21c);_0x439961['push']({'lockKey':_0x290381[_0x3dfc88(0x1f3)],'filePath':_0x290381[_0x3dfc88(0x1de)],'remoteId':_0xde73e5?.[_0x3dfc88(0x1fa)]??null,'mode':_0xde73e5?.[_0x3dfc88(0x1fa)]?'update':_0x3dfc88(0x214),'status':_0x15d3a6,..._0x2cac38[_0x3dfc88(0x1d1)]['has'](_0x290381[_0x3dfc88(0x1f3)])?{'error':_0x2cac38[_0x3dfc88(0x1d1)][_0x3dfc88(0x226)](_0x290381[_0x3dfc88(0x1f3)])}:{},..._0x5aee6c?{'conflict':_0x5aee6c}:{},..._0x2cac38['existingHooks']['has'](_0x290381[_0x3dfc88(0x1f3)])?{'datasetCode':_0xde73e5?.[_0x3dfc88(0x1d9)],'bindingPreserved':!![],'warnings':[existingHookWarning(_0x290381['lockKey'])]}:{},..._0x5a30e4?{'alias':_0x5a30e4[_0x3dfc88(0x1e6)]??null,'datasetCode':_0x5a30e4[_0x3dfc88(0x1d9)],'operationType':_0x290381[_0x3dfc88(0x1ed)],'functionNode':_0x290381['functionNode'],'warnings':_0x5a30e4['warnings']}:{}});}return{'method':'POST','url':_0x3dfc88(0x21a),'body':{'appCode':_0x1369e3[_0x3dfc88(0x1fd)],'force':_0x8452e9,'files':_0x439961,'cacheClearAtRuntime':_0x439961[_0x3dfc88(0x223)](_0xf00931=>_0xf00931['status']===_0x3dfc88(0x21c)),'cacheClearAtRuntimeTimes':_0x439961[_0x3dfc88(0x223)](_0x225372=>_0x225372['status']===_0x3dfc88(0x21c))?CACHE_CLEAR_ATTEMPTS:0x0},'description':_0x3dfc88(0x221)+_0x439961[_0x3dfc88(0x1f1)]+_0x3dfc88(0x1f6)};},async 'execute'(_0x546e4d){const _0x4e24bc=a44_0xad0615,_0x1e0fa0=loadBffProjectConfig(_0x546e4d[_0x4e24bc(0x1fd)]),_0x198079=await readBffLockFile(_0x1e0fa0[_0x4e24bc(0x1d2)]),{lockData:_0x5bc079,appLock:_0x11da3e}=ensureLockScope(_0x198079??createEmptyBffLock(),_0x546e4d[_0x4e24bc(0x1fd)],_0x1e0fa0[_0x4e24bc(0x1ec)],_0x4e24bc(0x225)),_0x55b057=await getTargetFunctions(_0x1e0fa0,_0x546e4d);if(_0x55b057[_0x4e24bc(0x1f1)]===0x0)return{'ok':!![],'data':{'uploaded':[],'skipped':[],'conflicts':[],'failed':[]},'message':_0x4e24bc(0x1e0)};const _0x16621e=_0x546e4d[_0x4e24bc(0x1f5)](_0x4e24bc(0x1f9)),_0x1a0147=JSON[_0x4e24bc(0x203)](JSON[_0x4e24bc(0x1c3)](_0x5bc079)),_0x7a9c95=_0x1a0147[_0x4e24bc(0x215)][_0x546e4d[_0x4e24bc(0x1fd)]];if(!_0x7a9c95)throw new Error(_0x4e24bc(0x1bf)+_0x546e4d['appCode']+_0x4e24bc(0x1eb));const _0x175215=_0x55b057[_0x4e24bc(0x223)](_0x32510e=>_0x32510e[_0x4e24bc(0x22b)]==='HOOK')?await scanLocalBffFunctions(_0x1e0fa0,_0x4e24bc(0x21b)):_0x55b057,_0x36bfd1=await buildHookMaps(_0x546e4d['appCode'],_0x546e4d[_0x4e24bc(0x1e7)],_0x175215,_0x7a9c95,_0x546e4d[_0x4e24bc(0x202)]||_0x546e4d[_0x4e24bc(0x1c1)]?.[_0x4e24bc(0x1c0)]||_0x546e4d[_0x4e24bc(0x1c1)]?.[_0x4e24bc(0x1db)]),_0x5c6ab6=[],_0x572eac=[],_0x19e72f=[],_0x47d0cb=[];for(const _0x1d9195 of _0x55b057){const _0x20f35c=_0x36bfd1['failures'][_0x4e24bc(0x226)](_0x1d9195[_0x4e24bc(0x1f3)]);if(_0x20f35c){_0x47d0cb[_0x4e24bc(0x225)]({'lockKey':_0x1d9195[_0x4e24bc(0x1f3)],'error':_0x20f35c});continue;}const _0x2c0d5c=await computeFileHash(_0x1d9195[_0x4e24bc(0x1de)]),_0x57c1f5=_0x7a9c95[_0x4e24bc(0x1e4)][_0x1d9195[_0x4e24bc(0x1f3)]];if(!_0x16621e&&_0x57c1f5&&_0x57c1f5[_0x4e24bc(0x220)]===_0x2c0d5c){_0x572eac[_0x4e24bc(0x225)]({'lockKey':_0x1d9195[_0x4e24bc(0x1f3)],'reason':_0x4e24bc(0x1d0)});continue;}if(_0x57c1f5?.[_0x4e24bc(0x1fa)]&&_0x57c1f5[_0x4e24bc(0x1ef)]==null){_0x19e72f[_0x4e24bc(0x225)](missingRemoteVersionConflict(_0x1d9195,_0x57c1f5));continue;}try{await uploadSingleFunction(_0x546e4d[_0x4e24bc(0x1fd)],_0x1d9195,_0x7a9c95,_0x36bfd1);const _0x1c2659=_0x7a9c95[_0x4e24bc(0x1e4)][_0x1d9195[_0x4e24bc(0x1f3)]];_0x5c6ab6['push']({'lockKey':_0x1d9195['lockKey'],'remoteId':_0x1c2659?.[_0x4e24bc(0x1fa)]??0x0});}catch(_0x214777){const _0x2aa472=remoteVersionChangedConflict(_0x1d9195,_0x57c1f5,_0x214777);if(_0x2aa472){_0x19e72f[_0x4e24bc(0x225)](_0x2aa472);continue;}_0x47d0cb[_0x4e24bc(0x225)]({'lockKey':_0x1d9195[_0x4e24bc(0x1f3)],'error':_0x214777 instanceof Error?_0x214777[_0x4e24bc(0x1df)]:String(_0x214777)});}}_0x7a9c95[_0x4e24bc(0x1dd)]=new Date()['toISOString'](),await writeBffLockFile(_0x1e0fa0[_0x4e24bc(0x1d2)],_0x1a0147),await waitForUploadedLockEntries(_0x1e0fa0[_0x4e24bc(0x1d2)],_0x546e4d[_0x4e24bc(0x1fd)],_0x5c6ab6['map'](_0x13cacb=>_0x13cacb[_0x4e24bc(0x1f3)]));let _0x4447ff={'attempted':![],'cleared':![]};if(_0x5c6ab6['length']>0x0)try{let _0x5198df='';for(let _0x2445eb=0x0;_0x2445eb<CACHE_CLEAR_ATTEMPTS;_0x2445eb+=0x1){_0x5198df=await clearBffScriptCache(),_0x2445eb<CACHE_CLEAR_ATTEMPTS-0x1&&await sleep(CACHE_CLEAR_INTERVAL_MS);}_0x4447ff={'attempted':!![],'cleared':!![],'message':_0x5198df||_0x4e24bc(0x229)};}catch(_0x110e0a){_0x4447ff={'attempted':!![],'cleared':![],'error':_0x110e0a instanceof Error?_0x110e0a[_0x4e24bc(0x1df)]:String(_0x110e0a)};}const _0x29db53=_0x47d0cb[_0x4e24bc(0x1f1)]===0x0&&(_0x4447ff[_0x4e24bc(0x1ff)]?_0x4447ff[_0x4e24bc(0x1e9)]:!![]),_0x41e941=_0x29db53,_0x4d7520=_0x4447ff[_0x4e24bc(0x1ff)]?_0x4447ff[_0x4e24bc(0x1e9)]?_0x4e24bc(0x1dc):_0x4e24bc(0x1bb):_0x4e24bc(0x224);return{'ok':_0x41e941,'data':{'uploaded':_0x5c6ab6,'skipped':_0x572eac,'conflicts':_0x19e72f,'failed':_0x47d0cb,'cacheClear':_0x4447ff,'warnings':[...[..._0x36bfd1[_0x4e24bc(0x1c5)][_0x4e24bc(0x1d8)]()][_0x4e24bc(0x210)](_0x3a5c91=>_0x3a5c91['warnings']),...[..._0x36bfd1[_0x4e24bc(0x1e2)]][_0x4e24bc(0x1c6)](existingHookWarning)]},'message':formatPushMessage(_0x5c6ab6['length'],_0x572eac[_0x4e24bc(0x1f1)],_0x19e72f[_0x4e24bc(0x1f1)],_0x47d0cb['length'],_0x4d7520)};}};function missingRemoteVersionConflict(_0x14251e,_0x5a9afe){const _0x1b47e2=a44_0xad0615;return remoteVersionConflict(_0x14251e,_0x5a9afe,_0x1b47e2(0x212),_0x1b47e2(0x1ea));}function remoteVersionChangedConflict(_0x487e2e,_0x3ad80c,_0x207844){const _0x1c0816=a44_0xad0615;if(!_0x3ad80c?.['remoteId']||_0x3ad80c['version']==null||!isRemoteVersionConflict(_0x207844))return undefined;return remoteVersionConflict(_0x487e2e,_0x3ad80c,_0x1c0816(0x20b),_0x1c0816(0x1fb));}function remoteVersionConflict(_0x17b2e9,_0x2c8b30,_0x483cc0,_0xd1016){const _0x121e43=a44_0xad0615;return{'code':_0x483cc0,'lockKey':_0x17b2e9[_0x121e43(0x1f3)],'filePath':_0x17b2e9[_0x121e43(0x1de)],'remoteId':_0x2c8b30[_0x121e43(0x1fa)],..._0x2c8b30[_0x121e43(0x1ef)]!=null?{'expectedVersion':_0x2c8b30[_0x121e43(0x1ef)]}:{},'message':_0xd1016,'nextAction':{'action':_0x121e43(0x1f0),'command':CLI_BIN_NAME+'\x20bff\x20detail\x20--id\x20'+_0x2c8b30[_0x121e43(0x1fa)]+_0x121e43(0x1bd),'requiresReview':!![],'message':_0x121e43(0x204)}};}function isRemoteVersionConflict(_0x4d094f){const _0x4a53ab=a44_0xad0615,_0x31f6b9=_0x4d094f instanceof Error?_0x4d094f[_0x4a53ab(0x1df)]:String(_0x4d094f),_0x298b6b=getPlatformErrorCode(_0x4d094f)??'';return[_0x31f6b9,_0x298b6b]['some'](_0x3edd7c=>/(?:version|optimistic)[\s_-]*(?:conflict|mismatch|changed|stale|out[\s_-]*of[\s_-]*date)|(?:conflict|mismatch|changed|stale|out[\s_-]*of[\s_-]*date)[\s_-]*(?:version|optimistic)/i[_0x4a53ab(0x200)](_0x3edd7c));}function a44_0x3283(){const _0x204300=['9EpSqmE','\x20--format\x20compress','Push\x20only\x20the\x20named\x20function\x20(requires\x20--type)','Lock\x20scope\x20for\x20app\x20\x22','currentApp','mergedCli','afterScriptId','stringify','description','resolutions','map','--name\x20requires\x20--type\x20to\x20identify\x20the\x20function.','size','dataset','functionName','\x20conflict','Push\x20only\x20this\x20script\x20type','string','before','script','unchanged','failures','lockFilePath','profileName','set','filter','Local\x20function\x20not\x20found:\x20','startsWith','values','datasetCode','58685kRCirP','defaultApp','runtime\x20cache\x20cleared','lastSync','filePath','message','No\x20local\x20Backend\x20Function\x20scripts\x20found.','1515840KRLRnj','existingHooks','\x20uploaded','functions','scriptType','alias','apiDir','name','cleared','The\x20local\x20sync\x20lock\x20has\x20no\x20remote\x20version\x20for\x20this\x20script.','\x22\x20not\x20found\x20after\x20ensureLockScope.','scriptsRoot','operationType','HOOK_DATASET_NOT_FOUND:','version','review_remote_and_merge','length','datasetId','lockKey','326082OWseyF','bool','\x20local\x20Backend\x20Function\x20script(s)\x20for\x20push\x20and\x20clear\x20runtime\x20cache\x20if\x20files\x20are\x20uploaded','Incomplete\x20HOOK\x20path:\x20','str','force','remoteId','Remote\x20script\x20version\x20changed\x20since\x20the\x20last\x20pull.','Dataset\x20metadata\x20is\x20unavailable;\x20the\x20existing\x20script\x20and\x20binding\x20were\x20verified.\x20Update\x20by\x20script\x20ID\x20without\x20rebinding.','appCode','conflict','attempted','test','15INZrch','selectedAppName','parse','Review\x20the\x20current\x20remote\x20source,\x20merge\x20it\x20into\x20the\x20local\x20script,\x20then\x20retry\x20push.\x20Do\x20not\x20use\x20--force\x20unless\x20you\x20intentionally\x20discard\x20local\x20changes.','every','283924OZkqOX','Cannot\x20verify\x20existing\x20HOOK\x20binding:\x20','5985680ADfByf','requires','Multiple\x20HOOK\x20directories\x20reference\x20the\x20same\x20missing\x20Dataset.\x20Resolve\x20duplicate\x20directories\x20before\x20pushing.','BFF_REMOTE_VERSION_CHANGED','Lock\x20file\x20not\x20settled\x20after\x20push\x20for\x20','functionNode','Existing\x20HOOK\x20identity,\x20version\x20or\x20binding\x20does\x20not\x20match\x20the\x20local\x20lock.\x20Pull\x20and\x20review\x20before\x20pushing.','bff','flatMap','delete','BFF_REMOTE_VERSION_MISSING','\x20resolution','create','apps',':\x20missing\x20remote\x20version.\x20Run\x20`push`\x20after\x20`pull`\x20to\x20sync\x20version\x20info.','failed','join','22736BNgSkk','/api/management/library/scripts/save','HOOK','would_push','write','add','25718QDfpqc','hash','Would\x20inspect\x20','require','some','runtime\x20cache\x20not\x20needed','push','get','beforeScriptId','525OqukVa','Runtime\x20script\x20cache\x20cleared.','Push\x20complete:\x20','type','has','EXISTING_HOOK_BINDING_PRESERVED','utf8','validation','runtime\x20cache\x20clear\x20failed'];a44_0x3283=function(){return _0x204300;};return a44_0x3283();}function formatPushMessage(_0x5e031d,_0x3e1fda,_0x1a3e8f,_0x4054c5,_0x2140ed){const _0x35676c=a44_0xad0615,_0x116840=[_0x35676c(0x22a)+_0x5e031d+_0x35676c(0x1e3),_0x3e1fda+'\x20skipped'];_0x1a3e8f>0x0&&_0x116840[_0x35676c(0x225)](_0x1a3e8f+_0x35676c(0x1cb)+(_0x1a3e8f===0x1?'':'s')+'\x20'+(_0x1a3e8f===0x1?_0x35676c(0x209):_0x35676c(0x222))+_0x35676c(0x213));if(_0x4054c5>0x0)_0x116840['push'](_0x4054c5+'\x20failed');return _0x116840[_0x35676c(0x225)](_0x2140ed),_0x116840[_0x35676c(0x218)](',\x20');}async function getTargetFunctions(_0x2eaa5b,_0x448ab0){const _0x5243ea=a44_0xad0615,_0x337f17=_0x448ab0[_0x5243ea(0x1f8)]('type'),_0x1488bd=_0x448ab0[_0x5243ea(0x1f8)](_0x5243ea(0x1e8)),_0x27d159=normalizeBffType(_0x337f17)??undefined;if(_0x1488bd&&!_0x27d159)throw CliErrors[_0x5243ea(0x1ba)](_0x5243ea(0x1c7));const _0x330b0d=await scanLocalBffFunctions(_0x2eaa5b,_0x27d159);if(_0x1488bd){const _0x234dec=_0x330b0d[_0x5243ea(0x1d5)](_0x8968ee=>_0x8968ee[_0x5243ea(0x1e8)]===_0x1488bd);if(_0x234dec[_0x5243ea(0x1f1)]===0x0)throw CliErrors['validation'](_0x5243ea(0x1d6)+_0x27d159+'/'+_0x1488bd);return _0x234dec;}return _0x330b0d;}function existingHookWarning(_0x4719e7){const _0x48f89b=a44_0xad0615;return{'code':_0x48f89b(0x1b8),'lockKey':_0x4719e7,'message':_0x48f89b(0x1fc)};}async function buildHookMaps(_0x4e2b8f,_0x2624d1,_0x272340,_0x18d400,_0x3bbf26){const _0x199866=a44_0xad0615,_0x17c5a0=_0x272340[_0x199866(0x223)](_0x3f0f24=>_0x3f0f24[_0x199866(0x22b)]==='HOOK');if(!_0x17c5a0)return{'resolutions':new Map(),'failures':new Map(),'existingHooks':new Set()};const _0x2d6e2e=resolveApiModelSource(_0x2624d1,_0x4e2b8f,_0x3bbf26),_0x1ce584=loadAliasMap(_0x2624d1,undefined,_0x2d6e2e['filePath'],_0x2d6e2e[_0x199866(0x1d3)]);assertUnambiguousHookAliases(_0x1ce584);const _0x54c25c=[..._0x1ce584[_0x199866(0x1c6)](_0x525ebc=>[_0x525ebc[_0x199866(0x1e6)],_0x525ebc[_0x199866(0x1d9)]]),...trackedHookDirectoryMappings(_0x18d400)[_0x199866(0x1c6)](_0x4fafe8=>[_0x4fafe8[_0x199866(0x1e6)],_0x4fafe8[_0x199866(0x1d9)]])],_0x3077b7=await listDatasets(_0x4e2b8f);assertUnambiguousHookDirectoryMappings(_0x54c25c[_0x199866(0x1c6)](([_0x41f303,_0x13f596])=>({'alias':_0x41f303,'datasetCode':_0x13f596})));const _0x348128=buildHookDirectoryIndexes(_0x3077b7,_0x54c25c),_0x3c9795=new Map(),_0x57af78=preflightPushHookDirectories(_0x272340,_0x18d400,_0x348128,_0x3c9795),_0x3a5b80=new Set(),_0x373b2d=_0x272340['filter'](_0x16a75a=>_0x3c9795[_0x199866(0x226)](_0x16a75a[_0x199866(0x1f3)])?.[_0x199866(0x1d7)](_0x199866(0x1ee))&&_0x18d400[_0x199866(0x1e4)][_0x16a75a[_0x199866(0x1f3)]]?.[_0x199866(0x1fa)]&&_0x18d400[_0x199866(0x1e4)][_0x16a75a[_0x199866(0x1f3)]]?.[_0x199866(0x1d9)]);if(_0x373b2d[_0x199866(0x1f1)]>0x0){let _0x445a60;try{_0x445a60=await getBffScriptStatistics(_0x4e2b8f);}catch(_0x317dd4){for(const _0x4ace7d of _0x373b2d)_0x3c9795['set'](_0x4ace7d[_0x199866(0x1f3)],_0x199866(0x207)+(_0x317dd4 instanceof Error?_0x317dd4[_0x199866(0x1df)]:String(_0x317dd4)));return{'resolutions':_0x57af78,'failures':_0x3c9795,'existingHooks':_0x3a5b80};}for(const _0x15e312 of _0x373b2d){const _0x1af62c=_0x18d400[_0x199866(0x1e4)][_0x15e312['lockKey']];try{const _0xb71ffd=new Set(_0x272340[_0x199866(0x1d5)](_0x2f18b7=>_0x2f18b7[_0x199866(0x22b)]===_0x199866(0x21b)&&_0x18d400[_0x199866(0x1e4)][_0x2f18b7['lockKey']]?.['datasetCode']===_0x1af62c[_0x199866(0x1d9)])[_0x199866(0x1c6)](_0x20fe21=>_0x20fe21[_0x199866(0x1e6)]));if(_0xb71ffd[_0x199866(0x1c8)]>0x1)throw CliErrors[_0x199866(0x1ba)](_0x199866(0x20a));const _0x3a6a08=_0x445a60[_0x199866(0x210)](_0x26f7a2=>[{'datasetCode':_0x26f7a2['datasetCode'],'operationType':snakeToCamel(_0x26f7a2[_0x199866(0x1ed)]),'functionNode':_0x199866(0x1ce),'id':_0x26f7a2[_0x199866(0x227)]},{'datasetCode':_0x26f7a2['datasetCode'],'operationType':snakeToCamel(_0x26f7a2['operationType']),'functionNode':'after','id':_0x26f7a2[_0x199866(0x1c2)]}])[_0x199866(0x1d5)](_0x31f27d=>_0x31f27d['id']===_0x1af62c[_0x199866(0x1fa)]),_0x68a49b=await getBffScriptInfo(_0x1af62c[_0x199866(0x1fa)]);if(_0x68a49b['id']!==_0x1af62c['remoteId']||_0x68a49b[_0x199866(0x1fd)]!==_0x4e2b8f||_0x68a49b[_0x199866(0x1e5)]!==_0x199866(0x21b)||_0x68a49b[_0x199866(0x1ca)]!==_0x15e312[_0x199866(0x1e8)]||_0x1af62c['version']==null||_0x68a49b[_0x199866(0x1ef)]!==_0x1af62c['version']||_0x3a6a08[_0x199866(0x1f1)]!==0x1||_0x3a6a08[0x0]['datasetCode']!==_0x1af62c[_0x199866(0x1d9)]||_0x3a6a08[0x0][_0x199866(0x1ed)]!==_0x15e312[_0x199866(0x1ed)]||_0x3a6a08[0x0][_0x199866(0x20d)]!==_0x15e312[_0x199866(0x20d)]||_0x1af62c[_0x199866(0x1ed)]!==_0x15e312[_0x199866(0x1ed)]||_0x1af62c['functionNode']!==_0x15e312['functionNode'])throw CliErrors['validation'](_0x199866(0x20e));_0x3a5b80[_0x199866(0x21e)](_0x15e312['lockKey']),_0x3c9795[_0x199866(0x211)](_0x15e312[_0x199866(0x1f3)]);}catch(_0x1421b3){_0x3c9795[_0x199866(0x1d4)](_0x15e312[_0x199866(0x1f3)],_0x1421b3 instanceof Error?_0x1421b3[_0x199866(0x1df)]:String(_0x1421b3));}}}return{'resolutions':_0x57af78,'failures':_0x3c9795,'existingHooks':_0x3a5b80};}async function uploadSingleFunction(_0x41082a,_0x252b88,_0xcae50b,_0x504c0e){const _0x818bb1=a44_0xad0615,_0x20081f=await readFile(_0x252b88[_0x818bb1(0x1de)],_0x818bb1(0x1b9)),_0x5ac78e=await computeFileHash(_0x252b88[_0x818bb1(0x1de)]),_0x11d353=_0xcae50b[_0x818bb1(0x1e4)][_0x252b88['lockKey']];if(_0x11d353?.[_0x818bb1(0x1fa)]&&_0x11d353[_0x818bb1(0x1ef)]==null)throw CliErrors[_0x818bb1(0x1ba)](_0x252b88[_0x818bb1(0x1f3)]+_0x818bb1(0x216));let _0x20e499=extractScriptDescription(_0x20081f);if(!_0x20e499&&_0x11d353?.['remoteId']){const _0x437872=await getBffScriptInfo(_0x11d353['remoteId']);_0x20e499=_0x437872[_0x818bb1(0x1c4)]||undefined;}const _0x1413f1={'appCode':_0x41082a,'functionName':_0x252b88[_0x818bb1(0x1e8)],'scriptType':_0x252b88[_0x818bb1(0x22b)],'scriptContent':_0x20081f};if(_0x11d353?.['remoteId'])_0x1413f1['id']=_0x11d353[_0x818bb1(0x1fa)];if(_0x11d353?.[_0x818bb1(0x1ef)]!=null)_0x1413f1[_0x818bb1(0x1ef)]=_0x11d353[_0x818bb1(0x1ef)];if(_0x20e499)_0x1413f1[_0x818bb1(0x1c4)]=_0x20e499;if(_0x252b88[_0x818bb1(0x22b)]==='HOOK'){const _0x43ed73=_0x504c0e['resolutions'][_0x818bb1(0x226)](_0x252b88[_0x818bb1(0x1f3)]);if(!_0x43ed73&&!_0x504c0e['existingHooks'][_0x818bb1(0x1b7)](_0x252b88[_0x818bb1(0x1f3)])||!_0x252b88[_0x818bb1(0x1ed)]||!_0x252b88[_0x818bb1(0x20d)])throw CliErrors['validation'](_0x818bb1(0x1f7)+_0x252b88[_0x818bb1(0x1f3)]);_0x43ed73&&(_0x1413f1[_0x818bb1(0x1f2)]=_0x43ed73[_0x818bb1(0x1c9)]['id'],_0x1413f1[_0x818bb1(0x1ed)]=_0x252b88[_0x818bb1(0x1ed)]),_0x1413f1[_0x818bb1(0x20d)]=_0x252b88[_0x818bb1(0x20d)];}const _0x4d3495=await saveBffScript(_0x1413f1),_0x3b295a=_0x4d3495['id'],_0x364f97=_0x4d3495[_0x818bb1(0x1cf)]??await getBffScriptInfo(_0x3b295a),_0x12c99d={'hash':_0x5ac78e,'remoteId':_0x3b295a,'version':_0x364f97[_0x818bb1(0x1ef)]};if(_0x252b88[_0x818bb1(0x22b)]===_0x818bb1(0x21b)){const _0x556d1a=_0x504c0e[_0x818bb1(0x1c5)][_0x818bb1(0x226)](_0x252b88[_0x818bb1(0x1f3)]);if(!_0x556d1a){_0xcae50b[_0x818bb1(0x1e4)][_0x252b88[_0x818bb1(0x1f3)]]={..._0x11d353,..._0x12c99d};return;}_0x12c99d[_0x818bb1(0x1e6)]=_0x556d1a[_0x818bb1(0x1e6)]??_0x11d353?.[_0x818bb1(0x1e6)],_0x12c99d[_0x818bb1(0x1d9)]=_0x556d1a['datasetCode'],_0x12c99d[_0x818bb1(0x1ed)]=_0x252b88[_0x818bb1(0x1ed)],_0x12c99d[_0x818bb1(0x20d)]=_0x252b88[_0x818bb1(0x20d)];}_0xcae50b[_0x818bb1(0x1e4)][_0x252b88[_0x818bb1(0x1f3)]]=_0x12c99d;}const LOCK_SETTLE_RETRY_COUNT=0x14,LOCK_SETTLE_DELAY_MS=0x64;async function waitForUploadedLockEntries(_0x16b99b,_0x15fac8,_0x2cc9f0){const _0x1f9fc7=a44_0xad0615;if(_0x2cc9f0[_0x1f9fc7(0x1f1)]===0x0)return;for(let _0x1b8dfa=0x0;_0x1b8dfa<LOCK_SETTLE_RETRY_COUNT;_0x1b8dfa+=0x1){const _0x13eed1=await readBffLockFile(_0x16b99b),_0x545abe=_0x13eed1?.['apps']?.[_0x15fac8]?.['functions']??{},_0x59d6f7=_0x2cc9f0[_0x1f9fc7(0x205)](_0x2ea208=>!!_0x545abe[_0x2ea208]?.[_0x1f9fc7(0x1fa)]);if(_0x59d6f7)return;await sleep(LOCK_SETTLE_DELAY_MS);}throw new Error(_0x1f9fc7(0x20c)+_0x2cc9f0['join'](',\x20')+'.');}
1
+ import{readFile}from"node:fs/promises";import{saveBffScript,getBffScriptInfo,getBffScriptStatistics,getPlatformErrorCode,listDatasets,clearBffScriptCache}from"../../core/api-client.js";import{loadAliasMap}from"../../core/alias-resolver.js";import{resolveApiModelSource}from"../../api/model-source.js";import{loadBffProjectConfig}from"../../core/bff/config.js";import{normalizeBffType,scanLocalBffFunctions}from"../../core/bff/file-system.js";import{buildHookDirectoryIndexes,assertUnambiguousHookAliases,assertUnambiguousHookDirectoryMappings,preflightPushHookDirectories,trackedHookDirectoryMappings}from"../../core/bff/hook-directory.js";import{computeFileHash}from"../../core/bff/hash.js";import{createEmptyBffLock,ensureLockScope,readBffLockFile,writeBffLockFile}from"../../core/bff/lock.js";import{extractScriptDescription,snakeToCamel}from"../../core/bff/utils.js";import{sleep}from"../../utils/sleep.js";import{CLI_BIN_NAME}from"../../constant/cli.js";import{CliErrors}from"../../errors.js"
2
+ ;const CACHE_CLEAR_ATTEMPTS=2;const CACHE_CLEAR_INTERVAL_MS=300;export const bffPush={service:"bff",command:"push",description:"Push local Backend Function scripts to remote",risk:"write",structuredErrors:true,flags:[{name:"type",type:"string",description:"Push only this script type",enum:["COMMON","ENDPOINT","HOOK"]},{name:"name",type:"string",description:"Push only the named function (requires --type)"},{name:"force",type:"boolean",description:"Force push ignoring hash protection"}],async dryRun(ctx){const config=loadBffProjectConfig(ctx.appCode);const rawLock=await readBffLockFile(config.lockFilePath);const{appLock:appLock}=ensureLockScope(rawLock??createEmptyBffLock(),ctx.appCode,config.scriptsRoot,"push");const localFunctions=await getTargetFunctions(config,ctx);const preflightFunctions=localFunctions.some(fn=>fn.type==="HOOK")?await scanLocalBffFunctions(config,"HOOK"):localFunctions
3
+ ;const hookMaps=await buildHookMaps(ctx.appCode,ctx.apiDir,preflightFunctions,appLock,ctx.selectedAppName||ctx.mergedCli?.currentApp||ctx.mergedCli?.defaultApp);const force=ctx.bool("force");const preview=[];for(const fn of localFunctions){const localHash=await computeFileHash(fn.filePath);const lockEntry=appLock.functions[fn.lockKey];const unchanged=!!lockEntry&&lockEntry.hash===localHash;const hook=hookMaps.resolutions.get(fn.lockKey);const missingRemoteVersion=!!lockEntry?.remoteId&&lockEntry.version==null&&(force||!unchanged);const conflict=missingRemoteVersion?missingRemoteVersionConflict(fn,lockEntry):undefined;const status=hookMaps.failures.has(fn.lockKey)?"failed":!force&&unchanged?"unchanged":conflict?"conflict":"would_push";preview.push({lockKey:fn.lockKey,filePath:fn.filePath,remoteId:lockEntry?.remoteId??null,mode:lockEntry?.remoteId?"update":"create",status:status,...hookMaps.failures.has(fn.lockKey)?{error:hookMaps.failures.get(fn.lockKey)}:{},...conflict?{
4
+ conflict:conflict}:{},...hookMaps.existingHooks.has(fn.lockKey)?{datasetCode:lockEntry?.datasetCode,bindingPreserved:true,warnings:[existingHookWarning(fn.lockKey)]}:{},...hook?{alias:hook.alias??null,datasetCode:hook.datasetCode,operationType:fn.operationType,functionNode:fn.functionNode,warnings:hook.warnings}:{}})}return{method:"POST",url:"/api/management/library/scripts/save",body:{appCode:ctx.appCode,force:force,files:preview,cacheClearAtRuntime:preview.some(item=>item.status==="would_push"),cacheClearAtRuntimeTimes:preview.some(item=>item.status==="would_push")?CACHE_CLEAR_ATTEMPTS:0},description:`Would inspect ${preview.length} local Backend Function script(s) for push and clear runtime cache if files are uploaded`}},async execute(ctx){const config=loadBffProjectConfig(ctx.appCode);const rawLock=await readBffLockFile(config.lockFilePath);const{lockData:lockData,appLock:appLock}=ensureLockScope(rawLock??createEmptyBffLock(),ctx.appCode,config.scriptsRoot,"push")
5
+ ;const localFunctions=await getTargetFunctions(config,ctx);if(localFunctions.length===0){return{ok:true,data:{uploaded:[],skipped:[],conflicts:[],failed:[]},message:"No local Backend Function scripts found."}}const force=ctx.bool("force");const nextLockData=JSON.parse(JSON.stringify(lockData));const nextAppLock=nextLockData.apps[ctx.appCode];if(!nextAppLock){throw new Error(`Lock scope for app "${ctx.appCode}" not found after ensureLockScope.`)}const preflightFunctions=localFunctions.some(fn=>fn.type==="HOOK")?await scanLocalBffFunctions(config,"HOOK"):localFunctions;const hookMaps=await buildHookMaps(ctx.appCode,ctx.apiDir,preflightFunctions,nextAppLock,ctx.selectedAppName||ctx.mergedCli?.currentApp||ctx.mergedCli?.defaultApp);const uploaded=[];const skipped=[];const conflicts=[];const failed=[];for(const fn of localFunctions){const preflightError=hookMaps.failures.get(fn.lockKey);if(preflightError){failed.push({lockKey:fn.lockKey,error:preflightError});continue}
6
+ const localHash=await computeFileHash(fn.filePath);const lockEntry=nextAppLock.functions[fn.lockKey];if(!force&&lockEntry&&lockEntry.hash===localHash){skipped.push({lockKey:fn.lockKey,reason:"unchanged"});continue}if(lockEntry?.remoteId&&lockEntry.version==null){conflicts.push(missingRemoteVersionConflict(fn,lockEntry));continue}try{await uploadSingleFunction(ctx.appCode,fn,nextAppLock,hookMaps);const entry=nextAppLock.functions[fn.lockKey];uploaded.push({lockKey:fn.lockKey,remoteId:entry?.remoteId??0})}catch(error){const conflict=remoteVersionChangedConflict(fn,lockEntry,error);if(conflict){conflicts.push(conflict);continue}failed.push({lockKey:fn.lockKey,error:error instanceof Error?error.message:String(error)})}}nextAppLock.lastSync=(new Date).toISOString();await writeBffLockFile(config.lockFilePath,nextLockData);await waitForUploadedLockEntries(config.lockFilePath,ctx.appCode,uploaded.map(item=>item.lockKey));let cacheClear={attempted:false,cleared:false};if(uploaded.length>0){try{
7
+ let message="";for(let attempt=0;attempt<CACHE_CLEAR_ATTEMPTS;attempt+=1){message=await clearBffScriptCache();if(attempt<CACHE_CLEAR_ATTEMPTS-1){await sleep(CACHE_CLEAR_INTERVAL_MS)}}cacheClear={attempted:true,cleared:true,message:message||"Runtime script cache cleared."}}catch(error){cacheClear={attempted:true,cleared:false,error:error instanceof Error?error.message:String(error)}}}const primarySucceeded=failed.length===0&&(cacheClear.attempted?cacheClear.cleared:true);const ok=primarySucceeded;const cacheMessage=cacheClear.attempted?cacheClear.cleared?"runtime cache cleared":"runtime cache clear failed":"runtime cache not needed";return{ok:ok,data:{uploaded:uploaded,skipped:skipped,conflicts:conflicts,failed:failed,cacheClear:cacheClear,warnings:[...[...hookMaps.resolutions.values()].flatMap(item=>item.warnings),...[...hookMaps.existingHooks].map(existingHookWarning)]},message:formatPushMessage(uploaded.length,skipped.length,conflicts.length,failed.length,cacheMessage)}}}
8
+ ;function missingRemoteVersionConflict(fn,lockEntry){return remoteVersionConflict(fn,lockEntry,"BFF_REMOTE_VERSION_MISSING","The local sync lock has no remote version for this script.")}function remoteVersionChangedConflict(fn,lockEntry,error){if(!lockEntry?.remoteId||lockEntry.version==null||!isRemoteVersionConflict(error)){return undefined}return remoteVersionConflict(fn,lockEntry,"BFF_REMOTE_VERSION_CHANGED","Remote script version changed since the last pull.")}function remoteVersionConflict(fn,lockEntry,code,message){return{code:code,lockKey:fn.lockKey,filePath:fn.filePath,remoteId:lockEntry.remoteId,...lockEntry.version!=null?{expectedVersion:lockEntry.version}:{},message:message,nextAction:{action:"review_remote_and_merge",command:`${CLI_BIN_NAME} bff detail --id ${lockEntry.remoteId} --format compress`,requiresReview:true,message:"Review the current remote source, merge it into the local script, then retry push. Do not use --force unless you intentionally discard local changes."
9
+ }}}function isRemoteVersionConflict(error){const message=error instanceof Error?error.message:String(error);const remoteCode=getPlatformErrorCode(error)??"";return[message,remoteCode].some(value=>/(?:version|optimistic)[\s_-]*(?:conflict|mismatch|changed|stale|out[\s_-]*of[\s_-]*date)|(?:conflict|mismatch|changed|stale|out[\s_-]*of[\s_-]*date)[\s_-]*(?:version|optimistic)/i.test(value))}function formatPushMessage(uploaded,skipped,conflicts,failed,cacheMessage){const parts=[`Push complete: ${uploaded} uploaded`,`${skipped} skipped`];if(conflicts>0){parts.push(`${conflicts} conflict${conflicts===1?"":"s"} ${conflicts===1?"requires":"require"} resolution`)}if(failed>0)parts.push(`${failed} failed`);parts.push(cacheMessage);return parts.join(", ")}async function getTargetFunctions(config,ctx){const typeFlag=ctx.str("type");const nameFlag=ctx.str("name");const filterType=normalizeBffType(typeFlag)??undefined;if(nameFlag&&!filterType){
10
+ throw CliErrors.validation("--name requires --type to identify the function.")}const allFunctions=await scanLocalBffFunctions(config,filterType);if(nameFlag){const matches=allFunctions.filter(fn=>fn.name===nameFlag);if(matches.length===0){throw CliErrors.validation(`Local function not found: ${filterType}/${nameFlag}`)}return matches}return allFunctions}function existingHookWarning(lockKey){return{code:"EXISTING_HOOK_BINDING_PRESERVED",lockKey:lockKey,message:"Dataset metadata is unavailable; the existing script and binding were verified. Update by script ID without rebinding."}}async function buildHookMaps(appCode,apiDir,localFunctions,appLock,selectedAppName){const hasHooks=localFunctions.some(fn=>fn.type==="HOOK");if(!hasHooks)return{resolutions:new Map,failures:new Map,existingHooks:new Set};const source=resolveApiModelSource(apiDir,appCode,selectedAppName);const aliasEntries=loadAliasMap(apiDir,undefined,source.filePath,source.profileName)
11
+ ;assertUnambiguousHookAliases(aliasEntries);const aliasToDatasetCode=[...aliasEntries.map(entry=>[entry.alias,entry.datasetCode]),...trackedHookDirectoryMappings(appLock).map(entry=>[entry.alias,entry.datasetCode])];const datasets=await listDatasets(appCode);assertUnambiguousHookDirectoryMappings(aliasToDatasetCode.map(([alias,datasetCode])=>({alias:alias,datasetCode:datasetCode})));const indexes=buildHookDirectoryIndexes(datasets,aliasToDatasetCode);const failures=new Map;const resolutions=preflightPushHookDirectories(localFunctions,appLock,indexes,failures);const existingHooks=new Set;const candidates=localFunctions.filter(fn=>failures.get(fn.lockKey)?.startsWith("HOOK_DATASET_NOT_FOUND:")&&appLock.functions[fn.lockKey]?.remoteId&&appLock.functions[fn.lockKey]?.datasetCode);if(candidates.length>0){let statistics;try{statistics=await getBffScriptStatistics(appCode)}catch(error){
12
+ for(const fn of candidates)failures.set(fn.lockKey,`Cannot verify existing HOOK binding: ${error instanceof Error?error.message:String(error)}`);return{resolutions:resolutions,failures:failures,existingHooks:existingHooks}}for(const fn of candidates){const entry=appLock.functions[fn.lockKey];try{const directories=new Set(localFunctions.filter(item=>item.type==="HOOK"&&appLock.functions[item.lockKey]?.datasetCode===entry.datasetCode).map(item=>item.alias));if(directories.size>1){throw CliErrors.validation("Multiple HOOK directories reference the same missing Dataset. Resolve duplicate directories before pushing.")}const bindings=statistics.flatMap(item=>[{datasetCode:item.datasetCode,operationType:snakeToCamel(item.operationType),functionNode:"before",id:item.beforeScriptId},{datasetCode:item.datasetCode,operationType:snakeToCamel(item.operationType),functionNode:"after",id:item.afterScriptId}]).filter(item=>item.id===entry.remoteId);const remote=await getBffScriptInfo(entry.remoteId)
13
+ ;if(remote.id!==entry.remoteId||remote.appCode!==appCode||remote.scriptType!=="HOOK"||remote.functionName!==fn.name||entry.version==null||remote.version!==entry.version||bindings.length!==1||bindings[0].datasetCode!==entry.datasetCode||bindings[0].operationType!==fn.operationType||bindings[0].functionNode!==fn.functionNode||entry.operationType!==fn.operationType||entry.functionNode!==fn.functionNode){throw CliErrors.validation("Existing HOOK identity, version or binding does not match the local lock. Pull and review before pushing.")}existingHooks.add(fn.lockKey);failures.delete(fn.lockKey)}catch(error){failures.set(fn.lockKey,error instanceof Error?error.message:String(error))}}}return{resolutions:resolutions,failures:failures,existingHooks:existingHooks}}async function uploadSingleFunction(appCode,fn,appLock,hookMaps){const sourceCode=await readFile(fn.filePath,"utf8");const hash=await computeFileHash(fn.filePath);const lockEntry=appLock.functions[fn.lockKey]
14
+ ;if(lockEntry?.remoteId&&lockEntry.version==null){throw CliErrors.validation(`${fn.lockKey}: missing remote version. Run \`push\` after \`pull\` to sync version info.`)}let descriptionToSend=extractScriptDescription(sourceCode);if(!descriptionToSend&&lockEntry?.remoteId){const remote=await getBffScriptInfo(lockEntry.remoteId);descriptionToSend=remote.description||undefined}const payload={appCode:appCode,functionName:fn.name,scriptType:fn.type,scriptContent:sourceCode};if(lockEntry?.remoteId)payload["id"]=lockEntry.remoteId;if(lockEntry?.version!=null)payload["version"]=lockEntry.version;if(descriptionToSend)payload["description"]=descriptionToSend;if(fn.type==="HOOK"){const hook=hookMaps.resolutions.get(fn.lockKey);if(!hook&&!hookMaps.existingHooks.has(fn.lockKey)||!fn.operationType||!fn.functionNode){throw CliErrors.validation(`Incomplete HOOK path: ${fn.lockKey}`)}if(hook){payload["datasetId"]=hook.dataset.id;payload["operationType"]=fn.operationType}
15
+ payload["functionNode"]=fn.functionNode}const saved=await saveBffScript(payload);const remoteId=saved.id;const latestScript=saved.script??await getBffScriptInfo(remoteId);const nextEntry={hash:hash,remoteId:remoteId,version:latestScript.version};if(fn.type==="HOOK"){const hook=hookMaps.resolutions.get(fn.lockKey);if(!hook){appLock.functions[fn.lockKey]={...lockEntry,...nextEntry};return}nextEntry.alias=hook.alias??lockEntry?.alias;nextEntry.datasetCode=hook.datasetCode;nextEntry.operationType=fn.operationType;nextEntry.functionNode=fn.functionNode}appLock.functions[fn.lockKey]=nextEntry}const LOCK_SETTLE_RETRY_COUNT=20;const LOCK_SETTLE_DELAY_MS=100;async function waitForUploadedLockEntries(lockFilePath,appCode,lockKeys){if(lockKeys.length===0)return;for(let i=0;i<LOCK_SETTLE_RETRY_COUNT;i+=1){const latestLock=await readBffLockFile(lockFilePath);const functions=latestLock?.apps?.[appCode]?.functions??{};const allPresent=lockKeys.every(lockKey=>!!functions[lockKey]?.remoteId)
16
+ ;if(allPresent)return;await sleep(LOCK_SETTLE_DELAY_MS)}throw new Error(`Lock file not settled after push for ${lockKeys.join(", ")}.`)}
@@ -1 +1,3 @@
1
- const a45_0x20a382=a45_0x3564;(function(_0x277e1d,_0x5a69ff){const _0x5b71bb=a45_0x3564,_0x44c136=_0x277e1d();while(!![]){try{const _0x49a2d6=-parseInt(_0x5b71bb(0xfc))/0x1+-parseInt(_0x5b71bb(0xff))/0x2+parseInt(_0x5b71bb(0xef))/0x3*(-parseInt(_0x5b71bb(0x112))/0x4)+-parseInt(_0x5b71bb(0x10c))/0x5+-parseInt(_0x5b71bb(0x104))/0x6*(-parseInt(_0x5b71bb(0xfe))/0x7)+-parseInt(_0x5b71bb(0x107))/0x8+parseInt(_0x5b71bb(0x105))/0x9;if(_0x49a2d6===_0x5a69ff)break;else _0x44c136['push'](_0x44c136['shift']());}catch(_0x3abda4){_0x44c136['push'](_0x44c136['shift']());}}}(a45_0x5aca,0x710be));import{listBffScripts,getBffScriptStatistics}from'../../core/api-client.js';import{loadAliasMap}from'../../core/alias-resolver.js';import{resolveApiModelSource}from'../../api/model-source.js';import{loadBffProjectConfig}from'../../core/bff/config.js';function a45_0x5aca(){const _0x398dc1=['profileName','boolean','Also\x20check\x20for\x20remote-only\x20scripts\x20not\x20present\x20locally','all','2508540jtFQBX','defaultApp','datasetCode','remote','\x20modified,\x20','All\x20Backend\x20Function\x20scripts\x20are\x20in\x20sync.','104OccGIL','hash','6504cBuKNS','appCode','apiDir','filePath','length','currentApp','has','read','map','\x20added,\x20','status','bff','\x20remote-only','766729wclWQd','mergedCli','23891yBXwEI','568806NYdWBM','Check\x20local\x20Backend\x20Function\x20sync\x20status\x20against\x20lock\x20file','bool','\x20unchanged','functions','36LbMWCz','25412346ntIZhH','lockKey','6174608wEbdir'];a45_0x5aca=function(){return _0x398dc1;};return a45_0x5aca();}import{createHookLocationMap,resolveRemoteScriptTarget,scanLocalBffFunctions}from'../../core/bff/file-system.js';import{computeFileHash}from'../../core/bff/hash.js';import{createEmptyBffLock,ensureLockScope,readBffLockFile}from'../../core/bff/lock.js';function a45_0x3564(_0x3cca7b,_0x45eb24){_0x3cca7b=_0x3cca7b-0xef;const _0x5aca54=a45_0x5aca();let _0x35644d=_0x5aca54[_0x3cca7b];return _0x35644d;}export const bffStatus={'service':a45_0x20a382(0xfa),'command':'status','description':a45_0x20a382(0x100),'risk':a45_0x20a382(0xf6),'flags':[{'name':a45_0x20a382(0x10f),'type':a45_0x20a382(0x109),'description':a45_0x20a382(0x10a)}],async 'execute'(_0x58397b){const _0x2af1c9=a45_0x20a382,_0x594e9f=loadBffProjectConfig(_0x58397b[_0x2af1c9(0xf0)]),_0x168a75=await readBffLockFile(_0x594e9f['lockFilePath']),{appLock:_0x4b9436}=ensureLockScope(_0x168a75??createEmptyBffLock(),_0x58397b[_0x2af1c9(0xf0)],_0x594e9f['scriptsRoot'],_0x2af1c9(0xf9)),_0x4bd572=await scanLocalBffFunctions(_0x594e9f),_0x40eb4c=[],_0x534170=[],_0x7c27a3=[];for(const _0x5a305a of _0x4bd572){const _0x5dc466=await computeFileHash(_0x5a305a['filePath']),_0x1dc141=_0x4b9436[_0x2af1c9(0x103)][_0x5a305a[_0x2af1c9(0x106)]];if(!_0x1dc141)_0x40eb4c['push'](_0x5a305a[_0x2af1c9(0x106)]);else _0x1dc141[_0x2af1c9(0x113)]!==_0x5dc466?_0x534170['push'](_0x5a305a[_0x2af1c9(0x106)]):_0x7c27a3['push'](_0x5a305a[_0x2af1c9(0x106)]);}const _0x29c63f=[];if(_0x58397b[_0x2af1c9(0x101)]('remote')){const _0xd67065=resolveApiModelSource(_0x58397b[_0x2af1c9(0xf1)],_0x58397b[_0x2af1c9(0xf0)],_0x58397b['selectedAppName']||_0x58397b[_0x2af1c9(0xfd)]?.[_0x2af1c9(0xf4)]||_0x58397b[_0x2af1c9(0xfd)]?.[_0x2af1c9(0x10d)]),_0x3c17f7=loadAliasMap(_0x58397b[_0x2af1c9(0xf1)],undefined,_0xd67065[_0x2af1c9(0xf2)],_0xd67065[_0x2af1c9(0x108)]),_0x4d55a7=new Map(_0x3c17f7[_0x2af1c9(0xf7)](_0x3692f0=>[_0x3692f0[_0x2af1c9(0x10e)],_0x3692f0['alias']])),[_0x192d3c,_0x5b7129]=await Promise[_0x2af1c9(0x10b)]([listBffScripts(_0x58397b['appCode']),getBffScriptStatistics(_0x58397b['appCode'])]),_0x587419=createHookLocationMap(_0x5b7129),_0x3e12d6=new Set(_0x4bd572[_0x2af1c9(0xf7)](_0x20e2a2=>_0x20e2a2['lockKey']));for(const _0x210efb of _0x192d3c){const _0x2b4853=resolveRemoteScriptTarget(_0x594e9f,_0x210efb,_0x587419,_0x4b9436['functions'],_0x4d55a7);_0x2b4853&&!_0x3e12d6[_0x2af1c9(0xf5)](_0x2b4853['lockKey'])&&_0x29c63f['push'](_0x2b4853['lockKey']);}}const _0xab5f95=_0x40eb4c['length']===0x0&&_0x534170[_0x2af1c9(0xf3)]===0x0&&_0x29c63f[_0x2af1c9(0xf3)]===0x0;return{'ok':!![],'data':{'added':_0x40eb4c,'modified':_0x534170,'unchanged':_0x7c27a3,'remoteOnly':_0x29c63f},'message':_0xab5f95?_0x2af1c9(0x111):_0x40eb4c[_0x2af1c9(0xf3)]+_0x2af1c9(0xf8)+_0x534170[_0x2af1c9(0xf3)]+_0x2af1c9(0x110)+_0x7c27a3[_0x2af1c9(0xf3)]+_0x2af1c9(0x102)+(_0x29c63f[_0x2af1c9(0xf3)]>0x0?',\x20'+_0x29c63f[_0x2af1c9(0xf3)]+_0x2af1c9(0xfb):'')};}};
1
+ import{listBffScripts,getBffScriptStatistics}from"../../core/api-client.js";import{loadAliasMap}from"../../core/alias-resolver.js";import{resolveApiModelSource}from"../../api/model-source.js";import{loadBffProjectConfig}from"../../core/bff/config.js";import{createHookLocationMap,resolveRemoteScriptTarget,scanLocalBffFunctions}from"../../core/bff/file-system.js";import{computeFileHash}from"../../core/bff/hash.js";import{createEmptyBffLock,ensureLockScope,readBffLockFile}from"../../core/bff/lock.js";export const bffStatus={service:"bff",command:"status",description:"Check local Backend Function sync status against lock file",risk:"read",flags:[{name:"remote",type:"boolean",description:"Also check for remote-only scripts not present locally"}],async execute(ctx){const config=loadBffProjectConfig(ctx.appCode);const rawLock=await readBffLockFile(config.lockFilePath);const{appLock:appLock}=ensureLockScope(rawLock??createEmptyBffLock(),ctx.appCode,config.scriptsRoot,"status")
2
+ ;const localFunctions=await scanLocalBffFunctions(config);const added=[];const modified=[];const unchanged=[];for(const fn of localFunctions){const localHash=await computeFileHash(fn.filePath);const lockEntry=appLock.functions[fn.lockKey];if(!lockEntry){added.push(fn.lockKey)}else if(lockEntry.hash!==localHash){modified.push(fn.lockKey)}else{unchanged.push(fn.lockKey)}}const remoteOnly=[];if(ctx.bool("remote")){const source=resolveApiModelSource(ctx.apiDir,ctx.appCode,ctx.selectedAppName||ctx.mergedCli?.currentApp||ctx.mergedCli?.defaultApp);const aliasEntries=loadAliasMap(ctx.apiDir,undefined,source.filePath,source.profileName);const datasetCodeToAlias=new Map(aliasEntries.map(e=>[e.datasetCode,e.alias]));const[scripts,statistics]=await Promise.all([listBffScripts(ctx.appCode),getBffScriptStatistics(ctx.appCode)]);const hookLocationMap=createHookLocationMap(statistics);const localKeys=new Set(localFunctions.map(fn=>fn.lockKey));for(const script of scripts){
3
+ const target=resolveRemoteScriptTarget(config,script,hookLocationMap,appLock.functions,datasetCodeToAlias);if(target&&!localKeys.has(target.lockKey)){remoteOnly.push(target.lockKey)}}}const synced=added.length===0&&modified.length===0&&remoteOnly.length===0;return{ok:true,data:{added:added,modified:modified,unchanged:unchanged,remoteOnly:remoteOnly},message:synced?"All Backend Function scripts are in sync.":`${added.length} added, ${modified.length} modified, ${unchanged.length} unchanged`+(remoteOnly.length>0?`, ${remoteOnly.length} remote-only`:"")}}};
@@ -1 +1,2 @@
1
- function a46_0x1efc(){const _0x4d9526=['inherit','2010306PkURHL','read','apiError','576279hTzDWH','\x20via\x20skills@latest','1756263xmbYBk','CLI\x20Built-in\x20Skill\x20','88dFDBlk','10STujrL','error','repairCommand','Install\x20or\x20refresh\x20the\x20Rabetbase\x20CLI\x20Built-in\x20Skill','\x20installed','cli-skill','installedPath','Resolve\x20the\x20Skills\x20CLI\x20installation\x20issue\x20and\x20run:\x20','\x20at\x20','skillVersion','969160gmZSqT','Installing\x20CLI\x20Built-in\x20Skill\x20from\x20the\x20current\x20package.','log',']:\x20','\x20is\x20already\x20current','3813754BVVprL','626233aBijtf','info','496496ioxDTm'];a46_0x1efc=function(){return _0x4d9526;};return a46_0x1efc();}const a46_0xa3a594=a46_0x2c1a;function a46_0x2c1a(_0x1db1b5,_0xc890f5){_0x1db1b5=_0x1db1b5-0x169;const _0x1efc71=a46_0x1efc();let _0x2c1a42=_0x1efc71[_0x1db1b5];return _0x2c1a42;}(function(_0x58e954,_0x3368e0){const _0x88a1f9=a46_0x2c1a,_0x27fad5=_0x58e954();while(!![]){try{const _0x2df87d=-parseInt(_0x88a1f9(0x170))/0x1+-parseInt(_0x88a1f9(0x16a))/0x2+-parseInt(_0x88a1f9(0x179))/0x3+parseInt(_0x88a1f9(0x172))/0x4+parseInt(_0x88a1f9(0x17c))/0x5*(parseInt(_0x88a1f9(0x174))/0x6)+parseInt(_0x88a1f9(0x16f))/0x7+parseInt(_0x88a1f9(0x17b))/0x8*(parseInt(_0x88a1f9(0x177))/0x9);if(_0x2df87d===_0x3368e0)break;else _0x27fad5['push'](_0x27fad5['shift']());}catch(_0x2c4ad3){_0x27fad5['push'](_0x27fad5['shift']());}}}(a46_0x1efc,0x54c13));import{CliErrors}from'../../errors.js';import{installBuiltinSkill}from'../../skills/builtin-skill.js';import{logger}from'../../utils/logger.js';export const cliSkillDefinitions=[{'service':a46_0xa3a594(0x181),'command':'install','description':a46_0xa3a594(0x17f),'risk':a46_0xa3a594(0x175),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'flags':[],async 'execute'(_0x569e7d){const _0x100cd9=a46_0xa3a594;logger['setLogPath'](process['cwd']()),logger[_0x100cd9(0x171)]('cli-skill-install',_0x100cd9(0x16b));const _0x47b7af=installBuiltinSkill({'stdio':_0x569e7d['nonInteractive']?'pipe':_0x100cd9(0x173)});if(!_0x47b7af['ok'])throw CliErrors[_0x100cd9(0x176)]('Built-in\x20Skill\x20install\x20failed\x20['+_0x47b7af['code']+_0x100cd9(0x16d)+(_0x47b7af[_0x100cd9(0x17d)]||'unknown'),_0x100cd9(0x183)+_0x47b7af[_0x100cd9(0x17e)]);return console[_0x100cd9(0x16c)](_0x47b7af['changed']?_0x100cd9(0x17a)+_0x47b7af[_0x100cd9(0x169)]+_0x100cd9(0x180)+(_0x47b7af[_0x100cd9(0x182)]?_0x100cd9(0x184)+_0x47b7af[_0x100cd9(0x182)]:_0x100cd9(0x178)):_0x100cd9(0x17a)+_0x47b7af[_0x100cd9(0x169)]+_0x100cd9(0x16e)+(_0x47b7af['installedPath']?'\x20at\x20'+_0x47b7af['installedPath']:'')),{'ok':!![]};}}];
1
+ import{CliErrors}from"../../errors.js";import{installBuiltinSkill}from"../../skills/builtin-skill.js";import{logger}from"../../utils/logger.js";export const cliSkillDefinitions=[{service:"cli-skill",command:"install",description:"Install or refresh the Rabetbase CLI Built-in Skill",risk:"read",requiresAuth:false,requiresAppCode:false,hasFormat:false,flags:[],async execute(ctx){logger.setLogPath(process.cwd());logger.info("cli-skill-install","Installing CLI Built-in Skill from the current package.");const result=installBuiltinSkill({stdio:ctx.nonInteractive?"pipe":"inherit"});if(!result.ok){throw CliErrors.apiError(`Built-in Skill install failed [${result.code}]: ${result.error||"unknown"}`,`Resolve the Skills CLI installation issue and run: ${result.repairCommand}`)}
2
+ console.log(result.changed?`CLI Built-in Skill ${result.skillVersion} installed${result.installedPath?` at ${result.installedPath}`:" via local skills installer"}`:`CLI Built-in Skill ${result.skillVersion} is already current${result.installedPath?` at ${result.installedPath}`:""}`);return{ok:true}}}];
@@ -1 +1,7 @@
1
- const a47_0x5bb842=a47_0x107d;(function(_0x3e79cb,_0x23ea10){const _0x5be222=a47_0x107d,_0x1d64a9=_0x3e79cb();while(!![]){try{const _0x2160bb=parseInt(_0x5be222(0xf7))/0x1+parseInt(_0x5be222(0xeb))/0x2*(parseInt(_0x5be222(0xb1))/0x3)+-parseInt(_0x5be222(0xed))/0x4+-parseInt(_0x5be222(0xba))/0x5+-parseInt(_0x5be222(0xe8))/0x6*(parseInt(_0x5be222(0xf1))/0x7)+parseInt(_0x5be222(0xad))/0x8+parseInt(_0x5be222(0xc8))/0x9;if(_0x2160bb===_0x23ea10)break;else _0x1d64a9['push'](_0x1d64a9['shift']());}catch(_0x438460){_0x1d64a9['push'](_0x1d64a9['shift']());}}}(a47_0xf05d,0x495fe));import a47_0x378bf7 from'chalk';import a47_0xf35b70 from'ora';import a47_0x353f3f from'semver';import{execa}from'execa';function a47_0x107d(_0x47ccbe,_0x2c5152){_0x47ccbe=_0x47ccbe-0xac;const _0xf05d67=a47_0xf05d();let _0x107d2a=_0xf05d67[_0x47ccbe];return _0x107d2a;}import{CLI_BIN_NAME,NPM_PACKAGE_NAME}from'../constant/cli.js';import{VERSION,GIT_COMMIT,BUILD_TIME}from'../generated/build-info.js';import{CliErrors}from'../errors.js';import{inspectInstalledBuiltinSkillVersion,installBuiltinSkill}from'../skills/builtin-skill.js';import{resolveNpmBin}from'../utils/platform.js';function getCurrentVersion(){const _0xea799e=a47_0x107d;return GIT_COMMIT!==_0xea799e(0xdb)?VERSION+'\x20('+GIT_COMMIT+',\x20'+BUILD_TIME[_0xea799e(0xb7)](0x0,0xa)+')':VERSION;}function detectPackageManager(){const _0x5c6c72=a47_0x107d,_0x57f798=process['execPath'][_0x5c6c72(0xc6)]();if(_0x57f798['includes']('bun'))return'bun';return _0x5c6c72(0xbf);}const updateFlags=[{'name':'beta','type':a47_0x5bb842(0xe0),'description':a47_0x5bb842(0xb9),'default':![]},{'name':a47_0x5bb842(0xdd),'type':a47_0x5bb842(0xb6),'description':'Install\x20a\x20specific\x20CLI\x20version'}];function getRequestedVersion(_0x9241d5){const _0x4bc17b=a47_0x5bb842;return _0x9241d5[_0x4bc17b(0x100)](_0x4bc17b(0xdd))[_0x4bc17b(0xe9)]();}function a47_0xf05d(){const _0x361814=['Try\x20manually:\x20','Unable\x20to\x20resolve\x20beta\x20version\x20from\x20npm','source','Run:\x20','expected\x20','state','/dist-tags','Current\x20version:\x20',',\x20then\x20verify\x20with:\x20','beta','unknown','Update\x20failed','version','start','valid','boolean','repairCommand',',\x20state\x20','CLI\x20Built-in\x20Skill\x20repair\x20failed\x20[','read','Unable\x20to\x20check\x20for\x20updates\x20(network\x20error)','--beta\x20and\x20--version\x20cannot\x20be\x20used\x20together.','object','1223058FIbCAI','trim','Beta\x20version:\x20','186qaVulK','fail','418996cwcdjk','\x20doctor','message','run','7zwVwnS','Already\x20on\x20requested\x20version\x20(v','\x20→\x20','Update\x20available:\x20','json','Requested\x20version:\x20','306549GFULoI','current','Try\x20manually:\x20npm\x20install\x20-g\x20','map','\x20update\x20--version\x20<version>','CLI\x20updated\x20to\x20v','bool','length','Updating\x20via\x20','str','validation','skillVersion','272624GKWcSN','pipe','Update\x20rabetbase\x20CLI\x20to\x20the\x20latest\x20version','filter','3447rCvIuN','update','Checking\x20for\x20updates...','green','Invalid\x20version:\x20','string','slice','\x20install\x20-g\x20','Install\x20the\x20version\x20from\x20npm\x20beta\x20dist-tag','1433920BAuhSN','\x20is\x20newer\x20than\x20npm\x20latest\x20v','yellow','Choose\x20either\x20npm\x20beta\x20dist-tag\x20or\x20an\x20exact\x20version.','code','npm','succeed','...','https://registry.npmjs.org/-/package/','error','latest','\x20\x20CLI\x20Built-in\x20Skill\x20','toLowerCase','Already\x20up\x20to\x20date\x20(v','4035906cptpAc','log','apiError','gray','timeout',',\x20found\x20','Updated\x20to\x20v','Version\x20comparison\x20failed','\x20is\x20up\x20to\x20date.'];a47_0xf05d=function(){return _0x361814;};return a47_0xf05d();}async function validateUpdateFlags(_0x409ba7){const _0x270042=a47_0x5bb842,_0x45e429=_0x409ba7[_0x270042(0xfd)](_0x270042(0xda)),_0x3b50eb=getRequestedVersion(_0x409ba7);if(_0x45e429&&_0x3b50eb)throw CliErrors['validation'](_0x270042(0xe6),_0x270042(0xbd));if(_0x3b50eb&&!a47_0x353f3f[_0x270042(0xdf)](_0x3b50eb))throw CliErrors[_0x270042(0x101)](_0x270042(0xb5)+_0x3b50eb,'Use\x20a\x20full\x20semver\x20such\x20as\x202.1.6\x20or\x202.1.6-beta.1.');}async function fetchNpmDistTags(){const _0x478dd0=a47_0x5bb842;try{const _0x574525=await fetch(_0x478dd0(0xc2)+encodeURIComponent(NPM_PACKAGE_NAME)+_0x478dd0(0xd7),{'signal':AbortSignal[_0x478dd0(0xcc)](0x2710)});if(!_0x574525['ok'])return null;const _0x3514d2=await _0x574525[_0x478dd0(0xf5)]();if(!_0x3514d2||typeof _0x3514d2!==_0x478dd0(0xe7))return null;return Object['fromEntries'](Object['entries'](_0x3514d2)[_0x478dd0(0xb0)](([,_0x312e0a])=>typeof _0x312e0a===_0x478dd0(0xb6)&&_0x312e0a['trim']()[_0x478dd0(0xfe)]>0x0)[_0x478dd0(0xfa)](([_0x4e8de,_0x2dc194])=>[_0x4e8de,String(_0x2dc194)[_0x478dd0(0xe9)]()]));}catch{return null;}}async function fetchNpmDistTagVersion(_0x589d90){const _0x21dbc2=await fetchNpmDistTags();return _0x21dbc2?.[_0x589d90]??null;}async function fetchLatestVersion(){return fetchNpmDistTagVersion('latest');}async function resolveTargetVersion(_0x1e90ea){const _0x4a2615=a47_0x5bb842,_0x24dcde=getRequestedVersion(_0x1e90ea);if(_0x24dcde)return{'version':_0x24dcde,'source':_0x4a2615(0xdd)};if(_0x1e90ea[_0x4a2615(0xfd)](_0x4a2615(0xda))){const _0x97a04a=await fetchNpmDistTagVersion(_0x4a2615(0xda));if(!_0x97a04a)return null;return{'version':_0x97a04a,'source':_0x4a2615(0xda)};}const _0x1db257=await fetchLatestVersion();if(!_0x1db257)return null;return{'version':_0x1db257,'source':_0x4a2615(0xc4)};}function shouldInstallTarget(_0x111c93,_0x1940be){const _0xa90901=a47_0x5bb842;if(_0x1940be[_0xa90901(0xd3)]===_0xa90901(0xdd)||_0x1940be[_0xa90901(0xd3)]==='beta')return!a47_0x353f3f['eq'](_0x111c93,_0x1940be[_0xa90901(0xdd)]);return a47_0x353f3f['lt'](_0x111c93,_0x1940be[_0xa90901(0xdd)]);}function getInstallPlanLabel(_0xca0e0f,_0x105160){const _0x303131=a47_0x5bb842;switch(_0x105160['source']){case _0x303131(0xda):return _0x303131(0xea)+a47_0x378bf7[_0x303131(0xbc)](_0xca0e0f)+'\x20→\x20'+a47_0x378bf7[_0x303131(0xb4)](_0x105160[_0x303131(0xdd)]);case'version':return _0x303131(0xf6)+a47_0x378bf7[_0x303131(0xbc)](_0xca0e0f)+_0x303131(0xf3)+a47_0x378bf7['green'](_0x105160['version']);case _0x303131(0xc4):default:return _0x303131(0xf4)+a47_0x378bf7[_0x303131(0xbc)](_0xca0e0f)+'\x20→\x20'+a47_0x378bf7['green'](_0x105160[_0x303131(0xdd)]);}}function repairCurrentBuiltinSkill(){const _0x58eec5=a47_0x5bb842;console[_0x58eec5(0xc9)](a47_0x378bf7[_0x58eec5(0xcb)]('Checking\x20CLI\x20Built-in\x20Skill...'));const _0x581ad7=installBuiltinSkill();if(_0x581ad7['ok']){console['log'](a47_0x378bf7[_0x58eec5(0xcb)](_0x58eec5(0xc5)+_0x581ad7[_0x58eec5(0xac)]+_0x58eec5(0xd0)));return;}throw CliErrors[_0x58eec5(0xca)](_0x58eec5(0xe3)+_0x581ad7[_0x58eec5(0xbe)]+']:\x20'+(_0x581ad7[_0x58eec5(0xc3)]||'unknown'),_0x58eec5(0xd4)+_0x581ad7[_0x58eec5(0xe1)]+',\x20then\x20verify\x20with:\x20'+CLI_BIN_NAME+_0x58eec5(0xee));}function verifyUpdatedBuiltinSkill(_0x37fba0){const _0x32f171=a47_0x5bb842,_0x42476e=inspectInstalledBuiltinSkillVersion(_0x37fba0);if(_0x42476e[_0x32f171(0xd6)]===_0x32f171(0xf8)){console['log'](a47_0x378bf7[_0x32f171(0xcb)](_0x32f171(0xc5)+_0x37fba0+_0x32f171(0xd0)));return;}const _0x183b5b=_0x42476e[_0x32f171(0xac)]?_0x32f171(0xd5)+_0x37fba0+_0x32f171(0xcd)+_0x42476e[_0x32f171(0xac)]:_0x32f171(0xd5)+_0x37fba0+_0x32f171(0xe2)+_0x42476e[_0x32f171(0xd6)];throw CliErrors['apiError'](_0x32f171(0xfc)+_0x37fba0+',\x20but\x20Built-in\x20Skill\x20verification\x20failed:\x20'+_0x183b5b,'Run:\x20'+_0x42476e['repairCommand']+_0x32f171(0xd9)+CLI_BIN_NAME+_0x32f171(0xee));}async function execute(_0x316267){const _0x6939a4=a47_0x5bb842;await validateUpdateFlags(_0x316267);const _0x289679=getCurrentVersion();console[_0x6939a4(0xc9)](_0x6939a4(0xd8)+_0x289679);const _0x4aab4c=a47_0xf35b70(_0x6939a4(0xb3))['start'](),_0xd1855=await resolveTargetVersion(_0x316267);if(!_0xd1855){const _0x4bac05=_0x316267[_0x6939a4(0xfd)](_0x6939a4(0xda))?_0x6939a4(0xd2):_0x6939a4(0xe5);_0x4aab4c[_0x6939a4(0xec)](_0x4bac05);throw CliErrors[_0x6939a4(0xca)](_0x4bac05,_0x6939a4(0xf9)+NPM_PACKAGE_NAME+'@'+(_0x316267[_0x6939a4(0xfd)](_0x6939a4(0xda))?_0x6939a4(0xda):_0x6939a4(0xc4)));}const _0x2cc82c=a47_0x353f3f[_0x6939a4(0xdf)](VERSION),_0x4cbffd=a47_0x353f3f['valid'](_0xd1855[_0x6939a4(0xdd)]);if(!_0x2cc82c||!_0x4cbffd){_0x4aab4c[_0x6939a4(0xec)](_0x6939a4(0xcf));throw CliErrors[_0x6939a4(0xca)]('Version\x20comparison\x20failed','Check\x20the\x20CLI\x20and\x20npm\x20versions,\x20then\x20retry:\x20'+CLI_BIN_NAME+_0x6939a4(0xfb));}if(!shouldInstallTarget(_0x2cc82c,_0xd1855)){const _0x19517f=_0xd1855[_0x6939a4(0xd3)]===_0x6939a4(0xdd)?_0x6939a4(0xf2)+_0xd1855[_0x6939a4(0xdd)]+')':a47_0x353f3f['gt'](_0x2cc82c,_0x4cbffd)?'Current\x20version\x20v'+_0x289679+_0x6939a4(0xbb)+_0xd1855['version']:_0x6939a4(0xc7)+_0xd1855[_0x6939a4(0xdd)]+')';return _0x4aab4c[_0x6939a4(0xc0)](_0x19517f),repairCurrentBuiltinSkill(),{'ok':!![]};}_0x4aab4c['info'](getInstallPlanLabel(_0x289679,_0xd1855));const _0x451be4=detectPackageManager(),_0x9920c1=_0x451be4===_0x6939a4(0xbf)?resolveNpmBin(_0x6939a4(0xbf)):_0x451be4,_0x33b9b6=a47_0xf35b70(_0x6939a4(0xff)+_0x451be4+_0x6939a4(0xc1))[_0x6939a4(0xde)]();try{await execa(_0x9920c1,['install','-g',NPM_PACKAGE_NAME+'@'+_0xd1855[_0x6939a4(0xdd)]],{'stdio':_0x6939a4(0xae)}),_0x33b9b6['succeed'](_0x6939a4(0xce)+_0xd1855[_0x6939a4(0xdd)]),console['log'](a47_0x378bf7[_0x6939a4(0xcb)]('\x20\x20Restart\x20your\x20terminal\x20to\x20use\x20the\x20new\x20version.'));}catch(_0x5b0382){_0x33b9b6[_0x6939a4(0xec)](_0x6939a4(0xdc));throw CliErrors['apiError']('Update\x20failed:\x20'+(_0x5b0382 instanceof Error?_0x5b0382[_0x6939a4(0xef)]:String(_0x5b0382)),_0x6939a4(0xd1)+_0x451be4+_0x6939a4(0xb8)+NPM_PACKAGE_NAME+'@'+_0xd1855['version']);}return verifyUpdatedBuiltinSkill(_0xd1855[_0x6939a4(0xdd)]),{'ok':!![]};}export const updateDefinition={'service':a47_0x5bb842(0xb2),'command':a47_0x5bb842(0xf0),'description':a47_0x5bb842(0xaf),'risk':a47_0x5bb842(0xe4),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'flags':updateFlags,'validate':validateUpdateFlags,'execute':execute};
1
+ import chalk from"chalk";import ora from"ora";import semver from"semver";import{execa}from"execa";import{CLI_BIN_NAME,NPM_PACKAGE_NAME}from"../constant/cli.js";import{VERSION,GIT_COMMIT,BUILD_TIME}from"../generated/build-info.js";import{CliErrors}from"../errors.js";import{installBuiltinSkill}from"../skills/builtin-skill.js";import{installUpdatedBuiltinSkill}from"../skills/install-updated-skill.js";import{resolveNpmBin}from"../utils/platform.js";function getCurrentVersion(){return GIT_COMMIT!=="unknown"?`${VERSION} (${GIT_COMMIT}, ${BUILD_TIME.slice(0,10)})`:VERSION}function detectPackageManager(){const execPath=process.execPath.toLowerCase();if(execPath.includes("bun"))return"bun";return"npm"}const updateFlags=[{name:"beta",type:"boolean",description:"Install the version from npm beta dist-tag",default:false},{name:"version",type:"string",description:"Install a specific CLI version"}];function getRequestedVersion(ctx){return ctx.str("version").trim()}
2
+ async function validateUpdateFlags(ctx){const wantsBeta=ctx.bool("beta");const requestedVersion=getRequestedVersion(ctx);if(wantsBeta&&requestedVersion){throw CliErrors.validation("--beta and --version cannot be used together.","Choose either npm beta dist-tag or an exact version.")}if(requestedVersion&&!semver.valid(requestedVersion)){throw CliErrors.validation(`Invalid version: ${requestedVersion}`,"Use a full semver such as 2.1.6 or 2.1.6-beta.1.")}}async function fetchNpmDistTags(){try{const res=await fetch(`https://registry.npmjs.org/-/package/${encodeURIComponent(NPM_PACKAGE_NAME)}/dist-tags`,{signal:AbortSignal.timeout(1e4)});if(!res.ok)return null;const data=await res.json();if(!data||typeof data!=="object")return null;return Object.fromEntries(Object.entries(data).filter(([,value])=>typeof value==="string"&&value.trim().length>0).map(([key,value])=>[key,String(value).trim()]))}catch{return null}}async function fetchNpmDistTagVersion(tag){const tags=await fetchNpmDistTags()
3
+ ;return tags?.[tag]??null}async function fetchLatestVersion(){return fetchNpmDistTagVersion("latest")}async function resolveTargetVersion(ctx){const requestedVersion=getRequestedVersion(ctx);if(requestedVersion){return{version:requestedVersion,source:"version"}}if(ctx.bool("beta")){const betaVersion=await fetchNpmDistTagVersion("beta");if(!betaVersion)return null;return{version:betaVersion,source:"beta"}}const latestVersion=await fetchLatestVersion();if(!latestVersion)return null;return{version:latestVersion,source:"latest"}}function shouldInstallTarget(currentVersion,target){if(target.source==="version"||target.source==="beta"){return!semver.eq(currentVersion,target.version)}return semver.lt(currentVersion,target.version)}function getInstallPlanLabel(currentVersion,target){switch(target.source){case"beta":return`Beta version: ${chalk.yellow(currentVersion)} → ${chalk.green(target.version)}`;case"version":
4
+ return`Requested version: ${chalk.yellow(currentVersion)} → ${chalk.green(target.version)}`;case"latest":default:return`Update available: ${chalk.yellow(currentVersion)} → ${chalk.green(target.version)}`}}function repairCurrentBuiltinSkill(){console.log(chalk.gray("Checking CLI Built-in Skill..."));const result=installBuiltinSkill();if(result.ok){console.log(chalk.gray(` CLI Built-in Skill ${result.skillVersion} is up to date.`));return}throw CliErrors.apiError(`CLI Built-in Skill repair failed [${result.code}]: ${result.error||"unknown"}`,`Run: ${result.repairCommand}, then verify with: ${CLI_BIN_NAME} doctor`)}async function execute(ctx){await validateUpdateFlags(ctx);const currentVersion=getCurrentVersion();console.log(`Current version: ${currentVersion}`);const spinner=ora("Checking for updates...").start();const target=await resolveTargetVersion(ctx);if(!target){
5
+ const failureMessage=ctx.bool("beta")?"Unable to resolve beta version from npm":"Unable to check for updates (network error)";spinner.fail(failureMessage);throw CliErrors.apiError(failureMessage,`Try manually: npm install -g ${NPM_PACKAGE_NAME}@${ctx.bool("beta")?"beta":"latest"}`)}const currentSemver=semver.valid(VERSION);const targetSemver=semver.valid(target.version);if(!currentSemver||!targetSemver){spinner.fail("Version comparison failed");throw CliErrors.apiError("Version comparison failed",`Check the CLI and npm versions, then retry: ${CLI_BIN_NAME} update --version <version>`)}if(!shouldInstallTarget(currentSemver,target)){const successMessage=target.source==="version"?`Already on requested version (v${target.version})`:semver.gt(currentSemver,targetSemver)?`Current version v${currentVersion} is newer than npm latest v${target.version}`:`Already up to date (v${target.version})`;repairCurrentBuiltinSkill();spinner.succeed(successMessage);return{ok:true}}
6
+ spinner.info(getInstallPlanLabel(currentVersion,target));const pm=detectPackageManager();const pmCmd=pm==="npm"?resolveNpmBin("npm"):pm;const installSpinner=ora(`Updating via ${pm}...`).start();try{await execa(pmCmd,["install","-g",`${NPM_PACKAGE_NAME}@${target.version}`],{stdio:"pipe"})}catch(err){installSpinner.fail("Update failed");throw CliErrors.apiError(`Update failed: ${err instanceof Error?err.message:String(err)}`,`Try manually: ${pm} install -g ${NPM_PACKAGE_NAME}@${target.version}`)}try{installUpdatedBuiltinSkill({version:target.version,packageManager:pm,packageManagerCommand:pmCmd})}catch(error){installSpinner.fail("CLI installed, but Built-in Skill installation failed");throw CliErrors.apiError(`CLI updated to v${target.version}, but Built-in Skill installation failed: ${error instanceof Error?error.message:String(error)}`,`Run: ${CLI_BIN_NAME} cli-skill install, then verify with: ${CLI_BIN_NAME} doctor`)}
7
+ installSpinner.succeed(`Updated CLI and Built-in Skill to v${target.version}`);console.log(chalk.gray(" Restart your terminal to use the new version."));return{ok:true}}export const updateDefinition={service:"update",command:"run",description:"Update rabetbase CLI to the latest version",risk:"read",requiresAuth:false,requiresAppCode:false,hasFormat:false,flags:updateFlags,validate:validateUpdateFlags,execute:execute};
@@ -1 +1 @@
1
- function a48_0x3b56(_0x56492f,_0x40af5e){_0x56492f=_0x56492f-0xb6;const _0x46fd33=a48_0x46fd();let _0x3b56dc=_0x46fd33[_0x56492f];return _0x3b56dc;}(function(_0x5910fe,_0x10a2f5){const _0xe65b61=a48_0x3b56,_0x1c8bda=_0x5910fe();while(!![]){try{const _0x420c15=-parseInt(_0xe65b61(0xbb))/0x1*(parseInt(_0xe65b61(0xb8))/0x2)+parseInt(_0xe65b61(0xbe))/0x3*(-parseInt(_0xe65b61(0xbf))/0x4)+parseInt(_0xe65b61(0xb6))/0x5*(-parseInt(_0xe65b61(0xb9))/0x6)+-parseInt(_0xe65b61(0xba))/0x7*(-parseInt(_0xe65b61(0xc0))/0x8)+-parseInt(_0xe65b61(0xb7))/0x9*(-parseInt(_0xe65b61(0xc1))/0xa)+parseInt(_0xe65b61(0xbc))/0xb+parseInt(_0xe65b61(0xbd))/0xc;if(_0x420c15===_0x10a2f5)break;else _0x1c8bda['push'](_0x1c8bda['shift']());}catch(_0x3d197c){_0x1c8bda['push'](_0x1c8bda['shift']());}}}(a48_0x46fd,0x62166));import{codegenSdk}from'../../commands/codegen/sdk.js';import{codegenSql}from'../../commands/codegen/sql.js';export const codegenDefinitions=[codegenSdk,codegenSql];function a48_0x46fd(){const _0x4e9c6a=['3094350ScqSZK','5jOzSpX','9PJVQhR','2QBWoNQ','2757912JRpUOj','252eAvhis','157159XxDynD','2546566YdsqpC','6766464ZXvfpN','16584YqwCmi','104tTAFKL','12776rizYuq'];a48_0x46fd=function(){return _0x4e9c6a;};return a48_0x46fd();}
1
+ import{codegenSdk}from"../../commands/codegen/sdk.js";import{codegenSql}from"../../commands/codegen/sql.js";export const codegenDefinitions=[codegenSdk,codegenSql];
@@ -1 +1 @@
1
- function a49_0x32ae(){const _0x340428=['read','9anpKIi','str','2QXufIB','bool','5856EtPIaw','1006192AaujNh','6969300djVdiv','code','tableName','boolean','operation','32VfysHS','appCode','72969kGYpZF','string','9306sASriK','skip-imports','Dataset\x20alias\x20defined\x20in\x20api.ts\x20(e.g.\x20order,\x20coupon)','Operation\x20name\x20(e.g.\x20filter,\x20getOne,\x20create,\x20update)','911125wWFPem','38826jqGzWG','12851470vNOzkQ','Generate\x20TypeScript\x20SDK\x20code\x20for\x20a\x20dataset\x20operation','1799zQJhaW','alias','sdk'];a49_0x32ae=function(){return _0x340428;};return a49_0x32ae();}const a49_0x543c25=a49_0x59c6;(function(_0x51d905,_0x1b6988){const _0x3922e4=a49_0x59c6,_0x25d29b=_0x51d905();while(!![]){try{const _0x11d116=-parseInt(_0x3922e4(0x16d))/0x1*(parseInt(_0x3922e4(0x177))/0x2)+parseInt(_0x3922e4(0x182))/0x3*(parseInt(_0x3922e4(0x180))/0x4)+parseInt(_0x3922e4(0x17b))/0x5+parseInt(_0x3922e4(0x16e))/0x6*(-parseInt(_0x3922e4(0x171))/0x7)+parseInt(_0x3922e4(0x17a))/0x8+parseInt(_0x3922e4(0x175))/0x9*(parseInt(_0x3922e4(0x16f))/0xa)+-parseInt(_0x3922e4(0x169))/0xb*(-parseInt(_0x3922e4(0x179))/0xc);if(_0x11d116===_0x1b6988)break;else _0x25d29b['push'](_0x25d29b['shift']());}catch(_0x875e42){_0x25d29b['push'](_0x25d29b['shift']());}}}(a49_0x32ae,0xcc999));import{getOperationDetail,generateSdkCode}from'../../core/api-client.js';function a49_0x59c6(_0xe19bbe,_0x1a5a0b){_0xe19bbe=_0xe19bbe-0x169;const _0x32aeae=a49_0x32ae();let _0x59c689=_0x32aeae[_0xe19bbe];return _0x59c689;}import{CODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';export const codegenSdk={'service':'codegen','command':a49_0x543c25(0x173),'description':a49_0x543c25(0x170),'risk':a49_0x543c25(0x174),'flags':[CODE_FLAG_OPTIONAL,{'name':a49_0x543c25(0x172),'type':a49_0x543c25(0x183),'description':a49_0x543c25(0x16b)},{'name':a49_0x543c25(0x17f),'type':a49_0x543c25(0x183),'required':!![],'description':a49_0x543c25(0x16c)},{'name':a49_0x543c25(0x16a),'type':a49_0x543c25(0x17e),'description':'Omit\x20import\x20statements\x20from\x20generated\x20code'}],async 'execute'(_0x132603){const _0x43e600=a49_0x543c25,{dataset:_0x2dd463,operation:_0x43fc8a}=await getOperationDetail(_0x132603[_0x43e600(0x181)],_0x132603[_0x43e600(0x176)](_0x43e600(0x17c)),_0x132603[_0x43e600(0x176)](_0x43e600(0x17f))),_0x20b792=generateSdkCode(_0x2dd463,_0x43fc8a,{'includeImports':!_0x132603[_0x43e600(0x178)]('skip-imports')});return{'ok':!![],'data':{'dataset':{'name':_0x2dd463['name'],'code':_0x2dd463[_0x43e600(0x17c)],'tableName':_0x2dd463[_0x43e600(0x17d)]},'operation':_0x132603[_0x43e600(0x176)](_0x43e600(0x17f)),'code':_0x20b792}};}};
1
+ import{getOperationDetail,generateSdkCode}from"../../core/api-client.js";import{CODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";export const codegenSdk={service:"codegen",command:"sdk",description:"Generate TypeScript SDK code for a dataset operation",risk:"read",flags:[CODE_FLAG_OPTIONAL,{name:"alias",type:"string",description:"Dataset alias defined in api.ts (e.g. order, coupon)"},{name:"operation",type:"string",required:true,description:"Operation name (e.g. filter, getOne, create, update)"},{name:"skip-imports",type:"boolean",description:"Omit import statements from generated code"}],async execute(ctx){const{dataset:dataset,operation:operation}=await getOperationDetail(ctx.appCode,ctx.str("code"),ctx.str("operation"));const code=generateSdkCode(dataset,operation,{includeImports:!ctx.bool("skip-imports")});return{ok:true,data:{dataset:{name:dataset.name,code:dataset.code,tableName:dataset.tableName},operation:ctx.str("operation"),code:code}}}};
@@ -1 +1 @@
1
- const a50_0x1e58f2=a50_0x49da;(function(_0x4453cf,_0x59c0f1){const _0x1da548=a50_0x49da,_0x5bf710=_0x4453cf();while(!![]){try{const _0x446d04=-parseInt(_0x1da548(0x118))/0x1*(parseInt(_0x1da548(0x10c))/0x2)+parseInt(_0x1da548(0x10a))/0x3+parseInt(_0x1da548(0x121))/0x4*(-parseInt(_0x1da548(0x112))/0x5)+-parseInt(_0x1da548(0x109))/0x6+-parseInt(_0x1da548(0x116))/0x7*(parseInt(_0x1da548(0x10f))/0x8)+-parseInt(_0x1da548(0x114))/0x9+parseInt(_0x1da548(0x113))/0xa*(parseInt(_0x1da548(0x10b))/0xb);if(_0x446d04===_0x59c0f1)break;else _0x5bf710['push'](_0x5bf710['shift']());}catch(_0x1c0665){_0x5bf710['push'](_0x5bf710['shift']());}}}(a50_0x1f21,0x39a85));function a50_0x49da(_0x270032,_0x2acc85){_0x270032=_0x270032-0x108;const _0x1f213b=a50_0x1f21();let _0x49da4f=_0x1f213b[_0x270032];return _0x49da4f;}import{getSqlQueryInfo,generateSqlCodeTemplate}from'../../core/api-client.js';function a50_0x1f21(){const _0x114be1=['appCode','Omit\x20import\x20statements\x20from\x20generated\x20code','string','no-imports','sqlCode','67444Qscucs','sdk','387576jDbuML','1383276nGJrAB','7794875SRAzzc','146WkRGkN','Generate\x20TypeScript\x20code\x20for\x20a\x20custom\x20SQL\x20query','boolean','152KHDMEm','bff','Code\x20target:\x20sdk\x20(default)\x20or\x20bff','55TnVeYz','10qbbdvE','3381543mTKtiA','read','50155LJJZdZ','codegen','2351oZxool','str','target','sqlcode'];a50_0x1f21=function(){return _0x114be1;};return a50_0x1f21();}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const codegenSql={'service':a50_0x1e58f2(0x117),'command':'sql','description':a50_0x1e58f2(0x10d),'risk':a50_0x1e58f2(0x115),'flags':[SQLCODE_FLAG,{'name':'target','type':a50_0x1e58f2(0x11e),'description':a50_0x1e58f2(0x111),'default':a50_0x1e58f2(0x108),'enum':[a50_0x1e58f2(0x108),a50_0x1e58f2(0x110)]},{'name':a50_0x1e58f2(0x11f),'type':a50_0x1e58f2(0x10e),'description':a50_0x1e58f2(0x11d)}],async 'execute'(_0x406e3f){const _0x5a9a18=a50_0x1e58f2,_0x3673ab=await getSqlQueryInfo(_0x406e3f[_0x5a9a18(0x11c)],_0x406e3f[_0x5a9a18(0x119)](_0x5a9a18(0x11b))),_0x170431=_0x406e3f[_0x5a9a18(0x119)](_0x5a9a18(0x11a))||'sdk',_0x58b2f3=generateSqlCodeTemplate(_0x3673ab,{'target':_0x170431,'includeImports':!_0x406e3f['bool']('no-imports')});return{'ok':!![],'data':{'sqlCode':_0x3673ab[_0x5a9a18(0x120)],'sqlName':_0x3673ab['sqlName'],'target':_0x170431,'code':_0x58b2f3}};}};
1
+ import{getSqlQueryInfo,generateSqlCodeTemplate}from"../../core/api-client.js";import{SQLCODE_FLAG}from"../../commands/common/flags.js";export const codegenSql={service:"codegen",command:"sql",description:"Generate TypeScript code for a custom SQL query",risk:"read",flags:[SQLCODE_FLAG,{name:"target",type:"string",description:"Code target: sdk (default) or bff",default:"sdk",enum:["sdk","bff"]},{name:"no-imports",type:"boolean",description:"Omit import statements from generated code"}],async execute(ctx){const sql=await getSqlQueryInfo(ctx.appCode,ctx.str("sqlcode"));const target=ctx.str("target")||"sdk";const code=generateSqlCodeTemplate(sql,{target:target,includeImports:!ctx.bool("no-imports")});return{ok:true,data:{sqlCode:sql.sqlCode,sqlName:sql.sqlName,target:target,code:code}}}};
@@ -1 +1,4 @@
1
- (function(_0x1059a5,_0x2326c3){const _0x4e781b=a51_0x367a,_0x144e88=_0x1059a5();while(!![]){try{const _0xd3ba57=parseInt(_0x4e781b(0x11e))/0x1+parseInt(_0x4e781b(0x100))/0x2*(parseInt(_0x4e781b(0x117))/0x3)+parseInt(_0x4e781b(0x107))/0x4+-parseInt(_0x4e781b(0x11b))/0x5*(-parseInt(_0x4e781b(0x104))/0x6)+parseInt(_0x4e781b(0x125))/0x7*(parseInt(_0x4e781b(0x103))/0x8)+-parseInt(_0x4e781b(0x108))/0x9*(parseInt(_0x4e781b(0x10d))/0xa)+-parseInt(_0x4e781b(0x129))/0xb;if(_0xd3ba57===_0x2326c3)break;else _0x144e88['push'](_0x144e88['shift']());}catch(_0x2c51e9){_0x144e88['push'](_0x144e88['shift']());}}}(a51_0x150a,0xb67d6));import{CliErrors}from'../../errors.js';import{CLI_BIN_NAME}from'../../constant/cli.js';import{collectAppProfileOverrides,getAppProfileFlagDefs,normalizeStoredDefaultApp}from'../../config/schema.js';import{readRawConfigWithLayers}from'../../context.js';import{readConfig,writeConfig,scopeLabel,resolveAppScopeForWrite,appDefinedIn}from'../../commands/app/shared.js';export function buildAppAddFlags(){const _0x1494b5=a51_0x367a;return[{'name':'appcode','type':_0x1494b5(0x112),'description':_0x1494b5(0x128),'required':!![]},{'name':_0x1494b5(0x116),'type':_0x1494b5(0x11a),'description':_0x1494b5(0x11c),'default':![]},...getAppProfileFlagDefs()];}function a51_0x367a(_0x5752e6,_0x1a7e62){_0x5752e6=_0x5752e6-0x100;const _0x150ab2=a51_0x150a();let _0x367aa0=_0x150ab2[_0x5752e6];return _0x367aa0;}export function buildAppRemoveFlags(){const _0xcebb91=a51_0x367a;return[{'name':_0xcebb91(0x116),'type':_0xcebb91(0x11a),'description':'Use\x20global\x20config\x20scope','default':![]}];}function a51_0x150a(){const _0x4f2023=['apps','329791uxauxT','\x22\x20not\x20found.','appcode','App\x20code','28233315eKniaZ','length','args','2DPrmCH','Usage:\x20','\x22\x20(appcode:\x20','16imXcNa','162QjqhvA','str','project','5256004EfEIYp','27MZBnYY','\x22\x20is\x20selected\x20automatically.','defaultApp','validation','\x20<name>\x20--appcode\x20<code>','2869450eHOgSt','\x20Note:\x20app\x20\x22','bool','trim','\x20<name>','string','\x20<name>\x20[--global]','App\x20\x22','globalConfig','global','3290343JEPfUx','\x20Remaining\x20app\x20\x22','\x20Default\x20app\x20changed\x20to\x20\x22','boolean','59525hSOnpW','Use\x20global\x20config\x20scope','projectConfig','1348535hvSnee','keys','Updated','flagMissing','\x22\x20still\x20defined\x20in\x20','object'];a51_0x150a=function(){return _0x4f2023;};return a51_0x150a();}export async function validateAppName(_0x3ab488,_0x2bfe69){const _0x28cc32=a51_0x367a,_0x255154=_0x3ab488['args'][0x0]?.[_0x28cc32(0x110)]();if(!_0x255154)throw CliErrors[_0x28cc32(0x10b)]('Missing\x20app\x20name.',_0x28cc32(0x101)+CLI_BIN_NAME+'\x20'+_0x2bfe69+_0x28cc32(0x111));}export async function runAppAdd(_0x504da3,_0x59285b){const _0x2d94ba=a51_0x367a,_0xfe559a=_0x504da3[_0x2d94ba(0x12b)][0x0]?.[_0x2d94ba(0x110)]();if(!_0xfe559a)throw CliErrors[_0x2d94ba(0x10b)]('Missing\x20app\x20name.',_0x2d94ba(0x101)+CLI_BIN_NAME+'\x20'+_0x59285b+_0x2d94ba(0x10c));const _0x5a8c2d=_0x504da3['str'](_0x2d94ba(0x127));if(!_0x5a8c2d)throw CliErrors[_0x2d94ba(0x121)]('appcode','Usage:\x20'+CLI_BIN_NAME+'\x20'+_0x59285b+_0x2d94ba(0x10c));const _0x377a23={'global':_0x504da3[_0x2d94ba(0x10f)](_0x2d94ba(0x116))},_0x271da4=readConfig(_0x377a23);if(!_0x271da4[_0x2d94ba(0x124)])_0x271da4[_0x2d94ba(0x124)]={};const _0x224a4a={'appcode':_0x5a8c2d,...collectAppProfileOverrides(_0x3fe1b6=>_0x504da3[_0x2d94ba(0x105)](_0x3fe1b6))},_0x474632=_0x271da4[_0x2d94ba(0x124)],_0x48feb6=Object[_0x2d94ba(0x11f)](_0x474632),_0xd8e2b5=typeof _0x271da4[_0x2d94ba(0x10a)]===_0x2d94ba(0x112)&&_0x474632[_0x271da4[_0x2d94ba(0x10a)]]?_0x271da4['defaultApp']:_0x48feb6[_0x2d94ba(0x12a)]===0x1?_0x48feb6[0x0]:undefined,_0x414874=!!_0x474632[_0xfe559a];_0x474632[_0xfe559a]=_0x224a4a;const _0x12abfd=normalizeStoredDefaultApp(_0x271da4,_0xd8e2b5);writeConfig(_0x271da4,_0x377a23);const _0x116f25=!_0x414874&&_0x12abfd?'\x20Default\x20app\x20is\x20\x22'+_0x12abfd+'\x22.':'',_0x1512f5=(_0x414874?_0x2d94ba(0x120):'Added')+'\x20app\x20\x22'+_0xfe559a+_0x2d94ba(0x102)+_0x5a8c2d+')'+scopeLabel(_0x377a23)+'.'+_0x116f25;return{'ok':!![],'message':_0x1512f5};}export async function runAppRemove(_0x1bcb01,_0x574a43){const _0x2658ca=a51_0x367a,_0x1a4737=_0x1bcb01[_0x2658ca(0x12b)][0x0]?.[_0x2658ca(0x110)]();if(!_0x1a4737)throw CliErrors['validation']('Missing\x20app\x20name.','Usage:\x20'+CLI_BIN_NAME+'\x20'+_0x574a43+_0x2658ca(0x113));const _0x2b09b5=_0x1bcb01[_0x2658ca(0x10f)]('global'),{config:_0x426c63,layers:_0xdbad76}=readRawConfigWithLayers(),_0x1684ec=_0x426c63[_0x2658ca(0x124)]??{};if(!_0x1684ec[_0x1a4737])throw CliErrors[_0x2658ca(0x10b)](_0x2658ca(0x114)+_0x1a4737+_0x2658ca(0x126));const _0x40a9ce=_0xdbad76[_0x2658ca(0x115)]['apps']&&typeof _0xdbad76[_0x2658ca(0x115)][_0x2658ca(0x124)]===_0x2658ca(0x123)?_0xdbad76[_0x2658ca(0x115)][_0x2658ca(0x124)]:{},_0x53ee2d=_0xdbad76[_0x2658ca(0x11d)][_0x2658ca(0x124)]&&typeof _0xdbad76[_0x2658ca(0x11d)][_0x2658ca(0x124)]===_0x2658ca(0x123)?_0xdbad76[_0x2658ca(0x11d)][_0x2658ca(0x124)]:{},_0x788ccf=appDefinedIn(_0x1a4737,_0x40a9ce,_0x53ee2d),_0x31e077=resolveAppScopeForWrite(_0x1a4737,_0x2b09b5,_0xdbad76),_0x262067={'global':_0x31e077===_0x2658ca(0x116)},_0x53655a=readConfig(_0x262067),_0x452ace=_0x53655a[_0x2658ca(0x124)];if(!_0x452ace||!_0x452ace[_0x1a4737])throw CliErrors[_0x2658ca(0x10b)](_0x2658ca(0x114)+_0x1a4737+_0x2658ca(0x126));delete _0x452ace[_0x1a4737];let _0x11c297='';const _0x4b3ae2=typeof _0x53655a[_0x2658ca(0x10a)]===_0x2658ca(0x112)?_0x53655a[_0x2658ca(0x10a)]:undefined,_0x25ab58=Object[_0x2658ca(0x11f)](_0x452ace),_0x594eaa=_0x4b3ae2===_0x1a4737?_0x25ab58[0x0]:_0x4b3ae2,_0xa3ab0f=normalizeStoredDefaultApp(_0x53655a,_0x594eaa);if(_0x4b3ae2===_0x1a4737&&_0x25ab58[_0x2658ca(0x12a)]===0x1)_0x11c297=_0x2658ca(0x118)+_0x25ab58[0x0]+_0x2658ca(0x109);else _0x4b3ae2===_0x1a4737&&_0xa3ab0f&&(_0x11c297=_0x2658ca(0x119)+_0xa3ab0f+'\x22.');Object[_0x2658ca(0x11f)](_0x452ace)['length']===0x0&&(delete _0x53655a['apps'],delete _0x53655a[_0x2658ca(0x10a)]);writeConfig(_0x53655a,_0x262067);const _0x517714=_0x788ccf==='both'?_0x2658ca(0x10e)+_0x1a4737+_0x2658ca(0x122)+(_0x31e077==='project'?_0x2658ca(0x116):_0x2658ca(0x106))+'\x20config.':'';return{'ok':!![],'message':'Removed\x20app\x20\x22'+_0x1a4737+'\x22'+scopeLabel(_0x262067)+'.'+_0x11c297+_0x517714};}
1
+ import{CliErrors}from"../../errors.js";import{CLI_BIN_NAME}from"../../constant/cli.js";import{collectAppProfileOverrides,getAppProfileFlagDefs,normalizeStoredDefaultApp}from"../../config/schema.js";import{readRawConfigWithLayers}from"../../context.js";import{readConfig,writeConfig,scopeLabel,resolveAppScopeForWrite,appDefinedIn}from"../../commands/app/shared.js";export function buildAppAddFlags(){return[{name:"appcode",type:"string",description:"App code",required:true},{name:"global",type:"boolean",description:"Use global config scope",default:false},...getAppProfileFlagDefs()]}export function buildAppRemoveFlags(){return[{name:"global",type:"boolean",description:"Use global config scope",default:false}]}export async function validateAppName(ctx,usageCmd){const name=ctx.args[0]?.trim();if(!name){throw CliErrors.validation("Missing app name.",`Usage: ${CLI_BIN_NAME} ${usageCmd} <name>`)}}export async function runAppAdd(ctx,usageCmd){const name=ctx.args[0]?.trim();if(!name){
2
+ throw CliErrors.validation("Missing app name.",`Usage: ${CLI_BIN_NAME} ${usageCmd} <name> --appcode <code>`)}const appcode=ctx.str("appcode");if(!appcode){throw CliErrors.flagMissing("appcode",`Usage: ${CLI_BIN_NAME} ${usageCmd} <name> --appcode <code>`)}const flags={global:ctx.bool("global")};const config=readConfig(flags);if(!config.apps)config.apps={};const profile={appcode:appcode,...collectAppProfileOverrides(flagName=>ctx.str(flagName))};const apps=config.apps;const previousNames=Object.keys(apps);const previousSelection=typeof config.defaultApp==="string"&&apps[config.defaultApp]?config.defaultApp:previousNames.length===1?previousNames[0]:undefined;const isUpdate=!!apps[name];apps[name]=profile;const storedDefault=normalizeStoredDefaultApp(config,previousSelection);writeConfig(config,flags);const extraMsg=!isUpdate&&storedDefault?` Default app is "${storedDefault}".`:""
3
+ ;const mainMsg=`${isUpdate?"Updated":"Added"} app "${name}" (appcode: ${appcode})${scopeLabel(flags)}.${extraMsg}`;return{ok:true,message:mainMsg}}export async function runAppRemove(ctx,usageCmd){const name=ctx.args[0]?.trim();if(!name){throw CliErrors.validation("Missing app name.",`Usage: ${CLI_BIN_NAME} ${usageCmd} <name> [--global]`)}const explicitGlobal=ctx.bool("global");const{config:merged,layers:layers}=readRawConfigWithLayers();const mergedApps=merged.apps??{};if(!mergedApps[name]){throw CliErrors.validation(`App "${name}" not found.`)}const globalApps=layers.globalConfig.apps&&typeof layers.globalConfig.apps==="object"?layers.globalConfig.apps:{};const projectApps=layers.projectConfig.apps&&typeof layers.projectConfig.apps==="object"?layers.projectConfig.apps:{};const definedIn=appDefinedIn(name,globalApps,projectApps);const scope=resolveAppScopeForWrite(name,explicitGlobal,layers);const targetFlags={global:scope==="global"};const config=readConfig(targetFlags)
4
+ ;const apps=config.apps;if(!apps||!apps[name]){throw CliErrors.validation(`App "${name}" not found.`)}delete apps[name];let extraMsg="";const previousDefault=typeof config.defaultApp==="string"?config.defaultApp:undefined;const remaining=Object.keys(apps);const preferred=previousDefault===name?remaining[0]:previousDefault;const storedDefault=normalizeStoredDefaultApp(config,preferred);if(previousDefault===name&&remaining.length===1){extraMsg=` Remaining app "${remaining[0]}" is selected automatically.`}else if(previousDefault===name&&storedDefault){extraMsg=` Default app changed to "${storedDefault}".`}if(Object.keys(apps).length===0){delete config.apps;delete config.defaultApp}writeConfig(config,targetFlags);const stillExistsNote=definedIn==="both"?` Note: app "${name}" still defined in ${scope==="project"?"global":"project"} config.`:"";return{ok:true,message:`Removed app "${name}"${scopeLabel(targetFlags)}.${extraMsg}${stillExistsNote}`}}
@@ -1 +1,4 @@
1
- (function(_0x800b2b,_0xf13666){const _0x47a074=a52_0x55fb,_0x245a79=_0x800b2b();while(!![]){try{const _0x498c67=-parseInt(_0x47a074(0xc0))/0x1+parseInt(_0x47a074(0xc1))/0x2+parseInt(_0x47a074(0xb1))/0x3*(parseInt(_0x47a074(0xb6))/0x4)+-parseInt(_0x47a074(0xc4))/0x5*(-parseInt(_0x47a074(0xc8))/0x6)+-parseInt(_0x47a074(0xb0))/0x7+-parseInt(_0x47a074(0xb9))/0x8+parseInt(_0x47a074(0xbc))/0x9;if(_0x498c67===_0xf13666)break;else _0x245a79['push'](_0x245a79['shift']());}catch(_0x21c2f2){_0x245a79['push'](_0x245a79['shift']());}}}(a52_0x5a15,0xe2884));import{input,checkbox,select}from'@inquirer/prompts';import a52_0x548d01 from'chalk';import{validateAppcode}from'../../commands/common/validate.js';import{listRemoteApps}from'../../core/api-client.js';import{withActiveCookie}from'../../utils/with-active-cookie.js';function a52_0x55fb(_0x3694b4,_0x4c8c12){_0x3694b4=_0x3694b4-0xa7;const _0x5a1544=a52_0x5a15();let _0x55fb1f=_0x5a1544[_0x3694b4];return _0x55fb1f;}import{writeCliSideChannelLine}from'../../utils/write-cli-side-channel.js';export async function promptCustomAppcode(){const _0x23f4f2=a52_0x55fb,_0x54d5ac=await input({'message':'App\x20Code:','validate':_0x200711=>{const _0x5c8f18=a52_0x55fb,_0x35ea74=validateAppcode(_0x200711[_0x5c8f18(0xaf)]());return _0x35ea74[_0x5c8f18(0xc3)]||_0x35ea74[_0x5c8f18(0xb8)]||_0x5c8f18(0xb5);}});return _0x54d5ac[_0x23f4f2(0xaf)]();}export async function promptAppSelection(_0x160f56){const _0xac74e8=a52_0x55fb,_0x339991=[{'name':a52_0x548d01[_0xac74e8(0xc2)](_0xac74e8(0xac)),'value':-0x1},..._0x160f56[_0xac74e8(0xcb)]((_0x29656b,_0x269f2f)=>({'name':_0x29656b[_0xac74e8(0xca)]+'\x20\x20'+a52_0x548d01['gray']('('+_0x29656b[_0xac74e8(0xb3)]+')'),'value':_0x269f2f}))],_0x40fdf1=await checkbox({'message':_0xac74e8(0xa9)+a52_0x548d01[_0xac74e8(0xbe)](_0x160f56['length'])+_0xac74e8(0xc9),'choices':_0x339991,'loop':![]});if(_0x40fdf1[_0xac74e8(0xaa)](-0x1))return _0xac74e8(0xcc);if(_0x40fdf1[_0xac74e8(0xbd)]===0x0)return'custom';return _0x40fdf1[_0xac74e8(0xcb)](_0x45be76=>_0x160f56[_0x45be76]);}export async function promptSingleAppSelection(_0x4e4216){const _0xc7b3e9=a52_0x55fb,_0x42ba8e=[{'name':a52_0x548d01['gray'](_0xc7b3e9(0xa7)),'value':_0xc7b3e9(0xbb)},{'name':a52_0x548d01[_0xc7b3e9(0xc2)]('✎\x20Enter\x20appcode\x20manually'),'value':_0xc7b3e9(0xcc)},..._0x4e4216[_0xc7b3e9(0xcb)](_0x3f1207=>({'name':_0x3f1207[_0xc7b3e9(0xca)]+'\x20\x20'+a52_0x548d01['gray']('('+_0x3f1207[_0xc7b3e9(0xb3)]+')'),'value':_0x3f1207[_0xc7b3e9(0xb3)]}))],_0x55b40a=await select({'message':_0xc7b3e9(0xab),'choices':_0x42ba8e});if(_0x55b40a===_0xc7b3e9(0xbb))return _0xc7b3e9(0xbb);if(_0x55b40a===_0xc7b3e9(0xcc))return'custom';return _0x4e4216[_0xc7b3e9(0xb2)](_0x3add34=>_0x3add34[_0xc7b3e9(0xb3)]===_0x55b40a);}function a52_0x5a15(){const _0x3eeed2=['find','appCode','\x0aCould\x20not\x20fetch\x20the\x20remote\x20app\x20list.\x20Enter\x20an\x20App\x20Code\x20manually.','Invalid\x20App\x20Code','18092FOOfve','Fetching\x20available\x20apps...','message','10060440efUVlP','✎\x20Enter\x20manually','skip','20467098OPKizQ','length','cyan','App\x20Code:','1628723pluGJy','1208112dddmNR','yellow','valid','1037725XLzHUg','No\x20available\x20apps\x20found.','Could\x20not\x20fetch\x20the\x20remote\x20app\x20list.\x20Enter\x20an\x20App\x20Code\x20manually.','gray','12aSBAIB','\x20apps.\x20Select\x20with\x20space,\x20a=all,\x20i=invert:','appName','map','custom','(Skip;\x20configure\x20later\x20with\x20config\x20set\x20appcode)','(No\x20login\x20session.\x20Enter\x20an\x20App\x20Code\x20manually\x20or\x20skip.)','Found\x20','includes','Select\x20the\x20app\x20to\x20bind:','✎\x20Enter\x20appcode\x20manually','\x20\x20(','manual','trim','3857455CFANex','711NUCORs'];a52_0x5a15=function(){return _0x3eeed2;};return a52_0x5a15();}export async function selectSingleAppcode(_0x142f6c){const _0x2a3fd6=a52_0x55fb;if(!_0x142f6c)return writeCliSideChannelLine(a52_0x548d01[_0x2a3fd6(0xc7)](_0x2a3fd6(0xa8))),_fallbackOrSkip();writeCliSideChannelLine('Fetching\x20available\x20apps...');let _0x15e614;try{_0x15e614=await withActiveCookie(_0x142f6c,()=>listRemoteApps());}catch(_0x533a8e){writeCliSideChannelLine(a52_0x548d01[_0x2a3fd6(0xc2)](_0x2a3fd6(0xc6)));if(_0x533a8e instanceof Error)writeCliSideChannelLine(a52_0x548d01[_0x2a3fd6(0xc7)]('\x20\x20('+_0x533a8e['message']+')'));return _fallbackOrSkip();}if(_0x15e614['length']===0x0)return writeCliSideChannelLine(a52_0x548d01[_0x2a3fd6(0xc2)](_0x2a3fd6(0xc5))),_fallbackOrSkip();const _0x458b6c=await promptSingleAppSelection(_0x15e614);if(_0x458b6c===_0x2a3fd6(0xbb))return'';if(_0x458b6c===_0x2a3fd6(0xcc))return promptCustomAppcode();return _0x458b6c['appCode'];}export async function selectMultipleApps(_0x53de7e){const _0x42f056=a52_0x55fb;writeCliSideChannelLine(_0x42f056(0xb7));let _0x5a7d09;try{_0x5a7d09=await withActiveCookie(_0x53de7e,()=>listRemoteApps());}catch(_0x16dc2b){writeCliSideChannelLine(_0x42f056(0xb4));if(_0x16dc2b instanceof Error)writeCliSideChannelLine(_0x42f056(0xad)+_0x16dc2b[_0x42f056(0xb8)]+')');return _0x42f056(0xcc);}if(_0x5a7d09[_0x42f056(0xbd)]===0x0)return writeCliSideChannelLine('\x0aNo\x20available\x20apps\x20found.'),_0x42f056(0xcc);return promptAppSelection(_0x5a7d09);}async function _fallbackOrSkip(){const _0x5cf878=a52_0x55fb,_0x3ae390=await select({'message':_0x5cf878(0xbf),'choices':[{'name':a52_0x548d01['gray']('(Skip;\x20configure\x20later)'),'value':_0x5cf878(0xbb)},{'name':a52_0x548d01[_0x5cf878(0xc2)](_0x5cf878(0xba)),'value':_0x5cf878(0xae)}]});if(_0x3ae390===_0x5cf878(0xbb))return'';return promptCustomAppcode();}
1
+ import{input,checkbox,select}from"@inquirer/prompts";import chalk from"chalk";import{validateAppcode}from"../../commands/common/validate.js";import{listRemoteApps}from"../../core/api-client.js";import{withActiveCookie}from"../../utils/with-active-cookie.js";import{writeCliSideChannelLine}from"../../utils/write-cli-side-channel.js";export async function promptCustomAppcode(){const code=await input({message:"App Code:",validate:value=>{const v=validateAppcode(value.trim());return v.valid||v.message||"Invalid App Code"}});return code.trim()}export async function promptAppSelection(apps){const choices=[{name:chalk.yellow("✎ Enter appcode manually"),value:-1},...apps.map((app,i)=>({name:`${app.appName} ${chalk.gray(`(${app.appCode})`)}`,value:i}))];const selected=await checkbox({message:`Found ${chalk.cyan(apps.length)} apps. Select with space, a=all, i=invert:`,choices:choices,loop:false});if(selected.includes(-1))return"custom";if(selected.length===0)return"custom"
2
+ ;return selected.map(i=>apps[i])}export async function promptSingleAppSelection(apps){const choices=[{name:chalk.gray("(Skip; configure later with config set appcode)"),value:"skip"},{name:chalk.yellow("✎ Enter appcode manually"),value:"custom"},...apps.map(app=>({name:`${app.appName} ${chalk.gray(`(${app.appCode})`)}`,value:app.appCode}))];const selected=await select({message:"Select the app to bind:",choices:choices});if(selected==="skip")return"skip";if(selected==="custom")return"custom";return apps.find(a=>a.appCode===selected)}export async function selectSingleAppcode(cookie){if(!cookie){writeCliSideChannelLine(chalk.gray("(No login session. Enter an App Code manually or skip.)"));return _fallbackOrSkip()}writeCliSideChannelLine("Fetching available apps...");let apps;try{apps=await withActiveCookie(cookie,()=>listRemoteApps())}catch(err){writeCliSideChannelLine(chalk.yellow("Could not fetch the remote app list. Enter an App Code manually."))
3
+ ;if(err instanceof Error)writeCliSideChannelLine(chalk.gray(` (${err.message})`));return _fallbackOrSkip()}if(apps.length===0){writeCliSideChannelLine(chalk.yellow("No available apps found."));return _fallbackOrSkip()}const result=await promptSingleAppSelection(apps);if(result==="skip")return"";if(result==="custom")return promptCustomAppcode();return result.appCode}export async function selectMultipleApps(cookie){writeCliSideChannelLine("Fetching available apps...");let apps;try{apps=await withActiveCookie(cookie,()=>listRemoteApps())}catch(err){writeCliSideChannelLine("\nCould not fetch the remote app list. Enter an App Code manually.");if(err instanceof Error)writeCliSideChannelLine(` (${err.message})`);return"custom"}if(apps.length===0){writeCliSideChannelLine("\nNo available apps found.");return"custom"}return promptAppSelection(apps)}async function _fallbackOrSkip(){const choice=await select({message:"App Code:",choices:[{name:chalk.gray("(Skip; configure later)"),value:"skip"
4
+ },{name:chalk.yellow("✎ Enter manually"),value:"manual"}]});if(choice==="skip")return"";return promptCustomAppcode()}
@@ -1 +1,2 @@
1
- const a53_0x37c8be=a53_0x471c;(function(_0x27358a,_0x4fffdb){const _0x2d7f71=a53_0x471c,_0x9063d8=_0x27358a();while(!![]){try{const _0x1d9abc=parseInt(_0x2d7f71(0x164))/0x1+parseInt(_0x2d7f71(0x16c))/0x2*(parseInt(_0x2d7f71(0x170))/0x3)+-parseInt(_0x2d7f71(0x15e))/0x4*(parseInt(_0x2d7f71(0x15d))/0x5)+parseInt(_0x2d7f71(0x16a))/0x6*(parseInt(_0x2d7f71(0x175))/0x7)+-parseInt(_0x2d7f71(0x171))/0x8*(-parseInt(_0x2d7f71(0x166))/0x9)+parseInt(_0x2d7f71(0x178))/0xa+-parseInt(_0x2d7f71(0x162))/0xb*(parseInt(_0x2d7f71(0x17c))/0xc);if(_0x1d9abc===_0x4fffdb)break;else _0x9063d8['push'](_0x9063d8['shift']());}catch(_0x3dc2c1){_0x9063d8['push'](_0x9063d8['shift']());}}}(a53_0x94a1,0xa6757));import{CLI_BIN_NAME}from'../../constant/cli.js';import{CliErrors}from'../../errors.js';const TERMINAL_STATUSES=new Set([a53_0x37c8be(0x17e),a53_0x37c8be(0x161)]),NON_TERMINAL_STATUSES=new Set([a53_0x37c8be(0x177),a53_0x37c8be(0x16b)]);export function normalizeAsyncTask(_0x3dcabe){const _0x3b7006=a53_0x37c8be,_0x55d3fc=typeof _0x3dcabe?.[_0x3b7006(0x17b)]==='string'?_0x3dcabe[_0x3b7006(0x17b)][_0x3b7006(0x16d)]():'';if(!_0x55d3fc)throw CliErrors[_0x3b7006(0x17d)]('Async\x20task\x20response\x20did\x20not\x20contain\x20a\x20taskId.');const _0x22c7a2=typeof _0x3dcabe[_0x3b7006(0x160)]==='string'?_0x3dcabe[_0x3b7006(0x160)][_0x3b7006(0x16d)]()['toUpperCase']():'';if(!_0x22c7a2)throw CliErrors[_0x3b7006(0x17d)](_0x3b7006(0x167)+_0x55d3fc+_0x3b7006(0x17f));return{'taskId':_0x55d3fc,'status':_0x22c7a2,'errorMessage':typeof _0x3dcabe['errorMessage']==='string'&&_0x3dcabe['errorMessage'][_0x3b7006(0x16d)]()?_0x3dcabe[_0x3b7006(0x163)]['trim']():null,'isTerminal':TERMINAL_STATUSES[_0x3b7006(0x15f)](_0x22c7a2),'knownStatus':TERMINAL_STATUSES[_0x3b7006(0x15f)](_0x22c7a2)||NON_TERMINAL_STATUSES[_0x3b7006(0x15f)](_0x22c7a2)};}export function buildAsyncTaskStatusCommand(_0x72af9c,_0x173683){const _0x28c369=a53_0x37c8be;return CLI_BIN_NAME+_0x28c369(0x179)+quoteShellArg(_0x72af9c)+_0x28c369(0x165)+quoteShellArg(_0x173683)+'\x20--format\x20compress';}function a53_0x471c(_0x3abd07,_0x106569){_0x3abd07=_0x3abd07-0x15d;const _0x94a15a=a53_0x94a1();let _0x471ccf=_0x94a15a[_0x3abd07];return _0x471ccf;}export function asyncTaskMessage(_0x29e8e8){const _0x3f3ee3=a53_0x37c8be;switch(_0x29e8e8['status']){case'PENDING':return _0x3f3ee3(0x168)+_0x29e8e8[_0x3f3ee3(0x17b)]+_0x3f3ee3(0x174);case _0x3f3ee3(0x16b):return'Task\x20'+_0x29e8e8[_0x3f3ee3(0x17b)]+_0x3f3ee3(0x176);case _0x3f3ee3(0x17e):return _0x3f3ee3(0x168)+_0x29e8e8[_0x3f3ee3(0x17b)]+_0x3f3ee3(0x172);case _0x3f3ee3(0x161):return _0x29e8e8[_0x3f3ee3(0x163)]?_0x3f3ee3(0x168)+_0x29e8e8[_0x3f3ee3(0x17b)]+_0x3f3ee3(0x173)+_0x29e8e8[_0x3f3ee3(0x163)]:'Task\x20'+_0x29e8e8[_0x3f3ee3(0x17b)]+_0x3f3ee3(0x16e);default:return'Task\x20'+_0x29e8e8[_0x3f3ee3(0x17b)]+_0x3f3ee3(0x16f)+_0x29e8e8[_0x3f3ee3(0x160)]+'.';}}function quoteShellArg(_0x4fcee7){const _0x4621aa=a53_0x37c8be;return'\x27'+_0x4fcee7[_0x4621aa(0x17a)](/'/g,_0x4621aa(0x169))+'\x27';}function a53_0x94a1(){const _0x186693=['\x20failed:\x20','\x20is\x20pending.','3066931PxjhxN','\x20is\x20processing.','PENDING','9024460eNtzGT','\x20task\x20status\x20--task-id\x20','replace','taskId','11709828AvKyQQ','apiError','SUCCESS','\x20response\x20did\x20not\x20contain\x20a\x20status.','6329515WlGURl','4aJZwie','has','status','FAILED','11ylklAI','errorMessage','1020116IilRyw','\x20--appcode\x20','32976ePTaNk','Async\x20task\x20','Task\x20','\x27\x5c\x27\x27','6bLGWux','PROCESSING','116WjnpxP','trim','\x20failed.','\x20returned\x20unknown\x20status\x20','12435bQqfEG','704QjVJUz','\x20completed\x20successfully.'];a53_0x94a1=function(){return _0x186693;};return a53_0x94a1();}
1
+ import{CLI_BIN_NAME}from"../../constant/cli.js";import{CliErrors}from"../../errors.js";const TERMINAL_STATUSES=new Set(["SUCCESS","FAILED"]);const NON_TERMINAL_STATUSES=new Set(["PENDING","PROCESSING"]);export function normalizeAsyncTask(task){const taskId=typeof task?.taskId==="string"?task.taskId.trim():"";if(!taskId){throw CliErrors.apiError("Async task response did not contain a taskId.")}const status=typeof task.status==="string"?task.status.trim().toUpperCase():"";if(!status){throw CliErrors.apiError(`Async task ${taskId} response did not contain a status.`)}return{taskId:taskId,status:status,errorMessage:typeof task.errorMessage==="string"&&task.errorMessage.trim()?task.errorMessage.trim():null,isTerminal:TERMINAL_STATUSES.has(status),knownStatus:TERMINAL_STATUSES.has(status)||NON_TERMINAL_STATUSES.has(status)}}export function buildAsyncTaskStatusCommand(taskId,appCode){
2
+ return`${CLI_BIN_NAME} task status --task-id ${quoteShellArg(taskId)} --appcode ${quoteShellArg(appCode)} --format compress`}export function asyncTaskMessage(task){switch(task.status){case"PENDING":return`Task ${task.taskId} is pending.`;case"PROCESSING":return`Task ${task.taskId} is processing.`;case"SUCCESS":return`Task ${task.taskId} completed successfully.`;case"FAILED":return task.errorMessage?`Task ${task.taskId} failed: ${task.errorMessage}`:`Task ${task.taskId} failed.`;default:return`Task ${task.taskId} returned unknown status ${task.status}.`}}function quoteShellArg(value){return`'${value.replace(/'/g,`'\\''`)}'`}
@@ -1 +1 @@
1
- (function(_0x4eb665,_0x1e6bf9){var _0xc29be2=a54_0x2f90,_0x27035b=_0x4eb665();while(!![]){try{var _0x41fd58=parseInt(_0xc29be2(0x83))/0x1+parseInt(_0xc29be2(0x84))/0x2+-parseInt(_0xc29be2(0x82))/0x3+parseInt(_0xc29be2(0x8b))/0x4*(-parseInt(_0xc29be2(0x8c))/0x5)+-parseInt(_0xc29be2(0x7f))/0x6+-parseInt(_0xc29be2(0x8a))/0x7*(parseInt(_0xc29be2(0x86))/0x8)+-parseInt(_0xc29be2(0x80))/0x9*(-parseInt(_0xc29be2(0x89))/0xa);if(_0x41fd58===_0x1e6bf9)break;else _0x27035b['push'](_0x27035b['shift']());}catch(_0x15ab6a){_0x27035b['push'](_0x27035b['shift']());}}}(a54_0x4725,0xe0f57));function a54_0x2f90(_0x37f223,_0x5d2984){_0x37f223=_0x37f223-0x7f;var _0x472538=a54_0x4725();var _0x2f90eb=_0x472538[_0x37f223];return _0x2f90eb;}export function asDryRunResult(_0x22ebf3,_0x39e04a){var _0x15762e=a54_0x2f90;return Object[_0x15762e(0x85)](_0x22ebf3,{'method':{'value':_0x39e04a[_0x15762e(0x88)],'enumerable':![]},'url':{'value':_0x39e04a[_0x15762e(0x81)],'enumerable':![]},..._0x39e04a['description']?{'description':{'value':_0x39e04a[_0x15762e(0x87)],'enumerable':![]}}:{}});}function a54_0x4725(){var _0x3e3838=['description','method','881730ZeFmjJ','7hlVCTQ','4NuBhOf','3765035qrClMB','3291774efclbv','126DwygUB','url','1414554KscGAW','791119gqQzZF','3643606stxAAg','defineProperties','9222072AzLUoH'];a54_0x4725=function(){return _0x3e3838;};return a54_0x4725();}
1
+ export function asDryRunResult(data,backend){return Object.defineProperties(data,{method:{value:backend.method,enumerable:false},url:{value:backend.url,enumerable:false},...backend.description?{description:{value:backend.description,enumerable:false}}:{}})}
@@ -1 +1,3 @@
1
- const a55_0x284042=a55_0x5e6c;function a55_0xc85f(){const _0x4611a9=['1564668jzNkIg','2098302AgtvMO','9034970vUqLdb','2568105xbRFkp','Source\x20field\x20name\x20used\x20to\x20locate\x20the\x20relation','MANY_TO_MANY','531055taNgFO','App\x20code\x20(overrides\x20config\x20file,\x20e.g.\x20app-xxxxx)','ONE_TO_MANY','2187258prOkjX','Relation\x20cardinality;\x20create\x20leaves\x20it\x20unset\x20when\x20omitted,\x20update\x20keeps\x20the\x20current\x20value','MYSQL','Source\x20database\x20connection\x20ID;\x20derived\x20from\x20the\x20source\x20dataset\x20when\x20omitted','datasetcode','from-datasetcode','SQL\x20code\x20identifier\x20(format:\x20xxxxxxxx-xxxxxxxx,\x20e.g.\x202305f915-dd48cd4c)','104eFUpUT','Source\x20DB_TABLE\x20dataset\x20code','15mEKSEA','Database\x20product\x20type','number','Dataset\x20code\x20(32-char\x20hex,\x20optionally\x20with\x20_xx_xx\x20suffix)','to-datasetcode','Write\x20to\x20the\x20global\x20configuration','from-column','global','Skip\x20testing\x20the\x20unsaved\x20database\x20configuration\x20before\x20create/update','string','Target\x20display\x20field;\x20create\x20defaults\x20to\x20the\x20target\x20field,\x20update\x20keeps\x20the\x20current\x20value','ONE_TO_ONE','Target\x20field\x20name','MANY_TO_ONE','sqlcode','App\x20code\x20(e.g.\x20app-xxxxx)','skip-connection-test','788038NqVCix','appcode','Target\x20DB_TABLE\x20dataset\x20code','4IWsSBu','boolean'];a55_0xc85f=function(){return _0x4611a9;};return a55_0xc85f();}(function(_0x4a260a,_0x2fc4d2){const _0x122cbd=a55_0x5e6c,_0x2ffb07=_0x4a260a();while(!![]){try{const _0x4b3215=-parseInt(_0x122cbd(0x14d))/0x1+parseInt(_0x122cbd(0x152))/0x2+-parseInt(_0x122cbd(0x153))/0x3*(parseInt(_0x122cbd(0x150))/0x4)+parseInt(_0x122cbd(0x164))/0x5*(parseInt(_0x122cbd(0x15b))/0x6)+-parseInt(_0x122cbd(0x158))/0x7*(-parseInt(_0x122cbd(0x162))/0x8)+parseInt(_0x122cbd(0x155))/0x9+-parseInt(_0x122cbd(0x154))/0xa;if(_0x4b3215===_0x2fc4d2)break;else _0x2ffb07['push'](_0x2ffb07['shift']());}catch(_0x51e15d){_0x2ffb07['push'](_0x2ffb07['shift']());}}}(a55_0xc85f,0xb8b68));export const CROSS_RELATION_FROM_DATASET_FLAG={'name':a55_0x284042(0x160),'type':a55_0x284042(0x16d),'required':!![],'description':a55_0x284042(0x163)};export const CROSS_RELATION_FROM_COLUMN_FLAG={'name':a55_0x284042(0x16a),'type':a55_0x284042(0x16d),'required':!![],'description':a55_0x284042(0x156)};export const CROSS_RELATION_TO_DATASET_FLAG={'name':a55_0x284042(0x168),'type':'string','required':!![],'description':a55_0x284042(0x14f)};export const CROSS_RELATION_TO_COLUMN_FLAG={'name':'to-column','type':a55_0x284042(0x16d),'required':!![],'description':a55_0x284042(0x170)};export const CROSS_RELATION_DBLINK_FLAG={'name':'from-dblink-id','type':'number','description':a55_0x284042(0x15e)};export const CROSS_RELATION_LABEL_FLAG={'name':'to-label-column','type':a55_0x284042(0x16d),'description':a55_0x284042(0x16e)};export const CROSS_RELATION_CARDINALITY_FLAG={'name':'cardinality','type':'string','enum':[a55_0x284042(0x16f),a55_0x284042(0x15a),a55_0x284042(0x171),a55_0x284042(0x157)],'description':a55_0x284042(0x15c)};export const GLOBAL_SCOPE_FLAG={'name':a55_0x284042(0x16b),'type':a55_0x284042(0x151),'default':![],'description':a55_0x284042(0x169)};function a55_0x5e6c(_0x205fe5,_0xde5541){_0x205fe5=_0x205fe5-0x14b;const _0xc85f3b=a55_0xc85f();let _0x5e6cd4=_0xc85f3b[_0x205fe5];return _0x5e6cd4;}export const DATASET_CODE_PATTERN={'regex':/^[a-f0-9]{32}(?:_[^_\s]+_[^_\s]+)?$/i,'description':'a\x2032-character\x20hex\x20code,\x20optionally\x20with\x20`_xx_xx`\x20suffix\x20(e.g.\x2099a909313f1fa7153186431e1c551588\x20or\x2099a909313f1fa7153186431e1c551588_75_3c7120aa)'};export const CODE_FLAG={'name':'code','type':a55_0x284042(0x16d),'required':!![],'description':a55_0x284042(0x167),'pattern':DATASET_CODE_PATTERN};export const CODE_FLAG_OPTIONAL={...CODE_FLAG,'required':![]};export const DATASETCODE_FLAG_OPTIONAL={...CODE_FLAG_OPTIONAL,'name':a55_0x284042(0x15f),'description':a55_0x284042(0x167)};export const SQLCODE_FLAG={'name':a55_0x284042(0x172),'type':a55_0x284042(0x16d),'required':!![],'description':a55_0x284042(0x161),'pattern':{'regex':/^[a-f0-9]{8}-[a-f0-9]{8}$/i,'description':'SQL\x20code\x20in\x20format\x20xxxxxxxx-xxxxxxxx\x20(e.g.\x202305f915-dd48cd4c)'}};export const APPCODE_FLAG_OPTIONAL={'name':a55_0x284042(0x14e),'type':'string','required':![],'description':a55_0x284042(0x159)};export const APPCODE_FLAG={...APPCODE_FLAG_OPTIONAL,'required':!![],'description':a55_0x284042(0x14b)};export const SQLCODE_FLAG_OPTIONAL={...SQLCODE_FLAG,'required':![]};export const DBLINK_ID_FLAG={'name':'id','type':a55_0x284042(0x166),'required':!![],'description':'Database\x20connection\x20ID\x20(dblink\x20id\x20from\x20db\x20list)'};export const DB_TYPE_FLAG={'name':'dbtype','type':a55_0x284042(0x16d),'required':!![],'description':a55_0x284042(0x165),'enum':[a55_0x284042(0x15d),'POSTGRESQL']};export const SKIP_CONNECTION_TEST_FLAG={'name':a55_0x284042(0x14c),'type':a55_0x284042(0x151),'description':a55_0x284042(0x16c)};
1
+ export const CROSS_RELATION_FROM_DATASET_FLAG={name:"from-datasetcode",type:"string",required:true,description:"Source DB_TABLE dataset code"};export const CROSS_RELATION_FROM_COLUMN_FLAG={name:"from-column",type:"string",required:true,description:"Source field name used to locate the relation"};export const CROSS_RELATION_TO_DATASET_FLAG={name:"to-datasetcode",type:"string",required:true,description:"Target DB_TABLE dataset code"};export const CROSS_RELATION_TO_COLUMN_FLAG={name:"to-column",type:"string",required:true,description:"Target field name"};export const CROSS_RELATION_DBLINK_FLAG={name:"from-dblink-id",type:"number",description:"Source database connection ID; derived from the source dataset when omitted"};export const CROSS_RELATION_LABEL_FLAG={name:"to-label-column",type:"string",description:"Target display field; create defaults to the target field, update keeps the current value"};export const CROSS_RELATION_CARDINALITY_FLAG={name:"cardinality",type:"string",
2
+ enum:["ONE_TO_ONE","ONE_TO_MANY","MANY_TO_ONE","MANY_TO_MANY"],description:"Relation cardinality; create leaves it unset when omitted, update keeps the current value"};export const GLOBAL_SCOPE_FLAG={name:"global",type:"boolean",default:false,description:"Write to the global configuration"};export const DATASET_CODE_PATTERN={regex:/^[a-f0-9]{32}(?:_[^_\s]+_[^_\s]+)?$/i,description:"a 32-character hex code, optionally with `_xx_xx` suffix (e.g. 99a909313f1fa7153186431e1c551588 or 99a909313f1fa7153186431e1c551588_75_3c7120aa)"};export const CODE_FLAG={name:"code",type:"string",required:true,description:"Dataset code (32-char hex, optionally with _xx_xx suffix)",pattern:DATASET_CODE_PATTERN};export const CODE_FLAG_OPTIONAL={...CODE_FLAG,required:false};export const DATASETCODE_FLAG_OPTIONAL={...CODE_FLAG_OPTIONAL,name:"datasetcode",description:"Dataset code (32-char hex, optionally with _xx_xx suffix)"};export const SQLCODE_FLAG={name:"sqlcode",type:"string",required:true,
3
+ description:"SQL code identifier (format: xxxxxxxx-xxxxxxxx, e.g. 2305f915-dd48cd4c)",pattern:{regex:/^[a-f0-9]{8}-[a-f0-9]{8}$/i,description:"SQL code in format xxxxxxxx-xxxxxxxx (e.g. 2305f915-dd48cd4c)"}};export const APPCODE_FLAG_OPTIONAL={name:"appcode",type:"string",required:false,description:"App code (overrides config file, e.g. app-xxxxx)"};export const APPCODE_FLAG={...APPCODE_FLAG_OPTIONAL,required:true,description:"App code (e.g. app-xxxxx)"};export const SQLCODE_FLAG_OPTIONAL={...SQLCODE_FLAG,required:false};export const DBLINK_ID_FLAG={name:"id",type:"number",required:true,description:"Database connection ID (dblink id from db list)"};export const DB_TYPE_FLAG={name:"dbtype",type:"string",required:true,description:"Database product type",enum:["MYSQL","POSTGRESQL"]};export const SKIP_CONNECTION_TEST_FLAG={name:"skip-connection-test",type:"boolean",description:"Skip testing the unsaved database configuration before create/update"};
@@ -1 +1 @@
1
- function a56_0x4935(_0x2d0860,_0x42bce1){_0x2d0860=_0x2d0860-0x1af;const _0x50bd40=a56_0x50bd();let _0x493518=_0x50bd40[_0x2d0860];return _0x493518;}(function(_0x1d4a1b,_0x3a958c){const _0x38e724=a56_0x4935,_0x48dc75=_0x1d4a1b();while(!![]){try{const _0x1ffb04=-parseInt(_0x38e724(0x1b1))/0x1*(-parseInt(_0x38e724(0x1c0))/0x2)+parseInt(_0x38e724(0x1b8))/0x3+parseInt(_0x38e724(0x1b7))/0x4*(parseInt(_0x38e724(0x1b6))/0x5)+-parseInt(_0x38e724(0x1b0))/0x6+parseInt(_0x38e724(0x1ba))/0x7+-parseInt(_0x38e724(0x1bd))/0x8*(parseInt(_0x38e724(0x1b3))/0x9)+-parseInt(_0x38e724(0x1b5))/0xa;if(_0x1ffb04===_0x3a958c)break;else _0x48dc75['push'](_0x48dc75['shift']());}catch(_0x5e877e){_0x48dc75['push'](_0x48dc75['shift']());}}}(a56_0x50bd,0xe7812));import{existsSync,statSync}from'node:fs';import{CliErrors}from'../../errors.js';const BYTES_PER_MB=0x400*0x400;function a56_0x50bd(){const _0x3eb8a1=['toFixed','9441775vTFjxT','isFile','\x20path\x20is\x20required.','2504yhXyFX','size','trim','1294ZGqpsi','validation','File\x20not\x20found:\x20','11146728yNulss','837mcPtFM','\x20MB','7695XDvnsS','File\x20is\x20not\x20a\x20regular\x20file:\x20','5373410tjwpml','471995SUIYWN','28zgEyUl','3179487VCMEal'];a56_0x50bd=function(){return _0x3eb8a1;};return a56_0x50bd();}export const DEVELOPMENT_UPLOAD_MAX_BYTES=0x32*BYTES_PER_MB;function formatBytes(_0x58d653){const _0x2ae2eb=a56_0x4935;if(_0x58d653>=BYTES_PER_MB){const _0x399d68=Math['ceil'](_0x58d653/BYTES_PER_MB*0x64)/0x64;return _0x399d68[_0x2ae2eb(0x1b9)](0x2)+_0x2ae2eb(0x1b2);}return _0x58d653+'\x20B';}export function requireDevelopmentUploadFile(_0x3859dc,_0x8b5681){const _0x405a19=a56_0x4935,_0x496d06=_0x3859dc[_0x405a19(0x1bf)]();if(!_0x496d06)throw CliErrors[_0x405a19(0x1c1)](_0x8b5681+_0x405a19(0x1bc));if(!existsSync(_0x496d06))throw CliErrors[_0x405a19(0x1c1)](_0x405a19(0x1af)+_0x496d06);const _0x576830=statSync(_0x496d06);if(!_0x576830[_0x405a19(0x1bb)]())throw CliErrors['validation'](_0x405a19(0x1b4)+_0x496d06);if(_0x576830['size']>DEVELOPMENT_UPLOAD_MAX_BYTES)throw CliErrors[_0x405a19(0x1c1)]('File\x20exceeds\x20the\x20development\x20upload\x20limit\x20of\x2050\x20MB:\x20'+_0x496d06+'\x20('+formatBytes(_0x576830[_0x405a19(0x1be)])+')');return{'path':_0x496d06,'size':_0x576830[_0x405a19(0x1be)]};}
1
+ import{existsSync,statSync}from"node:fs";import{CliErrors}from"../../errors.js";const BYTES_PER_MB=1024*1024;export const DEVELOPMENT_UPLOAD_MAX_BYTES=50*BYTES_PER_MB;function formatBytes(bytes){if(bytes>=BYTES_PER_MB){const megabytes=Math.ceil(bytes/BYTES_PER_MB*100)/100;return`${megabytes.toFixed(2)} MB`}return`${bytes} B`}export function requireDevelopmentUploadFile(filePath,label){const normalized=filePath.trim();if(!normalized){throw CliErrors.validation(`${label} path is required.`)}if(!existsSync(normalized)){throw CliErrors.validation(`File not found: ${normalized}`)}const stats=statSync(normalized);if(!stats.isFile()){throw CliErrors.validation(`File is not a regular file: ${normalized}`)}if(stats.size>DEVELOPMENT_UPLOAD_MAX_BYTES){throw CliErrors.validation(`File exceeds the development upload limit of 50 MB: ${normalized} (${formatBytes(stats.size)})`)}return{path:normalized,size:stats.size}}