@lovrabet/rabetbase-cli 2.5.2-beta.2 → 2.5.2-beta.4

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 (354) hide show
  1. package/README.md +2 -2
  2. package/lib/api/api-doc.js +1 -1
  3. package/lib/api/fetch-model-list.js +1 -1
  4. package/lib/api/generate-api-file.js +1 -1
  5. package/lib/api/generate-sdk-config-file.js +1 -1
  6. package/lib/auth/auth-server-ui.js +1 -1
  7. package/lib/auth/auth-server.js +1 -1
  8. package/lib/auth/constant.js +1 -1
  9. package/lib/auth/get-cookie.js +1 -1
  10. package/lib/auth/get-session-user.js +1 -1
  11. package/lib/auth/is-session-valid.js +1 -1
  12. package/lib/auth/login-success-html.js +1 -1
  13. package/lib/auth/logout.js +1 -1
  14. package/lib/cli-flags.js +1 -1
  15. package/lib/cli.js +1 -1
  16. package/lib/commands/api/generate.js +1 -1
  17. package/lib/commands/api/index.js +1 -1
  18. package/lib/commands/api/list.js +1 -1
  19. package/lib/commands/api/pull.js +1 -1
  20. package/lib/commands/api/shared.js +1 -1
  21. package/lib/commands/app/index.js +1 -1
  22. package/lib/commands/app/list.js +1 -1
  23. package/lib/commands/app/members-list.js +1 -1
  24. package/lib/commands/app/remote-directory.js +1 -1
  25. package/lib/commands/app/shared.d.ts +1 -0
  26. package/lib/commands/app/shared.js +1 -1
  27. package/lib/commands/app-config/delete.js +1 -1
  28. package/lib/commands/app-config/get.js +1 -1
  29. package/lib/commands/app-config/index.js +1 -1
  30. package/lib/commands/app-config/list.js +1 -1
  31. package/lib/commands/app-config/set.js +1 -1
  32. package/lib/commands/app-config/shared.js +1 -1
  33. package/lib/commands/auth/index.js +1 -1
  34. package/lib/commands/bff/create.js +1 -1
  35. package/lib/commands/bff/delete.js +1 -1
  36. package/lib/commands/bff/detail.js +1 -1
  37. package/lib/commands/bff/index.js +1 -1
  38. package/lib/commands/bff/list.js +1 -1
  39. package/lib/commands/bff/pull.js +1 -1
  40. package/lib/commands/bff/push.js +1 -1
  41. package/lib/commands/bff/status.js +1 -1
  42. package/lib/commands/cli-skill/index.js +1 -1
  43. package/lib/commands/cli-update.js +1 -1
  44. package/lib/commands/codegen/index.js +1 -1
  45. package/lib/commands/codegen/sdk.js +1 -1
  46. package/lib/commands/codegen/sql.js +1 -1
  47. package/lib/commands/common/app-registry.js +1 -1
  48. package/lib/commands/common/app-selector.js +1 -1
  49. package/lib/commands/common/async-task.js +1 -1
  50. package/lib/commands/common/dry-run.js +1 -1
  51. package/lib/commands/common/flags.js +1 -1
  52. package/lib/commands/common/local-file.js +1 -1
  53. package/lib/commands/common/validate.js +1 -1
  54. package/lib/commands/config/delete.js +1 -1
  55. package/lib/commands/config/get.js +1 -1
  56. package/lib/commands/config/index.js +1 -1
  57. package/lib/commands/config/init.js +1 -1
  58. package/lib/commands/config/list.js +1 -1
  59. package/lib/commands/config/set.js +1 -1
  60. package/lib/commands/config/shared.js +1 -1
  61. package/lib/commands/dataset/business-group-update.js +1 -1
  62. package/lib/commands/dataset/business-groups.js +1 -1
  63. package/lib/commands/dataset/capability.js +1 -1
  64. package/lib/commands/dataset/delete.js +1 -1
  65. package/lib/commands/dataset/detail.js +1 -1
  66. package/lib/commands/dataset/extend-update.js +1 -1
  67. package/lib/commands/dataset/field-restore.js +1 -1
  68. package/lib/commands/dataset/field-update.js +1 -1
  69. package/lib/commands/dataset/generate.js +1 -1
  70. package/lib/commands/dataset/index.js +1 -1
  71. package/lib/commands/dataset/list.js +1 -1
  72. package/lib/commands/dataset/operations.js +1 -1
  73. package/lib/commands/dataset/relation-audit.js +1 -1
  74. package/lib/commands/dataset/relation-create.js +1 -1
  75. package/lib/commands/dataset/relation-delete.js +1 -1
  76. package/lib/commands/dataset/relation-shared.js +1 -1
  77. package/lib/commands/dataset/relation-update.js +1 -1
  78. package/lib/commands/dataset/relations.js +1 -1
  79. package/lib/commands/dataset/rename.js +1 -1
  80. package/lib/commands/dataset/restore.js +1 -1
  81. package/lib/commands/dataset/user-deleted-field-list.js +1 -1
  82. package/lib/commands/db/analysis-batching.js +1 -1
  83. package/lib/commands/db/analyze-batch-plan.js +1 -1
  84. package/lib/commands/db/analyze-cancel.js +1 -1
  85. package/lib/commands/db/analyze-start.js +1 -1
  86. package/lib/commands/db/analyze-status.js +1 -1
  87. package/lib/commands/db/create.js +1 -1
  88. package/lib/commands/db/delete.js +1 -1
  89. package/lib/commands/db/detail.js +1 -1
  90. package/lib/commands/db/diff-refresh-start.js +1 -1
  91. package/lib/commands/db/diff-refresh-status.js +1 -1
  92. package/lib/commands/db/diff.js +1 -1
  93. package/lib/commands/db/index.js +1 -1
  94. package/lib/commands/db/list.js +1 -1
  95. package/lib/commands/db/shared.js +1 -1
  96. package/lib/commands/db/table-diff-shared.js +1 -1
  97. package/lib/commands/db/tables.js +1 -1
  98. package/lib/commands/db/test.js +1 -1
  99. package/lib/commands/db/update.js +1 -1
  100. package/lib/commands/deployment/auto-sync.js +1 -1
  101. package/lib/commands/deployment/index.js +1 -1
  102. package/lib/commands/deployment/sync-all.js +1 -1
  103. package/lib/commands/deployment/sync-jobs.js +1 -1
  104. package/lib/commands/deployment/sync-status.js +1 -1
  105. package/lib/commands/deployment/sync.js +1 -1
  106. package/lib/commands/doctor.js +1 -1
  107. package/lib/commands/file/index.js +1 -1
  108. package/lib/commands/instant-api-policy/current.js +1 -1
  109. package/lib/commands/instant-api-policy/index.js +1 -1
  110. package/lib/commands/instant-api-policy/init.js +1 -1
  111. package/lib/commands/instant-api-policy/publish.js +1 -1
  112. package/lib/commands/instant-api-policy/pull.js +1 -1
  113. package/lib/commands/instant-api-policy/revision.js +1 -1
  114. package/lib/commands/instant-api-policy/revisions.js +1 -1
  115. package/lib/commands/instant-api-policy/rollback.js +1 -1
  116. package/lib/commands/instant-api-policy/shared.js +1 -1
  117. package/lib/commands/instant-api-policy/validate.js +1 -1
  118. package/lib/commands/issue/index.js +1 -1
  119. package/lib/commands/issue/nudge.js +1 -1
  120. package/lib/commands/issue/report.js +1 -1
  121. package/lib/commands/issue/shared.js +1 -1
  122. package/lib/commands/kb/create.js +1 -1
  123. package/lib/commands/kb/delete.js +1 -1
  124. package/lib/commands/kb/detail.js +1 -1
  125. package/lib/commands/kb/index.js +1 -1
  126. package/lib/commands/kb/list.js +1 -1
  127. package/lib/commands/kb/search.js +1 -1
  128. package/lib/commands/kb/shared.js +1 -1
  129. package/lib/commands/kb/update.js +1 -1
  130. package/lib/commands/logs/index.js +1 -1
  131. package/lib/commands/menu/asset-update.js +1 -1
  132. package/lib/commands/menu/delete.js +1 -1
  133. package/lib/commands/menu/external-link-create.js +1 -1
  134. package/lib/commands/menu/external-link-update.js +1 -1
  135. package/lib/commands/menu/group-create.js +1 -1
  136. package/lib/commands/menu/group-update.js +1 -1
  137. package/lib/commands/menu/index.js +1 -1
  138. package/lib/commands/menu/list.js +1 -1
  139. package/lib/commands/menu/move.js +1 -1
  140. package/lib/commands/menu/regroup-start.js +1 -1
  141. package/lib/commands/menu/rename.js +1 -1
  142. package/lib/commands/menu/shared/compare-table.js +1 -1
  143. package/lib/commands/menu/shared/delete-plan.js +1 -1
  144. package/lib/commands/menu/shared/facts.js +1 -1
  145. package/lib/commands/menu/shared/index.js +1 -1
  146. package/lib/commands/menu/shared/inquirer.js +1 -1
  147. package/lib/commands/menu/shared/local-pages.js +1 -1
  148. package/lib/commands/menu/shared/logic.js +1 -1
  149. package/lib/commands/menu/shared/mutations.js +1 -1
  150. package/lib/commands/menu/shared/service.js +1 -1
  151. package/lib/commands/menu/shared/sync-core.js +1 -1
  152. package/lib/commands/menu/shared/update-core.js +1 -1
  153. package/lib/commands/menu/shared/valid-url.js +1 -1
  154. package/lib/commands/menu/sync.js +1 -1
  155. package/lib/commands/menu/visibility-update.js +1 -1
  156. package/lib/commands/notification/config-create.js +1 -1
  157. package/lib/commands/notification/config-delete.js +1 -1
  158. package/lib/commands/notification/config-list.js +1 -1
  159. package/lib/commands/notification/config-update.js +1 -1
  160. package/lib/commands/notification/index.js +1 -1
  161. package/lib/commands/notification/shared.js +1 -1
  162. package/lib/commands/ocr/index.js +1 -1
  163. package/lib/commands/page/create.js +1 -1
  164. package/lib/commands/page/custom/detail.js +1 -1
  165. package/lib/commands/page/custom/list.js +1 -1
  166. package/lib/commands/page/custom/publish.js +1 -1
  167. package/lib/commands/page/custom/shared.d.ts +0 -8
  168. package/lib/commands/page/custom/shared.js +1 -1
  169. package/lib/commands/page/custom/syntax.js +1 -1
  170. package/lib/commands/page/custom/update.js +1 -1
  171. package/lib/commands/page/data-list-status.js +1 -1
  172. package/lib/commands/page/generate-start.js +1 -1
  173. package/lib/commands/page/generate-status.js +1 -1
  174. package/lib/commands/page/index.js +1 -1
  175. package/lib/commands/page/pull.js +1 -1
  176. package/lib/commands/page/push.js +1 -1
  177. package/lib/commands/page/relation-audit.js +1 -1
  178. package/lib/commands/page/restore.js +1 -1
  179. package/lib/commands/page/shared.js +1 -1
  180. package/lib/commands/page/sync.js +1 -1
  181. package/lib/commands/project/create/enhanced-guided-create.js +1 -1
  182. package/lib/commands/project/create/format-elapsed.js +1 -1
  183. package/lib/commands/project/create/main.js +1 -1
  184. package/lib/commands/project/create/materialize-project-template.js +1 -1
  185. package/lib/commands/project/create/project-name.js +1 -1
  186. package/lib/commands/project/create/project-template-archive.js +1 -1
  187. package/lib/commands/project/create/project-template-path.js +1 -1
  188. package/lib/commands/project/create/use-copy-project-template.js +1 -1
  189. package/lib/commands/project/create/use-format-code.js +1 -1
  190. package/lib/commands/project/create/use-install-dependencies.js +1 -1
  191. package/lib/commands/project/domain-routing-sync.js +1 -1
  192. package/lib/commands/project/index.js +1 -1
  193. package/lib/commands/project/upgrade.js +1 -1
  194. package/lib/commands/registry.js +1 -1
  195. package/lib/commands/role/delete.js +1 -1
  196. package/lib/commands/role/detail.js +1 -1
  197. package/lib/commands/role/index.js +1 -1
  198. package/lib/commands/role/list.js +1 -1
  199. package/lib/commands/role/shared.js +1 -1
  200. package/lib/commands/role/update.js +1 -1
  201. package/lib/commands/role/user-add.js +1 -1
  202. package/lib/commands/role/user-remove.js +1 -1
  203. package/lib/commands/role/user-resolve.js +1 -1
  204. package/lib/commands/rule/get.js +1 -1
  205. package/lib/commands/rule/index.js +1 -1
  206. package/lib/commands/rule/list.js +1 -1
  207. package/lib/commands/rule/set.js +1 -1
  208. package/lib/commands/rule/shared.js +1 -1
  209. package/lib/commands/run/index.d.ts +4 -0
  210. package/lib/commands/run/index.js +1 -1
  211. package/lib/commands/schema.js +1 -1
  212. package/lib/commands/sql/create.js +1 -1
  213. package/lib/commands/sql/delete.js +1 -1
  214. package/lib/commands/sql/detail.js +1 -1
  215. package/lib/commands/sql/exec.js +1 -1
  216. package/lib/commands/sql/index.js +1 -1
  217. package/lib/commands/sql/list.js +1 -1
  218. package/lib/commands/sql/pull.js +1 -1
  219. package/lib/commands/sql/push.js +1 -1
  220. package/lib/commands/sql/shared.js +1 -1
  221. package/lib/commands/sql/status.js +1 -1
  222. package/lib/commands/sql/validate.js +1 -1
  223. package/lib/commands/task/index.js +1 -1
  224. package/lib/commands/task/status.js +1 -1
  225. package/lib/commands/tenant/index.js +1 -1
  226. package/lib/commands/tenant/members-list.js +1 -1
  227. package/lib/commands/tenant/shared.js +1 -1
  228. package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
  229. package/lib/commands/user-account/index.js +1 -1
  230. package/lib/commands/workspace/add.js +1 -1
  231. package/lib/commands/workspace/index.js +1 -1
  232. package/lib/commands/workspace/remove.js +1 -1
  233. package/lib/config/domain-config.d.ts +3 -7
  234. package/lib/config/domain-config.js +1 -1
  235. package/lib/config/project-domain-routing.d.ts +5 -1
  236. package/lib/config/project-domain-routing.js +1 -1
  237. package/lib/config/schema.js +1 -1
  238. package/lib/constant/cdn.js +1 -1
  239. package/lib/constant/cli.js +1 -1
  240. package/lib/constant/defaults.js +1 -1
  241. package/lib/constant/domain.js +1 -1
  242. package/lib/constant/env.js +1 -1
  243. package/lib/constant/output.js +1 -1
  244. package/lib/constant/paths.js +1 -1
  245. package/lib/constant/region.js +1 -1
  246. package/lib/constant/risk.js +1 -1
  247. package/lib/constant/routing-profile.js +1 -1
  248. package/lib/context/app-resolver.js +1 -1
  249. package/lib/context/auth-resolver.js +1 -1
  250. package/lib/context/config-loader.js +1 -1
  251. package/lib/context.js +1 -1
  252. package/lib/core/alias-resolver.js +1 -1
  253. package/lib/core/api-client.d.ts +1 -26
  254. package/lib/core/api-client.js +1 -1
  255. package/lib/core/bff/config.js +1 -1
  256. package/lib/core/bff/file-system.js +1 -1
  257. package/lib/core/bff/hash.js +1 -1
  258. package/lib/core/bff/lock.js +1 -1
  259. package/lib/core/bff/utils.js +1 -1
  260. package/lib/core/db-resolver.js +1 -1
  261. package/lib/core/instant-api-policy/config.js +1 -1
  262. package/lib/core/kb-search-client.js +1 -1
  263. package/lib/core/page/file-system.d.ts +43 -0
  264. package/lib/core/page/file-system.js +1 -1
  265. package/lib/core/page/hash.js +1 -1
  266. package/lib/core/page/lock.js +1 -1
  267. package/lib/core/sql-index-auditor.js +1 -1
  268. package/lib/core/sql-sync/config.js +1 -1
  269. package/lib/core/sql-sync/file-system.js +1 -1
  270. package/lib/core/sql-sync/hash.js +1 -1
  271. package/lib/core/sql-sync/lock.js +1 -1
  272. package/lib/core/sql-sync/utils.js +1 -1
  273. package/lib/core/sql-validator.js +1 -1
  274. package/lib/errors.js +1 -1
  275. package/lib/framework/build-all-flags.js +1 -1
  276. package/lib/framework/error-output.js +1 -1
  277. package/lib/framework/explicit-yes.js +1 -1
  278. package/lib/framework/flags.js +1 -1
  279. package/lib/framework/help.js +1 -1
  280. package/lib/framework/index.js +1 -1
  281. package/lib/framework/output.js +1 -1
  282. package/lib/framework/response.js +1 -1
  283. package/lib/framework/runner-alias.js +1 -1
  284. package/lib/framework/runner.js +1 -1
  285. package/lib/framework/schema-export.js +1 -1
  286. package/lib/framework/supported-flags.js +1 -1
  287. package/lib/framework/types.js +1 -1
  288. package/lib/generated/build-info.d.ts +4 -4
  289. package/lib/generated/build-info.js +1 -1
  290. package/lib/generated/official-routing.d.ts +1 -1
  291. package/lib/generated/official-routing.js +1 -1
  292. package/lib/generated/routing-contract.d.ts +1 -3
  293. package/lib/generated/routing-contract.js +1 -1
  294. package/lib/help.js +1 -1
  295. package/lib/postinstall.js +1 -1
  296. package/lib/runtime/confirmation.js +1 -1
  297. package/lib/runtime/event.js +1 -1
  298. package/lib/runtime/index.js +1 -1
  299. package/lib/runtime/queue.js +1 -1
  300. package/lib/runtime/resolve.js +1 -1
  301. package/lib/skills/builtin-skill.js +1 -1
  302. package/lib/skills/main.js +1 -1
  303. package/lib/skills/npx-skills-add.js +1 -1
  304. package/lib/skills/skill-presence.js +1 -1
  305. package/lib/telemetry/cli-command-trace.js +1 -1
  306. package/lib/telemetry/cli-help-trace.js +1 -1
  307. package/lib/telemetry/ensure-cli-otel-config.js +1 -1
  308. package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
  309. package/lib/telemetry/send-cli-trace-log.js +1 -1
  310. package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
  311. package/lib/utils/ai_config.js +1 -1
  312. package/lib/utils/apply-jq-filter.js +1 -1
  313. package/lib/utils/cdn-config.js +1 -1
  314. package/lib/utils/check-sdk-version.js +1 -1
  315. package/lib/utils/cli-version-check.js +1 -1
  316. package/lib/utils/cli-version-policy.js +1 -1
  317. package/lib/utils/config.js +1 -1
  318. package/lib/utils/entity-with-id.js +1 -1
  319. package/lib/utils/file-utils.js +1 -1
  320. package/lib/utils/guides-cdn.js +1 -1
  321. package/lib/utils/http-client.js +1 -1
  322. package/lib/utils/is-non-interactive.js +1 -1
  323. package/lib/utils/logger.js +1 -1
  324. package/lib/utils/params.js +1 -1
  325. package/lib/utils/platform.js +1 -1
  326. package/lib/utils/sleep.js +1 -1
  327. package/lib/utils/template-replacer.js +1 -1
  328. package/lib/utils/update-notice.js +1 -1
  329. package/lib/utils/version.js +1 -1
  330. package/lib/utils/with-active-cookie.js +1 -1
  331. package/lib/utils/write-cli-side-channel.js +1 -1
  332. package/package.json +2 -1
  333. package/skills/rabetbase/SKILL.md +6 -6
  334. package/skills/rabetbase/guides/custom-page-workflow.md +35 -17
  335. package/skills/rabetbase/guides/page-development-workflow.md +1 -1
  336. package/skills/rabetbase/knowledge/components.md +292 -0
  337. package/skills/rabetbase/knowledge/custom-page/generation-standards.md +74 -4
  338. package/skills/rabetbase/knowledge/custom-page/page-templates.md +68 -0
  339. package/skills/rabetbase/references/rabetbase-app-members-list.md +2 -0
  340. package/skills/rabetbase/references/rabetbase-page-create.md +21 -9
  341. package/skills/rabetbase/references/rabetbase-page-custom-detail.md +1 -1
  342. package/skills/rabetbase/references/rabetbase-page-custom-update.md +13 -9
  343. package/skills/rabetbase/references/rabetbase-project-create.md +5 -2
  344. package/skills/rabetbase/references/rabetbase-project-domain-routing-sync.md +2 -2
  345. package/skills/rabetbase/references/rabetbase-run.md +1 -0
  346. package/skills/rabetbase.manifest.json +5 -4
  347. package/templates/README.md +10 -4
  348. package/templates/custom-pages/blank.json +5 -0
  349. package/templates/custom-pages/dashboard.json +5 -0
  350. package/templates/custom-pages/onepage.json +5 -0
  351. package/templates/generate-api/api.ts.tpl +1 -1
  352. package/lib/commands/page/custom/template.d.ts +0 -8
  353. package/lib/commands/page/custom/template.js +0 -1
  354. package/skills/rabetbase/knowledge/custom-page/components.md +0 -225
@@ -1 +1 @@
1
- const a205_0x40adb6=a205_0x1d1a;(function(_0x1974ab,_0x1c6aa0){const _0x13e7a6=a205_0x1d1a,_0x1369c6=_0x1974ab();while(!![]){try{const _0x41e46d=-parseInt(_0x13e7a6(0x11b))/0x1*(-parseInt(_0x13e7a6(0x13e))/0x2)+parseInt(_0x13e7a6(0x13a))/0x3*(parseInt(_0x13e7a6(0x142))/0x4)+parseInt(_0x13e7a6(0x122))/0x5*(-parseInt(_0x13e7a6(0x12f))/0x6)+-parseInt(_0x13e7a6(0x119))/0x7+-parseInt(_0x13e7a6(0x129))/0x8*(-parseInt(_0x13e7a6(0x10d))/0x9)+parseInt(_0x13e7a6(0x117))/0xa*(-parseInt(_0x13e7a6(0x124))/0xb)+-parseInt(_0x13e7a6(0x125))/0xc*(-parseInt(_0x13e7a6(0x120))/0xd);if(_0x41e46d===_0x1c6aa0)break;else _0x1369c6['push'](_0x1369c6['shift']());}catch(_0x1477a6){_0x1369c6['push'](_0x1369c6['shift']());}}}(a205_0x4c55,0xcc7a6));function a205_0x1d1a(_0x5edae0,_0x40047a){_0x5edae0=_0x5edae0-0x10c;const _0x4c55d6=a205_0x4c55();let _0x1d1a2c=_0x4c55d6[_0x5edae0];return _0x1d1a2c;}import{getAppRule,isPlatformTransportFailure,saveAppRule}from'../../core/api-client.js';import{asDryRunResult}from'../../commands/common/dry-run.js';import{APP_RULE_TYPE_FLAG,appRuleContextScope,appRuleError,appRuleFileName,inspectAppRuleContent,projectAppRule,readAppRuleFile,readAppRuleType}from'../../commands/rule/shared.js';function a205_0x4c55(){const _0x471622=['1068ivUFcA','str','Inspect\x20it\x20with\x20`rabetbase\x20rule\x20get\x20--type\x20','input','40lZhETS','beforeRecord','app_rule_set_outcome_unknown','Expected\x20','.\x20Run\x20rule\x20get\x20and\x20review\x20before\x20retrying.','Non-atomic\x20preflight\x20assertion\x20for\x20the\x20current\x20version','18rkjnHO','before','verified','\x20for\x20','rule','\x20--format\x20compress`;\x20do\x20not\x20resubmit\x20automatically.','planned',';\x20current\x20version\x20is\x20','app_rule_expected_version_invalid','POST','app_rule_verification_failed','189579nuBMhF','Pass\x20a\x20UTF-8\x20Markdown\x20file.','file','cause','566tuRtMg','content','version','rules','4JmHULz','app_rule_version_mismatch','type','contentHash','trim','\x20could\x20not\x20be\x20verified.','flag','appCode','unconfigured','1762623TQVkOX','/smartapi/knowledge-base/save','Set\x20','--file\x20is\x20required.','\x20does\x20not\x20prove\x20the\x20requested\x20set\x20state.','\x20version\x20changed\x20before\x20write.','replacement','expected-version','string','defineProperty','7010RDXbss','set','9175376tmeIUd','cookie','2162IgLIHw','expectedVersion','rabetbase\x20rule\x20get\x20--type\x20','--expected-version\x20is\x20a\x20non-atomic\x20read-before-write\x20assertion;\x20the\x20server\x20save\x20contract\x20has\x20no\x20version\x20predicate.','Set\x20an\x20agent\x20context\x20rule\x20from\x20a\x20UTF-8\x20Markdown\x20file','407030PEBXZI','app_rule_file_required','1821905mAIvJt','\x20--format\x20compress','18821ikLpHb'];a205_0x4c55=function(){return _0x471622;};return a205_0x4c55();}const SAVE_PATH=a205_0x40adb6(0x10e),NON_ATOMIC_WARNING=a205_0x40adb6(0x11e);function readSetInput(_0x434f12){const _0x5e1b6b=a205_0x40adb6,_0x34675a=readAppRuleType(_0x434f12),_0x404b09=_0x434f12[_0x5e1b6b(0x126)](_0x5e1b6b(0x13c))[_0x5e1b6b(0x146)]();if(!_0x404b09)throw appRuleError(_0x5e1b6b(0x121),_0x5e1b6b(0x110),_0x5e1b6b(0x13b));const _0x381373=_0x434f12[_0x5e1b6b(0x148)](_0x5e1b6b(0x114));let _0x4eb56a;if(_0x381373!==undefined){_0x4eb56a=Number(_0x381373);if(!Number['isSafeInteger'](_0x4eb56a)||_0x4eb56a<0x0)throw appRuleError(_0x5e1b6b(0x137),'--expected-version\x20must\x20be\x20a\x20non-negative\x20safe\x20integer.');}return{'type':_0x34675a,'file':_0x404b09,'expectedVersion':_0x4eb56a};}async function prepareSet(_0x19f688){const _0x1c36cb=a205_0x40adb6,_0x5bb0f6=readSetInput(_0x19f688),_0x224c5e=await readAppRuleFile(_0x5bb0f6['file']),_0x4cdbcd=await getAppRule(_0x19f688[_0x1c36cb(0x11a)],{'appCode':_0x19f688[_0x1c36cb(0x149)],'type':_0x5bb0f6[_0x1c36cb(0x144)]});if(_0x5bb0f6[_0x1c36cb(0x11c)]!==undefined&&_0x4cdbcd?.['version']!==_0x5bb0f6[_0x1c36cb(0x11c)])throw appRuleError(_0x1c36cb(0x143),appRuleFileName(_0x5bb0f6[_0x1c36cb(0x144)])+_0x1c36cb(0x112),_0x1c36cb(0x12c)+_0x5bb0f6[_0x1c36cb(0x11c)]+_0x1c36cb(0x136)+(_0x4cdbcd?.[_0x1c36cb(0x140)]??_0x1c36cb(0x10c))+_0x1c36cb(0x12d));return{'input':_0x5bb0f6,'replacement':_0x224c5e,'beforeRecord':_0x4cdbcd,'before':projectAppRule(_0x5bb0f6[_0x1c36cb(0x144)],_0x4cdbcd),'planned':{'type':_0x5bb0f6['type'],'fileName':appRuleFileName(_0x5bb0f6[_0x1c36cb(0x144)]),'contextScope':appRuleContextScope(_0x5bb0f6['type']),'enabled':!![],'appCode':_0x19f688[_0x1c36cb(0x149)],'scope':_0x1c36cb(0x141),'contentByteSize':_0x224c5e['byteSize'],'contentHash':_0x224c5e[_0x1c36cb(0x145)]}};}function warningsFor(_0x358cfd){return _0x358cfd===undefined?[]:[NON_ATOMIC_WARNING];}export const ruleSet={'service':a205_0x40adb6(0x133),'command':a205_0x40adb6(0x118),'description':a205_0x40adb6(0x11f),'risk':'write','requiresAppCode':!![],'structuredErrors':!![],'flags':[APP_RULE_TYPE_FLAG,{'name':a205_0x40adb6(0x13c),'type':a205_0x40adb6(0x115),'required':!![],'description':'UTF-8\x20Markdown\x20file\x20(maximum\x205\x20MiB)'},{'name':a205_0x40adb6(0x114),'type':'number','required':![],'description':a205_0x40adb6(0x12e)}],async 'validate'(_0x2f661a){readSetInput(_0x2f661a);},async 'dryRun'(_0x50ec14){const _0x4fd174=a205_0x40adb6,_0x44573c=await prepareSet(_0x50ec14);return asDryRunResult({'operation':_0x4fd174(0x118),'selector':{'appCode':_0x50ec14['appCode'],'scope':'rules','type':_0x44573c['input']['type']},'before':_0x44573c[_0x4fd174(0x130)],'after':_0x44573c[_0x4fd174(0x135)],'dryRun':!![],'backend':{'method':_0x4fd174(0x138),'path':SAVE_PATH},'warnings':warningsFor(_0x44573c[_0x4fd174(0x128)]['expectedVersion']),'verification':{'expectedVersion':_0x44573c[_0x4fd174(0x128)]['expectedVersion']??null,'atomicCompareAndSet':![],'lookupCommand':_0x4fd174(0x11d)+_0x44573c['input'][_0x4fd174(0x144)]+'\x20--format\x20compress'}},{'method':_0x4fd174(0x138),'url':SAVE_PATH});},async 'execute'(_0x32e8f7){const _0x47739=a205_0x40adb6,_0x164c1e=await prepareSet(_0x32e8f7);let _0x37de74=![];try{await saveAppRule(_0x32e8f7[_0x47739(0x11a)],{'appCode':_0x32e8f7['appCode'],'type':_0x164c1e['input'][_0x47739(0x144)],'content':_0x164c1e['replacement'][_0x47739(0x13f)]});}catch(_0xd174f7){if(!isPlatformTransportFailure(_0xd174f7))throw _0xd174f7;_0x37de74=!![];}let _0x483f6a;try{_0x483f6a=await getAppRule(_0x32e8f7[_0x47739(0x11a)],{'appCode':_0x32e8f7[_0x47739(0x149)],'type':_0x164c1e[_0x47739(0x128)]['type']});}catch(_0x4e114b){const _0x1d3763=appRuleError(_0x37de74?_0x47739(0x12b):'app_rule_verification_unavailable','The\x20set\x20request\x20was\x20sent,\x20but\x20'+appRuleFileName(_0x164c1e[_0x47739(0x128)][_0x47739(0x144)])+_0x47739(0x147),'Do\x20not\x20resubmit\x20automatically.\x20Inspect\x20the\x20exact\x20rule\x20state\x20before\x20retrying.');Object[_0x47739(0x116)](_0x1d3763,_0x47739(0x13d),{'value':_0x4e114b,'enumerable':![]});throw _0x1d3763;}const _0x281ebc=_0x483f6a&&inspectAppRuleContent(_0x483f6a[_0x47739(0x13f)])[_0x47739(0x145)]===_0x164c1e[_0x47739(0x113)][_0x47739(0x145)],_0x3a9929=_0x483f6a&&(_0x164c1e[_0x47739(0x12a)]===null||_0x483f6a[_0x47739(0x140)]>_0x164c1e[_0x47739(0x12a)][_0x47739(0x140)]);if(!_0x483f6a||!_0x281ebc||!_0x3a9929)throw appRuleError(_0x37de74?_0x47739(0x12b):_0x47739(0x139),appRuleFileName(_0x164c1e[_0x47739(0x128)][_0x47739(0x144)])+_0x47739(0x111),_0x47739(0x127)+_0x164c1e[_0x47739(0x128)][_0x47739(0x144)]+_0x47739(0x134));const _0x3c2abe=warningsFor(_0x164c1e[_0x47739(0x128)][_0x47739(0x11c)]);_0x37de74&&_0x3c2abe['push']('Set\x20response\x20was\x20unavailable;\x20verified\x20the\x20exact\x20content\x20readback\x20without\x20resubmitting.');const _0x449e09=projectAppRule(_0x164c1e[_0x47739(0x128)][_0x47739(0x144)],_0x483f6a);return{'ok':!![],'data':{'operation':_0x47739(0x118),'selector':{'appCode':_0x32e8f7['appCode'],'scope':_0x47739(0x141),'type':_0x164c1e['input'][_0x47739(0x144)]},'before':_0x164c1e[_0x47739(0x130)],'after':_0x449e09,'dryRun':![],'backend':{'method':_0x47739(0x138),'path':SAVE_PATH},'warnings':_0x3c2abe,'verification':{'status':_0x47739(0x131),'recoveredAfterUnknownResponse':_0x37de74,'expectedVersion':_0x164c1e[_0x47739(0x128)][_0x47739(0x11c)]??null,'atomicCompareAndSet':![],'lookupCommand':_0x47739(0x11d)+_0x164c1e[_0x47739(0x128)]['type']+_0x47739(0x123)}},'message':_0x47739(0x10f)+appRuleFileName(_0x164c1e[_0x47739(0x128)]['type'])+_0x47739(0x132)+_0x32e8f7[_0x47739(0x149)]};}};
1
+ const a204_0x33a771=a204_0x2e74;function a204_0x2fcb(){const _0x5d4d27=['17407107YsUijb','number','\x20does\x20not\x20prove\x20the\x20requested\x20set\x20state.','push','content','expected-version','12090OykzKI','app_rule_expected_version_invalid','Set\x20','\x20for\x20','type','flag','byteSize','set','6290692eBoEDQ','2379730zASSpq','planned','app_rule_verification_failed','defineProperty','contentHash','--expected-version\x20is\x20a\x20non-atomic\x20read-before-write\x20assertion;\x20the\x20server\x20save\x20contract\x20has\x20no\x20version\x20predicate.','30728bGJSbR',';\x20current\x20version\x20is\x20','\x20version\x20changed\x20before\x20write.','--file\x20is\x20required.','\x20--format\x20compress`;\x20do\x20not\x20resubmit\x20automatically.','appCode','cause','The\x20set\x20request\x20was\x20sent,\x20but\x20','app_rule_verification_unavailable','Non-atomic\x20preflight\x20assertion\x20for\x20the\x20current\x20version','beforeRecord','Inspect\x20it\x20with\x20`rabetbase\x20rule\x20get\x20--type\x20','--expected-version\x20must\x20be\x20a\x20non-negative\x20safe\x20integer.','rules','UTF-8\x20Markdown\x20file\x20(maximum\x205\x20MiB)','isSafeInteger','\x20--format\x20compress','.\x20Run\x20rule\x20get\x20and\x20review\x20before\x20retrying.','str','write','176060OrBFpu','app_rule_version_mismatch','file','app_rule_set_outcome_unknown','version','Expected\x20','rule','string','24wsgcXe','replacement','before','POST','5302iVAOXy','Set\x20an\x20agent\x20context\x20rule\x20from\x20a\x20UTF-8\x20Markdown\x20file','Pass\x20a\x20UTF-8\x20Markdown\x20file.','cookie','26jehHrV','Do\x20not\x20resubmit\x20automatically.\x20Inspect\x20the\x20exact\x20rule\x20state\x20before\x20retrying.','expectedVersion','7kysUcD','43017glZBDI','input','rabetbase\x20rule\x20get\x20--type\x20','verified'];a204_0x2fcb=function(){return _0x5d4d27;};return a204_0x2fcb();}(function(_0x374bd3,_0x1aeefe){const _0x458c72=a204_0x2e74,_0x116d41=_0x374bd3();while(!![]){try{const _0x180b06=-parseInt(_0x458c72(0x115))/0x1+-parseInt(_0x458c72(0x125))/0x2*(-parseInt(_0x458c72(0x129))/0x3)+parseInt(_0x458c72(0x13b))/0x4+parseInt(_0x458c72(0x13c))/0x5*(parseInt(_0x458c72(0x11d))/0x6)+parseInt(_0x458c72(0x128))/0x7*(parseInt(_0x458c72(0x142))/0x8)+-parseInt(_0x458c72(0x12d))/0x9+-parseInt(_0x458c72(0x133))/0xa*(parseInt(_0x458c72(0x121))/0xb);if(_0x180b06===_0x1aeefe)break;else _0x116d41['push'](_0x116d41['shift']());}catch(_0x51e5c7){_0x116d41['push'](_0x116d41['shift']());}}}(a204_0x2fcb,0xedbd8));import{getAppRule,isPlatformTransportFailure,saveAppRule}from'../../core/api-client.js';import{asDryRunResult}from'../../commands/common/dry-run.js';import{APP_RULE_TYPE_FLAG,appRuleContextScope,appRuleError,appRuleFileName,inspectAppRuleContent,projectAppRule,readAppRuleFile,readAppRuleType}from'../../commands/rule/shared.js';const SAVE_PATH='/smartapi/knowledge-base/save',NON_ATOMIC_WARNING=a204_0x33a771(0x141);function readSetInput(_0x26257c){const _0x3ba28d=a204_0x33a771,_0x124964=readAppRuleType(_0x26257c),_0xde5306=_0x26257c[_0x3ba28d(0x113)](_0x3ba28d(0x117))['trim']();if(!_0xde5306)throw appRuleError('app_rule_file_required',_0x3ba28d(0x104),_0x3ba28d(0x123));const _0x5eacc6=_0x26257c[_0x3ba28d(0x138)]('expected-version');let _0x367fc2;if(_0x5eacc6!==undefined){_0x367fc2=Number(_0x5eacc6);if(!Number[_0x3ba28d(0x110)](_0x367fc2)||_0x367fc2<0x0)throw appRuleError(_0x3ba28d(0x134),_0x3ba28d(0x10d));}return{'type':_0x124964,'file':_0xde5306,'expectedVersion':_0x367fc2};}async function prepareSet(_0x1b757b){const _0x7b14f3=a204_0x33a771,_0x3379dc=readSetInput(_0x1b757b),_0x1fa588=await readAppRuleFile(_0x3379dc[_0x7b14f3(0x117)]),_0x1cfd31=await getAppRule(_0x1b757b['cookie'],{'appCode':_0x1b757b[_0x7b14f3(0x106)],'type':_0x3379dc['type']});if(_0x3379dc[_0x7b14f3(0x127)]!==undefined&&_0x1cfd31?.[_0x7b14f3(0x119)]!==_0x3379dc[_0x7b14f3(0x127)])throw appRuleError(_0x7b14f3(0x116),appRuleFileName(_0x3379dc[_0x7b14f3(0x137)])+_0x7b14f3(0x103),_0x7b14f3(0x11a)+_0x3379dc[_0x7b14f3(0x127)]+_0x7b14f3(0x102)+(_0x1cfd31?.['version']??'unconfigured')+_0x7b14f3(0x112));return{'input':_0x3379dc,'replacement':_0x1fa588,'beforeRecord':_0x1cfd31,'before':projectAppRule(_0x3379dc['type'],_0x1cfd31),'planned':{'type':_0x3379dc['type'],'fileName':appRuleFileName(_0x3379dc['type']),'contextScope':appRuleContextScope(_0x3379dc[_0x7b14f3(0x137)]),'enabled':!![],'appCode':_0x1b757b['appCode'],'scope':_0x7b14f3(0x10e),'contentByteSize':_0x1fa588[_0x7b14f3(0x139)],'contentHash':_0x1fa588[_0x7b14f3(0x140)]}};}function warningsFor(_0x2e44cd){return _0x2e44cd===undefined?[]:[NON_ATOMIC_WARNING];}function a204_0x2e74(_0x139b89,_0x5ab03f){_0x139b89=_0x139b89-0x102;const _0x2fcb1e=a204_0x2fcb();let _0x2e74b0=_0x2fcb1e[_0x139b89];return _0x2e74b0;}export const ruleSet={'service':a204_0x33a771(0x11b),'command':a204_0x33a771(0x13a),'description':a204_0x33a771(0x122),'risk':a204_0x33a771(0x114),'requiresAppCode':!![],'structuredErrors':!![],'flags':[APP_RULE_TYPE_FLAG,{'name':a204_0x33a771(0x117),'type':a204_0x33a771(0x11c),'required':!![],'description':a204_0x33a771(0x10f)},{'name':a204_0x33a771(0x132),'type':a204_0x33a771(0x12e),'required':![],'description':a204_0x33a771(0x10a)}],async 'validate'(_0x368d55){readSetInput(_0x368d55);},async 'dryRun'(_0xfc95c1){const _0x2b37c5=a204_0x33a771,_0x24703c=await prepareSet(_0xfc95c1);return asDryRunResult({'operation':_0x2b37c5(0x13a),'selector':{'appCode':_0xfc95c1[_0x2b37c5(0x106)],'scope':'rules','type':_0x24703c[_0x2b37c5(0x12a)][_0x2b37c5(0x137)]},'before':_0x24703c[_0x2b37c5(0x11f)],'after':_0x24703c[_0x2b37c5(0x13d)],'dryRun':!![],'backend':{'method':_0x2b37c5(0x120),'path':SAVE_PATH},'warnings':warningsFor(_0x24703c[_0x2b37c5(0x12a)][_0x2b37c5(0x127)]),'verification':{'expectedVersion':_0x24703c['input'][_0x2b37c5(0x127)]??null,'atomicCompareAndSet':![],'lookupCommand':_0x2b37c5(0x12b)+_0x24703c[_0x2b37c5(0x12a)][_0x2b37c5(0x137)]+_0x2b37c5(0x111)}},{'method':_0x2b37c5(0x120),'url':SAVE_PATH});},async 'execute'(_0x493fb5){const _0x569ce0=a204_0x33a771,_0x5444c9=await prepareSet(_0x493fb5);let _0x44ba71=![];try{await saveAppRule(_0x493fb5[_0x569ce0(0x124)],{'appCode':_0x493fb5[_0x569ce0(0x106)],'type':_0x5444c9[_0x569ce0(0x12a)][_0x569ce0(0x137)],'content':_0x5444c9['replacement']['content']});}catch(_0x3e3990){if(!isPlatformTransportFailure(_0x3e3990))throw _0x3e3990;_0x44ba71=!![];}let _0x3a4808;try{_0x3a4808=await getAppRule(_0x493fb5['cookie'],{'appCode':_0x493fb5[_0x569ce0(0x106)],'type':_0x5444c9[_0x569ce0(0x12a)][_0x569ce0(0x137)]});}catch(_0x4e3e6f){const _0x472ed5=appRuleError(_0x44ba71?_0x569ce0(0x118):_0x569ce0(0x109),_0x569ce0(0x108)+appRuleFileName(_0x5444c9[_0x569ce0(0x12a)]['type'])+'\x20could\x20not\x20be\x20verified.',_0x569ce0(0x126));Object[_0x569ce0(0x13f)](_0x472ed5,_0x569ce0(0x107),{'value':_0x4e3e6f,'enumerable':![]});throw _0x472ed5;}const _0x1db561=_0x3a4808&&inspectAppRuleContent(_0x3a4808[_0x569ce0(0x131)])[_0x569ce0(0x140)]===_0x5444c9[_0x569ce0(0x11e)]['contentHash'],_0x165302=_0x3a4808&&(_0x5444c9[_0x569ce0(0x10b)]===null||_0x3a4808[_0x569ce0(0x119)]>_0x5444c9[_0x569ce0(0x10b)][_0x569ce0(0x119)]);if(!_0x3a4808||!_0x1db561||!_0x165302)throw appRuleError(_0x44ba71?'app_rule_set_outcome_unknown':_0x569ce0(0x13e),appRuleFileName(_0x5444c9[_0x569ce0(0x12a)][_0x569ce0(0x137)])+_0x569ce0(0x12f),_0x569ce0(0x10c)+_0x5444c9['input'][_0x569ce0(0x137)]+_0x569ce0(0x105));const _0xdf2855=warningsFor(_0x5444c9[_0x569ce0(0x12a)][_0x569ce0(0x127)]);_0x44ba71&&_0xdf2855[_0x569ce0(0x130)]('Set\x20response\x20was\x20unavailable;\x20verified\x20the\x20exact\x20content\x20readback\x20without\x20resubmitting.');const _0x2bee28=projectAppRule(_0x5444c9['input']['type'],_0x3a4808);return{'ok':!![],'data':{'operation':'set','selector':{'appCode':_0x493fb5['appCode'],'scope':_0x569ce0(0x10e),'type':_0x5444c9['input'][_0x569ce0(0x137)]},'before':_0x5444c9[_0x569ce0(0x11f)],'after':_0x2bee28,'dryRun':![],'backend':{'method':_0x569ce0(0x120),'path':SAVE_PATH},'warnings':_0xdf2855,'verification':{'status':_0x569ce0(0x12c),'recoveredAfterUnknownResponse':_0x44ba71,'expectedVersion':_0x5444c9[_0x569ce0(0x12a)][_0x569ce0(0x127)]??null,'atomicCompareAndSet':![],'lookupCommand':_0x569ce0(0x12b)+_0x5444c9[_0x569ce0(0x12a)][_0x569ce0(0x137)]+'\x20--format\x20compress'}},'message':_0x569ce0(0x135)+appRuleFileName(_0x5444c9[_0x569ce0(0x12a)][_0x569ce0(0x137)])+_0x569ce0(0x136)+_0x493fb5[_0x569ce0(0x106)]};}};
@@ -1 +1 @@
1
- const a206_0x418450=a206_0x36bc;(function(_0x363c56,_0x256ec8){const _0x3c725d=a206_0x36bc,_0x3794c9=_0x363c56();while(!![]){try{const _0x58d91f=parseInt(_0x3c725d(0x90))/0x1+parseInt(_0x3c725d(0x96))/0x2*(-parseInt(_0x3c725d(0xb2))/0x3)+parseInt(_0x3c725d(0x98))/0x4+parseInt(_0x3c725d(0xb7))/0x5+parseInt(_0x3c725d(0xb8))/0x6*(parseInt(_0x3c725d(0x91))/0x7)+-parseInt(_0x3c725d(0xb3))/0x8*(-parseInt(_0x3c725d(0xae))/0x9)+parseInt(_0x3c725d(0x8f))/0xa*(-parseInt(_0x3c725d(0xa4))/0xb);if(_0x58d91f===_0x256ec8)break;else _0x3794c9['push'](_0x3794c9['shift']());}catch(_0x5b386b){_0x3794c9['push'](_0x3794c9['shift']());}}}(a206_0x5870,0x9eee5));import{createHash}from'node:crypto';function a206_0x5870(){const _0xe3370e=['sha256','isFile','app_rule_content_invalid','360pjmlsz','1215694cRocCP','60872TPYega','type','byteSize','decode','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','44YSVBno','digest','1862972xEDPNX','size','Cannot\x20read\x20app\x20rule\x20file:\x20','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','message','--file\x20is\x20required.','hex','Pass\x20a\x20UTF-8\x20Markdown\x20file.','utf-8','version','str','updateTime','430518IKdfcf','DATABASE.md','toLowerCase','app_rule_content_too_large','utf8','appCode','RULES.md','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','page-api-development','trim','450693qzqqQR','byteLength','database','rules','4995aIiAnm','8DpFhRi','Cannot\x20access\x20app\x20rule\x20file:\x20','update','app_rule_file_unreadable','1086165TiCJrI','102pEtpoz','string','content','Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','app_rule_file_required','createTime'];a206_0x5870=function(){return _0xe3370e;};return a206_0x5870();}import{readFile,stat}from'node:fs/promises';import{resolve}from'node:path';import{TextDecoder}from'node:util';import{CliError}from'../../errors.js';export const APP_RULE_TYPES=['rules',a206_0x418450(0xb0)];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;const APP_RULE_FILES={'rules':a206_0x418450(0xaa),'database':a206_0x418450(0xa5)},APP_RULE_CONTEXT_SCOPES={'rules':a206_0x418450(0xac),'database':'database-analysis'};export function appRuleError(_0x307f16,_0x4ec1c1,_0x28d29b){return new CliError(_0x307f16,0x1,_0x4ec1c1,_0x28d29b);}export function readAppRuleType(_0x436c7f){const _0x24a699=a206_0x418450,_0x56f8f6=_0x436c7f[_0x24a699(0xa2)]('type')[_0x24a699(0xad)]()[_0x24a699(0xa6)]();if(_0x56f8f6!==_0x24a699(0xb1)&&_0x56f8f6!==_0x24a699(0xb0))throw appRuleError('app_rule_type_invalid',_0x24a699(0x95));return _0x56f8f6;}function a206_0x36bc(_0x3fd84b,_0x51dedd){_0x3fd84b=_0x3fd84b-0x87;const _0x5870ac=a206_0x5870();let _0x36bc15=_0x5870ac[_0x3fd84b];return _0x36bc15;}export function appRuleFileName(_0x1668b0){return APP_RULE_FILES[_0x1668b0];}export function appRuleContextScope(_0x258ade){return APP_RULE_CONTEXT_SCOPES[_0x258ade];}export function inspectAppRuleContent(_0x13ee86){const _0x427a31=a206_0x418450,_0x5d6529=Buffer['from'](_0x13ee86,_0x427a31(0xa8));return{'content':_0x13ee86,'byteSize':_0x5d6529[_0x427a31(0xaf)],'contentHash':'sha256:'+createHash(_0x427a31(0x8c))[_0x427a31(0xb5)](_0x5d6529)[_0x427a31(0x97)](_0x427a31(0x9e))};}export async function readAppRuleFile(_0x5e75ab){const _0x1d2326=a206_0x418450,_0x3eec76=_0x5e75ab[_0x1d2326(0xad)]();if(!_0x3eec76)throw appRuleError(_0x1d2326(0x8a),_0x1d2326(0x9d),_0x1d2326(0x9f));const _0x51e5a2=resolve(_0x3eec76);let _0x8dc901;try{_0x8dc901=await stat(_0x51e5a2);}catch(_0x19e66a){throw appRuleError(_0x1d2326(0xb6),_0x1d2326(0xb4)+_0x3eec76,_0x19e66a instanceof Error?_0x19e66a[_0x1d2326(0x9c)]:String(_0x19e66a));}if(!_0x8dc901[_0x1d2326(0x8d)]())throw appRuleError('app_rule_file_invalid','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20'+_0x3eec76);if(_0x8dc901[_0x1d2326(0x99)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x1d2326(0xa7),_0x1d2326(0x9b));let _0x11e8ce;try{_0x11e8ce=await readFile(_0x51e5a2);}catch(_0xc482d7){throw appRuleError(_0x1d2326(0xb6),_0x1d2326(0x9a)+_0x3eec76,_0xc482d7 instanceof Error?_0xc482d7[_0x1d2326(0x9c)]:String(_0xc482d7));}if(_0x11e8ce[_0x1d2326(0xaf)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x1d2326(0xa7),_0x1d2326(0x9b));let _0x473ea1;try{_0x473ea1=new TextDecoder(_0x1d2326(0xa0),{'fatal':!![],'ignoreBOM':!![]})[_0x1d2326(0x94)](_0x11e8ce);}catch{throw appRuleError(_0x1d2326(0x8e),_0x1d2326(0xab)+_0x3eec76);}if(!_0x473ea1['trim']())throw appRuleError('app_rule_content_invalid','App\x20rule\x20file\x20is\x20blank:\x20'+_0x3eec76);return inspectAppRuleContent(_0x473ea1);}export function projectAppRule(_0x55b51b,_0x37cba2){const _0x491fe8=a206_0x418450;if(!_0x37cba2)return{'type':_0x55b51b,'fileName':appRuleFileName(_0x55b51b),'contextScope':appRuleContextScope(_0x55b51b),'enabled':![]};const _0x329d8a=inspectAppRuleContent(_0x37cba2[_0x491fe8(0x88)]);return{'type':_0x55b51b,'fileName':appRuleFileName(_0x55b51b),'contextScope':appRuleContextScope(_0x55b51b),'enabled':!![],'id':_0x37cba2['id'],'scope':_0x37cba2['scope'],'appCode':_0x37cba2[_0x491fe8(0xa9)],'version':_0x37cba2[_0x491fe8(0xa1)],'contentByteSize':_0x329d8a[_0x491fe8(0x93)],'contentHash':_0x329d8a['contentHash'],..._0x37cba2['createTime']!==undefined&&_0x37cba2[_0x491fe8(0x8b)]!==null?{'createTime':_0x37cba2[_0x491fe8(0x8b)]}:{},..._0x37cba2[_0x491fe8(0xa3)]!==undefined&&_0x37cba2['updateTime']!==null?{'updateTime':_0x37cba2['updateTime']}:{}};}export const APP_RULE_TYPE_FLAG={'name':a206_0x418450(0x92),'type':a206_0x418450(0x87),'required':!![],'description':a206_0x418450(0x89),'enum':[...APP_RULE_TYPES]};
1
+ const a205_0x22d813=a205_0x1131;(function(_0x4b169a,_0x905811){const _0x32a140=a205_0x1131,_0x985d09=_0x4b169a();while(!![]){try{const _0x279266=-parseInt(_0x32a140(0x177))/0x1+-parseInt(_0x32a140(0x159))/0x2*(-parseInt(_0x32a140(0x17e))/0x3)+parseInt(_0x32a140(0x162))/0x4+-parseInt(_0x32a140(0x155))/0x5*(parseInt(_0x32a140(0x176))/0x6)+parseInt(_0x32a140(0x158))/0x7+parseInt(_0x32a140(0x17d))/0x8+-parseInt(_0x32a140(0x171))/0x9;if(_0x279266===_0x905811)break;else _0x985d09['push'](_0x985d09['shift']());}catch(_0x3cda41){_0x985d09['push'](_0x985d09['shift']());}}}(a205_0x4550,0xed07d));import{createHash}from'node:crypto';function a205_0x4550(){const _0x5dfbdf=['utf8','type','utf-8','App\x20rule\x20file\x20is\x20blank:\x20','string','byteLength','40488084oidtXS','App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.','App\x20rule\x20file\x20is\x20not\x20valid\x20UTF-8:\x20','str','page-api-development','36330xaREou','123010YmCden','rules','update','size','isFile','message','13750136XlxZRm','3999hHRtxS','trim','createTime','sha256','--type\x20must\x20be\x20either\x20rules\x20or\x20database.','App\x20rule\x20path\x20is\x20not\x20a\x20regular\x20file:\x20','hex','app_rule_content_invalid','1305HVSUAm','Pass\x20a\x20UTF-8\x20Markdown\x20file.','from','11871629nnZIZZ','2764lTeFxk','database-analysis','sha256:','byteSize','app_rule_file_required','appCode','toLowerCase','app_rule_file_invalid','updateTime','7663992DbWnhp','Cannot\x20read\x20app\x20rule\x20file:\x20','digest','app_rule_file_unreadable','Context\x20rule\x20type:\x20rules\x20for\x20page/API\x20development\x20agents\x20(DB\x20Agent\x20excluded),\x20database\x20for\x20DB\x20Agent\x20database\x20analysis','contentHash','content','app_rule_content_too_large','database'];a205_0x4550=function(){return _0x5dfbdf;};return a205_0x4550();}import{readFile,stat}from'node:fs/promises';import{resolve}from'node:path';function a205_0x1131(_0x118003,_0x70e174){_0x118003=_0x118003-0x150;const _0x45507b=a205_0x4550();let _0x1131fc=_0x45507b[_0x118003];return _0x1131fc;}import{TextDecoder}from'node:util';import{CliError}from'../../errors.js';export const APP_RULE_TYPES=[a205_0x22d813(0x178),a205_0x22d813(0x16a)];export const MAX_APP_RULE_BYTES=0x5*0x400*0x400;const APP_RULE_FILES={'rules':'RULES.md','database':'DATABASE.md'},APP_RULE_CONTEXT_SCOPES={'rules':a205_0x22d813(0x175),'database':a205_0x22d813(0x15a)};export function appRuleError(_0x368452,_0x3aa576,_0x3bed6a){return new CliError(_0x368452,0x1,_0x3aa576,_0x3bed6a);}export function readAppRuleType(_0x368c90){const _0x2014f6=a205_0x22d813,_0x2750d9=_0x368c90[_0x2014f6(0x174)](_0x2014f6(0x16c))['trim']()[_0x2014f6(0x15f)]();if(_0x2750d9!==_0x2014f6(0x178)&&_0x2750d9!==_0x2014f6(0x16a))throw appRuleError('app_rule_type_invalid',_0x2014f6(0x151));return _0x2750d9;}export function appRuleFileName(_0x41f7b6){return APP_RULE_FILES[_0x41f7b6];}export function appRuleContextScope(_0x306add){return APP_RULE_CONTEXT_SCOPES[_0x306add];}export function inspectAppRuleContent(_0x37526a){const _0x9ae676=a205_0x22d813,_0x2126b7=Buffer[_0x9ae676(0x157)](_0x37526a,_0x9ae676(0x16b));return{'content':_0x37526a,'byteSize':_0x2126b7[_0x9ae676(0x170)],'contentHash':_0x9ae676(0x15b)+createHash(_0x9ae676(0x150))[_0x9ae676(0x179)](_0x2126b7)[_0x9ae676(0x164)](_0x9ae676(0x153))};}export async function readAppRuleFile(_0x2f68d2){const _0x5551ad=a205_0x22d813,_0x4111f7=_0x2f68d2[_0x5551ad(0x17f)]();if(!_0x4111f7)throw appRuleError(_0x5551ad(0x15d),'--file\x20is\x20required.',_0x5551ad(0x156));const _0x14f23b=resolve(_0x4111f7);let _0x334be2;try{_0x334be2=await stat(_0x14f23b);}catch(_0x3afca9){throw appRuleError(_0x5551ad(0x165),'Cannot\x20access\x20app\x20rule\x20file:\x20'+_0x4111f7,_0x3afca9 instanceof Error?_0x3afca9[_0x5551ad(0x17c)]:String(_0x3afca9));}if(!_0x334be2[_0x5551ad(0x17b)]())throw appRuleError(_0x5551ad(0x160),_0x5551ad(0x152)+_0x4111f7);if(_0x334be2[_0x5551ad(0x17a)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x5551ad(0x169),'App\x20rule\x20content\x20exceeds\x20the\x205\x20MiB\x20server\x20limit.');let _0x9b5fbe;try{_0x9b5fbe=await readFile(_0x14f23b);}catch(_0x4d4f6d){throw appRuleError('app_rule_file_unreadable',_0x5551ad(0x163)+_0x4111f7,_0x4d4f6d instanceof Error?_0x4d4f6d['message']:String(_0x4d4f6d));}if(_0x9b5fbe[_0x5551ad(0x170)]>MAX_APP_RULE_BYTES)throw appRuleError(_0x5551ad(0x169),_0x5551ad(0x172));let _0x401178;try{_0x401178=new TextDecoder(_0x5551ad(0x16d),{'fatal':!![],'ignoreBOM':!![]})['decode'](_0x9b5fbe);}catch{throw appRuleError(_0x5551ad(0x154),_0x5551ad(0x173)+_0x4111f7);}if(!_0x401178['trim']())throw appRuleError(_0x5551ad(0x154),_0x5551ad(0x16e)+_0x4111f7);return inspectAppRuleContent(_0x401178);}export function projectAppRule(_0x161d5c,_0x13bc30){const _0x18b38c=a205_0x22d813;if(!_0x13bc30)return{'type':_0x161d5c,'fileName':appRuleFileName(_0x161d5c),'contextScope':appRuleContextScope(_0x161d5c),'enabled':![]};const _0x3cabac=inspectAppRuleContent(_0x13bc30[_0x18b38c(0x168)]);return{'type':_0x161d5c,'fileName':appRuleFileName(_0x161d5c),'contextScope':appRuleContextScope(_0x161d5c),'enabled':!![],'id':_0x13bc30['id'],'scope':_0x13bc30['scope'],'appCode':_0x13bc30[_0x18b38c(0x15e)],'version':_0x13bc30['version'],'contentByteSize':_0x3cabac[_0x18b38c(0x15c)],'contentHash':_0x3cabac[_0x18b38c(0x167)],..._0x13bc30[_0x18b38c(0x180)]!==undefined&&_0x13bc30[_0x18b38c(0x180)]!==null?{'createTime':_0x13bc30[_0x18b38c(0x180)]}:{},..._0x13bc30[_0x18b38c(0x161)]!==undefined&&_0x13bc30['updateTime']!==null?{'updateTime':_0x13bc30[_0x18b38c(0x161)]}:{}};}export const APP_RULE_TYPE_FLAG={'name':'type','type':a205_0x22d813(0x16f),'required':!![],'description':a205_0x22d813(0x166),'enum':[...APP_RULE_TYPES]};
@@ -1,2 +1,6 @@
1
1
  import type { CommandDefinition } from "../../framework/types.js";
2
+ export declare function syncProjectDomainRoutingBeforeScript(cwd: string, scriptName: string): {
3
+ path: string;
4
+ changed: boolean;
5
+ } | null;
2
6
  export declare const runDefinition: CommandDefinition;
@@ -1 +1 @@
1
- const a207_0x4d9aaa=a207_0xc20c;(function(_0x4d2960,_0x45e0ac){const _0x56474b=a207_0xc20c,_0x1ce377=_0x4d2960();while(!![]){try{const _0x55bc94=-parseInt(_0x56474b(0x112))/0x1+-parseInt(_0x56474b(0x120))/0x2+parseInt(_0x56474b(0xf9))/0x3+-parseInt(_0x56474b(0x10a))/0x4+parseInt(_0x56474b(0x128))/0x5+parseInt(_0x56474b(0x10d))/0x6+-parseInt(_0x56474b(0x127))/0x7;if(_0x55bc94===_0x45e0ac)break;else _0x1ce377['push'](_0x1ce377['shift']());}catch(_0x11b498){_0x1ce377['push'](_0x1ce377['shift']());}}}(a207_0x1d38,0xaba91));import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';function a207_0xc20c(_0x48337d,_0x3b90cc){_0x48337d=_0x48337d-0xf3;const _0x1d385e=a207_0x1d38();let _0xc20cc6=_0x1d385e[_0x48337d];return _0xc20cc6;}import{resolve,delimiter,join}from'node:path';import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';function a207_0x1d38(){const _0x43935b=['4155333grLHuk','build','\x0a\x20\x20Usage:\x20','has','(none)','start','\x0a\x20\x20Available\x20scripts:\x0a','close','\x20run\x20preview\x20--watch','parse','vite\x20preview\x20exited\x20with\x20code\x20','\x20run\x20start','push','all','watch','preview','needsUpgrade','1697148BdrOgv','length','\x20\x20\x20\x20','3944400uSSMKB','node_modules','.bin','inherit','npm','286559rEnXMW','args','Script\x20name\x20defined\x20in\x20package.json','vite','\x22\x20not\x20found\x20in\x20package.json.','error','keys','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','log','slice','bool','join','validation','dev','1811284vQPwzC','Script\x20\x22','\x20exited\x20with\x20code\x20','No\x20scripts\x20defined\x20in\x20package.json.','scripts','pnpm-lock.yaml','boolean','5623898AZjhpw','5402560XWkBuE','package.json','\x20run\x20<script>\x0a','\x20run\x20build','yarn.lock','cwd','\x20run\x20','\x20run\x20preview','write','run','utf-8'];a207_0x1d38=function(){return _0x43935b;};return a207_0x1d38();}import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set([a207_0x4d9aaa(0xfe),a207_0x4d9aaa(0x11f)]);function readPackageScripts(_0x3d1b3c){const _0x17c29d=a207_0x4d9aaa,_0x46cd38=resolve(_0x3d1b3c,_0x17c29d(0x129));if(!existsSync(_0x46cd38))return null;try{const _0x379d3a=JSON[_0x17c29d(0x102)](readFileSync(_0x46cd38,_0x17c29d(0xf8)));return _0x379d3a[_0x17c29d(0x124)]??{};}catch{return null;}}function detectPackageManager(_0x5901e5){const _0x334926=a207_0x4d9aaa;if(existsSync(resolve(_0x5901e5,'bun.lockb'))||existsSync(resolve(_0x5901e5,'bun.lock')))return'bun';if(existsSync(resolve(_0x5901e5,_0x334926(0x125))))return'pnpm';if(existsSync(resolve(_0x5901e5,_0x334926(0x12c))))return'yarn';return _0x334926(0x111);}async function versionCheck(_0x2c5817){const _0x1e53ae=a207_0x4d9aaa,_0x3a56e9=await checkCliVersion();(_0x3a56e9[_0x1e53ae(0x109)]||_0x3a56e9['belowMinimum'])&&(printCliUpgradeWarning(_0x3a56e9),assertCliVersionSupported(_0x3a56e9));const _0x195976=await checkSdkVersion(_0x2c5817);if(_0x195976[_0x1e53ae(0x109)])printSdkUpgradeWarning(_0x195976);}function spawnScript(_0x58046a,_0x36d3b3,_0x1a6be2,_0x223094){return new Promise((_0x316629,_0x180b48)=>{const _0x512344=a207_0xc20c,_0x4f517c=['run',_0x36d3b3,..._0x1a6be2],_0x833ca1=spawn(_0x58046a,_0x4f517c,{'cwd':_0x223094,'stdio':_0x512344(0x110),'shell':!![],'env':{...process.env,'PATH':''+join(_0x223094,_0x512344(0x10e),_0x512344(0x10f))+delimiter+process.env.PATH}});_0x833ca1['on'](_0x512344(0x100),_0x2d2ba8=>{const _0x18ffe6=_0x512344;if(_0x2d2ba8===0x0||_0x2d2ba8===null)_0x316629();else _0x180b48(new Error(_0x58046a+_0x18ffe6(0xf4)+_0x36d3b3+_0x18ffe6(0x122)+_0x2d2ba8));}),_0x833ca1['on'](_0x512344(0x117),_0x180b48);});}function spawnViteBuildWatch(_0x5d0bf8){return new Promise((_0x3d17a2,_0x1db726)=>{const _0x2e4741=a207_0xc20c,_0x5e11be=spawn(_0x2e4741(0x115),[_0x2e4741(0xfa),'--watch'],{'cwd':_0x5d0bf8,'stdio':_0x2e4741(0x110),'shell':!![],'env':{...process.env,'PATH':''+join(_0x5d0bf8,_0x2e4741(0x10e),_0x2e4741(0x10f))+delimiter+process.env.PATH}});_0x5e11be['on'](_0x2e4741(0x100),_0x312abd=>{const _0x3aab36=_0x2e4741;if(_0x312abd===0x0||_0x312abd===null)_0x3d17a2();else _0x1db726(new Error(_0x3aab36(0x119)+_0x312abd));}),_0x5e11be['on'](_0x2e4741(0x117),_0x1db726);});}function spawnVitePreview(_0x193e10){return new Promise((_0x283097,_0x5f2dcf)=>{const _0x35896a=a207_0xc20c,_0x59649b=spawn(_0x35896a(0x115),[_0x35896a(0x108)],{'cwd':_0x193e10,'stdio':_0x35896a(0x110),'shell':!![],'env':{...process.env,'PATH':''+join(_0x193e10,_0x35896a(0x10e),'.bin')+delimiter+process.env.PATH}});_0x59649b['on'](_0x35896a(0x100),_0x46293c=>{const _0x470540=_0x35896a;if(_0x46293c===0x0||_0x46293c===null)_0x283097();else _0x5f2dcf(new Error(_0x470540(0x103)+_0x46293c));}),_0x59649b['on']('error',_0x5f2dcf);});}const runFlags=[{'name':a207_0x4d9aaa(0x107),'type':a207_0x4d9aaa(0x126),'description':'Enable\x20watch\x20mode\x20for\x20preview','default':![]}];export const runDefinition={'service':a207_0x4d9aaa(0xf7),'command':a207_0x4d9aaa(0xf7),'description':'Run\x20a\x20package.json\x20script','risk':a207_0x4d9aaa(0xf6),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':'script','description':a207_0x4d9aaa(0x114),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x168d4a=a207_0x4d9aaa,_0x42e28b=[];return _0x42e28b['push']('\x20\x20EXAMPLES'),_0x42e28b[_0x168d4a(0x105)](_0x168d4a(0x10c)+CLI_BIN_NAME+_0x168d4a(0x104)),_0x42e28b[_0x168d4a(0x105)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x168d4a(0x12b)),_0x42e28b[_0x168d4a(0x105)]('\x20\x20\x20\x20'+CLI_BIN_NAME+_0x168d4a(0xf5)),_0x42e28b[_0x168d4a(0x105)](_0x168d4a(0x10c)+CLI_BIN_NAME+_0x168d4a(0x101)),_0x42e28b[_0x168d4a(0x11d)]('\x0a');},async 'execute'(_0x200ac8){const _0xb5c091=a207_0x4d9aaa,_0x4b141a=process[_0xb5c091(0xf3)](),_0x1547c0=_0x200ac8[_0xb5c091(0x113)][0x0],_0x4942d1=_0x200ac8[_0xb5c091(0x113)][_0xb5c091(0x11b)](0x1),_0x550e68=readPackageScripts(_0x4b141a);if(!_0x550e68)throw CliErrors[_0xb5c091(0x11e)]('No\x20package.json\x20found\x20in\x20current\x20directory.');if(!_0x1547c0){const _0x265100=Object[_0xb5c091(0x118)](_0x550e68);if(_0x265100[_0xb5c091(0x10b)]===0x0)console['log'](_0xb5c091(0x123));else{console[_0xb5c091(0x11a)](_0xb5c091(0xff));for(const _0x321e51 of _0x265100){console[_0xb5c091(0x11a)](_0xb5c091(0x10c)+_0x321e51);}console['log'](_0xb5c091(0xfb)+CLI_BIN_NAME+_0xb5c091(0x12a));}return{'ok':!![]};}if(!_0x550e68[_0x1547c0])throw CliErrors[_0xb5c091(0x11e)](_0xb5c091(0x121)+_0x1547c0+_0xb5c091(0x116),'Available:\x20'+(Object[_0xb5c091(0x118)](_0x550e68)[_0xb5c091(0x11d)](',\x20')||_0xb5c091(0xfd)));const _0xd622bb=detectPackageManager(_0x4b141a);VERSION_CHECK_SCRIPTS[_0xb5c091(0xfc)](_0x1547c0)&&await versionCheck(_0x4b141a);if(_0x1547c0===_0xb5c091(0x108)&&_0x200ac8[_0xb5c091(0x11c)](_0xb5c091(0x107)))return await Promise[_0xb5c091(0x106)]([spawnViteBuildWatch(_0x4b141a),spawnVitePreview(_0x4b141a)]),{'ok':!![]};return await spawnScript(_0xd622bb,_0x1547c0,_0x4942d1,_0x4b141a),{'ok':!![]};}};
1
+ const a206_0x10f0ad=a206_0x5e53;(function(_0x1c89c3,_0xdcbcce){const _0x2dfb0d=a206_0x5e53,_0x5c6146=_0x1c89c3();while(!![]){try{const _0x2fe736=parseInt(_0x2dfb0d(0x1bc))/0x1*(parseInt(_0x2dfb0d(0x1a2))/0x2)+parseInt(_0x2dfb0d(0x1b2))/0x3+-parseInt(_0x2dfb0d(0x1be))/0x4+parseInt(_0x2dfb0d(0x1a7))/0x5*(parseInt(_0x2dfb0d(0x19f))/0x6)+-parseInt(_0x2dfb0d(0x182))/0x7*(parseInt(_0x2dfb0d(0x198))/0x8)+parseInt(_0x2dfb0d(0x18a))/0x9+-parseInt(_0x2dfb0d(0x1ab))/0xa*(-parseInt(_0x2dfb0d(0x1a5))/0xb);if(_0x2fe736===_0xdcbcce)break;else _0x5c6146['push'](_0x5c6146['shift']());}catch(_0x39d104){_0x5c6146['push'](_0x5c6146['shift']());}}}(a206_0x10e6,0x99fca));import{readFileSync,existsSync}from'node:fs';import{CLI_BIN_NAME}from'../../constant/cli.js';import{resolve,delimiter,join}from'node:path';function a206_0x5e53(_0x88da9c,_0x1d9847){_0x88da9c=_0x88da9c-0x17f;const _0x10e679=a206_0x10e6();let _0x5e530c=_0x10e679[_0x88da9c];return _0x5e530c;}import{spawn}from'node:child_process';import{CliErrors}from'../../errors.js';import{findProjectRootDirectory,resolveConfigPath}from'../../context/config-loader.js';import{writeProjectDomainRoutingManifest}from'../../config/project-domain-routing.js';import{checkSdkVersion,printSdkUpgradeWarning}from'../../utils/check-sdk-version.js';import{assertCliVersionSupported,checkCliVersion,printCliUpgradeWarning}from'../../utils/cli-version-check.js';const VERSION_CHECK_SCRIPTS=new Set([a206_0x10f0ad(0x1b7),'dev']),DOMAIN_ROUTING_SYNC_SCRIPTS=new Set(['start','dev',a206_0x10f0ad(0x1b9),a206_0x10f0ad(0x184)]);export function syncProjectDomainRoutingBeforeScript(_0x21b70c,_0x49812d){const _0x4eb45b=a206_0x10f0ad;if(!DOMAIN_ROUTING_SYNC_SCRIPTS[_0x4eb45b(0x1a8)](_0x49812d))return null;const _0x4c6edb=findProjectRootDirectory(_0x21b70c);if(!resolveConfigPath(_0x4c6edb))return null;const _0x26d94c=writeProjectDomainRoutingManifest(_0x4c6edb);return{'path':_0x26d94c[_0x4eb45b(0x19e)],'changed':_0x26d94c[_0x4eb45b(0x1bd)]};}function readPackageScripts(_0x5f06b7){const _0x3ba7ad=a206_0x10f0ad,_0x331505=resolve(_0x5f06b7,'package.json');if(!existsSync(_0x331505))return null;try{const _0x4537a3=JSON[_0x3ba7ad(0x1a4)](readFileSync(_0x331505,_0x3ba7ad(0x1a3)));return _0x4537a3[_0x3ba7ad(0x1a6)]??{};}catch{return null;}}function detectPackageManager(_0x424dae){const _0x2672fa=a206_0x10f0ad;if(existsSync(resolve(_0x424dae,_0x2672fa(0x1c0)))||existsSync(resolve(_0x424dae,'bun.lock')))return _0x2672fa(0x1a0);if(existsSync(resolve(_0x424dae,_0x2672fa(0x1bb))))return'pnpm';if(existsSync(resolve(_0x424dae,_0x2672fa(0x1a9))))return'yarn';return _0x2672fa(0x180);}async function versionCheck(_0x226bcd){const _0x4dd0f9=a206_0x10f0ad,_0x1f8683=await checkCliVersion();(_0x1f8683[_0x4dd0f9(0x1aa)]||_0x1f8683[_0x4dd0f9(0x1ba)])&&(printCliUpgradeWarning(_0x1f8683),assertCliVersionSupported(_0x1f8683));const _0x49dd8e=await checkSdkVersion(_0x226bcd);if(_0x49dd8e['needsUpgrade'])printSdkUpgradeWarning(_0x49dd8e);}function a206_0x10e6(){const _0x4ed02d=['validation','bun.lockb','\x20run\x20start','join','npm','script','7300258smzggp','\x0a\x20\x20Usage:\x20','preview','push','inherit','\x20\x20EXAMPLES','\x20run\x20','\x20run\x20preview','4216176Qaptpo','\x20run\x20<script>\x0a','watch','\x0a\x20\x20Available\x20scripts:\x0a','.bin','No\x20package.json\x20found\x20in\x20current\x20directory.','Available:\x20','close','run','\x20\x20\x20\x20','length','Enable\x20watch\x20mode\x20for\x20preview','boolean','Run\x20a\x20package.json\x20script','8xWjlkG','slice','(none)','No\x20scripts\x20defined\x20in\x20package.json.','error','args','path','6vbcSuG','bun','Script\x20name\x20defined\x20in\x20package.json','94uGTbSV','utf-8','parse','44lqjddl','scripts','2787755APhKJD','has','yarn.lock','needsUpgrade','698520DaCzXo','\x22\x20not\x20found\x20in\x20package.json.','vite\x20preview\x20exited\x20with\x20code\x20','all','\x20run\x20build','write','vite','1884759wxgQVo','log','\x20exited\x20with\x20code\x20','node_modules','vite\x20build\x20--watch\x20exited\x20with\x20code\x20','start','Script\x20\x22','build','belowMinimum','pnpm-lock.yaml','4243JEPhVa','changed','1837892oOxARa'];a206_0x10e6=function(){return _0x4ed02d;};return a206_0x10e6();}function spawnScript(_0x4c060f,_0x381c83,_0x1c1735,_0x4f0831){return new Promise((_0x28777a,_0x58633b)=>{const _0x984bd1=a206_0x5e53,_0x11c6a2=[_0x984bd1(0x192),_0x381c83,..._0x1c1735],_0x12045f=spawn(_0x4c060f,_0x11c6a2,{'cwd':_0x4f0831,'stdio':_0x984bd1(0x186),'shell':!![],'env':{...process.env,'PATH':''+join(_0x4f0831,_0x984bd1(0x1b5),_0x984bd1(0x18e))+delimiter+process.env.PATH}});_0x12045f['on']('close',_0xbf5bd3=>{const _0x3591b8=_0x984bd1;if(_0xbf5bd3===0x0||_0xbf5bd3===null)_0x28777a();else _0x58633b(new Error(_0x4c060f+_0x3591b8(0x188)+_0x381c83+_0x3591b8(0x1b4)+_0xbf5bd3));}),_0x12045f['on'](_0x984bd1(0x19c),_0x58633b);});}function spawnViteBuildWatch(_0x39b1c4){return new Promise((_0x2c650c,_0x537b48)=>{const _0x46d51c=a206_0x5e53,_0x47c920=spawn(_0x46d51c(0x1b1),[_0x46d51c(0x1b9),'--watch'],{'cwd':_0x39b1c4,'stdio':_0x46d51c(0x186),'shell':!![],'env':{...process.env,'PATH':''+join(_0x39b1c4,'node_modules',_0x46d51c(0x18e))+delimiter+process.env.PATH}});_0x47c920['on']('close',_0x19fb4c=>{const _0x4c92f1=_0x46d51c;if(_0x19fb4c===0x0||_0x19fb4c===null)_0x2c650c();else _0x537b48(new Error(_0x4c92f1(0x1b6)+_0x19fb4c));}),_0x47c920['on'](_0x46d51c(0x19c),_0x537b48);});}function spawnVitePreview(_0x460fc8){return new Promise((_0x317240,_0x18c828)=>{const _0x245e04=a206_0x5e53,_0x44c55b=spawn(_0x245e04(0x1b1),['preview'],{'cwd':_0x460fc8,'stdio':'inherit','shell':!![],'env':{...process.env,'PATH':''+join(_0x460fc8,_0x245e04(0x1b5),_0x245e04(0x18e))+delimiter+process.env.PATH}});_0x44c55b['on'](_0x245e04(0x191),_0x1665da=>{const _0x21ddfe=_0x245e04;if(_0x1665da===0x0||_0x1665da===null)_0x317240();else _0x18c828(new Error(_0x21ddfe(0x1ad)+_0x1665da));}),_0x44c55b['on'](_0x245e04(0x19c),_0x18c828);});}const runFlags=[{'name':'watch','type':a206_0x10f0ad(0x196),'description':a206_0x10f0ad(0x195),'default':![]}];export const runDefinition={'service':a206_0x10f0ad(0x192),'command':'run','description':a206_0x10f0ad(0x197),'risk':a206_0x10f0ad(0x1b0),'requiresAuth':![],'requiresAppCode':![],'hasFormat':![],'args':[{'name':a206_0x10f0ad(0x181),'description':a206_0x10f0ad(0x1a1),'required':![]}],'flags':runFlags,'helpExtra':()=>{const _0x3a5075=a206_0x10f0ad,_0x37b4fb=[];return _0x37b4fb[_0x3a5075(0x185)](_0x3a5075(0x187)),_0x37b4fb[_0x3a5075(0x185)](_0x3a5075(0x193)+CLI_BIN_NAME+_0x3a5075(0x1c1)),_0x37b4fb[_0x3a5075(0x185)](_0x3a5075(0x193)+CLI_BIN_NAME+_0x3a5075(0x1af)),_0x37b4fb[_0x3a5075(0x185)](_0x3a5075(0x193)+CLI_BIN_NAME+_0x3a5075(0x189)),_0x37b4fb[_0x3a5075(0x185)]('\x20\x20\x20\x20'+CLI_BIN_NAME+'\x20run\x20preview\x20--watch'),_0x37b4fb[_0x3a5075(0x17f)]('\x0a');},async 'execute'(_0x240ea8){const _0x283e64=a206_0x10f0ad,_0x2a7900=process['cwd'](),_0x2258bc=_0x240ea8[_0x283e64(0x19d)][0x0],_0x3fab47=_0x240ea8['args'][_0x283e64(0x199)](0x1),_0x4631e5=readPackageScripts(_0x2a7900);if(!_0x4631e5)throw CliErrors[_0x283e64(0x1bf)](_0x283e64(0x18f));if(!_0x2258bc){const _0x1bd90b=Object['keys'](_0x4631e5);if(_0x1bd90b[_0x283e64(0x194)]===0x0)console[_0x283e64(0x1b3)](_0x283e64(0x19b));else{console[_0x283e64(0x1b3)](_0x283e64(0x18d));for(const _0x463a87 of _0x1bd90b){console[_0x283e64(0x1b3)]('\x20\x20\x20\x20'+_0x463a87);}console[_0x283e64(0x1b3)](_0x283e64(0x183)+CLI_BIN_NAME+_0x283e64(0x18b));}return{'ok':!![]};}if(!_0x4631e5[_0x2258bc])throw CliErrors['validation'](_0x283e64(0x1b8)+_0x2258bc+_0x283e64(0x1ac),_0x283e64(0x190)+(Object['keys'](_0x4631e5)[_0x283e64(0x17f)](',\x20')||_0x283e64(0x19a)));const _0x3d5f10=detectPackageManager(_0x2a7900),_0x499879=syncProjectDomainRoutingBeforeScript(_0x2a7900,_0x2258bc);_0x499879?.[_0x283e64(0x1bd)]&&console[_0x283e64(0x19c)]('Domain\x20routing\x20synchronized:\x20'+_0x499879['path']);VERSION_CHECK_SCRIPTS[_0x283e64(0x1a8)](_0x2258bc)&&await versionCheck(_0x2a7900);if(_0x2258bc===_0x283e64(0x184)&&_0x240ea8['bool'](_0x283e64(0x18c)))return await Promise[_0x283e64(0x1ae)]([spawnViteBuildWatch(_0x2a7900),spawnVitePreview(_0x2a7900)]),{'ok':!![]};return await spawnScript(_0x3d5f10,_0x2258bc,_0x3fab47,_0x2a7900),{'ok':!![]};}};
@@ -1 +1 @@
1
- const a208_0x51d6d1=a208_0x2d4e;function a208_0x2602(){const _0x5c3d99=['2979695DlWkwv','schema','797678xrSmCJ','json','4152320UQCTpk','2917019giMhZh','554925ZPJghU','442270BnvmcI','export','4079580jkJmpE','Export\x20machine-readable\x20command\x20schema\x20(JSON)','6JkTAGQ'];a208_0x2602=function(){return _0x5c3d99;};return a208_0x2602();}(function(_0x56e27b,_0x1d60bb){const _0xede564=a208_0x2d4e,_0x6230c5=_0x56e27b();while(!![]){try{const _0x490465=-parseInt(_0xede564(0x1df))/0x1+-parseInt(_0xede564(0x1d8))/0x2+parseInt(_0xede564(0x1d7))/0x3+parseInt(_0xede564(0x1da))/0x4+parseInt(_0xede564(0x1dd))/0x5*(-parseInt(_0xede564(0x1dc))/0x6)+parseInt(_0xede564(0x1d6))/0x7+parseInt(_0xede564(0x1d5))/0x8;if(_0x490465===_0x1d60bb)break;else _0x6230c5['push'](_0x6230c5['shift']());}catch(_0x4e90a5){_0x6230c5['push'](_0x6230c5['shift']());}}}(a208_0x2602,0x80633));import{buildSchemaPayload}from'../framework/schema-export.js';function a208_0x2d4e(_0x11ebc6,_0x41e7a4){_0x11ebc6=_0x11ebc6-0x1d5;const _0x2602e6=a208_0x2602();let _0x2d4e31=_0x2602e6[_0x11ebc6];return _0x2d4e31;}async function execute(_0x5bd100){const _0x5b4fd7=await buildSchemaPayload();return{'ok':!![],'data':_0x5b4fd7};}export const schemaDefinition={'service':a208_0x51d6d1(0x1de),'command':a208_0x51d6d1(0x1d9),'description':a208_0x51d6d1(0x1db),'risk':'read','requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':a208_0x51d6d1(0x1e0),'flags':[],'execute':execute};
1
+ function a207_0x4643(_0xca5135,_0x1473b1){_0xca5135=_0xca5135-0x12c;const _0x447928=a207_0x4479();let _0x464300=_0x447928[_0xca5135];return _0x464300;}function a207_0x4479(){const _0x375a05=['2zkXPrQ','5497681IefNUJ','1087257cdJLYk','Export\x20machine-readable\x20command\x20schema\x20(JSON)','7467vUhHgl','3037472NgVMnX','8LomCeV','5290425FezLYX','export','2888160ZVWJyr','635275ilcOMr','read','schema'];a207_0x4479=function(){return _0x375a05;};return a207_0x4479();}const a207_0x60f0a1=a207_0x4643;(function(_0x360008,_0x5e4ba1){const _0x4f5422=a207_0x4643,_0x4046a4=_0x360008();while(!![]){try{const _0x258b51=parseInt(_0x4f5422(0x12e))/0x1+-parseInt(_0x4f5422(0x137))/0x2*(-parseInt(_0x4f5422(0x12c))/0x3)+-parseInt(_0x4f5422(0x12f))/0x4+parseInt(_0x4f5422(0x134))/0x5+parseInt(_0x4f5422(0x133))/0x6+parseInt(_0x4f5422(0x138))/0x7+-parseInt(_0x4f5422(0x130))/0x8*(parseInt(_0x4f5422(0x131))/0x9);if(_0x258b51===_0x5e4ba1)break;else _0x4046a4['push'](_0x4046a4['shift']());}catch(_0x1aeda9){_0x4046a4['push'](_0x4046a4['shift']());}}}(a207_0x4479,0x65aeb));import{buildSchemaPayload}from'../framework/schema-export.js';async function execute(_0xde6bc2){const _0x13aa95=await buildSchemaPayload();return{'ok':!![],'data':_0x13aa95};}export const schemaDefinition={'service':a207_0x60f0a1(0x136),'command':a207_0x60f0a1(0x132),'description':a207_0x60f0a1(0x12d),'risk':a207_0x60f0a1(0x135),'requiresAuth':![],'requiresAppCode':![],'hasFormat':!![],'defaultOutputFormat':'json','flags':[],'execute':execute};
@@ -1 +1 @@
1
- const a209_0x3bbc76=a209_0x8857;(function(_0xdd1a74,_0x175e99){const _0xfa6a94=a209_0x8857,_0x2fea65=_0xdd1a74();while(!![]){try{const _0x222982=parseInt(_0xfa6a94(0x13e))/0x1+-parseInt(_0xfa6a94(0x129))/0x2+parseInt(_0xfa6a94(0x133))/0x3*(parseInt(_0xfa6a94(0x135))/0x4)+parseInt(_0xfa6a94(0x12a))/0x5*(parseInt(_0xfa6a94(0x11b))/0x6)+parseInt(_0xfa6a94(0x124))/0x7+parseInt(_0xfa6a94(0x10f))/0x8*(-parseInt(_0xfa6a94(0x13c))/0x9)+parseInt(_0xfa6a94(0x141))/0xa*(-parseInt(_0xfa6a94(0x111))/0xb);if(_0x222982===_0x175e99)break;else _0x2fea65['push'](_0x2fea65['shift']());}catch(_0x3d3b5b){_0x2fea65['push'](_0x2fea65['shift']());}}}(a209_0x56aa,0x5185b));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x1f8607){const _0x35a079=a209_0x8857;if(_0x1f8607==='mybatisXml')return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','\x20\x20SELECT\x201\x20AS\x20id',_0x35a079(0x10e),''][_0x35a079(0x147)]('\x0a');return[_0x35a079(0x119),''][_0x35a079(0x147)]('\x0a');}function a209_0x56aa(){const _0x18b674=['number','487937YciVpO','/smartapi/custom/saveUserCustomSql','toISOString','218930wErFNz','length','SQL\x20name:','appCode','sqls','__manual__','join','Created\x20SQL\x20query\x20','mode','Plain\x20SQL\x20(sql)','utf8','mybatisXml','</select>','195816weNldL','description','605JVFEjN','✎\x20Enter\x20dbId\x20manually','Select\x20the\x20local\x20SQL\x20mode:','stringify','isFinite','name','sqlCode','nonInteractive','SELECT\x201\x20AS\x20id;','<server-generated-sqlCode>','498NqjAqv','dbName','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','dbId','string','For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags','db-id','create','validation','4028094bIjRpw','Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','str','Local\x20SQL\x20file\x20mode','790086ifAIkf','37425eidkWh','SQL\x20query\x20display\x20name','map','new','sqlRootDir','trim','flag','For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly','sqlName','1993644wxsdDf','write','4cRnpOG','parse','sql','flagMissing','catch','lockFilePath','isInteger','153sWshGZ'];a209_0x56aa=function(){return _0x18b674;};return a209_0x56aa();}export const sqlCreate={'service':a209_0x3bbc76(0x137),'command':a209_0x3bbc76(0x122),'description':a209_0x3bbc76(0x125),'risk':a209_0x3bbc76(0x134),'flags':[{'name':'name','type':a209_0x3bbc76(0x11f),'description':a209_0x3bbc76(0x12b)},{'name':a209_0x3bbc76(0x121),'type':'number','description':'Target\x20database\x20ID'},{'name':'mode','type':'string','enum':['sql','mybatisXml'],'description':a209_0x3bbc76(0x128)}],async 'validate'(_0x32fc45){const _0x35bf95=a209_0x3bbc76;if(!_0x32fc45['nonInteractive'])return;if(!_0x32fc45[_0x35bf95(0x127)]('name')[_0x35bf95(0x12f)]())throw CliErrors[_0x35bf95(0x138)](_0x35bf95(0x116),_0x35bf95(0x126));const _0x5d380e=resolveProvidedDbId(_0x32fc45);if(typeof _0x5d380e!=='number'||!Number[_0x35bf95(0x115)](_0x5d380e)||_0x5d380e<=0x0)throw CliErrors[_0x35bf95(0x138)](_0x35bf95(0x121),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');if(!_0x32fc45['str'](_0x35bf95(0x149))[_0x35bf95(0x12f)]())throw CliErrors[_0x35bf95(0x138)](_0x35bf95(0x149),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');},async 'dryRun'(_0x551bf9){const _0x1ba103=a209_0x3bbc76,_0x5e21c4=loadSqlProjectConfig(_0x551bf9[_0x1ba103(0x144)]),{sqlName:_0xa5e675,dbId:_0x4669dc,dbName:_0x445871,mode:_0x398b20}=await resolveSqlNewInputs(_0x551bf9),_0x25e61c=buildSqlRelativePath(_0x1ba103(0x11a),_0xa5e675,_0x445871,_0x398b20,_0x4669dc),_0x5aa860=_0x5e21c4[_0x1ba103(0x12e)]+'/'+_0x25e61c;return{'method':'POST','url':_0x1ba103(0x13f),'body':{'appCode':_0x551bf9['appCode'],'sqlName':_0xa5e675,'dbId':_0x4669dc,'mode':_0x398b20,'localPath':_0x5aa860},'description':_0x1ba103(0x11d)+_0x5e21c4[_0x1ba103(0x12e)]};},async 'execute'(_0x389359){const _0x336283=a209_0x3bbc76,_0x2757a4=loadSqlProjectConfig(_0x389359[_0x336283(0x144)]),{sqlName:_0x4bbcc1,dbId:_0x1c081a,dbName:_0x2eb0de,mode:_0x3d76af}=await resolveSqlNewInputs(_0x389359),_0x5a81ea=generateSqlTemplate(_0x3d76af),_0xa38b48=await createSqlQuery({'appCode':_0x389359[_0x336283(0x144)],'sqlName':_0x4bbcc1,'dbId':_0x1c081a,'sqlContent':_0x5a81ea}),_0x27a1b7=ensureRemoteSqlContent(_0xa38b48),_0x3172da=_0x2eb0de||await getDbName(_0x389359[_0x336283(0x144)],_0x1c081a)[_0x336283(0x139)](()=>undefined),_0x578126=buildSqlRelativePath(_0xa38b48[_0x336283(0x117)],_0xa38b48[_0x336283(0x132)],_0x3172da,_0x3d76af,_0x1c081a),_0x3c1b94=_0x2757a4[_0x336283(0x12e)]+'/'+_0x578126,_0x1fb947=buildLocalSqlFileContent({'sqlCode':_0xa38b48[_0x336283(0x117)],'sqlName':_0xa38b48[_0x336283(0x132)],'dbId':_0xa38b48['dbId']},_0x27a1b7,{'dbName':_0x3172da,'mode':_0x3d76af,'syncedAt':new Date()[_0x336283(0x140)](),'description':_0xa38b48[_0x336283(0x110)]});if(await fileExists(_0x3c1b94))throw CliErrors[_0x336283(0x123)]('File\x20already\x20exists:\x20'+_0x3c1b94);await ensureParentDirectory(_0x3c1b94),await writeFile(_0x3c1b94,_0x1fb947,_0x336283(0x14b));const _0x34be9a=await readSqlLockFile(_0x2757a4[_0x336283(0x13a)]),{lockData:_0x3eddcf,appLock:_0xbc73f4}=ensureSqlLockScope(_0x34be9a??createEmptySqlLock(),_0x2757a4[_0x336283(0x144)],_0x2757a4['sqlRoot'],_0x336283(0x12d));return _0xbc73f4[_0x336283(0x145)][_0xa38b48[_0x336283(0x117)]]={...buildSqlLockEntry(_0xa38b48,_0x27a1b7,computeSqlContentHash(_0x1fb947),{'dbName':_0x3172da}),'path':_0x578126,'mode':_0x3d76af},_0xbc73f4['lastSync']=new Date()[_0x336283(0x140)](),await writeSqlLockFile(_0x2757a4[_0x336283(0x13a)],_0x3eddcf),{'ok':!![],'data':{'id':_0xa38b48['id'],'sqlCode':_0xa38b48[_0x336283(0x117)],'sqlName':_0xa38b48[_0x336283(0x132)],'dbId':_0xa38b48['dbId'],'path':_0x3c1b94,'mode':_0x3d76af},'message':_0x336283(0x148)+_0xa38b48[_0x336283(0x117)]};}};async function resolveSqlNewInputs(_0x1727a2){const _0xdf1657=await resolveSqlNameInput(_0x1727a2),{dbId:_0x2f6eec,dbName:_0x234c32}=await resolveDbSelection(_0x1727a2),_0x228942=await resolveSqlModeInput(_0x1727a2);return{'sqlName':_0xdf1657,'dbId':_0x2f6eec,'dbName':_0x234c32,'mode':_0x228942};}function a209_0x8857(_0x3390d1,_0x333263){_0x3390d1=_0x3390d1-0x10e;const _0x56aa77=a209_0x56aa();let _0x8857d5=_0x56aa77[_0x3390d1];return _0x8857d5;}async function resolveSqlNameInput(_0x36e034){const _0x2a620c=a209_0x3bbc76,_0x234c87=_0x36e034['str'](_0x2a620c(0x116))[_0x2a620c(0x12f)]();if(_0x234c87)return _0x234c87;if(_0x36e034[_0x2a620c(0x118)])throw CliErrors['flagMissing'](_0x2a620c(0x116),_0x2a620c(0x126));return(await input({'message':_0x2a620c(0x143),'validate':_0x4838f1=>_0x4838f1[_0x2a620c(0x12f)]()?!![]:'SQL\x20name\x20cannot\x20be\x20empty'}))[_0x2a620c(0x12f)]();}async function resolveDbSelection(_0x1b368f){const _0x132500=a209_0x3bbc76,_0x2c5297=resolveProvidedDbId(_0x1b368f);if(typeof _0x2c5297==='number'&&Number[_0x132500(0x115)](_0x2c5297)&&_0x2c5297>0x0)return{'dbId':_0x2c5297,'dbName':await getDbName(_0x1b368f[_0x132500(0x144)],_0x2c5297)['catch'](()=>undefined)};if(_0x1b368f[_0x132500(0x118)])throw CliErrors[_0x132500(0x138)](_0x132500(0x121),'--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x5577d1=await listDatabases(_0x1b368f[_0x132500(0x144)])['catch'](()=>[]);if(_0x5577d1[_0x132500(0x142)]===0x1)return{'dbId':_0x5577d1[0x0][_0x132500(0x11e)],'dbName':_0x5577d1[0x0]['dbName']};if(_0x5577d1['length']>0x1){const _0x563a80=await select({'message':'Select\x20the\x20target\x20database:','choices':[..._0x5577d1[_0x132500(0x12c)](_0x15b66f=>({'name':_0x15b66f['dbName']+'\x20('+_0x15b66f['dbId']+')','value':serializeDbSelection(_0x15b66f)})),{'name':_0x132500(0x112),'value':'__manual__'}]});if(_0x563a80!==_0x132500(0x146))return deserializeDbSelection(_0x563a80);}const _0x27551f=await input({'message':'Target\x20database\x20dbId:','validate':_0x3be5d5=>{const _0x27fc9a=_0x132500,_0x16e615=_0x3be5d5[_0x27fc9a(0x12f)]();if(!_0x16e615)return'dbId\x20cannot\x20be\x20empty';const _0x348ee7=Number(_0x16e615);if(!Number[_0x27fc9a(0x13b)](_0x348ee7)||_0x348ee7<=0x0)return'dbId\x20must\x20be\x20a\x20positive\x20integer';return!![];}});return{'dbId':Number(_0x27551f[_0x132500(0x12f)]())};}async function resolveSqlModeInput(_0xaab165){const _0x50368d=a209_0x3bbc76,_0x3a77a6=_0xaab165[_0x50368d(0x127)](_0x50368d(0x149))[_0x50368d(0x12f)]();if(_0x3a77a6===_0x50368d(0x137)||_0x3a77a6===_0x50368d(0x14c))return _0x3a77a6;if(_0xaab165[_0x50368d(0x118)])throw CliErrors[_0x50368d(0x138)](_0x50368d(0x149),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x50368d(0x113),'choices':[{'name':_0x50368d(0x14a),'value':_0x50368d(0x137),'description':_0x50368d(0x131)},{'name':'MyBatis\x20XML\x20(mybatisXml)','value':_0x50368d(0x14c),'description':_0x50368d(0x120)}]});}function serializeDbSelection(_0x252373){const _0x1ae80a=a209_0x3bbc76;return JSON[_0x1ae80a(0x114)]({'dbId':_0x252373['dbId'],'dbName':_0x252373[_0x1ae80a(0x11c)]});}function deserializeDbSelection(_0x2c1494){const _0x5783df=a209_0x3bbc76;try{const _0x3b8f38=JSON[_0x5783df(0x136)](_0x2c1494);if(typeof _0x3b8f38['dbId']===_0x5783df(0x13d)&&Number['isFinite'](_0x3b8f38[_0x5783df(0x11e)]))return{'dbId':_0x3b8f38[_0x5783df(0x11e)],'dbName':_0x3b8f38['dbName']};}catch{}throw CliErrors[_0x5783df(0x123)]('Invalid\x20database\x20selection\x20payload:\x20'+_0x2c1494);}function resolveProvidedDbId(_0xdc740c){const _0x2148f7=a209_0x3bbc76,_0x558295=_0xdc740c[_0x2148f7(0x130)]('db-id');if(typeof _0x558295===_0x2148f7(0x13d)&&Number['isFinite'](_0x558295))return _0x558295;return undefined;}
1
+ const a208_0x49ade1=a208_0x568d;(function(_0x348238,_0x430c11){const _0x470e1b=a208_0x568d,_0x3ff933=_0x348238();while(!![]){try{const _0x48f38e=-parseInt(_0x470e1b(0x14e))/0x1*(parseInt(_0x470e1b(0x168))/0x2)+-parseInt(_0x470e1b(0x152))/0x3+parseInt(_0x470e1b(0x13b))/0x4*(parseInt(_0x470e1b(0x15b))/0x5)+parseInt(_0x470e1b(0x149))/0x6+-parseInt(_0x470e1b(0x147))/0x7*(parseInt(_0x470e1b(0x150))/0x8)+parseInt(_0x470e1b(0x15e))/0x9+parseInt(_0x470e1b(0x165))/0xa*(parseInt(_0x470e1b(0x153))/0xb);if(_0x48f38e===_0x430c11)break;else _0x3ff933['push'](_0x3ff933['shift']());}catch(_0x33ee70){_0x3ff933['push'](_0x3ff933['shift']());}}}(a208_0x2123,0xe385d));import{writeFile}from'node:fs/promises';import{input,select}from'@inquirer/prompts';import{createSqlQuery}from'../../core/api-client.js';function a208_0x2123(){const _0x38e45d=['map','SQL\x20name\x20cannot\x20be\x20empty','mybatisXml','21430mlDCbO','Plain\x20SQL\x20(sql)','sqlRoot','8386jkGwbD','<server-generated-sqlCode>','--db-id\x20is\x20required\x20in\x20non-interactive\x20mode.','mode','parse','Would\x20create\x20a\x20new\x20SQL\x20query\x20and\x20scaffold\x20it\x20under\x20','join','sqlRootDir','Select\x20the\x20local\x20SQL\x20mode:','str','length','flag','sql','sqlName','db-id','create','POST','isInteger','nonInteractive','flagMissing','Invalid\x20database\x20selection\x20payload:\x20','278004wemjgW','catch','trim','Target\x20database\x20ID','__manual__','dbName','appCode','isFinite','dbId','validation','Select\x20the\x20target\x20database:','new','212884IRQJdy','lastSync','942582qZGFeK','description','lockFilePath','sqlCode','utf8','334DSTyne','MyBatis\x20XML\x20(mybatisXml)','248bXPjcP','stringify','4872636ywzGoU','13442aXEMgk','dbId\x20must\x20be\x20a\x20positive\x20integer','SQL\x20query\x20display\x20name','✎\x20Enter\x20dbId\x20manually','Target\x20database\x20dbId:','</select>','--name\x20is\x20required\x20in\x20non-interactive\x20mode.','name','110VOvWVW','toISOString','string','5350626SVkhWa','dbId\x20cannot\x20be\x20empty','--mode\x20is\x20required\x20in\x20non-interactive\x20mode.','number'];a208_0x2123=function(){return _0x38e45d;};return a208_0x2123();}import{getDbName,listDatabases}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{buildSqlRelativePath}from'../../core/sql-sync/utils.js';import{CliErrors}from'../../errors.js';import{buildLocalSqlFileContent,buildSqlLockEntry,ensureRemoteSqlContent}from'./shared.js';function generateSqlTemplate(_0x3a29a9){const _0x272913=a208_0x568d;if(_0x3a29a9===_0x272913(0x164))return['<select\x20id=\x22query\x22\x20resultType=\x22map\x22>','\x20\x20SELECT\x201\x20AS\x20id',_0x272913(0x158),''][_0x272913(0x16e)]('\x0a');return['SELECT\x201\x20AS\x20id;','']['join']('\x0a');}export const sqlCreate={'service':a208_0x49ade1(0x132),'command':a208_0x49ade1(0x135),'description':'Create\x20a\x20new\x20custom\x20SQL\x20and\x20scaffold\x20it\x20locally','risk':'write','flags':[{'name':a208_0x49ade1(0x15a),'type':'string','description':a208_0x49ade1(0x155)},{'name':a208_0x49ade1(0x134),'type':a208_0x49ade1(0x161),'description':a208_0x49ade1(0x13e)},{'name':a208_0x49ade1(0x16b),'type':a208_0x49ade1(0x15d),'enum':[a208_0x49ade1(0x132),a208_0x49ade1(0x164)],'description':'Local\x20SQL\x20file\x20mode'}],async 'validate'(_0x3b8737){const _0xc63564=a208_0x49ade1;if(!_0x3b8737[_0xc63564(0x138)])return;if(!_0x3b8737[_0xc63564(0x171)](_0xc63564(0x15a))[_0xc63564(0x13d)]())throw CliErrors['flagMissing']('name','--name\x20is\x20required\x20in\x20non-interactive\x20mode.');const _0x59a3fe=resolveProvidedDbId(_0x3b8737);if(typeof _0x59a3fe!==_0xc63564(0x161)||!Number['isFinite'](_0x59a3fe)||_0x59a3fe<=0x0)throw CliErrors[_0xc63564(0x139)](_0xc63564(0x134),_0xc63564(0x16a));if(!_0x3b8737['str']('mode')[_0xc63564(0x13d)]())throw CliErrors[_0xc63564(0x139)](_0xc63564(0x16b),_0xc63564(0x160));},async 'dryRun'(_0x48f737){const _0x1dd38f=a208_0x49ade1,_0x4faf89=loadSqlProjectConfig(_0x48f737[_0x1dd38f(0x141)]),{sqlName:_0x5f4767,dbId:_0x5c0e4f,dbName:_0x4a0a92,mode:_0x56aa1e}=await resolveSqlNewInputs(_0x48f737),_0x3f2a5b=buildSqlRelativePath(_0x1dd38f(0x169),_0x5f4767,_0x4a0a92,_0x56aa1e,_0x5c0e4f),_0x3ff2e2=_0x4faf89[_0x1dd38f(0x16f)]+'/'+_0x3f2a5b;return{'method':_0x1dd38f(0x136),'url':'/smartapi/custom/saveUserCustomSql','body':{'appCode':_0x48f737['appCode'],'sqlName':_0x5f4767,'dbId':_0x5c0e4f,'mode':_0x56aa1e,'localPath':_0x3ff2e2},'description':_0x1dd38f(0x16d)+_0x4faf89[_0x1dd38f(0x16f)]};},async 'execute'(_0x8748a6){const _0x371b1b=a208_0x49ade1,_0x161836=loadSqlProjectConfig(_0x8748a6[_0x371b1b(0x141)]),{sqlName:_0x74f28c,dbId:_0x35d6b9,dbName:_0x26aaa2,mode:_0x1f965a}=await resolveSqlNewInputs(_0x8748a6),_0x5022cf=generateSqlTemplate(_0x1f965a),_0x4180c0=await createSqlQuery({'appCode':_0x8748a6[_0x371b1b(0x141)],'sqlName':_0x74f28c,'dbId':_0x35d6b9,'sqlContent':_0x5022cf}),_0xee7cb=ensureRemoteSqlContent(_0x4180c0),_0x4d10ff=_0x26aaa2||await getDbName(_0x8748a6[_0x371b1b(0x141)],_0x35d6b9)[_0x371b1b(0x13c)](()=>undefined),_0x249b59=buildSqlRelativePath(_0x4180c0[_0x371b1b(0x14c)],_0x4180c0[_0x371b1b(0x133)],_0x4d10ff,_0x1f965a,_0x35d6b9),_0xb01006=_0x161836[_0x371b1b(0x16f)]+'/'+_0x249b59,_0x5bd19f=buildLocalSqlFileContent({'sqlCode':_0x4180c0[_0x371b1b(0x14c)],'sqlName':_0x4180c0[_0x371b1b(0x133)],'dbId':_0x4180c0[_0x371b1b(0x143)]},_0xee7cb,{'dbName':_0x4d10ff,'mode':_0x1f965a,'syncedAt':new Date()[_0x371b1b(0x15c)](),'description':_0x4180c0[_0x371b1b(0x14a)]});if(await fileExists(_0xb01006))throw CliErrors[_0x371b1b(0x144)]('File\x20already\x20exists:\x20'+_0xb01006);await ensureParentDirectory(_0xb01006),await writeFile(_0xb01006,_0x5bd19f,_0x371b1b(0x14d));const _0x1a627e=await readSqlLockFile(_0x161836[_0x371b1b(0x14b)]),{lockData:_0x251dc2,appLock:_0x2171fa}=ensureSqlLockScope(_0x1a627e??createEmptySqlLock(),_0x161836['appCode'],_0x161836[_0x371b1b(0x167)],_0x371b1b(0x146));return _0x2171fa['sqls'][_0x4180c0[_0x371b1b(0x14c)]]={...buildSqlLockEntry(_0x4180c0,_0xee7cb,computeSqlContentHash(_0x5bd19f),{'dbName':_0x4d10ff}),'path':_0x249b59,'mode':_0x1f965a},_0x2171fa[_0x371b1b(0x148)]=new Date()[_0x371b1b(0x15c)](),await writeSqlLockFile(_0x161836[_0x371b1b(0x14b)],_0x251dc2),{'ok':!![],'data':{'id':_0x4180c0['id'],'sqlCode':_0x4180c0['sqlCode'],'sqlName':_0x4180c0[_0x371b1b(0x133)],'dbId':_0x4180c0[_0x371b1b(0x143)],'path':_0xb01006,'mode':_0x1f965a},'message':'Created\x20SQL\x20query\x20'+_0x4180c0[_0x371b1b(0x14c)]};}};async function resolveSqlNewInputs(_0x47c8a6){const _0xdb7a63=await resolveSqlNameInput(_0x47c8a6),{dbId:_0xac57d6,dbName:_0x431f00}=await resolveDbSelection(_0x47c8a6),_0x4d2b60=await resolveSqlModeInput(_0x47c8a6);return{'sqlName':_0xdb7a63,'dbId':_0xac57d6,'dbName':_0x431f00,'mode':_0x4d2b60};}async function resolveSqlNameInput(_0x3662cd){const _0x4ac785=a208_0x49ade1,_0x376d43=_0x3662cd[_0x4ac785(0x171)](_0x4ac785(0x15a))[_0x4ac785(0x13d)]();if(_0x376d43)return _0x376d43;if(_0x3662cd[_0x4ac785(0x138)])throw CliErrors[_0x4ac785(0x139)](_0x4ac785(0x15a),_0x4ac785(0x159));return(await input({'message':'SQL\x20name:','validate':_0x1f28bd=>_0x1f28bd[_0x4ac785(0x13d)]()?!![]:_0x4ac785(0x163)}))[_0x4ac785(0x13d)]();}async function resolveDbSelection(_0x43b932){const _0x35e095=a208_0x49ade1,_0x350b22=resolveProvidedDbId(_0x43b932);if(typeof _0x350b22===_0x35e095(0x161)&&Number['isFinite'](_0x350b22)&&_0x350b22>0x0)return{'dbId':_0x350b22,'dbName':await getDbName(_0x43b932['appCode'],_0x350b22)['catch'](()=>undefined)};if(_0x43b932[_0x35e095(0x138)])throw CliErrors['flagMissing'](_0x35e095(0x134),_0x35e095(0x16a));const _0xabceee=await listDatabases(_0x43b932['appCode'])[_0x35e095(0x13c)](()=>[]);if(_0xabceee[_0x35e095(0x172)]===0x1)return{'dbId':_0xabceee[0x0][_0x35e095(0x143)],'dbName':_0xabceee[0x0][_0x35e095(0x140)]};if(_0xabceee[_0x35e095(0x172)]>0x1){const _0x19ab2a=await select({'message':_0x35e095(0x145),'choices':[..._0xabceee[_0x35e095(0x162)](_0xd33931=>({'name':_0xd33931[_0x35e095(0x140)]+'\x20('+_0xd33931[_0x35e095(0x143)]+')','value':serializeDbSelection(_0xd33931)})),{'name':_0x35e095(0x156),'value':_0x35e095(0x13f)}]});if(_0x19ab2a!=='__manual__')return deserializeDbSelection(_0x19ab2a);}const _0x161e4b=await input({'message':_0x35e095(0x157),'validate':_0xbd6d73=>{const _0x159f1c=_0x35e095,_0x4cda22=_0xbd6d73[_0x159f1c(0x13d)]();if(!_0x4cda22)return _0x159f1c(0x15f);const _0x2aaff9=Number(_0x4cda22);if(!Number[_0x159f1c(0x137)](_0x2aaff9)||_0x2aaff9<=0x0)return _0x159f1c(0x154);return!![];}});return{'dbId':Number(_0x161e4b['trim']())};}async function resolveSqlModeInput(_0x320968){const _0x212c05=a208_0x49ade1,_0x345806=_0x320968[_0x212c05(0x171)](_0x212c05(0x16b))[_0x212c05(0x13d)]();if(_0x345806===_0x212c05(0x132)||_0x345806===_0x212c05(0x164))return _0x345806;if(_0x320968[_0x212c05(0x138)])throw CliErrors[_0x212c05(0x139)](_0x212c05(0x16b),'--mode\x20is\x20required\x20in\x20non-interactive\x20mode.');return await select({'message':_0x212c05(0x170),'choices':[{'name':_0x212c05(0x166),'value':_0x212c05(0x132),'description':'For\x20SELECT\x20/\x20INSERT\x20/\x20UPDATE\x20/\x20DELETE\x20statements\x20that\x20run\x20directly'},{'name':_0x212c05(0x14f),'value':_0x212c05(0x164),'description':'For\x20MyBatis\x20XML\x20SQL\x20with\x20dynamic\x20tags'}]});}function a208_0x568d(_0x455469,_0x140661){_0x455469=_0x455469-0x132;const _0x2123d4=a208_0x2123();let _0x568d3f=_0x2123d4[_0x455469];return _0x568d3f;}function serializeDbSelection(_0x43d6d1){const _0x1d8ce2=a208_0x49ade1;return JSON[_0x1d8ce2(0x151)]({'dbId':_0x43d6d1['dbId'],'dbName':_0x43d6d1[_0x1d8ce2(0x140)]});}function deserializeDbSelection(_0xbb199a){const _0x10d172=a208_0x49ade1;try{const _0x3ab68b=JSON[_0x10d172(0x16c)](_0xbb199a);if(typeof _0x3ab68b[_0x10d172(0x143)]===_0x10d172(0x161)&&Number['isFinite'](_0x3ab68b['dbId']))return{'dbId':_0x3ab68b[_0x10d172(0x143)],'dbName':_0x3ab68b[_0x10d172(0x140)]};}catch{}throw CliErrors['validation'](_0x10d172(0x13a)+_0xbb199a);}function resolveProvidedDbId(_0x58a8e9){const _0x4e0489=a208_0x49ade1,_0x530216=_0x58a8e9[_0x4e0489(0x173)](_0x4e0489(0x134));if(typeof _0x530216===_0x4e0489(0x161)&&Number[_0x4e0489(0x142)](_0x530216))return _0x530216;return undefined;}
@@ -1 +1 @@
1
- const a210_0x346af7=a210_0x57a0;(function(_0xc8961b,_0x365ee1){const _0x464917=a210_0x57a0,_0x33ad67=_0xc8961b();while(!![]){try{const _0x45f9c9=parseInt(_0x464917(0x117))/0x1*(parseInt(_0x464917(0x11d))/0x2)+parseInt(_0x464917(0x11f))/0x3+-parseInt(_0x464917(0x114))/0x4+-parseInt(_0x464917(0x107))/0x5+parseInt(_0x464917(0x10b))/0x6*(parseInt(_0x464917(0x112))/0x7)+parseInt(_0x464917(0x115))/0x8+-parseInt(_0x464917(0x10e))/0x9;if(_0x45f9c9===_0x365ee1)break;else _0x33ad67['push'](_0x33ad67['shift']());}catch(_0x2ad3b5){_0x33ad67['push'](_0x33ad67['shift']());}}}(a210_0x5a21,0x33f70));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';function a210_0x5a21(){const _0xe1b0b5=['str','1244181avtJww','remoteId','No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22','filter','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','Would\x20delete\x20SQL\x20','toISOString','POST','sqlRootDir','length','sqlRoot','1517365quvFOH','lockFilePath','trashedTo','/smartapi/custom/deleteUserCustomSql','462pWgyHu','startsWith','appCode','84303hnlcDS','trashDir','high-risk-write','sqls','2821JdioPf','sqlcode','1668864RzlgJF','860248owypdp','Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','145ynVThA','entries','validation','projectRoot','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','delete','5374XbdbYF'];a210_0x5a21=function(){return _0xe1b0b5;};return a210_0x5a21();}function a210_0x57a0(_0x2bf913,_0x1fa11c){_0x2bf913=_0x2bf913-0x105;const _0x5a21e6=a210_0x5a21();let _0x57a017=_0x5a21e6[_0x2bf913];return _0x57a017;}import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDelete={'service':'sql','command':a210_0x346af7(0x11c),'description':a210_0x346af7(0x116),'risk':a210_0x346af7(0x110),'flags':[SQLCODE_FLAG],async 'validate'(_0x455665){const _0x47c128=a210_0x346af7,_0x5c22a7=loadSqlProjectConfig(_0x455665['appCode']),_0x3624f1=await readSqlLockFile(_0x5c22a7[_0x47c128(0x108)]);if(!_0x3624f1)throw CliErrors[_0x47c128(0x119)](_0x47c128(0x11b));},async 'dryRun'(_0x388c48){const _0x2b763a=a210_0x346af7,_0x607308=loadSqlProjectConfig(_0x388c48[_0x2b763a(0x10d)]),_0x1a7b26=await readSqlLockFile(_0x607308[_0x2b763a(0x108)]);if(!_0x1a7b26)throw CliErrors['validation'](_0x2b763a(0x11b));const {appLock:_0xf0639}=ensureSqlLockScope(_0x1a7b26,_0x388c48[_0x2b763a(0x10d)],_0x607308[_0x2b763a(0x106)],_0x2b763a(0x11c)),_0x103199=_0x388c48[_0x2b763a(0x11e)]('sqlcode'),_0x5c07df=_0xf0639[_0x2b763a(0x111)][_0x103199];if(!_0x5c07df)throw CliErrors[_0x2b763a(0x119)](_0x2b763a(0x121)+_0x103199+'\x22.');return{'method':_0x2b763a(0x126),'url':_0x2b763a(0x10a),'body':{'sqlCode':_0x103199,'id':_0x5c07df[_0x2b763a(0x120)],'localPath':resolveLocalSqlFilePath(_0x607308,_0x103199,_0x5c07df)},'description':_0x2b763a(0x124)+_0x103199+_0x2b763a(0x123)+_0x607308[_0x2b763a(0x10f)]};},async 'execute'(_0x5177b9){const _0x435162=a210_0x346af7,_0x366aaf=loadSqlProjectConfig(_0x5177b9['appCode']),_0xae5470=await readSqlLockFile(_0x366aaf[_0x435162(0x108)]);if(!_0xae5470)throw CliErrors[_0x435162(0x119)]('SQL\x20lock\x20file\x20not\x20found.');const {lockData:_0x4e00eb,appLock:_0x382277}=ensureSqlLockScope(_0xae5470,_0x5177b9[_0x435162(0x10d)],_0x366aaf[_0x435162(0x106)],_0x435162(0x11c)),_0x82aaf0=_0x5177b9[_0x435162(0x11e)](_0x435162(0x113)),_0x28aded=_0x382277[_0x435162(0x111)][_0x82aaf0];if(!_0x28aded)throw CliErrors[_0x435162(0x119)](_0x435162(0x121)+_0x82aaf0+'\x22.');await deleteSqlQuery({'id':_0x28aded[_0x435162(0x120)],'sqlCode':_0x82aaf0}),_0x382277[_0x435162(0x111)]=Object['fromEntries'](Object[_0x435162(0x118)](_0x382277[_0x435162(0x111)])[_0x435162(0x122)](([_0x2c05a5])=>_0x2c05a5!==_0x82aaf0)),_0x382277['lastSync']=new Date()[_0x435162(0x125)](),await writeSqlLockFile(_0x366aaf[_0x435162(0x108)],_0x4e00eb);const _0x34249b=resolveLocalSqlFilePath(_0x366aaf,_0x82aaf0,_0x28aded);let _0x38008f;await fileExists(_0x34249b)&&(_0x38008f=await moveToTrash(_0x366aaf[_0x435162(0x11a)],_0x366aaf[_0x435162(0x10f)],_0x34249b),await cleanupEmptyDirectories(dirname(_0x34249b),_0x366aaf[_0x435162(0x127)]));const _0x1d28c2={'deleted':_0x82aaf0,'remoteId':_0x28aded[_0x435162(0x120)]};if(_0x38008f)_0x1d28c2[_0x435162(0x109)]=_0x38008f;return{'ok':!![],'data':_0x1d28c2,'message':'Deleted\x20'+_0x82aaf0+(_0x38008f?'\x20(local\x20file\x20moved\x20to\x20trash)':'')};}};async function moveToTrash(_0x4cc1e8,_0x274235,_0x4f0fa3){const _0x5dd694=a210_0x346af7,_0x1dca0c=new Date()[_0x5dd694(0x125)]()['replace'](/[:.]/g,'-'),_0x54f8ff=relative(_0x4cc1e8,_0x4f0fa3),_0x1b6264=join(_0x274235,_0x1dca0c,_0x54f8ff);return await mkdir(dirname(_0x1b6264),{'recursive':!![]}),await rename(_0x4f0fa3,_0x1b6264),_0x1b6264;}async function cleanupEmptyDirectories(_0x1cd155,_0x4d8236){const _0x195969=a210_0x346af7;let _0x14c793=resolve(_0x1cd155);const _0x4320b2=resolve(_0x4d8236);while(_0x14c793[_0x195969(0x10c)](''+_0x4320b2+sep)||_0x14c793===_0x4320b2){if(_0x14c793===_0x4320b2)return;try{const _0x3d9bf4=await readdir(_0x14c793);if(_0x3d9bf4[_0x195969(0x105)]>0x0)return;await rmdir(_0x14c793);}catch{return;}_0x14c793=dirname(_0x14c793);}}
1
+ const a209_0x1e769a=a209_0x3e83;(function(_0xe44360,_0x18740e){const _0x408758=a209_0x3e83,_0x5ae1f1=_0xe44360();while(!![]){try{const _0x32bb5c=-parseInt(_0x408758(0xfa))/0x1*(parseInt(_0x408758(0x10a))/0x2)+-parseInt(_0x408758(0x10b))/0x3+parseInt(_0x408758(0x10c))/0x4+parseInt(_0x408758(0x111))/0x5*(-parseInt(_0x408758(0x10f))/0x6)+-parseInt(_0x408758(0x101))/0x7*(-parseInt(_0x408758(0x104))/0x8)+-parseInt(_0x408758(0x116))/0x9+parseInt(_0x408758(0x102))/0xa;if(_0x32bb5c===_0x18740e)break;else _0x5ae1f1['push'](_0x5ae1f1['shift']());}catch(_0x1c90a2){_0x5ae1f1['push'](_0x5ae1f1['shift']());}}}(a209_0xba5e,0xb2ff2));import{mkdir,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{deleteSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{fileExists}from'../../core/bff/file-system.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{CliErrors}from'../../errors.js';function a209_0x3e83(_0x8b5ac9,_0x35066d){_0x8b5ac9=_0x8b5ac9-0xf9;const _0xba5ebf=a209_0xba5e();let _0x3e83ff=_0xba5ebf[_0x8b5ac9];return _0x3e83ff;}import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a209_0xba5e(){const _0x403da3=['8tcziMZ','high-risk-write','trashDir','projectRoot','/smartapi/custom/deleteUserCustomSql','SQL\x20lock\x20file\x20not\x20found.','93706WLJqWv','4321647kdAvOd','2424044JnZLuV','validation','sql','6VhnBIu','replace','3263705WphRwn','sqls','sqlRoot','str','Deleted\x20','1568034RAfCRF','filter','lastSync','remoteId','sqlRootDir','startsWith','delete','sqlcode','31tHxlrL','toISOString','length','appCode','SQL\x20lock\x20file\x20not\x20found.\x20Run\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first.','Would\x20delete\x20SQL\x20','\x20from\x20remote\x20and\x20move\x20local\x20file\x20to\x20','934283XBjrHL','37136490gUFpwg','lockFilePath'];a209_0xba5e=function(){return _0x403da3;};return a209_0xba5e();}export const sqlDelete={'service':a209_0x1e769a(0x10e),'command':a209_0x1e769a(0x11c),'description':'Delete\x20a\x20SQL\x20query\x20from\x20remote\x20and\x20local','risk':a209_0x1e769a(0x105),'flags':[SQLCODE_FLAG],async 'validate'(_0x42171f){const _0x399271=a209_0x1e769a,_0x313136=loadSqlProjectConfig(_0x42171f[_0x399271(0xfd)]),_0x5743a4=await readSqlLockFile(_0x313136['lockFilePath']);if(!_0x5743a4)throw CliErrors[_0x399271(0x10d)](_0x399271(0xfe));},async 'dryRun'(_0x2c1b91){const _0x1548cc=a209_0x1e769a,_0x369e43=loadSqlProjectConfig(_0x2c1b91[_0x1548cc(0xfd)]),_0x413d65=await readSqlLockFile(_0x369e43[_0x1548cc(0x103)]);if(!_0x413d65)throw CliErrors[_0x1548cc(0x10d)](_0x1548cc(0xfe));const {appLock:_0x4341a5}=ensureSqlLockScope(_0x413d65,_0x2c1b91[_0x1548cc(0xfd)],_0x369e43[_0x1548cc(0x113)],'delete'),_0x4a5cdf=_0x2c1b91[_0x1548cc(0x114)](_0x1548cc(0xf9)),_0x3f432d=_0x4341a5['sqls'][_0x4a5cdf];if(!_0x3f432d)throw CliErrors[_0x1548cc(0x10d)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x4a5cdf+'\x22.');return{'method':'POST','url':_0x1548cc(0x108),'body':{'sqlCode':_0x4a5cdf,'id':_0x3f432d['remoteId'],'localPath':resolveLocalSqlFilePath(_0x369e43,_0x4a5cdf,_0x3f432d)},'description':_0x1548cc(0xff)+_0x4a5cdf+_0x1548cc(0x100)+_0x369e43[_0x1548cc(0x106)]};},async 'execute'(_0x1af15f){const _0x174c7d=a209_0x1e769a,_0x5aaecb=loadSqlProjectConfig(_0x1af15f[_0x174c7d(0xfd)]),_0x10a96e=await readSqlLockFile(_0x5aaecb['lockFilePath']);if(!_0x10a96e)throw CliErrors[_0x174c7d(0x10d)](_0x174c7d(0x109));const {lockData:_0x53b985,appLock:_0x3eb085}=ensureSqlLockScope(_0x10a96e,_0x1af15f[_0x174c7d(0xfd)],_0x5aaecb[_0x174c7d(0x113)],_0x174c7d(0x11c)),_0x1cc385=_0x1af15f[_0x174c7d(0x114)](_0x174c7d(0xf9)),_0x2d110b=_0x3eb085[_0x174c7d(0x112)][_0x1cc385];if(!_0x2d110b)throw CliErrors[_0x174c7d(0x10d)]('No\x20SQL\x20lock\x20entry\x20found\x20for\x20\x22'+_0x1cc385+'\x22.');await deleteSqlQuery({'id':_0x2d110b[_0x174c7d(0x119)],'sqlCode':_0x1cc385}),_0x3eb085[_0x174c7d(0x112)]=Object['fromEntries'](Object['entries'](_0x3eb085[_0x174c7d(0x112)])[_0x174c7d(0x117)](([_0x3ae4af])=>_0x3ae4af!==_0x1cc385)),_0x3eb085[_0x174c7d(0x118)]=new Date()[_0x174c7d(0xfb)](),await writeSqlLockFile(_0x5aaecb[_0x174c7d(0x103)],_0x53b985);const _0x5c79ce=resolveLocalSqlFilePath(_0x5aaecb,_0x1cc385,_0x2d110b);let _0x479976;await fileExists(_0x5c79ce)&&(_0x479976=await moveToTrash(_0x5aaecb[_0x174c7d(0x107)],_0x5aaecb['trashDir'],_0x5c79ce),await cleanupEmptyDirectories(dirname(_0x5c79ce),_0x5aaecb[_0x174c7d(0x11a)]));const _0xaef9bb={'deleted':_0x1cc385,'remoteId':_0x2d110b['remoteId']};if(_0x479976)_0xaef9bb['trashedTo']=_0x479976;return{'ok':!![],'data':_0xaef9bb,'message':_0x174c7d(0x115)+_0x1cc385+(_0x479976?'\x20(local\x20file\x20moved\x20to\x20trash)':'')};}};async function moveToTrash(_0x41edd1,_0x25212e,_0x3d3824){const _0x42dde2=a209_0x1e769a,_0x15f36b=new Date()[_0x42dde2(0xfb)]()[_0x42dde2(0x110)](/[:.]/g,'-'),_0x12766a=relative(_0x41edd1,_0x3d3824),_0x51381d=join(_0x25212e,_0x15f36b,_0x12766a);return await mkdir(dirname(_0x51381d),{'recursive':!![]}),await rename(_0x3d3824,_0x51381d),_0x51381d;}async function cleanupEmptyDirectories(_0x401cf9,_0x5b8bb6){const _0x4f8c64=a209_0x1e769a;let _0x46167f=resolve(_0x401cf9);const _0x47c927=resolve(_0x5b8bb6);while(_0x46167f[_0x4f8c64(0x11b)](''+_0x47c927+sep)||_0x46167f===_0x47c927){if(_0x46167f===_0x47c927)return;try{const _0x57c38e=await readdir(_0x46167f);if(_0x57c38e[_0x4f8c64(0xfc)]>0x0)return;await rmdir(_0x46167f);}catch{return;}_0x46167f=dirname(_0x46167f);}}
@@ -1 +1 @@
1
- const a211_0x9cf73f=a211_0x4e7a;(function(_0x3e28a1,_0x513b47){const _0x402ae5=a211_0x4e7a,_0x1d9e52=_0x3e28a1();while(!![]){try{const _0x31064a=-parseInt(_0x402ae5(0x17f))/0x1+parseInt(_0x402ae5(0x181))/0x2*(-parseInt(_0x402ae5(0x176))/0x3)+-parseInt(_0x402ae5(0x187))/0x4+-parseInt(_0x402ae5(0x173))/0x5*(-parseInt(_0x402ae5(0x182))/0x6)+parseInt(_0x402ae5(0x17e))/0x7*(parseInt(_0x402ae5(0x17d))/0x8)+parseInt(_0x402ae5(0x17b))/0x9*(parseInt(_0x402ae5(0x184))/0xa)+-parseInt(_0x402ae5(0x188))/0xb*(-parseInt(_0x402ae5(0x180))/0xc);if(_0x31064a===_0x513b47)break;else _0x1d9e52['push'](_0x1d9e52['shift']());}catch(_0x442aa3){_0x1d9e52['push'](_0x1d9e52['shift']());}}}(a211_0x58d9,0x83082));function a211_0x4e7a(_0xc1e78,_0x2dc99f){_0xc1e78=_0xc1e78-0x173;const _0x58d9a5=a211_0x58d9();let _0x4e7a13=_0x58d9a5[_0xc1e78];return _0x4e7a13;}import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a211_0x58d9(){const _0x5c5e8d=['731128NwUyMj','21bXUakJ','944843qgVWXn','228SWqCQq','236ptVbIw','30jzyqDr','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','160EmbMkn','Return\x20full\x20raw\x20SQL\x20query\x20object','verbose','1950796BCjnDW','718817ELXjWy','sqlContent','sql','bool','688990XqhndT','str','appCode','15786GEtVVx','dbId','boolean','sqlCode','sqlName','216792IHdhpL','read'];a211_0x58d9=function(){return _0x5c5e8d;};return a211_0x58d9();}import{SQLCODE_FLAG}from'../../commands/common/flags.js';export const sqlDetail={'service':a211_0x9cf73f(0x18a),'command':'detail','description':a211_0x9cf73f(0x183),'risk':a211_0x9cf73f(0x17c),'flags':[SQLCODE_FLAG,{'name':'verbose','type':a211_0x9cf73f(0x178),'description':a211_0x9cf73f(0x185)}],async 'execute'(_0x4251f8){const _0x257e94=a211_0x9cf73f,_0xb12220=await getSqlQueryInfo(_0x4251f8['appCode'],_0x4251f8[_0x257e94(0x174)]('sqlcode')),_0x32102c=_0x4251f8[_0x257e94(0x18b)](_0x257e94(0x186));if(_0x32102c)return{'ok':!![],'data':_0xb12220};const _0x22de95=_0xb12220[_0x257e94(0x177)]?await getDbName(_0x4251f8[_0x257e94(0x175)],_0xb12220[_0x257e94(0x177)]):undefined;return{'ok':!![],'data':{'sqlCode':_0xb12220[_0x257e94(0x179)],'sqlName':_0xb12220[_0x257e94(0x17a)],'db':_0x22de95?_0x22de95+'\x20('+_0xb12220[_0x257e94(0x177)]+')':_0xb12220[_0x257e94(0x177)]??'','description':_0xb12220['description']??'','sqlContent':_0xb12220[_0x257e94(0x189)]??''}};}};
1
+ function a210_0x1235(){const _0x3033f6=['32TCPkwk','2787966YqUXpR','sql','495003YJrMWs','sqlName','verbose','275kKxAjR','sqlCode','936168NjbjJD','appCode','dbId','str','Get\x20custom\x20SQL\x20query\x20details\x20by\x20sqlCode','description','37612OocnNK','5794370SbfNCN','523817mMEEGF','read','sqlcode','boolean','281366pmqGkt','2nfsGvF'];a210_0x1235=function(){return _0x3033f6;};return a210_0x1235();}const a210_0x53f0bb=a210_0x6347;(function(_0x3f728b,_0x1561a8){const _0x157eb7=a210_0x6347,_0x1b2734=_0x3f728b();while(!![]){try{const _0x3f6516=parseInt(_0x157eb7(0x136))/0x1+-parseInt(_0x157eb7(0x137))/0x2*(-parseInt(_0x157eb7(0x13b))/0x3)+-parseInt(_0x157eb7(0x130))/0x4*(parseInt(_0x157eb7(0x13e))/0x5)+-parseInt(_0x157eb7(0x12a))/0x6+parseInt(_0x157eb7(0x132))/0x7*(-parseInt(_0x157eb7(0x138))/0x8)+parseInt(_0x157eb7(0x139))/0x9+parseInt(_0x157eb7(0x131))/0xa;if(_0x3f6516===_0x1561a8)break;else _0x1b2734['push'](_0x1b2734['shift']());}catch(_0x436424){_0x1b2734['push'](_0x1b2734['shift']());}}}(a210_0x1235,0x58a35));import{getSqlQueryInfo}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';function a210_0x6347(_0x3809b1,_0x56d93e){_0x3809b1=_0x3809b1-0x129;const _0x123580=a210_0x1235();let _0x6347ba=_0x123580[_0x3809b1];return _0x6347ba;}export const sqlDetail={'service':a210_0x53f0bb(0x13a),'command':'detail','description':a210_0x53f0bb(0x12e),'risk':a210_0x53f0bb(0x133),'flags':[SQLCODE_FLAG,{'name':a210_0x53f0bb(0x13d),'type':a210_0x53f0bb(0x135),'description':'Return\x20full\x20raw\x20SQL\x20query\x20object'}],async 'execute'(_0x45d4cd){const _0x1e5e08=a210_0x53f0bb,_0x2637fc=await getSqlQueryInfo(_0x45d4cd[_0x1e5e08(0x12b)],_0x45d4cd[_0x1e5e08(0x12d)](_0x1e5e08(0x134))),_0xaf33c9=_0x45d4cd['bool']('verbose');if(_0xaf33c9)return{'ok':!![],'data':_0x2637fc};const _0x1cfa45=_0x2637fc[_0x1e5e08(0x12c)]?await getDbName(_0x45d4cd[_0x1e5e08(0x12b)],_0x2637fc[_0x1e5e08(0x12c)]):undefined;return{'ok':!![],'data':{'sqlCode':_0x2637fc[_0x1e5e08(0x129)],'sqlName':_0x2637fc[_0x1e5e08(0x13c)],'db':_0x1cfa45?_0x1cfa45+'\x20('+_0x2637fc[_0x1e5e08(0x12c)]+')':_0x2637fc[_0x1e5e08(0x12c)]??'','description':_0x2637fc[_0x1e5e08(0x12f)]??'','sqlContent':_0x2637fc['sqlContent']??''}};}};
@@ -1 +1 @@
1
- const a212_0x25e4ca=a212_0x5568;(function(_0x1798fa,_0x25549c){const _0x4afa9b=a212_0x5568,_0x69bd0f=_0x1798fa();while(!![]){try{const _0x3e2716=-parseInt(_0x4afa9b(0xd2))/0x1*(-parseInt(_0x4afa9b(0xcc))/0x2)+-parseInt(_0x4afa9b(0xcb))/0x3+parseInt(_0x4afa9b(0xc3))/0x4*(-parseInt(_0x4afa9b(0xda))/0x5)+parseInt(_0x4afa9b(0xca))/0x6*(parseInt(_0x4afa9b(0xd0))/0x7)+parseInt(_0x4afa9b(0xd8))/0x8*(-parseInt(_0x4afa9b(0xd3))/0x9)+-parseInt(_0x4afa9b(0xc9))/0xa*(-parseInt(_0x4afa9b(0xd9))/0xb)+parseInt(_0x4afa9b(0xc4))/0xc;if(_0x3e2716===_0x25549c)break;else _0x69bd0f['push'](_0x69bd0f['shift']());}catch(_0x312476){_0x69bd0f['push'](_0x69bd0f['shift']());}}}(a212_0x1297,0x6950c));import{executeSql}from'../../core/api-client.js';function a212_0x5568(_0x174ed9,_0x4a4c3d){_0x174ed9=_0x174ed9-0xc3;const _0x1297e9=a212_0x1297();let _0x556855=_0x1297e9[_0x174ed9];return _0x556855;}function a212_0x1297(){const _0x29a405=['Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','execError','12qCTNLB','5967444EfprDC','Returned\x20','appCode','SQL\x20execution\x20failed','read','10ehHjQk','6XPYEJJ','349947eOYQsd','4098eZNiAG','sql','params','execSuccess','453467qzcBmi','isArray','311AhHHYh','87966ofbrYz','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','str','length','now','392wHZKrk','6678001kRiPxV','1299085fZSFGd'];a212_0x1297=function(){return _0x29a405;};return a212_0x1297();}import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':a212_0x25e4ca(0xcd),'command':'exec','description':a212_0x25e4ca(0xdb),'risk':a212_0x25e4ca(0xc8),'flags':[SQLCODE_FLAG,{'name':'params','type':'string','description':a212_0x25e4ca(0xd4)}],async 'execute'(_0x4cc91a){const _0x1bc074=a212_0x25e4ca,_0x3e34ef=parseJsonParams(_0x4cc91a['str'](_0x1bc074(0xce))),_0x2a16e4=Date[_0x1bc074(0xd7)](),_0x577d03=await executeSql(_0x4cc91a[_0x1bc074(0xc6)],_0x4cc91a[_0x1bc074(0xd5)]('sqlcode'),_0x3e34ef),_0x4bf96b=Date[_0x1bc074(0xd7)]()-_0x2a16e4,_0x5218e3=_0x577d03?.['execResult']??_0x577d03,_0x3b9cfe=_0x577d03?.[_0x1bc074(0xcf)]??!![];if(!_0x3b9cfe)return{'ok':![],'data':{'error':_0x577d03?.[_0x1bc074(0xdc)]||_0x1bc074(0xc7),'elapsed':_0x4bf96b},'message':_0x1bc074(0xc7)};const _0x2a999f=Array[_0x1bc074(0xd1)](_0x5218e3)?_0x5218e3:[];return{'ok':!![],'data':{'rows':_0x2a999f,'rowCount':_0x2a999f[_0x1bc074(0xd6)],'elapsed':_0x4bf96b},'message':_0x1bc074(0xc5)+_0x2a999f[_0x1bc074(0xd6)]+'\x20row(s)\x20in\x20'+_0x4bf96b+'ms'};}};
1
+ const a211_0x1a20b7=a211_0x58d4;function a211_0x58d4(_0x4a4ea2,_0x69cc79){_0x4a4ea2=_0x4a4ea2-0x19e;const _0x49137a=a211_0x4913();let _0x58d4f8=_0x49137a[_0x4a4ea2];return _0x58d4f8;}(function(_0xe14953,_0x3bad3c){const _0x1f9919=a211_0x58d4,_0x110c59=_0xe14953();while(!![]){try{const _0x2cf350=parseInt(_0x1f9919(0x1a1))/0x1+parseInt(_0x1f9919(0x1ab))/0x2+-parseInt(_0x1f9919(0x1a6))/0x3+-parseInt(_0x1f9919(0x19f))/0x4*(-parseInt(_0x1f9919(0x1a3))/0x5)+parseInt(_0x1f9919(0x1a7))/0x6*(-parseInt(_0x1f9919(0x1a0))/0x7)+parseInt(_0x1f9919(0x1a5))/0x8*(parseInt(_0x1f9919(0x1b3))/0x9)+-parseInt(_0x1f9919(0x1ae))/0xa*(-parseInt(_0x1f9919(0x1af))/0xb);if(_0x2cf350===_0x3bad3c)break;else _0x110c59['push'](_0x110c59['shift']());}catch(_0x290311){_0x110c59['push'](_0x110c59['shift']());}}}(a211_0x4913,0x876e7));import{executeSql}from'../../core/api-client.js';import{SQLCODE_FLAG}from'../../commands/common/flags.js';import{parseJsonParams}from'../../utils/params.js';export const sqlExec={'service':'sql','command':'exec','description':a211_0x1a20b7(0x1b6),'risk':'read','flags':[SQLCODE_FLAG,{'name':a211_0x1a20b7(0x1a9),'type':a211_0x1a20b7(0x19e),'description':a211_0x1a20b7(0x1b4)}],async 'execute'(_0x147c95){const _0x3aa0e5=a211_0x1a20b7,_0x4d9371=parseJsonParams(_0x147c95['str'](_0x3aa0e5(0x1a9))),_0x13889a=Date[_0x3aa0e5(0x1a8)](),_0x253e91=await executeSql(_0x147c95['appCode'],_0x147c95[_0x3aa0e5(0x1a4)](_0x3aa0e5(0x1b5)),_0x4d9371),_0x3146c1=Date[_0x3aa0e5(0x1a8)]()-_0x13889a,_0x48b79c=_0x253e91?.[_0x3aa0e5(0x1b7)]??_0x253e91,_0x52186d=_0x253e91?.[_0x3aa0e5(0x1ad)]??!![];if(!_0x52186d)return{'ok':![],'data':{'error':_0x253e91?.[_0x3aa0e5(0x1aa)]||_0x3aa0e5(0x1a2),'elapsed':_0x3146c1},'message':_0x3aa0e5(0x1a2)};const _0x492bc2=Array[_0x3aa0e5(0x1b2)](_0x48b79c)?_0x48b79c:[];return{'ok':!![],'data':{'rows':_0x492bc2,'rowCount':_0x492bc2[_0x3aa0e5(0x1b1)],'elapsed':_0x3146c1},'message':_0x3aa0e5(0x1ac)+_0x492bc2[_0x3aa0e5(0x1b1)]+_0x3aa0e5(0x1b0)+_0x3146c1+'ms'};}};function a211_0x4913(){const _0x5ec9c9=['11GmXsRw','\x20row(s)\x20in\x20','length','isArray','369OTwzwp','SQL\x20parameters\x20as\x20JSON\x20string\x20(e.g.\x20\x27{\x22key\x22:\x22value\x22}\x27)','sqlcode','Execute\x20a\x20custom\x20SQL\x20query\x20by\x20sqlCode','execResult','string','35524FTxsmq','525462URlvdA','210825gfjpJW','SQL\x20execution\x20failed','35axSMEw','str','129640VUOzdM','1913508tqDQZB','84tXtCOK','now','params','execError','1963942SaadQV','Returned\x20','execSuccess','3241190iHahnE'];a211_0x4913=function(){return _0x5ec9c9;};return a211_0x4913();}
@@ -1 +1 @@
1
- (function(_0x514dc0,_0x4da15b){const _0x4fdaeb=a213_0x23bb,_0x2cb779=_0x514dc0();while(!![]){try{const _0x7f6a6f=parseInt(_0x4fdaeb(0x153))/0x1+-parseInt(_0x4fdaeb(0x155))/0x2*(-parseInt(_0x4fdaeb(0x157))/0x3)+-parseInt(_0x4fdaeb(0x156))/0x4+parseInt(_0x4fdaeb(0x159))/0x5+parseInt(_0x4fdaeb(0x151))/0x6+parseInt(_0x4fdaeb(0x154))/0x7+parseInt(_0x4fdaeb(0x152))/0x8*(-parseInt(_0x4fdaeb(0x158))/0x9);if(_0x7f6a6f===_0x4da15b)break;else _0x2cb779['push'](_0x2cb779['shift']());}catch(_0xa422f0){_0x2cb779['push'](_0x2cb779['shift']());}}}(a213_0x5ea5,0xa3f03));function a213_0x23bb(_0x4afa10,_0xe68e78){_0x4afa10=_0x4afa10-0x151;const _0x5ea577=a213_0x5ea5();let _0x23bb5f=_0x5ea577[_0x4afa10];return _0x23bb5f;}import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';function a213_0x5ea5(){const _0x5cde2c=['247173WNjDjR','578268bnzrOH','5687985pMRGgg','3793800vJhTtG','440bHoYcX','1230899RyjRLF','6876030vMlVRv','22OviMeb','2736144AvMDzy'];a213_0x5ea5=function(){return _0x5cde2c;};return a213_0x5ea5();}import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
1
+ function a212_0x5c85(_0x578c62,_0x4e1e57){_0x578c62=_0x578c62-0xe5;const _0x30a83c=a212_0x30a8();let _0x5c8572=_0x30a83c[_0x578c62];return _0x5c8572;}(function(_0x4555ee,_0x421720){const _0xf06536=a212_0x5c85,_0x52c251=_0x4555ee();while(!![]){try{const _0x1f594f=parseInt(_0xf06536(0xee))/0x1*(parseInt(_0xf06536(0xea))/0x2)+parseInt(_0xf06536(0xe9))/0x3*(parseInt(_0xf06536(0xed))/0x4)+-parseInt(_0xf06536(0xe7))/0x5*(-parseInt(_0xf06536(0xf0))/0x6)+parseInt(_0xf06536(0xeb))/0x7+parseInt(_0xf06536(0xe8))/0x8*(-parseInt(_0xf06536(0xec))/0x9)+parseInt(_0xf06536(0xe6))/0xa*(parseInt(_0xf06536(0xe5))/0xb)+-parseInt(_0xf06536(0xef))/0xc;if(_0x1f594f===_0x421720)break;else _0x52c251['push'](_0x52c251['shift']());}catch(_0x1e457e){_0x52c251['push'](_0x52c251['shift']());}}}(a212_0x30a8,0xc2931));import{sqlList}from'../../commands/sql/list.js';import{sqlDetail}from'../../commands/sql/detail.js';import{sqlValidate}from'../../commands/sql/validate.js';import{sqlExec}from'../../commands/sql/exec.js';import{sqlPull}from'../../commands/sql/pull.js';import{sqlCreate}from'../../commands/sql/create.js';import{sqlStatus}from'../../commands/sql/status.js';import{sqlPush}from'../../commands/sql/push.js';function a212_0x30a8(){const _0x55c049=['2976qYMPzF','11604241dygOuZ','10qYYsdN','2720PVxQcB','8ajtXaJ','6iVEgKy','309002JqapSc','9002952LnJztI','10040841TFlWsE','256796tGMHNj','8ahiGrF','24752052jTCATa'];a212_0x30a8=function(){return _0x55c049;};return a212_0x30a8();}import{sqlDelete}from'../../commands/sql/delete.js';export const sqlDefinitions=[sqlList,sqlDetail,sqlStatus,sqlCreate,sqlPush,sqlValidate,sqlExec,sqlPull,sqlDelete];
@@ -1 +1 @@
1
- const a214_0x111549=a214_0x1ff1;(function(_0x54bf9a,_0x267df8){const _0x1356dc=a214_0x1ff1,_0x3a63d7=_0x54bf9a();while(!![]){try{const _0x408cc4=-parseInt(_0x1356dc(0x138))/0x1*(parseInt(_0x1356dc(0x13e))/0x2)+-parseInt(_0x1356dc(0x140))/0x3*(-parseInt(_0x1356dc(0x124))/0x4)+parseInt(_0x1356dc(0x126))/0x5*(-parseInt(_0x1356dc(0x13d))/0x6)+parseInt(_0x1356dc(0x12a))/0x7+-parseInt(_0x1356dc(0x132))/0x8*(-parseInt(_0x1356dc(0x139))/0x9)+parseInt(_0x1356dc(0x12e))/0xa+-parseInt(_0x1356dc(0x12f))/0xb;if(_0x408cc4===_0x267df8)break;else _0x3a63d7['push'](_0x3a63d7['shift']());}catch(_0xaf58d8){_0x3a63d7['push'](_0x3a63d7['shift']());}}}(a214_0x5175,0x2d98a));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a214_0x5175(){const _0x5d7e35=['3680450FfpcDO','9037468wVmVib','totalCount','appCode','171808IcIZJU','sqlCode','boolean','List\x20custom\x20SQL\x20queries','No\x20custom\x20SQL\x20queries\x20found.','read','90715ZbdCEi','117UoFPnn','pagesize','page','length','125268RlDkMH','2qPFaUo','verbose','3jANnwy','str','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','paging','name','description','number','1244464jACaMH','\x20SQL\x20queries\x20(total:\x20','5HHylDm','num','Filter\x20by\x20SQL\x20name','dbId','1131158pSWbHA','Page\x20number','Found\x20','bool'];a214_0x5175=function(){return _0x5d7e35;};return a214_0x5175();}function a214_0x1ff1(_0x4003a8,_0x264ce6){_0x4003a8=_0x4003a8-0x122;const _0x51752b=a214_0x5175();let _0x1ff14b=_0x51752b[_0x4003a8];return _0x1ff14b;}export const sqlList={'service':'sql','command':'list','description':a214_0x111549(0x135),'risk':a214_0x111549(0x137),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a214_0x111549(0x144),'type':'string','description':a214_0x111549(0x128)},{'name':a214_0x111549(0x13b),'type':a214_0x111549(0x123),'description':a214_0x111549(0x12b),'default':0x1},{'name':a214_0x111549(0x13a),'type':'number','description':'Page\x20size'},{'name':a214_0x111549(0x13f),'type':a214_0x111549(0x134),'description':a214_0x111549(0x142)}],async 'execute'(_0x3043a2){const _0x5c84f1=a214_0x111549,_0xbd2763=await listSqlQueries(_0x3043a2[_0x5c84f1(0x131)],{'sqlCode':_0x3043a2[_0x5c84f1(0x141)]('sqlcode')||undefined,'sqlName':_0x3043a2[_0x5c84f1(0x141)]('name')||undefined,'currentPage':_0x3043a2[_0x5c84f1(0x127)](_0x5c84f1(0x13b)),'pageSize':_0x3043a2[_0x5c84f1(0x127)](_0x5c84f1(0x13a),0x32)}),_0x23469e=_0x3043a2[_0x5c84f1(0x12d)](_0x5c84f1(0x13f)),_0x3885ec=_0xbd2763['tableData']??[],_0x2e5dbc=_0xbd2763[_0x5c84f1(0x143)]?.[_0x5c84f1(0x130)]??_0x3885ec[_0x5c84f1(0x13c)];let _0x335d65;return _0x23469e?_0x335d65=_0x3885ec:_0x335d65=await Promise['all'](_0x3885ec['map'](async _0x138bdc=>{const _0xd90e16=_0x5c84f1;let _0x34cb0e;try{_0x34cb0e=_0x138bdc[_0xd90e16(0x129)]?await getDbName(_0x3043a2['appCode'],_0x138bdc[_0xd90e16(0x129)]):undefined;}catch{}return{'sqlCode':_0x138bdc[_0xd90e16(0x133)],'sqlName':_0x138bdc['sqlName'],'description':_0x138bdc[_0xd90e16(0x122)]??'','db':_0x34cb0e?_0x34cb0e+'\x20('+_0x138bdc['dbId']+')':_0x138bdc[_0xd90e16(0x129)]??''};})),{'ok':!![],'data':_0x335d65,'message':_0x3885ec[_0x5c84f1(0x13c)]===0x0?_0x5c84f1(0x136):_0x5c84f1(0x12c)+_0x3885ec[_0x5c84f1(0x13c)]+_0x5c84f1(0x125)+_0x2e5dbc+').'};}};
1
+ const a213_0x1e4a7a=a213_0x1d44;(function(_0xbaaef3,_0x582fc1){const _0x5e9feb=a213_0x1d44,_0x2afa5f=_0xbaaef3();while(!![]){try{const _0x17df73=parseInt(_0x5e9feb(0xb5))/0x1+-parseInt(_0x5e9feb(0xac))/0x2*(-parseInt(_0x5e9feb(0xc4))/0x3)+-parseInt(_0x5e9feb(0xc0))/0x4+parseInt(_0x5e9feb(0xcc))/0x5*(-parseInt(_0x5e9feb(0xbb))/0x6)+-parseInt(_0x5e9feb(0xc1))/0x7*(parseInt(_0x5e9feb(0xaa))/0x8)+-parseInt(_0x5e9feb(0xc3))/0x9+parseInt(_0x5e9feb(0xc7))/0xa*(parseInt(_0x5e9feb(0xb9))/0xb);if(_0x17df73===_0x582fc1)break;else _0x2afa5f['push'](_0x2afa5f['shift']());}catch(_0x53cc33){_0x2afa5f['push'](_0x2afa5f['shift']());}}}(a213_0x5300,0x5becf));import{listSqlQueries}from'../../core/api-client.js';import{getDbName}from'../../core/db-resolver.js';function a213_0x1d44(_0x2a8c6,_0x4c161a){_0x2a8c6=_0x2a8c6-0xa7;const _0x53009e=a213_0x5300();let _0x1d4478=_0x53009e[_0x2a8c6];return _0x1d4478;}import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';function a213_0x5300(){const _0x33a7f6=['string','43698YDxykX','sql','bool','read','tableData','1897820wewfGC','3172127GcFLFw','paging','1185246dMplJR','153WOYIYh','Return\x20full\x20SQL\x20query\x20objects\x20including\x20parameters\x20and\x20SQL\x20content','number','5767390VNZpAI','description','map','pagesize','sqlCode','335pCAZZR','Page\x20size','name','dbId','page','appCode','8YokcyL','Found\x20','5682wzTFyC','length','\x20SQL\x20queries\x20(total:\x20','List\x20custom\x20SQL\x20queries','str','Filter\x20by\x20SQL\x20name','totalCount','boolean','num','625429RWhMjm','verbose','all','Page\x20number','22raUvIz'];a213_0x5300=function(){return _0x33a7f6;};return a213_0x5300();}export const sqlList={'service':a213_0x1e4a7a(0xbc),'command':'list','description':a213_0x1e4a7a(0xaf),'risk':a213_0x1e4a7a(0xbe),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a213_0x1e4a7a(0xce),'type':a213_0x1e4a7a(0xba),'description':a213_0x1e4a7a(0xb1)},{'name':a213_0x1e4a7a(0xa8),'type':a213_0x1e4a7a(0xc6),'description':a213_0x1e4a7a(0xb8),'default':0x1},{'name':a213_0x1e4a7a(0xca),'type':a213_0x1e4a7a(0xc6),'description':a213_0x1e4a7a(0xcd)},{'name':a213_0x1e4a7a(0xb6),'type':a213_0x1e4a7a(0xb3),'description':a213_0x1e4a7a(0xc5)}],async 'execute'(_0xc8b980){const _0xeaedce=a213_0x1e4a7a,_0x3eecee=await listSqlQueries(_0xc8b980[_0xeaedce(0xa9)],{'sqlCode':_0xc8b980['str']('sqlcode')||undefined,'sqlName':_0xc8b980[_0xeaedce(0xb0)](_0xeaedce(0xce))||undefined,'currentPage':_0xc8b980['num'](_0xeaedce(0xa8)),'pageSize':_0xc8b980[_0xeaedce(0xb4)]('pagesize',0x32)}),_0x2aa2dc=_0xc8b980[_0xeaedce(0xbd)](_0xeaedce(0xb6)),_0x1f5218=_0x3eecee[_0xeaedce(0xbf)]??[],_0x3e7ff8=_0x3eecee[_0xeaedce(0xc2)]?.[_0xeaedce(0xb2)]??_0x1f5218['length'];let _0x2871d7;return _0x2aa2dc?_0x2871d7=_0x1f5218:_0x2871d7=await Promise[_0xeaedce(0xb7)](_0x1f5218[_0xeaedce(0xc9)](async _0x1b17e7=>{const _0x3a3d34=_0xeaedce;let _0x40e331;try{_0x40e331=_0x1b17e7[_0x3a3d34(0xa7)]?await getDbName(_0xc8b980[_0x3a3d34(0xa9)],_0x1b17e7[_0x3a3d34(0xa7)]):undefined;}catch{}return{'sqlCode':_0x1b17e7[_0x3a3d34(0xcb)],'sqlName':_0x1b17e7['sqlName'],'description':_0x1b17e7[_0x3a3d34(0xc8)]??'','db':_0x40e331?_0x40e331+'\x20('+_0x1b17e7[_0x3a3d34(0xa7)]+')':_0x1b17e7[_0x3a3d34(0xa7)]??''};})),{'ok':!![],'data':_0x2871d7,'message':_0x1f5218[_0xeaedce(0xad)]===0x0?'No\x20custom\x20SQL\x20queries\x20found.':_0xeaedce(0xab)+_0x1f5218[_0xeaedce(0xad)]+_0xeaedce(0xae)+_0x3e7ff8+').'};}};
@@ -1 +1 @@
1
- const a215_0x262db2=a215_0x2775;(function(_0x3aabb4,_0x46d6c3){const _0x4742ac=a215_0x2775,_0xe5cde4=_0x3aabb4();while(!![]){try{const _0x4bf9c3=-parseInt(_0x4742ac(0x133))/0x1*(-parseInt(_0x4742ac(0x10d))/0x2)+parseInt(_0x4742ac(0x10c))/0x3+-parseInt(_0x4742ac(0x118))/0x4+-parseInt(_0x4742ac(0x136))/0x5+-parseInt(_0x4742ac(0x148))/0x6+parseInt(_0x4742ac(0x10a))/0x7+parseInt(_0x4742ac(0x134))/0x8;if(_0x4bf9c3===_0x46d6c3)break;else _0xe5cde4['push'](_0xe5cde4['shift']());}catch(_0x5abc77){_0xe5cde4['push'](_0xe5cde4['shift']());}}}(a215_0x2ae4,0x4267f));import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';function a215_0x2775(_0x516d41,_0x76b139){_0x516d41=_0x516d41-0x109;const _0x2ae455=a215_0x2ae4();let _0x27755f=_0x2ae455[_0x516d41];return _0x27755f;}const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x458d74,_0x221d37){const _0x5d66c6=a215_0x2775,_0x472f51=[];let _0x43dc68=0x1;while(!![]){const _0x5786fd=await listSqlQueries(_0x458d74,{'currentPage':_0x43dc68,'pageSize':PAGE_SIZE,'sqlCode':_0x221d37[_0x5d66c6(0x143)],'sqlName':_0x221d37['sqlName']}),_0x3902ee=_0x5786fd['tableData']??[];_0x472f51[_0x5d66c6(0x13f)](..._0x3902ee);if(_0x3902ee[_0x5d66c6(0x13c)]===0x0)break;const _0x1ccd44=_0x5786fd[_0x5d66c6(0x12b)]?.[_0x5d66c6(0x12c)];if(_0x1ccd44!=null?_0x472f51[_0x5d66c6(0x13c)]>=_0x1ccd44:_0x3902ee[_0x5d66c6(0x13c)]<PAGE_SIZE)break;_0x43dc68++;}return _0x472f51;}async function ensureSqlContent(_0xa1f979){const _0x189b27=a215_0x2775;if(_0xa1f979['sqlContent']!=null&&String(_0xa1f979[_0x189b27(0x130)])[_0x189b27(0x13c)]>0x0)return _0xa1f979;return getSqlQueryDetail(_0xa1f979[_0x189b27(0x143)]);}export const sqlPull={'service':a215_0x262db2(0x147),'command':a215_0x262db2(0x11b),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':a215_0x262db2(0x142),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a215_0x262db2(0x117),'type':a215_0x262db2(0x122),'description':a215_0x262db2(0x12f)},{'name':a215_0x262db2(0x113),'type':a215_0x262db2(0x146),'description':a215_0x262db2(0x11a)}],async 'dryRun'(_0x26d0b8){const _0xee4d46=a215_0x262db2,_0x259d81=loadSqlProjectConfig(_0x26d0b8[_0xee4d46(0x126)]),_0x5210cd=await readSqlLockFile(_0x259d81[_0xee4d46(0x139)]),{appLock:_0x3c424d}=ensureSqlLockScope(_0x5210cd??createEmptySqlLock(),_0x259d81[_0xee4d46(0x126)],_0x259d81[_0xee4d46(0x119)],_0xee4d46(0x11b)),_0x40d759=await fetchAllSqlQueries(_0x26d0b8[_0xee4d46(0x126)],{'sqlCode':_0x26d0b8[_0xee4d46(0x12a)](_0xee4d46(0x10e))||undefined,'sqlName':_0x26d0b8[_0xee4d46(0x12a)](_0xee4d46(0x117))||undefined}),_0x7047ce=[];for(const _0x12d53c of _0x40d759){const _0x28a92f=await ensureSqlContent(_0x12d53c),_0x19cd2d=ensureRemoteSqlContent(_0x28a92f),_0x2c01df=detectModeFromSql(_0x28a92f),_0x2a5eb6=_0x28a92f[_0xee4d46(0x12e)]?await getDbName(_0x26d0b8[_0xee4d46(0x126)],Number(_0x28a92f[_0xee4d46(0x12e)]))['catch'](()=>undefined):undefined,_0x58e72a=buildLocalSqlFileContent({'sqlCode':_0x28a92f[_0xee4d46(0x143)],'sqlName':_0x28a92f[_0xee4d46(0x141)],'dbId':_0x28a92f[_0xee4d46(0x12e)]},_0x19cd2d,{'dbName':_0x2a5eb6,'mode':_0x2c01df,'syncedAt':new Date()[_0xee4d46(0x137)](),'description':_0x28a92f['description']}),_0x290d4c=buildSqlLockEntry(_0x28a92f,_0x19cd2d,'',{'dbName':_0x2a5eb6}),_0x375989=resolveLocalSqlFilePath(_0x259d81,_0x28a92f[_0xee4d46(0x143)],_0x290d4c);let _0x194889=_0xee4d46(0x129),_0x385516;if(await fileExists(_0x375989)){const _0x147095=await readFile(_0x375989,'utf8');isEquivalentPulledSqlFile(_0x147095,_0x58e72a,_0x2c01df)?(_0x194889=_0xee4d46(0x13d),_0x385516='unchanged'):(_0x194889=_0xee4d46(0x123),_0x385516=_0xee4d46(0x116));}_0x7047ce[_0xee4d46(0x13f)]({'sqlCode':_0x28a92f[_0xee4d46(0x143)],'sqlName':_0x28a92f['sqlName'],'filePath':_0x375989,'status':_0x194889,'reason':_0x385516});}return{'method':_0xee4d46(0x131),'url':_0xee4d46(0x13b),'body':{'appCode':_0x26d0b8[_0xee4d46(0x126)],'sqlCode':_0x26d0b8['str'](_0xee4d46(0x10e))||null,'sqlName':_0x26d0b8[_0xee4d46(0x12a)](_0xee4d46(0x117))||null,'files':_0x7047ce},'description':_0xee4d46(0x144)+_0x7047ce['length']+_0xee4d46(0x11d)+_0x259d81['sqlRootDir']};},async 'execute'(_0x1c5246){const _0x28080b=a215_0x262db2,_0x41f067=loadSqlProjectConfig(_0x1c5246[_0x28080b(0x126)]),_0x3d003c=await readSqlLockFile(_0x41f067[_0x28080b(0x139)]),{lockData:_0x394221,appLock:_0x3314c8}=ensureSqlLockScope(_0x3d003c??createEmptySqlLock(),_0x41f067[_0x28080b(0x126)],_0x41f067[_0x28080b(0x119)],'pull'),_0x33d8af=_0x1c5246[_0x28080b(0x13a)]('force'),_0x18459a=await fetchAllSqlQueries(_0x1c5246['appCode'],{'sqlCode':_0x1c5246[_0x28080b(0x12a)](_0x28080b(0x10e))||undefined,'sqlName':_0x1c5246[_0x28080b(0x12a)](_0x28080b(0x117))||undefined});if(_0x18459a[_0x28080b(0x13c)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':_0x28080b(0x112)};const _0x5971d2=[],_0x5a5331=[];for(const _0x18c9e of _0x18459a){try{_0x5971d2[_0x28080b(0x13f)](await ensureSqlContent(_0x18c9e));}catch(_0x86deaa){_0x5a5331['push']({'sqlCode':_0x18c9e[_0x28080b(0x143)],'error':_0x86deaa instanceof Error?_0x86deaa[_0x28080b(0x145)]:String(_0x86deaa)});}}if(_0x33d8af&&!_0x1c5246[_0x28080b(0x13e)]){let _0x12d4a9=![];for(const _0x1f35df of _0x5971d2){const _0x34b0f2=detectModeFromSql(_0x1f35df),_0x3b576d=_0x1f35df[_0x28080b(0x12e)]?await getDbName(_0x1c5246[_0x28080b(0x126)],Number(_0x1f35df[_0x28080b(0x12e)]))[_0x28080b(0x10f)](()=>undefined):undefined,_0x554bf6=buildLocalSqlFileContent({'sqlCode':_0x1f35df[_0x28080b(0x143)],'sqlName':_0x1f35df[_0x28080b(0x141)],'dbId':_0x1f35df[_0x28080b(0x12e)]},ensureRemoteSqlContent(_0x1f35df),{'dbName':_0x3b576d,'mode':_0x34b0f2,'syncedAt':new Date()[_0x28080b(0x137)](),'description':_0x1f35df[_0x28080b(0x127)]}),_0x1071f1=resolveLocalSqlFilePath(_0x41f067,_0x1f35df[_0x28080b(0x143)],buildSqlLockEntry(_0x1f35df,ensureRemoteSqlContent(_0x1f35df),'',{'dbName':_0x3b576d}));if(await fileExists(_0x1071f1)){const _0x127073=await readFile(_0x1071f1,'utf8');if(!isEquivalentPulledSqlFile(_0x127073,_0x554bf6,_0x34b0f2)){_0x12d4a9=!![];break;}}}if(_0x12d4a9){const _0x3ab1d8=await confirmForceOverwrite('Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.');if(!_0x3ab1d8)throw CliErrors[_0x28080b(0x121)](_0x28080b(0x120));}}const _0x67bba0=cloneSqlLockData(_0x394221),_0xea34ec=_0x67bba0[_0x28080b(0x124)][_0x41f067[_0x28080b(0x126)]],_0x52c620=[],_0x4f0649=[];for(const _0x2e0d76 of _0x5971d2){const _0x3dabab=_0xea34ec['sqls'][_0x2e0d76[_0x28080b(0x143)]],_0x5a1645=ensureRemoteSqlContent(_0x2e0d76),_0x14f17c=detectModeFromSql(_0x2e0d76),_0x33871b=_0x2e0d76[_0x28080b(0x12e)]?await getDbName(_0x1c5246[_0x28080b(0x126)],Number(_0x2e0d76['dbId']))[_0x28080b(0x10f)](()=>undefined):undefined,_0x535d92=buildLocalSqlFileContent({'sqlCode':_0x2e0d76[_0x28080b(0x143)],'sqlName':_0x2e0d76['sqlName'],'dbId':_0x2e0d76[_0x28080b(0x12e)]},_0x5a1645,{'dbName':_0x33871b,'mode':_0x14f17c,'syncedAt':new Date()['toISOString'](),'description':_0x2e0d76[_0x28080b(0x127)]}),_0x1e0d0a=buildSqlLockEntry(_0x2e0d76,_0x5a1645,computeSqlContentHash(_0x535d92),{'dbName':_0x33871b}),_0x1184c0=_0x1e0d0a[_0x28080b(0x12d)],_0x4a04d4=join(_0x41f067[_0x28080b(0x109)],_0x1184c0);try{if(await fileExists(_0x4a04d4)){const _0x211863=await readFile(_0x4a04d4,_0x28080b(0x138));if(isEquivalentPulledSqlFile(_0x211863,_0x535d92,_0x14f17c)){_0x4f0649[_0x28080b(0x13f)]({'sqlCode':_0x2e0d76[_0x28080b(0x143)],'reason':_0x28080b(0x125)}),_0xea34ec[_0x28080b(0x11c)][_0x2e0d76['sqlCode']]={..._0x1e0d0a,'hash':computeSqlContentHash(_0x211863),'path':_0x1184c0};continue;}if(!_0x33d8af){_0x4f0649['push']({'sqlCode':_0x2e0d76[_0x28080b(0x143)],'reason':_0x28080b(0x11e)});continue;}}const _0x395fd2=_0x3dabab?.[_0x28080b(0x12d)]?join(_0x41f067[_0x28080b(0x109)],_0x3dabab[_0x28080b(0x12d)]):undefined;_0x395fd2&&_0x395fd2!==_0x4a04d4&&await fileExists(_0x395fd2)&&await rm(_0x395fd2,{'force':!![]}),await ensureParentDirectory(_0x4a04d4),await writeFile(_0x4a04d4,_0x535d92,_0x28080b(0x138)),_0xea34ec['sqls'][_0x2e0d76['sqlCode']]={..._0x1e0d0a,'path':_0x1184c0},_0x52c620[_0x28080b(0x13f)]({'sqlCode':_0x2e0d76[_0x28080b(0x143)],'filePath':_0x4a04d4});}catch(_0x409b85){_0x5a5331[_0x28080b(0x13f)]({'sqlCode':_0x2e0d76[_0x28080b(0x143)],'error':_0x409b85 instanceof Error?_0x409b85[_0x28080b(0x145)]:String(_0x409b85)});}}return _0xea34ec[_0x28080b(0x11f)]=new Date()[_0x28080b(0x137)](),await writeSqlLockFile(_0x41f067['lockFilePath'],_0x67bba0),{'ok':_0x5a5331[_0x28080b(0x13c)]===0x0,'data':{'pulled':_0x52c620,'skipped':_0x4f0649,'failed':_0x5a5331},'message':_0x28080b(0x128)+_0x52c620[_0x28080b(0x13c)]+_0x28080b(0x140)+_0x4f0649[_0x28080b(0x13c)]+'\x20skipped,\x20'+_0x5a5331[_0x28080b(0x13c)]+_0x28080b(0x111)};}};function a215_0x2ae4(){const _0x15ff83=['sqlRoot','Force\x20overwrite\x20local\x20unsynced\x20changes','pull','sqls','\x20SQL\x20file(s)\x20into\x20','local\x20differs\x20from\x20remote','lastSync','Force\x20pull\x20cancelled.','cancelled','string','conflict','apps','unchanged','appCode','description','Pull\x20complete:\x20','would_pull','str','paging','totalCount','path','dbId','Filter\x20by\x20SQL\x20display\x20name','sqlContent','POST','trimStart','10777QtPVPb','2808752rcvczf','test','2501765lEHtPh','toISOString','utf8','lockFilePath','bool','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','length','skipped','nonInteractive','push','\x20written,\x20','sqlName','read','sqlCode','Would\x20pull\x20','message','boolean','sql','577164pbBWEY','sqlRootDir','2349536EsJfJA','filter','210282HVwbbW','34kGwJgz','sqlcode','catch','replace','\x20failed','No\x20remote\x20SQL\x20queries\x20matched.','force','mybatisXml','split','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','name','285996joZzGO'];a215_0x2ae4=function(){return _0x15ff83;};return a215_0x2ae4();}function detectModeFromSql(_0x4f44c6){const _0x354603=a215_0x262db2,_0x326b34=ensureRemoteSqlContent(_0x4f44c6),_0x2cd4e7=stripLocalSqlMetadata(_0x326b34,_0x354603(0x114))[_0x354603(0x132)]();if(/^<(select|insert|update|delete)\b/i[_0x354603(0x135)](_0x2cd4e7))return _0x354603(0x114);return _0x354603(0x147);}function isEquivalentPulledSqlFile(_0x5d9abe,_0x2671e2,_0x381f8c){return normalizePullComparableContent(_0x5d9abe,_0x381f8c)===normalizePullComparableContent(_0x2671e2,_0x381f8c);}function normalizePullComparableContent(_0x4c0b0a,_0x16ba6f){const _0x2d03cf=a215_0x262db2,_0x3b9431=_0x4c0b0a[_0x2d03cf(0x110)](/\r\n/g,'\x0a')[_0x2d03cf(0x115)]('\x0a'),_0x5c8d61=_0x3b9431[_0x2d03cf(0x10b)](_0x1d9598=>!isSyncedAtMetadataLine(_0x1d9598,_0x16ba6f));return _0x5c8d61['join']('\x0a');}function isSyncedAtMetadataLine(_0x1e2246,_0x53a16e){const _0x20bfc9=a215_0x262db2;if(_0x53a16e===_0x20bfc9(0x114))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x20bfc9(0x135)](_0x1e2246);return/^\s*--\s*@lovrabet\.syncedAt:/['test'](_0x1e2246);}
1
+ const a214_0x3c3d70=a214_0x17ae;(function(_0x5a46f5,_0x880215){const _0x3e43de=a214_0x17ae,_0x2fba7d=_0x5a46f5();while(!![]){try{const _0x36be53=-parseInt(_0x3e43de(0x12c))/0x1+parseInt(_0x3e43de(0x117))/0x2*(parseInt(_0x3e43de(0x134))/0x3)+parseInt(_0x3e43de(0x122))/0x4*(parseInt(_0x3e43de(0x13a))/0x5)+-parseInt(_0x3e43de(0x116))/0x6*(parseInt(_0x3e43de(0x149))/0x7)+-parseInt(_0x3e43de(0x14f))/0x8*(-parseInt(_0x3e43de(0x11d))/0x9)+-parseInt(_0x3e43de(0x144))/0xa+parseInt(_0x3e43de(0x11a))/0xb;if(_0x36be53===_0x880215)break;else _0x2fba7d['push'](_0x2fba7d['shift']());}catch(_0x4585ec){_0x2fba7d['push'](_0x2fba7d['shift']());}}}(a214_0xa5a4,0x351d3));function a214_0xa5a4(){const _0x165f18=['test','1831455nNABFS','lastSync','pull','path','Pull\x20complete:\x20','132RIewQv','mybatisXml','sqlContent','push','local\x20differs\x20from\x20remote\x20(use\x20--force\x20to\x20overwrite)','skipped','sqlName','nonInteractive','paging','Force\x20pull\x20will\x20overwrite\x20local\x20SQL\x20that\x20differs\x20from\x20remote.','291221JCEpon','local\x20differs\x20from\x20remote','sqlRoot','/smartapi/custom/queryUserCustomSqlList\x20+\x20/smartapi/custom/getUserCustomSql','message','length','\x20skipped,\x20','str','10893CEqirb','split','appCode','replace','name','description','17365MVfLXW','toISOString','read','filter','Force\x20pull\x20cancelled.','trimStart','force','catch','sql','POST','4071840IMRhvb','join','\x20failed','sqlRootDir','\x20written,\x20','21UzvpjZ','Filter\x20by\x20SQL\x20display\x20name','dbId','totalCount','sqlcode','lockFilePath','8JMUMLU','tableData','sqls','unchanged','conflict','100062NoTXiK','190woiDjr','utf8','sqlCode','3332362xePQWh','apps'];a214_0xa5a4=function(){return _0x165f18;};return a214_0xa5a4();}import{readFile,rm,writeFile}from'node:fs/promises';import{join}from'node:path';import{getSqlQueryDetail,listSqlQueries}from'../../core/api-client.js';import{ensureParentDirectory,fileExists}from'../../core/bff/file-system.js';import{getDbName}from'../../core/db-resolver.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{computeSqlContentHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{resolveLocalSqlFilePath}from'../../core/sql-sync/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildLocalSqlFileContent,buildSqlLockEntry,cloneSqlLockData,confirmForceOverwrite,ensureRemoteSqlContent,stripLocalSqlMetadata}from'./shared.js';const PAGE_SIZE=0x64;async function fetchAllSqlQueries(_0x529dd6,_0x40bfcd){const _0x44b3b3=a214_0x17ae,_0x3d7950=[];let _0x4d506b=0x1;while(!![]){const _0x51d867=await listSqlQueries(_0x529dd6,{'currentPage':_0x4d506b,'pageSize':PAGE_SIZE,'sqlCode':_0x40bfcd[_0x44b3b3(0x119)],'sqlName':_0x40bfcd[_0x44b3b3(0x128)]}),_0x45011a=_0x51d867[_0x44b3b3(0x112)]??[];_0x3d7950[_0x44b3b3(0x125)](..._0x45011a);if(_0x45011a[_0x44b3b3(0x131)]===0x0)break;const _0x3bcc47=_0x51d867[_0x44b3b3(0x12a)]?.[_0x44b3b3(0x14c)];if(_0x3bcc47!=null?_0x3d7950[_0x44b3b3(0x131)]>=_0x3bcc47:_0x45011a['length']<PAGE_SIZE)break;_0x4d506b++;}return _0x3d7950;}async function ensureSqlContent(_0x2d0722){const _0x52efb3=a214_0x17ae;if(_0x2d0722[_0x52efb3(0x124)]!=null&&String(_0x2d0722[_0x52efb3(0x124)])[_0x52efb3(0x131)]>0x0)return _0x2d0722;return getSqlQueryDetail(_0x2d0722['sqlCode']);}export const sqlPull={'service':a214_0x3c3d70(0x142),'command':a214_0x3c3d70(0x11f),'description':'Pull\x20remote\x20SQL\x20queries\x20to\x20local\x20.rabetbase/sql/','risk':a214_0x3c3d70(0x13c),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':a214_0x3c3d70(0x138),'type':'string','description':a214_0x3c3d70(0x14a)},{'name':'force','type':'boolean','description':'Force\x20overwrite\x20local\x20unsynced\x20changes'}],async 'dryRun'(_0x5a516e){const _0x6b3151=a214_0x3c3d70,_0x5b3fec=loadSqlProjectConfig(_0x5a516e[_0x6b3151(0x136)]),_0x395948=await readSqlLockFile(_0x5b3fec[_0x6b3151(0x14e)]),{appLock:_0x5ceca9}=ensureSqlLockScope(_0x395948??createEmptySqlLock(),_0x5b3fec['appCode'],_0x5b3fec[_0x6b3151(0x12e)],_0x6b3151(0x11f)),_0x1e69e6=await fetchAllSqlQueries(_0x5a516e[_0x6b3151(0x136)],{'sqlCode':_0x5a516e['str'](_0x6b3151(0x14d))||undefined,'sqlName':_0x5a516e[_0x6b3151(0x133)](_0x6b3151(0x138))||undefined}),_0xbca407=[];for(const _0x4ad4ea of _0x1e69e6){const _0x48b069=await ensureSqlContent(_0x4ad4ea),_0x586122=ensureRemoteSqlContent(_0x48b069),_0x82d1b7=detectModeFromSql(_0x48b069),_0x45157a=_0x48b069[_0x6b3151(0x14b)]?await getDbName(_0x5a516e[_0x6b3151(0x136)],Number(_0x48b069['dbId']))[_0x6b3151(0x141)](()=>undefined):undefined,_0x2979b8=buildLocalSqlFileContent({'sqlCode':_0x48b069[_0x6b3151(0x119)],'sqlName':_0x48b069[_0x6b3151(0x128)],'dbId':_0x48b069[_0x6b3151(0x14b)]},_0x586122,{'dbName':_0x45157a,'mode':_0x82d1b7,'syncedAt':new Date()[_0x6b3151(0x13b)](),'description':_0x48b069[_0x6b3151(0x139)]}),_0x31acfe=buildSqlLockEntry(_0x48b069,_0x586122,'',{'dbName':_0x45157a}),_0x1bf0f9=resolveLocalSqlFilePath(_0x5b3fec,_0x48b069['sqlCode'],_0x31acfe);let _0x42ed54='would_pull',_0x3670cb;if(await fileExists(_0x1bf0f9)){const _0x339f05=await readFile(_0x1bf0f9,'utf8');isEquivalentPulledSqlFile(_0x339f05,_0x2979b8,_0x82d1b7)?(_0x42ed54=_0x6b3151(0x127),_0x3670cb=_0x6b3151(0x114)):(_0x42ed54=_0x6b3151(0x115),_0x3670cb=_0x6b3151(0x126));}_0xbca407[_0x6b3151(0x125)]({'sqlCode':_0x48b069[_0x6b3151(0x119)],'sqlName':_0x48b069['sqlName'],'filePath':_0x1bf0f9,'status':_0x42ed54,'reason':_0x3670cb});}return{'method':_0x6b3151(0x143),'url':_0x6b3151(0x12f),'body':{'appCode':_0x5a516e[_0x6b3151(0x136)],'sqlCode':_0x5a516e[_0x6b3151(0x133)](_0x6b3151(0x14d))||null,'sqlName':_0x5a516e[_0x6b3151(0x133)](_0x6b3151(0x138))||null,'files':_0xbca407},'description':'Would\x20pull\x20'+_0xbca407[_0x6b3151(0x131)]+'\x20SQL\x20file(s)\x20into\x20'+_0x5b3fec[_0x6b3151(0x147)]};},async 'execute'(_0x366482){const _0xb58714=a214_0x3c3d70,_0x19428d=loadSqlProjectConfig(_0x366482[_0xb58714(0x136)]),_0x1f43e0=await readSqlLockFile(_0x19428d[_0xb58714(0x14e)]),{lockData:_0x338b3c,appLock:_0x1d40b2}=ensureSqlLockScope(_0x1f43e0??createEmptySqlLock(),_0x19428d[_0xb58714(0x136)],_0x19428d[_0xb58714(0x12e)],_0xb58714(0x11f)),_0x5ad1b3=_0x366482['bool'](_0xb58714(0x140)),_0x3c2716=await fetchAllSqlQueries(_0x366482['appCode'],{'sqlCode':_0x366482[_0xb58714(0x133)](_0xb58714(0x14d))||undefined,'sqlName':_0x366482['str'](_0xb58714(0x138))||undefined});if(_0x3c2716[_0xb58714(0x131)]===0x0)return{'ok':!![],'data':{'pulled':[],'skipped':[],'failed':[]},'message':'No\x20remote\x20SQL\x20queries\x20matched.'};const _0x1f35ef=[],_0x20dc65=[];for(const _0xc86de1 of _0x3c2716){try{_0x1f35ef[_0xb58714(0x125)](await ensureSqlContent(_0xc86de1));}catch(_0x4f4e22){_0x20dc65['push']({'sqlCode':_0xc86de1[_0xb58714(0x119)],'error':_0x4f4e22 instanceof Error?_0x4f4e22[_0xb58714(0x130)]:String(_0x4f4e22)});}}if(_0x5ad1b3&&!_0x366482[_0xb58714(0x129)]){let _0x22d262=![];for(const _0x7a7a6b of _0x1f35ef){const _0x27707a=detectModeFromSql(_0x7a7a6b),_0x36ba57=_0x7a7a6b[_0xb58714(0x14b)]?await getDbName(_0x366482[_0xb58714(0x136)],Number(_0x7a7a6b[_0xb58714(0x14b)]))[_0xb58714(0x141)](()=>undefined):undefined,_0x55f0b8=buildLocalSqlFileContent({'sqlCode':_0x7a7a6b[_0xb58714(0x119)],'sqlName':_0x7a7a6b['sqlName'],'dbId':_0x7a7a6b[_0xb58714(0x14b)]},ensureRemoteSqlContent(_0x7a7a6b),{'dbName':_0x36ba57,'mode':_0x27707a,'syncedAt':new Date()['toISOString'](),'description':_0x7a7a6b[_0xb58714(0x139)]}),_0x4db2fb=resolveLocalSqlFilePath(_0x19428d,_0x7a7a6b['sqlCode'],buildSqlLockEntry(_0x7a7a6b,ensureRemoteSqlContent(_0x7a7a6b),'',{'dbName':_0x36ba57}));if(await fileExists(_0x4db2fb)){const _0x35667a=await readFile(_0x4db2fb,_0xb58714(0x118));if(!isEquivalentPulledSqlFile(_0x35667a,_0x55f0b8,_0x27707a)){_0x22d262=!![];break;}}}if(_0x22d262){const _0x15519b=await confirmForceOverwrite(_0xb58714(0x12b));if(!_0x15519b)throw CliErrors['cancelled'](_0xb58714(0x13e));}}const _0x516b29=cloneSqlLockData(_0x338b3c),_0x26b728=_0x516b29[_0xb58714(0x11b)][_0x19428d[_0xb58714(0x136)]],_0x295f7b=[],_0x15e004=[];for(const _0xae9f79 of _0x1f35ef){const _0x1639b5=_0x26b728[_0xb58714(0x113)][_0xae9f79[_0xb58714(0x119)]],_0xd60383=ensureRemoteSqlContent(_0xae9f79),_0x4e5157=detectModeFromSql(_0xae9f79),_0x1123af=_0xae9f79[_0xb58714(0x14b)]?await getDbName(_0x366482[_0xb58714(0x136)],Number(_0xae9f79[_0xb58714(0x14b)]))[_0xb58714(0x141)](()=>undefined):undefined,_0x87ff8d=buildLocalSqlFileContent({'sqlCode':_0xae9f79[_0xb58714(0x119)],'sqlName':_0xae9f79['sqlName'],'dbId':_0xae9f79['dbId']},_0xd60383,{'dbName':_0x1123af,'mode':_0x4e5157,'syncedAt':new Date()[_0xb58714(0x13b)](),'description':_0xae9f79['description']}),_0x46d758=buildSqlLockEntry(_0xae9f79,_0xd60383,computeSqlContentHash(_0x87ff8d),{'dbName':_0x1123af}),_0x3b970b=_0x46d758[_0xb58714(0x120)],_0x1ff41e=join(_0x19428d[_0xb58714(0x147)],_0x3b970b);try{if(await fileExists(_0x1ff41e)){const _0xf232b9=await readFile(_0x1ff41e,_0xb58714(0x118));if(isEquivalentPulledSqlFile(_0xf232b9,_0x87ff8d,_0x4e5157)){_0x15e004[_0xb58714(0x125)]({'sqlCode':_0xae9f79[_0xb58714(0x119)],'reason':'unchanged'}),_0x26b728[_0xb58714(0x113)][_0xae9f79[_0xb58714(0x119)]]={..._0x46d758,'hash':computeSqlContentHash(_0xf232b9),'path':_0x3b970b};continue;}if(!_0x5ad1b3){_0x15e004[_0xb58714(0x125)]({'sqlCode':_0xae9f79[_0xb58714(0x119)],'reason':_0xb58714(0x12d)});continue;}}const _0x1c0bba=_0x1639b5?.[_0xb58714(0x120)]?join(_0x19428d['sqlRootDir'],_0x1639b5[_0xb58714(0x120)]):undefined;_0x1c0bba&&_0x1c0bba!==_0x1ff41e&&await fileExists(_0x1c0bba)&&await rm(_0x1c0bba,{'force':!![]}),await ensureParentDirectory(_0x1ff41e),await writeFile(_0x1ff41e,_0x87ff8d,_0xb58714(0x118)),_0x26b728[_0xb58714(0x113)][_0xae9f79[_0xb58714(0x119)]]={..._0x46d758,'path':_0x3b970b},_0x295f7b['push']({'sqlCode':_0xae9f79['sqlCode'],'filePath':_0x1ff41e});}catch(_0x22db42){_0x20dc65[_0xb58714(0x125)]({'sqlCode':_0xae9f79[_0xb58714(0x119)],'error':_0x22db42 instanceof Error?_0x22db42[_0xb58714(0x130)]:String(_0x22db42)});}}return _0x26b728[_0xb58714(0x11e)]=new Date()[_0xb58714(0x13b)](),await writeSqlLockFile(_0x19428d[_0xb58714(0x14e)],_0x516b29),{'ok':_0x20dc65[_0xb58714(0x131)]===0x0,'data':{'pulled':_0x295f7b,'skipped':_0x15e004,'failed':_0x20dc65},'message':_0xb58714(0x121)+_0x295f7b[_0xb58714(0x131)]+_0xb58714(0x148)+_0x15e004[_0xb58714(0x131)]+_0xb58714(0x132)+_0x20dc65[_0xb58714(0x131)]+_0xb58714(0x146)};}};function a214_0x17ae(_0x2bc71e,_0x420e56){_0x2bc71e=_0x2bc71e-0x112;const _0xa5a462=a214_0xa5a4();let _0x17ae9=_0xa5a462[_0x2bc71e];return _0x17ae9;}function detectModeFromSql(_0x5925aa){const _0x3e420f=a214_0x3c3d70,_0x5a15af=ensureRemoteSqlContent(_0x5925aa),_0x32c539=stripLocalSqlMetadata(_0x5a15af,_0x3e420f(0x123))[_0x3e420f(0x13f)]();if(/^<(select|insert|update|delete)\b/i[_0x3e420f(0x11c)](_0x32c539))return _0x3e420f(0x123);return _0x3e420f(0x142);}function isEquivalentPulledSqlFile(_0x499766,_0x9d39dc,_0x2eeb3e){return normalizePullComparableContent(_0x499766,_0x2eeb3e)===normalizePullComparableContent(_0x9d39dc,_0x2eeb3e);}function normalizePullComparableContent(_0x3e0ebb,_0x1d6c65){const _0x357ee0=a214_0x3c3d70,_0x53122f=_0x3e0ebb[_0x357ee0(0x137)](/\r\n/g,'\x0a')[_0x357ee0(0x135)]('\x0a'),_0x31db20=_0x53122f[_0x357ee0(0x13d)](_0xce9b4c=>!isSyncedAtMetadataLine(_0xce9b4c,_0x1d6c65));return _0x31db20[_0x357ee0(0x145)]('\x0a');}function isSyncedAtMetadataLine(_0x4176c0,_0x27fed4){const _0x67e211=a214_0x3c3d70;if(_0x27fed4===_0x67e211(0x123))return/^\s*<!--\s*@lovrabet\.syncedAt:/[_0x67e211(0x11c)](_0x4176c0);return/^\s*--\s*@lovrabet\.syncedAt:/[_0x67e211(0x11c)](_0x4176c0);}
@@ -1 +1 @@
1
- const a216_0x2ffbea=a216_0x2326;(function(_0x490177,_0x17f7b0){const _0x6720=a216_0x2326,_0x41db4c=_0x490177();while(!![]){try{const _0x496f02=parseInt(_0x6720(0x10b))/0x1+-parseInt(_0x6720(0xff))/0x2*(parseInt(_0x6720(0xe1))/0x3)+-parseInt(_0x6720(0xdb))/0x4*(-parseInt(_0x6720(0xd9))/0x5)+-parseInt(_0x6720(0x102))/0x6*(parseInt(_0x6720(0x114))/0x7)+parseInt(_0x6720(0xfe))/0x8+parseInt(_0x6720(0x100))/0x9*(parseInt(_0x6720(0xe0))/0xa)+parseInt(_0x6720(0xee))/0xb;if(_0x496f02===_0x17f7b0)break;else _0x41db4c['push'](_0x41db4c['shift']());}catch(_0x211b0a){_0x41db4c['push'](_0x41db4c['shift']());}}}(a216_0x419a,0x3e618));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';function a216_0x2326(_0x20513c,_0x4a0652){_0x20513c=_0x20513c-0xd7;const _0x419a89=a216_0x419a();let _0x2326af=_0x419a89[_0x20513c];return _0x2326af;}import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';function a216_0x419a(){const _0x2fefa0=['Push\x20local\x20SQL\x20files\x20to\x20remote','map','dbName','join','\x20failed','.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.','7sLgsgX','isFinite','lockFilePath','Local\x20directory\x20\x22','missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first','\x22\x20for\x20sqlCode\x20','\x20pushed,\x20','\x20SQL\x20file(s)','sqlRootDir','toISOString','status','message','15geUWpF','hash','506452wqncbl','startsWith','exec','appCode',',\x20deployment\x20sync\x20','92750buKWVm','2517guwFtF','has','sqls','remoteId','utf8','get','dbId','sqlcode','replace','\x20skipped,\x20','unchanged','version','validation','3168693XRNuzX','write','mode','filter','/smartapi/custom/updateUserCustomSql','Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20','boolean','projectRoot','filePath','length','sqlConfig','sqlName','sql','str','No\x20database\x20matches\x20local\x20directory\x20\x22','catch','813904iKSaLH','854sWfXya','18vozjjT','dbDirectory','1114842RTGOgT','Would\x20push\x20','path','relativePath','POST','sqlRoot','sqlCode','bool','push','11382SxOvQY','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','force'];a216_0x419a=function(){return _0x2fefa0;};return a216_0x419a();}import{automaticDeploymentSyncSucceeded,buildAutomaticDeploymentSyncPreview,runAutomaticDeploymentSync}from'../../commands/deployment/auto-sync.js';async function getTargetSqlQueries(_0x14539a,_0x328813,_0x3dec19){const _0x2b3058=a216_0x2326,_0x16aaef=await scanLocalSqlQueries(_0x14539a),_0x1130f1=new Map();for(const _0x3396f7 of _0x16aaef){if(_0x3dec19&&_0x3396f7[_0x2b3058(0x108)]!==_0x3dec19)continue;const _0x5ddbb0=_0x1130f1[_0x2b3058(0xe6)](_0x3396f7[_0x2b3058(0x108)])??[];_0x5ddbb0[_0x2b3058(0x10a)](_0x3396f7),_0x1130f1['set'](_0x3396f7[_0x2b3058(0x108)],_0x5ddbb0);}if(_0x3dec19&&!_0x1130f1[_0x2b3058(0xe2)](_0x3dec19))throw CliErrors[_0x2b3058(0xed)]('Local\x20SQL\x20not\x20found:\x20'+_0x3dec19);const _0x5334ad=[];for(const [_0x4c0e46,_0x4ee96b]of _0x1130f1['entries']()){if(_0x4ee96b[_0x2b3058(0xf7)]===0x1){_0x5334ad[_0x2b3058(0x10a)](_0x4ee96b[0x0]);continue;}const _0x556c1b=_0x328813[_0x2b3058(0xe3)][_0x4c0e46],_0x4eb5c9=_0x556c1b?.[_0x2b3058(0x104)],_0xe03f=_0x4eb5c9?_0x4ee96b[_0x2b3058(0xf1)](_0x4e61ed=>_0x4e61ed[_0x2b3058(0x105)]!==_0x4eb5c9):_0x4ee96b;if(_0x556c1b&&_0xe03f[_0x2b3058(0xf7)]===0x1){_0x5334ad[_0x2b3058(0x10a)](_0xe03f[0x0]);continue;}throw CliErrors['validation'](_0x2b3058(0xf3)+_0x4c0e46+_0x2b3058(0x113));}return _0x5334ad;}export const sqlPush={'service':a216_0x2ffbea(0xfa),'command':a216_0x2ffbea(0x10a),'description':a216_0x2ffbea(0x10e),'risk':a216_0x2ffbea(0xef),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a216_0x2ffbea(0xf4),'description':'Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock'}],async 'dryRun'(_0x4fb42c){const _0x35a941=a216_0x2ffbea,_0x1873fb=loadSqlProjectConfig(_0x4fb42c[_0x35a941(0xde)]),_0x2d426c=await readSqlLockFile(_0x1873fb['lockFilePath']),{appLock:_0x2484cd}=ensureSqlLockScope(_0x2d426c??createEmptySqlLock(),_0x4fb42c['appCode'],_0x1873fb[_0x35a941(0x107)],_0x35a941(0x10a)),_0x225ede=await getTargetSqlQueries(_0x1873fb,_0x2484cd,_0x4fb42c[_0x35a941(0xfb)](_0x35a941(0xe8))||undefined),_0x533de4=[];for(const _0x1c81a2 of _0x225ede){const _0x315d99=await computeSqlFileHash(_0x1c81a2[_0x35a941(0xf6)]),_0x6145ec=_0x2484cd['sqls'][_0x1c81a2[_0x35a941(0x108)]],_0x104646=!!_0x6145ec&&(_0x6145ec[_0x35a941(0x104)]!==_0x1c81a2['relativePath']||!!_0x1c81a2[_0x35a941(0xf9)]&&_0x6145ec['sqlName']!==_0x1c81a2[_0x35a941(0xf9)]);if(!_0x4fb42c[_0x35a941(0x109)](_0x35a941(0x10d))&&_0x6145ec&&_0x6145ec[_0x35a941(0xda)]===_0x315d99&&!_0x104646)continue;_0x533de4[_0x35a941(0x10a)](_0x1c81a2['sqlCode']);}return{'method':_0x35a941(0x106),'url':_0x35a941(0xf2),'deploymentSync':buildAutomaticDeploymentSyncPreview(_0x35a941(0xfa),_0x533de4),'body':{'sqlCodes':_0x533de4,'appCode':_0x4fb42c['appCode']},'description':_0x35a941(0x103)+_0x533de4[_0x35a941(0xf7)]+_0x35a941(0x11b)};},async 'execute'(_0xfd896c){const _0x328a8c=a216_0x2ffbea,_0x199065=loadSqlProjectConfig(_0xfd896c[_0x328a8c(0xde)]),_0x1fd5e1=await readSqlLockFile(_0x199065[_0x328a8c(0x116)]),{lockData:_0x9cca70,appLock:_0x193ce5}=ensureSqlLockScope(_0x1fd5e1??createEmptySqlLock(),_0xfd896c[_0x328a8c(0xde)],_0x199065[_0x328a8c(0x107)],_0x328a8c(0x10a)),_0x59cd29=await getTargetSqlQueries(_0x199065,_0x193ce5,_0xfd896c[_0x328a8c(0xfb)](_0x328a8c(0xe8))||undefined);if(_0x59cd29[_0x328a8c(0xf7)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':'No\x20local\x20SQL\x20files\x20found.'};const _0x530699=[],_0x5e3a3c=[],_0x233cd3=[];for(const _0xdc77ee of _0x59cd29){const _0x1f85be=_0x193ce5[_0x328a8c(0xe3)][_0xdc77ee['sqlCode']];if(!_0x1f85be){_0x233cd3['push']({'sqlCode':_0xdc77ee[_0x328a8c(0x108)],'error':_0x328a8c(0x10c)});continue;}try{const _0x5578bc=await computeSqlFileHash(_0xdc77ee[_0x328a8c(0xf6)]),_0x417e8a=_0x1f85be[_0x328a8c(0x104)]!==_0xdc77ee[_0x328a8c(0x105)]||!!_0xdc77ee[_0x328a8c(0xf9)]&&_0x1f85be['sqlName']!==_0xdc77ee[_0x328a8c(0xf9)];if(!_0xfd896c[_0x328a8c(0x109)]('force')&&_0x1f85be[_0x328a8c(0xda)]===_0x5578bc&&!_0x417e8a){_0x5e3a3c[_0x328a8c(0x10a)]({'sqlCode':_0xdc77ee[_0x328a8c(0x108)],'reason':_0x328a8c(0xeb)});continue;}if(_0x1f85be[_0x328a8c(0xec)]==null){_0x233cd3[_0x328a8c(0x10a)]({'sqlCode':_0xdc77ee[_0x328a8c(0x108)],'error':_0x328a8c(0x118)});continue;}const _0x1edcca=await readFile(_0xdc77ee['filePath'],_0x328a8c(0xe5)),_0x3e6553=stripLocalSqlMetadata(_0x1edcca,_0xdc77ee[_0x328a8c(0xf0)]),_0x297e8a=_0xdc77ee[_0x328a8c(0xf9)]||_0x1f85be[_0x328a8c(0xf9)],_0x489e14=await resolveTargetDbBinding(_0xfd896c[_0x328a8c(0xde)],_0xdc77ee,_0x1f85be),_0x202486=await updateSqlQuery({'id':_0x1f85be['remoteId'],'appCode':_0xfd896c['appCode'],'sqlCode':_0xdc77ee[_0x328a8c(0x108)],'sqlName':_0x297e8a,'dbId':_0x489e14[_0x328a8c(0xe7)],'version':_0x1f85be[_0x328a8c(0xec)],'sqlContent':_0x3e6553,'sqlConfig':_0x1f85be[_0x328a8c(0xf8)]??undefined}),_0x13e40b=_0x202486['dbId']?await getDbName(_0xfd896c['appCode'],Number(_0x202486[_0x328a8c(0xe7)]))['catch'](()=>_0x489e14[_0x328a8c(0x110)]):_0x489e14['dbName'];_0x193ce5[_0x328a8c(0xe3)][_0xdc77ee['sqlCode']]={...buildSqlLockEntry(_0x202486,_0x3e6553,_0x5578bc,{'dbName':_0x13e40b}),'path':_0xdc77ee[_0x328a8c(0x105)],'mode':_0x1f85be[_0x328a8c(0xf0)]},await archivePreviousSqlFileIfNeeded(_0x199065,_0x1f85be[_0x328a8c(0x104)],_0xdc77ee[_0x328a8c(0x105)]),_0x530699[_0x328a8c(0x10a)]({'sqlCode':_0xdc77ee[_0x328a8c(0x108)],'remoteId':_0x1f85be[_0x328a8c(0xe4)]});}catch(_0x285337){_0x233cd3['push']({'sqlCode':_0xdc77ee['sqlCode'],'error':_0x285337 instanceof Error?_0x285337[_0x328a8c(0xd8)]:String(_0x285337)});}}_0x193ce5['lastSync']=new Date()[_0x328a8c(0x11d)](),await writeSqlLockFile(_0x199065[_0x328a8c(0x116)],_0x9cca70);const _0x53e844=_0x233cd3[_0x328a8c(0xf7)]===0x0,_0x37832d=await runAutomaticDeploymentSync(_0xfd896c,_0x328a8c(0xfa),_0x530699[_0x328a8c(0x10f)](_0x1bf213=>_0x1bf213[_0x328a8c(0x108)]),_0x53e844),_0x65c5a0=_0x53e844&&automaticDeploymentSyncSucceeded(_0x37832d),_0x11e508=_0x328a8c(0xdf)+_0x37832d[_0x328a8c(0xd7)];return{'ok':_0x65c5a0,'data':{'pushed':_0x530699,'skipped':_0x5e3a3c,'failed':_0x233cd3,'deploymentSync':_0x37832d},'message':'Push\x20complete:\x20'+_0x530699[_0x328a8c(0xf7)]+_0x328a8c(0x11a)+_0x5e3a3c[_0x328a8c(0xf7)]+_0x328a8c(0xea)+_0x233cd3[_0x328a8c(0xf7)]+_0x328a8c(0x112)+_0x11e508};}};async function archivePreviousSqlFileIfNeeded(_0x119a71,_0x568cee,_0x40b084){const _0x405eb8=a216_0x2ffbea;if(!_0x568cee||_0x568cee===_0x40b084)return;const _0x277bda=join(_0x119a71[_0x405eb8(0x11c)],_0x568cee);if(!await fileExists(_0x277bda))return;const _0x47536e=await moveToTrash(_0x119a71[_0x405eb8(0xf5)],_0x119a71['trashDir'],_0x277bda);await cleanupEmptyDirectories(dirname(_0x277bda),_0x119a71[_0x405eb8(0x11c)]),void _0x47536e;}async function moveToTrash(_0x2fb11a,_0x274eec,_0x57c852){const _0x374658=a216_0x2ffbea,_0x177d71=new Date()[_0x374658(0x11d)]()[_0x374658(0xe9)](/[:.]/g,'-'),_0x4f41ea=relative(_0x2fb11a,_0x57c852),_0x3522a3=join(_0x274eec,_0x177d71,_0x4f41ea);return await mkdir(dirname(_0x3522a3),{'recursive':!![]}),await rename(_0x57c852,_0x3522a3),_0x3522a3;}async function cleanupEmptyDirectories(_0x2e6e0a,_0x434f31){const _0x300260=a216_0x2ffbea;let _0x4ec0ec=resolve(_0x2e6e0a);const _0x3d3b63=resolve(_0x434f31);while(_0x4ec0ec[_0x300260(0xdc)](''+_0x3d3b63+sep)||_0x4ec0ec===_0x3d3b63){if(_0x4ec0ec===_0x3d3b63)return;try{const _0x43ba76=await readdir(_0x4ec0ec);if(_0x43ba76['length']>0x0)return;await rmdir(_0x4ec0ec);}catch{return;}_0x4ec0ec=dirname(_0x4ec0ec);}}async function resolveTargetDbBinding(_0xacf96c,_0x241fa9,_0x24b6fd){const _0x362984=a216_0x2ffbea,_0x5e5248=_0x241fa9[_0x362984(0x101)];if(!_0x5e5248)return{'dbId':_0x24b6fd['dbId'],'dbName':_0x24b6fd[_0x362984(0x110)]};const _0x46dffb=buildDbDirectoryName(_0x24b6fd[_0x362984(0x110)],_0x24b6fd[_0x362984(0xe7)]);if(_0x5e5248===_0x46dffb)return{'dbId':_0x24b6fd[_0x362984(0xe7)],'dbName':_0x24b6fd[_0x362984(0x110)]};const _0x38a716=parseExplicitDbDirectory(_0x5e5248);if(_0x38a716!=null)return{'dbId':_0x38a716,'dbName':await getDbName(_0xacf96c,_0x38a716)[_0x362984(0xfd)](()=>undefined)};const _0x15f4c1=await listDatabases(_0xacf96c),_0x3f0bb0=_0x15f4c1[_0x362984(0xf1)](_0x12b555=>buildDbDirectoryName(_0x12b555[_0x362984(0x110)],_0x12b555[_0x362984(0xe7)])===_0x5e5248);if(_0x3f0bb0[_0x362984(0xf7)]===0x1)return{'dbId':_0x3f0bb0[0x0][_0x362984(0xe7)],'dbName':_0x3f0bb0[0x0]['dbName']};if(_0x3f0bb0['length']===0x0)throw CliErrors[_0x362984(0xed)](_0x362984(0xfc)+_0x5e5248+_0x362984(0x119)+_0x241fa9[_0x362984(0x108)]+'.');const _0x1db9c6=_0x3f0bb0[_0x362984(0x10f)](_0x5f5123=>_0x5f5123['dbName']+'\x20('+_0x5f5123[_0x362984(0xe7)]+')')[_0x362984(0x111)](',\x20');throw CliErrors[_0x362984(0xed)](_0x362984(0x117)+_0x5e5248+'\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20'+_0x241fa9[_0x362984(0x108)]+':\x20'+_0x1db9c6);}function parseExplicitDbDirectory(_0x15044f){const _0x5e7cc2=a216_0x2ffbea,_0x80d19e=/^db-(\d+)$/[_0x5e7cc2(0xdd)](_0x15044f);if(!_0x80d19e)return null;const _0x2a5f1c=Number(_0x80d19e[0x1]);return Number[_0x5e7cc2(0x115)](_0x2a5f1c)&&_0x2a5f1c>0x0?_0x2a5f1c:null;}
1
+ function a215_0x12f0(_0xbdd56e,_0x4725c4){_0xbdd56e=_0xbdd56e-0x168;const _0x5f4b65=a215_0x5f4b();let _0x12f004=_0x5f4b65[_0xbdd56e];return _0x12f004;}const a215_0xcbefa9=a215_0x12f0;(function(_0x3ac303,_0x17ea0c){const _0xde30b5=a215_0x12f0,_0x14911d=_0x3ac303();while(!![]){try{const _0x37d46a=parseInt(_0xde30b5(0x1a4))/0x1*(parseInt(_0xde30b5(0x172))/0x2)+parseInt(_0xde30b5(0x1a6))/0x3*(-parseInt(_0xde30b5(0x1a5))/0x4)+-parseInt(_0xde30b5(0x1a1))/0x5+parseInt(_0xde30b5(0x19d))/0x6*(parseInt(_0xde30b5(0x173))/0x7)+-parseInt(_0xde30b5(0x170))/0x8*(-parseInt(_0xde30b5(0x18e))/0x9)+parseInt(_0xde30b5(0x19b))/0xa+-parseInt(_0xde30b5(0x191))/0xb;if(_0x37d46a===_0x17ea0c)break;else _0x14911d['push'](_0x14911d['shift']());}catch(_0x5a4f60){_0x14911d['push'](_0x14911d['shift']());}}}(a215_0x5f4b,0x72a64));import{mkdir,readFile,readdir,rename,rmdir}from'node:fs/promises';import{dirname,join,relative,resolve,sep}from'node:path';import{updateSqlQuery}from'../../core/api-client.js';import{loadSqlProjectConfig}from'../../core/sql-sync/config.js';import{getDbName,listDatabases}from'../../core/db-resolver.js';import{scanLocalSqlQueries}from'../../core/sql-sync/file-system.js';import{computeSqlFileHash}from'../../core/sql-sync/hash.js';import{createEmptySqlLock,ensureSqlLockScope,readSqlLockFile,writeSqlLockFile}from'../../core/sql-sync/lock.js';import{fileExists}from'../../core/bff/file-system.js';import{CliErrors}from'../../errors.js';import{SQLCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{buildSqlLockEntry,stripLocalSqlMetadata}from'./shared.js';import{buildDbDirectoryName}from'../../core/sql-sync/utils.js';import{automaticDeploymentSyncSucceeded,buildAutomaticDeploymentSyncPreview,runAutomaticDeploymentSync}from'../../commands/deployment/auto-sync.js';async function getTargetSqlQueries(_0x257f8f,_0x5c9720,_0x3d3ce6){const _0x5b4537=a215_0x12f0,_0xdf2b60=await scanLocalSqlQueries(_0x257f8f),_0xb1fdf9=new Map();for(const _0x5e606d of _0xdf2b60){if(_0x3d3ce6&&_0x5e606d[_0x5b4537(0x16a)]!==_0x3d3ce6)continue;const _0x1a4fef=_0xb1fdf9[_0x5b4537(0x176)](_0x5e606d[_0x5b4537(0x16a)])??[];_0x1a4fef[_0x5b4537(0x1ac)](_0x5e606d),_0xb1fdf9['set'](_0x5e606d['sqlCode'],_0x1a4fef);}if(_0x3d3ce6&&!_0xb1fdf9[_0x5b4537(0x180)](_0x3d3ce6))throw CliErrors[_0x5b4537(0x175)](_0x5b4537(0x18c)+_0x3d3ce6);const _0x50a687=[];for(const [_0x50f372,_0x5c23e4]of _0xb1fdf9['entries']()){if(_0x5c23e4[_0x5b4537(0x188)]===0x1){_0x50a687[_0x5b4537(0x1ac)](_0x5c23e4[0x0]);continue;}const _0x1dc143=_0x5c9720[_0x5b4537(0x1a7)][_0x50f372],_0x15647a=_0x1dc143?.[_0x5b4537(0x189)],_0x1a772b=_0x15647a?_0x5c23e4[_0x5b4537(0x169)](_0x535b38=>_0x535b38[_0x5b4537(0x171)]!==_0x15647a):_0x5c23e4;if(_0x1dc143&&_0x1a772b['length']===0x1){_0x50a687[_0x5b4537(0x1ac)](_0x1a772b[0x0]);continue;}throw CliErrors['validation']('Multiple\x20local\x20SQL\x20files\x20found\x20for\x20sqlCode\x20'+_0x50f372+'.\x20Keep\x20only\x20one\x20file\x20under\x20its\x20sqlCode\x20directory\x20before\x20pushing.');}return _0x50a687;}export const sqlPush={'service':a215_0xcbefa9(0x17f),'command':a215_0xcbefa9(0x1ac),'description':'Push\x20local\x20SQL\x20files\x20to\x20remote','risk':a215_0xcbefa9(0x18d),'flags':[SQLCODE_FLAG_OPTIONAL,{'name':'force','type':a215_0xcbefa9(0x193),'description':a215_0xcbefa9(0x17b)}],async 'dryRun'(_0x52307a){const _0x1943e4=a215_0xcbefa9,_0x8b20d5=loadSqlProjectConfig(_0x52307a['appCode']),_0x51287=await readSqlLockFile(_0x8b20d5[_0x1943e4(0x18f)]),{appLock:_0x5d6794}=ensureSqlLockScope(_0x51287??createEmptySqlLock(),_0x52307a[_0x1943e4(0x192)],_0x8b20d5[_0x1943e4(0x1a9)],'push'),_0x5ceb51=await getTargetSqlQueries(_0x8b20d5,_0x5d6794,_0x52307a[_0x1943e4(0x197)]('sqlcode')||undefined),_0x205b00=[];for(const _0x2b115f of _0x5ceb51){const _0x3b8807=await computeSqlFileHash(_0x2b115f[_0x1943e4(0x18a)]),_0x476958=_0x5d6794[_0x1943e4(0x1a7)][_0x2b115f[_0x1943e4(0x16a)]],_0x5db518=!!_0x476958&&(_0x476958[_0x1943e4(0x189)]!==_0x2b115f['relativePath']||!!_0x2b115f[_0x1943e4(0x199)]&&_0x476958['sqlName']!==_0x2b115f[_0x1943e4(0x199)]);if(!_0x52307a[_0x1943e4(0x174)](_0x1943e4(0x183))&&_0x476958&&_0x476958[_0x1943e4(0x185)]===_0x3b8807&&!_0x5db518)continue;_0x205b00[_0x1943e4(0x1ac)](_0x2b115f['sqlCode']);}return{'method':_0x1943e4(0x187),'url':_0x1943e4(0x195),'deploymentSync':buildAutomaticDeploymentSyncPreview('sql',_0x205b00),'body':{'sqlCodes':_0x205b00,'appCode':_0x52307a['appCode']},'description':_0x1943e4(0x198)+_0x205b00[_0x1943e4(0x188)]+_0x1943e4(0x19e)};},async 'execute'(_0x5aa444){const _0x16f73c=a215_0xcbefa9,_0x1e9e16=loadSqlProjectConfig(_0x5aa444[_0x16f73c(0x192)]),_0x5a4554=await readSqlLockFile(_0x1e9e16[_0x16f73c(0x18f)]),{lockData:_0x54342f,appLock:_0x5a3e40}=ensureSqlLockScope(_0x5a4554??createEmptySqlLock(),_0x5aa444[_0x16f73c(0x192)],_0x1e9e16[_0x16f73c(0x1a9)],_0x16f73c(0x1ac)),_0xfeef18=await getTargetSqlQueries(_0x1e9e16,_0x5a3e40,_0x5aa444[_0x16f73c(0x197)](_0x16f73c(0x1a8))||undefined);if(_0xfeef18[_0x16f73c(0x188)]===0x0)return{'ok':!![],'data':{'pushed':[],'skipped':[],'failed':[]},'message':_0x16f73c(0x194)};const _0x1cb20c=[],_0x32a695=[],_0x58863b=[];for(const _0x41859e of _0xfeef18){const _0x48a77a=_0x5a3e40['sqls'][_0x41859e[_0x16f73c(0x16a)]];if(!_0x48a77a){_0x58863b[_0x16f73c(0x1ac)]({'sqlCode':_0x41859e[_0x16f73c(0x16a)],'error':_0x16f73c(0x17c)});continue;}try{const _0x1759e4=await computeSqlFileHash(_0x41859e['filePath']),_0x4b7ea2=_0x48a77a[_0x16f73c(0x189)]!==_0x41859e[_0x16f73c(0x171)]||!!_0x41859e['sqlName']&&_0x48a77a[_0x16f73c(0x199)]!==_0x41859e[_0x16f73c(0x199)];if(!_0x5aa444[_0x16f73c(0x174)](_0x16f73c(0x183))&&_0x48a77a['hash']===_0x1759e4&&!_0x4b7ea2){_0x32a695['push']({'sqlCode':_0x41859e['sqlCode'],'reason':_0x16f73c(0x16f)});continue;}if(_0x48a77a[_0x16f73c(0x16c)]==null){_0x58863b[_0x16f73c(0x1ac)]({'sqlCode':_0x41859e[_0x16f73c(0x16a)],'error':'missing\x20remote\x20version;\x20run\x20`rabetbase\x20sql\x20pull`\x20to\x20refresh\x20version\x20info\x20first'});continue;}const _0x30be43=await readFile(_0x41859e[_0x16f73c(0x18a)],_0x16f73c(0x17d)),_0x49a919=stripLocalSqlMetadata(_0x30be43,_0x41859e[_0x16f73c(0x17a)]),_0x409ab7=_0x41859e[_0x16f73c(0x199)]||_0x48a77a['sqlName'],_0x16edb5=await resolveTargetDbBinding(_0x5aa444[_0x16f73c(0x192)],_0x41859e,_0x48a77a),_0x323e94=await updateSqlQuery({'id':_0x48a77a[_0x16f73c(0x181)],'appCode':_0x5aa444['appCode'],'sqlCode':_0x41859e[_0x16f73c(0x16a)],'sqlName':_0x409ab7,'dbId':_0x16edb5[_0x16f73c(0x168)],'version':_0x48a77a['version'],'sqlContent':_0x49a919,'sqlConfig':_0x48a77a['sqlConfig']??undefined}),_0x1a992b=_0x323e94['dbId']?await getDbName(_0x5aa444[_0x16f73c(0x192)],Number(_0x323e94[_0x16f73c(0x168)]))[_0x16f73c(0x19f)](()=>_0x16edb5['dbName']):_0x16edb5[_0x16f73c(0x190)];_0x5a3e40[_0x16f73c(0x1a7)][_0x41859e[_0x16f73c(0x16a)]]={...buildSqlLockEntry(_0x323e94,_0x49a919,_0x1759e4,{'dbName':_0x1a992b}),'path':_0x41859e['relativePath'],'mode':_0x48a77a[_0x16f73c(0x17a)]},await archivePreviousSqlFileIfNeeded(_0x1e9e16,_0x48a77a[_0x16f73c(0x189)],_0x41859e['relativePath']),_0x1cb20c['push']({'sqlCode':_0x41859e['sqlCode'],'remoteId':_0x48a77a[_0x16f73c(0x181)]});}catch(_0xfc8ec3){_0x58863b[_0x16f73c(0x1ac)]({'sqlCode':_0x41859e[_0x16f73c(0x16a)],'error':_0xfc8ec3 instanceof Error?_0xfc8ec3['message']:String(_0xfc8ec3)});}}_0x5a3e40['lastSync']=new Date()[_0x16f73c(0x19c)](),await writeSqlLockFile(_0x1e9e16[_0x16f73c(0x18f)],_0x54342f);const _0x52994a=_0x58863b[_0x16f73c(0x188)]===0x0,_0x54f089=await runAutomaticDeploymentSync(_0x5aa444,_0x16f73c(0x17f),_0x1cb20c[_0x16f73c(0x177)](_0x4fde4d=>_0x4fde4d[_0x16f73c(0x16a)]),_0x52994a),_0x322287=_0x52994a&&automaticDeploymentSyncSucceeded(_0x54f089),_0xa6cf82=_0x16f73c(0x16e)+_0x54f089[_0x16f73c(0x186)];return{'ok':_0x322287,'data':{'pushed':_0x1cb20c,'skipped':_0x32a695,'failed':_0x58863b,'deploymentSync':_0x54f089},'message':_0x16f73c(0x1a3)+_0x1cb20c[_0x16f73c(0x188)]+_0x16f73c(0x182)+_0x32a695[_0x16f73c(0x188)]+_0x16f73c(0x184)+_0x58863b[_0x16f73c(0x188)]+_0x16f73c(0x196)+_0xa6cf82};}};async function archivePreviousSqlFileIfNeeded(_0x55d7d7,_0xda71d9,_0x2a3842){const _0x44c188=a215_0xcbefa9;if(!_0xda71d9||_0xda71d9===_0x2a3842)return;const _0x52f0ac=join(_0x55d7d7[_0x44c188(0x179)],_0xda71d9);if(!await fileExists(_0x52f0ac))return;const _0x4cadf2=await moveToTrash(_0x55d7d7[_0x44c188(0x1a0)],_0x55d7d7[_0x44c188(0x18b)],_0x52f0ac);await cleanupEmptyDirectories(dirname(_0x52f0ac),_0x55d7d7[_0x44c188(0x179)]),void _0x4cadf2;}function a215_0x5f4b(){const _0xd4e21c=['map','\x22\x20matches\x20multiple\x20databases\x20for\x20sqlCode\x20','sqlRootDir','mode','Force\x20push\x20even\x20if\x20local\x20hash\x20matches\x20lock','local\x20SQL\x20is\x20not\x20tracked\x20by\x20sql.lock.json;\x20use\x20`rabetbase\x20sql\x20create`\x20or\x20`rabetbase\x20sql\x20pull`\x20first','utf8','dbDirectory','sql','has','remoteId','\x20pushed,\x20','force','\x20skipped,\x20','hash','status','POST','length','path','filePath','trashDir','Local\x20SQL\x20not\x20found:\x20','write','7135632tMjPyi','lockFilePath','dbName','14010843MQgyde','appCode','boolean','No\x20local\x20SQL\x20files\x20found.','/smartapi/custom/updateUserCustomSql','\x20failed','str','Would\x20push\x20','sqlName','isFinite','4720530OcYdjE','toISOString','799518ujXskK','\x20SQL\x20file(s)','catch','projectRoot','1166375RXaQRO','Local\x20directory\x20\x22','Push\x20complete:\x20','11QNnkIb','512188MSVCUZ','6iSmFGW','sqls','sqlcode','sqlRoot','\x22\x20for\x20sqlCode\x20','startsWith','push','dbId','filter','sqlCode','No\x20database\x20matches\x20local\x20directory\x20\x22','version','join',',\x20deployment\x20sync\x20','unchanged','8XSaaJu','relativePath','30594gHVYkc','42TJjKVR','bool','validation','get'];a215_0x5f4b=function(){return _0xd4e21c;};return a215_0x5f4b();}async function moveToTrash(_0x34713b,_0x27d575,_0x6aa3e7){const _0x3919e3=a215_0xcbefa9,_0x31bbe3=new Date()[_0x3919e3(0x19c)]()['replace'](/[:.]/g,'-'),_0x1b5783=relative(_0x34713b,_0x6aa3e7),_0x4dfdcb=join(_0x27d575,_0x31bbe3,_0x1b5783);return await mkdir(dirname(_0x4dfdcb),{'recursive':!![]}),await rename(_0x6aa3e7,_0x4dfdcb),_0x4dfdcb;}async function cleanupEmptyDirectories(_0x29395b,_0x225830){const _0x55dfe8=a215_0xcbefa9;let _0x3cf030=resolve(_0x29395b);const _0x53f8c3=resolve(_0x225830);while(_0x3cf030[_0x55dfe8(0x1ab)](''+_0x53f8c3+sep)||_0x3cf030===_0x53f8c3){if(_0x3cf030===_0x53f8c3)return;try{const _0x5b9135=await readdir(_0x3cf030);if(_0x5b9135[_0x55dfe8(0x188)]>0x0)return;await rmdir(_0x3cf030);}catch{return;}_0x3cf030=dirname(_0x3cf030);}}async function resolveTargetDbBinding(_0x401fe1,_0x208cd9,_0x1df611){const _0x34142e=a215_0xcbefa9,_0x2dd49c=_0x208cd9[_0x34142e(0x17e)];if(!_0x2dd49c)return{'dbId':_0x1df611['dbId'],'dbName':_0x1df611[_0x34142e(0x190)]};const _0x1e72c2=buildDbDirectoryName(_0x1df611[_0x34142e(0x190)],_0x1df611[_0x34142e(0x168)]);if(_0x2dd49c===_0x1e72c2)return{'dbId':_0x1df611[_0x34142e(0x168)],'dbName':_0x1df611['dbName']};const _0xb34f99=parseExplicitDbDirectory(_0x2dd49c);if(_0xb34f99!=null)return{'dbId':_0xb34f99,'dbName':await getDbName(_0x401fe1,_0xb34f99)[_0x34142e(0x19f)](()=>undefined)};const _0x4cd210=await listDatabases(_0x401fe1),_0x5b8c2d=_0x4cd210[_0x34142e(0x169)](_0x30d18b=>buildDbDirectoryName(_0x30d18b[_0x34142e(0x190)],_0x30d18b[_0x34142e(0x168)])===_0x2dd49c);if(_0x5b8c2d[_0x34142e(0x188)]===0x1)return{'dbId':_0x5b8c2d[0x0][_0x34142e(0x168)],'dbName':_0x5b8c2d[0x0][_0x34142e(0x190)]};if(_0x5b8c2d[_0x34142e(0x188)]===0x0)throw CliErrors['validation'](_0x34142e(0x16b)+_0x2dd49c+_0x34142e(0x1aa)+_0x208cd9[_0x34142e(0x16a)]+'.');const _0x3bc769=_0x5b8c2d[_0x34142e(0x177)](_0x48c044=>_0x48c044[_0x34142e(0x190)]+'\x20('+_0x48c044['dbId']+')')[_0x34142e(0x16d)](',\x20');throw CliErrors[_0x34142e(0x175)](_0x34142e(0x1a2)+_0x2dd49c+_0x34142e(0x178)+_0x208cd9[_0x34142e(0x16a)]+':\x20'+_0x3bc769);}function parseExplicitDbDirectory(_0x251d06){const _0x483fdd=a215_0xcbefa9,_0x3f607e=/^db-(\d+)$/['exec'](_0x251d06);if(!_0x3f607e)return null;const _0x37a595=Number(_0x3f607e[0x1]);return Number[_0x483fdd(0x19a)](_0x37a595)&&_0x37a595>0x0?_0x37a595:null;}