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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (446) hide show
  1. package/README.md +42 -17
  2. package/lib/api/api-doc.js +3 -1
  3. package/lib/api/api-group.js +3 -1
  4. package/lib/api/fetch-model-list.js +1 -1
  5. package/lib/api/generate-api-file.js +8 -1
  6. package/lib/api/generate-sdk-config-file.js +1 -1
  7. package/lib/api/legacy-api-file.js +2 -1
  8. package/lib/api/model-registry-file.js +11 -1
  9. package/lib/api/model-registry-scaffold.js +2 -1
  10. package/lib/api/model-source.js +3 -1
  11. package/lib/auth/auth-server-ui.js +2 -1
  12. package/lib/auth/auth-server.js +5 -1
  13. package/lib/auth/constant.js +1 -1
  14. package/lib/auth/get-cookie.js +1 -1
  15. package/lib/auth/get-session-user.js +1 -1
  16. package/lib/auth/is-session-valid.js +1 -1
  17. package/lib/auth/login-success-html.js +3 -1
  18. package/lib/auth/logout.js +1 -1
  19. package/lib/cli-flags.js +1 -1
  20. package/lib/cli.js +5 -1
  21. package/lib/commands/api/generate.js +4 -1
  22. package/lib/commands/api/index.js +1 -1
  23. package/lib/commands/api/list.js +2 -1
  24. package/lib/commands/api/pull.js +10 -1
  25. package/lib/commands/api/shared.js +1 -1
  26. package/lib/commands/app/detail.js +1 -1
  27. package/lib/commands/app/index.js +1 -1
  28. package/lib/commands/app/list.js +5 -1
  29. package/lib/commands/app/members-list.js +1 -1
  30. package/lib/commands/app/remote-directory.js +1 -1
  31. package/lib/commands/app/shared.js +4 -1
  32. package/lib/commands/app-config/delete.js +2 -1
  33. package/lib/commands/app-config/get.js +2 -1
  34. package/lib/commands/app-config/index.js +1 -1
  35. package/lib/commands/app-config/list.js +2 -1
  36. package/lib/commands/app-config/set.js +3 -1
  37. package/lib/commands/app-config/shared.d.ts +9 -2
  38. package/lib/commands/app-config/shared.js +6 -1
  39. package/lib/commands/auth/index.js +1 -1
  40. package/lib/commands/bff/create.js +11 -1
  41. package/lib/commands/bff/delete.js +6 -1
  42. package/lib/commands/bff/detail.js +1 -1
  43. package/lib/commands/bff/index.js +1 -1
  44. package/lib/commands/bff/list.js +1 -1
  45. package/lib/commands/bff/logs.js +4 -1
  46. package/lib/commands/bff/pull.js +22 -1
  47. package/lib/commands/bff/push.js +16 -1
  48. package/lib/commands/bff/status.js +3 -1
  49. package/lib/commands/cli-skill/index.js +2 -1
  50. package/lib/commands/cli-update.js +7 -1
  51. package/lib/commands/codegen/index.js +1 -1
  52. package/lib/commands/codegen/sdk.js +1 -1
  53. package/lib/commands/codegen/sql.js +1 -1
  54. package/lib/commands/common/app-registry.js +4 -1
  55. package/lib/commands/common/app-selector.js +4 -1
  56. package/lib/commands/common/async-task.js +2 -1
  57. package/lib/commands/common/dry-run.js +1 -1
  58. package/lib/commands/common/flags.js +3 -1
  59. package/lib/commands/common/local-file.js +1 -1
  60. package/lib/commands/common/validate.js +1 -1
  61. package/lib/commands/config/delete.js +2 -1
  62. package/lib/commands/config/get.js +1 -1
  63. package/lib/commands/config/index.js +1 -1
  64. package/lib/commands/config/init.js +5 -1
  65. package/lib/commands/config/list.js +1 -1
  66. package/lib/commands/config/set.js +4 -1
  67. package/lib/commands/config/shared.js +2 -1
  68. package/lib/commands/dataset/batch-design.js +9 -1
  69. package/lib/commands/dataset/business-group-update.js +10 -1
  70. package/lib/commands/dataset/business-groups.js +1 -1
  71. package/lib/commands/dataset/capability.js +3 -1
  72. package/lib/commands/dataset/cross-relation-create.js +2 -1
  73. package/lib/commands/dataset/cross-relation-delete.js +1 -1
  74. package/lib/commands/dataset/cross-relation-list.js +2 -1
  75. package/lib/commands/dataset/cross-relation-shared.js +10 -1
  76. package/lib/commands/dataset/cross-relation-update.js +2 -1
  77. package/lib/commands/dataset/delete.js +6 -1
  78. package/lib/commands/dataset/design-context.js +1 -1
  79. package/lib/commands/dataset/design-start.js +1 -1
  80. package/lib/commands/dataset/design-status.js +1 -1
  81. package/lib/commands/dataset/design-sync-retry.js +1 -1
  82. package/lib/commands/dataset/design-sync-status.js +1 -1
  83. package/lib/commands/dataset/design-validate.js +1 -1
  84. package/lib/commands/dataset/detail.js +5 -1
  85. package/lib/commands/dataset/extend-update.js +7 -1
  86. package/lib/commands/dataset/field-restore.js +7 -1
  87. package/lib/commands/dataset/field-update.js +7 -1
  88. package/lib/commands/dataset/generate.js +19 -1
  89. package/lib/commands/dataset/index.js +3 -1
  90. package/lib/commands/dataset/list.js +2 -1
  91. package/lib/commands/dataset/operations.js +2 -1
  92. package/lib/commands/dataset/relation-audit.js +7 -1
  93. package/lib/commands/dataset/relation-create.js +3 -1
  94. package/lib/commands/dataset/relation-delete.js +3 -1
  95. package/lib/commands/dataset/relation-shared.js +21 -1
  96. package/lib/commands/dataset/relation-update.js +4 -1
  97. package/lib/commands/dataset/relations.js +7 -1
  98. package/lib/commands/dataset/rename.js +4 -1
  99. package/lib/commands/dataset/restore.js +7 -1
  100. package/lib/commands/dataset/user-deleted-field-list.js +3 -1
  101. package/lib/commands/db/analysis-batching.js +3 -1
  102. package/lib/commands/db/analyze-batch-plan.js +2 -1
  103. package/lib/commands/db/analyze-cancel.js +1 -1
  104. package/lib/commands/db/analyze-start.js +3 -1
  105. package/lib/commands/db/analyze-status.js +6 -1
  106. package/lib/commands/db/create.js +4 -1
  107. package/lib/commands/db/cross-db-analysis-shared.js +3 -1
  108. package/lib/commands/db/cross-db-analyze-latest.js +1 -1
  109. package/lib/commands/db/cross-db-analyze-start.js +2 -1
  110. package/lib/commands/db/cross-db-analyze-status.js +1 -1
  111. package/lib/commands/db/delete.js +3 -1
  112. package/lib/commands/db/detail.js +1 -1
  113. package/lib/commands/db/diff-refresh-start.js +1 -1
  114. package/lib/commands/db/diff-refresh-status.js +2 -1
  115. package/lib/commands/db/diff.js +3 -1
  116. package/lib/commands/db/index.js +2 -1
  117. package/lib/commands/db/list.js +2 -1
  118. package/lib/commands/db/shared.js +3 -1
  119. package/lib/commands/db/table-diff-shared.js +2 -1
  120. package/lib/commands/db/tables.js +2 -1
  121. package/lib/commands/db/test.js +2 -1
  122. package/lib/commands/db/update.js +4 -1
  123. package/lib/commands/deployment/index.js +1 -1
  124. package/lib/commands/deployment/sync-all.js +3 -1
  125. package/lib/commands/deployment/sync-jobs.js +2 -1
  126. package/lib/commands/deployment/sync-status.js +2 -1
  127. package/lib/commands/doctor.js +12 -1
  128. package/lib/commands/file/index.js +3 -1
  129. package/lib/commands/flow/create.js +2 -1
  130. package/lib/commands/flow/detail.js +3 -1
  131. package/lib/commands/flow/index.js +1 -1
  132. package/lib/commands/flow/list.js +2 -1
  133. package/lib/commands/flow/page-list.js +2 -1
  134. package/lib/commands/flow/publish.js +2 -1
  135. package/lib/commands/flow/runtime-resources-shared.js +3 -1
  136. package/lib/commands/flow/runtime-role-list.js +2 -1
  137. package/lib/commands/flow/runtime-role-user-list.js +2 -1
  138. package/lib/commands/flow/runtime-user-search.js +2 -1
  139. package/lib/commands/flow/shared.js +6 -1
  140. package/lib/commands/flow/update.js +4 -1
  141. package/lib/commands/flow/validate.js +2 -1
  142. package/lib/commands/instant-api-policy/current.js +1 -1
  143. package/lib/commands/instant-api-policy/index.js +1 -1
  144. package/lib/commands/instant-api-policy/init.js +2 -1
  145. package/lib/commands/instant-api-policy/publish.js +5 -1
  146. package/lib/commands/instant-api-policy/pull.js +2 -1
  147. package/lib/commands/instant-api-policy/revision.js +1 -1
  148. package/lib/commands/instant-api-policy/revisions.js +1 -1
  149. package/lib/commands/instant-api-policy/rollback.js +5 -1
  150. package/lib/commands/instant-api-policy/shared.js +5 -1
  151. package/lib/commands/instant-api-policy/validate.js +1 -1
  152. package/lib/commands/issue/context.js +1 -1
  153. package/lib/commands/issue/index.js +1 -1
  154. package/lib/commands/issue/nudge.js +2 -1
  155. package/lib/commands/issue/report.js +5 -1
  156. package/lib/commands/kb/create.js +5 -1
  157. package/lib/commands/kb/delete.js +5 -1
  158. package/lib/commands/kb/detail.js +1 -1
  159. package/lib/commands/kb/import-api.d.ts +3 -0
  160. package/lib/commands/kb/import-api.js +1 -0
  161. package/lib/commands/kb/import-resume.d.ts +2 -0
  162. package/lib/commands/kb/import-resume.js +2 -0
  163. package/lib/commands/kb/import-shared.d.ts +69 -0
  164. package/lib/commands/kb/import-shared.js +9 -0
  165. package/lib/commands/kb/import-status.d.ts +2 -0
  166. package/lib/commands/kb/import-status.js +1 -0
  167. package/lib/commands/kb/import.d.ts +2 -0
  168. package/lib/commands/kb/import.js +3 -0
  169. package/lib/commands/kb/index.js +1 -1
  170. package/lib/commands/kb/list.js +1 -1
  171. package/lib/commands/kb/search.js +3 -1
  172. package/lib/commands/kb/shared.js +9 -1
  173. package/lib/commands/kb/update.js +7 -1
  174. package/lib/commands/logs/index.js +2 -1
  175. package/lib/commands/menu/asset-update.js +8 -1
  176. package/lib/commands/menu/delete.js +15 -1
  177. package/lib/commands/menu/external-link-create.js +16 -1
  178. package/lib/commands/menu/external-link-update.js +10 -1
  179. package/lib/commands/menu/group-create.js +8 -1
  180. package/lib/commands/menu/group-update.js +6 -1
  181. package/lib/commands/menu/index.js +2 -1
  182. package/lib/commands/menu/list.js +1 -1
  183. package/lib/commands/menu/move.js +6 -1
  184. package/lib/commands/menu/regroup-start.js +11 -1
  185. package/lib/commands/menu/rename.js +9 -1
  186. package/lib/commands/menu/shared/compare-table.js +2 -1
  187. package/lib/commands/menu/shared/delete-plan.js +13 -1
  188. package/lib/commands/menu/shared/facts.js +5 -1
  189. package/lib/commands/menu/shared/index.js +1 -1
  190. package/lib/commands/menu/shared/inquirer.js +4 -1
  191. package/lib/commands/menu/shared/local-pages.js +5 -1
  192. package/lib/commands/menu/shared/logic.js +3 -1
  193. package/lib/commands/menu/shared/mutations.js +9 -1
  194. package/lib/commands/menu/shared/path.js +1 -1
  195. package/lib/commands/menu/shared/service.js +4 -1
  196. package/lib/commands/menu/shared/subapp-assets.js +4 -1
  197. package/lib/commands/menu/shared/sync-core.js +7 -1
  198. package/lib/commands/menu/shared/types.js +1 -1
  199. package/lib/commands/menu/shared/update-core.js +8 -1
  200. package/lib/commands/menu/shared/valid-url.js +1 -1
  201. package/lib/commands/menu/subapp-assets-status.js +1 -1
  202. package/lib/commands/menu/subapp-assets-update.js +7 -1
  203. package/lib/commands/menu/sync.js +7 -1
  204. package/lib/commands/menu/visibility-update.js +13 -1
  205. package/lib/commands/metric/contract.d.ts +8 -0
  206. package/lib/commands/metric/contract.js +5 -0
  207. package/lib/commands/metric/definition.d.ts +43 -0
  208. package/lib/commands/metric/definition.js +4 -0
  209. package/lib/commands/metric/delete.d.ts +2 -0
  210. package/lib/commands/metric/delete.js +3 -0
  211. package/lib/commands/metric/detail.d.ts +2 -0
  212. package/lib/commands/metric/detail.js +1 -0
  213. package/lib/commands/metric/example.d.ts +2 -0
  214. package/lib/commands/metric/example.js +1 -0
  215. package/lib/commands/metric/index.d.ts +2 -0
  216. package/lib/commands/metric/index.js +1 -0
  217. package/lib/commands/metric/list.d.ts +2 -0
  218. package/lib/commands/metric/list.js +2 -0
  219. package/lib/commands/metric/publication-diff.d.ts +8 -0
  220. package/lib/commands/metric/publication-diff.js +1 -0
  221. package/lib/commands/metric/publish.d.ts +2 -0
  222. package/lib/commands/metric/publish.js +4 -0
  223. package/lib/commands/metric/schema.d.ts +2 -0
  224. package/lib/commands/metric/schema.js +1 -0
  225. package/lib/commands/metric/shared.d.ts +14 -0
  226. package/lib/commands/metric/shared.js +2 -0
  227. package/lib/commands/metric/validate.d.ts +2 -0
  228. package/lib/commands/metric/validate.js +1 -0
  229. package/lib/commands/notification/config-create.js +4 -1
  230. package/lib/commands/notification/config-delete.js +4 -1
  231. package/lib/commands/notification/config-list.js +2 -1
  232. package/lib/commands/notification/config-update.js +4 -1
  233. package/lib/commands/notification/index.js +1 -1
  234. package/lib/commands/notification/shared.js +18 -1
  235. package/lib/commands/ocr/index.js +4 -1
  236. package/lib/commands/page/create.js +6 -1
  237. package/lib/commands/page/custom/detail.js +2 -1
  238. package/lib/commands/page/custom/list.js +2 -1
  239. package/lib/commands/page/custom/publish.js +3 -1
  240. package/lib/commands/page/custom/shared.js +3 -1
  241. package/lib/commands/page/custom/syntax.js +2 -1
  242. package/lib/commands/page/custom/update.js +3 -1
  243. package/lib/commands/page/data-list-status.js +2 -1
  244. package/lib/commands/page/generate-start.js +5 -1
  245. package/lib/commands/page/generate-status.js +4 -1
  246. package/lib/commands/page/index.js +2 -1
  247. package/lib/commands/page/pull.js +6 -1
  248. package/lib/commands/page/push.js +11 -1
  249. package/lib/commands/page/relation-audit.js +15 -1
  250. package/lib/commands/page/restore.js +5 -1
  251. package/lib/commands/page/shared.js +16 -1
  252. package/lib/commands/page/sync.js +2 -1
  253. package/lib/commands/project/api-architecture-upgrade.js +11 -1
  254. package/lib/commands/project/create/enhanced-guided-create.js +2 -1
  255. package/lib/commands/project/create/format-elapsed.js +1 -1
  256. package/lib/commands/project/create/main.js +13 -1
  257. package/lib/commands/project/create/materialize-project-template.js +12 -1
  258. package/lib/commands/project/create/project-name.js +1 -1
  259. package/lib/commands/project/create/project-template-archive.js +5 -1
  260. package/lib/commands/project/create/project-template-path.js +1 -1
  261. package/lib/commands/project/create/use-copy-project-template.js +2 -1
  262. package/lib/commands/project/create/use-format-code.js +1 -1
  263. package/lib/commands/project/create/use-install-dependencies.js +1 -1
  264. package/lib/commands/project/domain-routing-sync.js +1 -1
  265. package/lib/commands/project/index.js +4 -1
  266. package/lib/commands/project/upgrade.js +7 -1
  267. package/lib/commands/registry.js +10 -1
  268. package/lib/commands/role/delete.js +2 -1
  269. package/lib/commands/role/detail.js +1 -1
  270. package/lib/commands/role/index.js +1 -1
  271. package/lib/commands/role/list.js +2 -1
  272. package/lib/commands/role/shared.js +8 -1
  273. package/lib/commands/role/update.js +3 -1
  274. package/lib/commands/role/user-add.js +2 -1
  275. package/lib/commands/role/user-remove.js +2 -1
  276. package/lib/commands/role/user-resolve.js +1 -1
  277. package/lib/commands/rule/get.js +1 -1
  278. package/lib/commands/rule/index.js +1 -1
  279. package/lib/commands/rule/list.js +1 -1
  280. package/lib/commands/rule/set.js +7 -1
  281. package/lib/commands/rule/shared.js +4 -1
  282. package/lib/commands/run/index.js +5 -1
  283. package/lib/commands/schema.js +1 -1
  284. package/lib/commands/sql/create.js +7 -1
  285. package/lib/commands/sql/delete.js +4 -1
  286. package/lib/commands/sql/detail.js +1 -1
  287. package/lib/commands/sql/exec.js +1 -1
  288. package/lib/commands/sql/index.js +1 -1
  289. package/lib/commands/sql/list.js +2 -1
  290. package/lib/commands/sql/pull.js +10 -1
  291. package/lib/commands/sql/push.js +9 -1
  292. package/lib/commands/sql/shared.js +5 -1
  293. package/lib/commands/sql/status.js +3 -1
  294. package/lib/commands/sql/validate.js +5 -1
  295. package/lib/commands/task/index.js +1 -1
  296. package/lib/commands/task/status.js +2 -1
  297. package/lib/commands/tenant/index.js +1 -1
  298. package/lib/commands/tenant/members-list.js +2 -1
  299. package/lib/commands/tenant/shared.js +2 -1
  300. package/lib/commands/user-account/dingding-sandbox-bind.js +2 -1
  301. package/lib/commands/user-account/feishu-bind.js +2 -1
  302. package/lib/commands/user-account/index.js +1 -1
  303. package/lib/commands/workspace/add.js +1 -1
  304. package/lib/commands/workspace/index.js +7 -1
  305. package/lib/commands/workspace/remove.js +1 -1
  306. package/lib/config/domain-config.js +8 -1
  307. package/lib/config/project-domain-routing.js +3 -1
  308. package/lib/config/region-config.js +2 -1
  309. package/lib/config/schema.js +7 -1
  310. package/lib/constant/cdn.js +2 -1
  311. package/lib/constant/cli.js +8 -1
  312. package/lib/constant/defaults.js +1 -1
  313. package/lib/constant/domain.js +4 -1
  314. package/lib/constant/env.js +1 -1
  315. package/lib/constant/output.js +1 -1
  316. package/lib/constant/paths.js +1 -1
  317. package/lib/constant/region.js +1 -1
  318. package/lib/constant/risk.js +1 -1
  319. package/lib/constant/routing-profile.js +1 -1
  320. package/lib/context/app-resolver.js +7 -1
  321. package/lib/context/auth-resolver.js +1 -1
  322. package/lib/context/config-loader.js +7 -1
  323. package/lib/context.js +9 -1
  324. package/lib/core/alias-resolver.js +5 -1
  325. package/lib/core/api-client.d.ts +14 -7
  326. package/lib/core/api-client.js +69 -1
  327. package/lib/core/bff/config.js +1 -1
  328. package/lib/core/bff/file-system.js +6 -1
  329. package/lib/core/bff/hash.js +1 -1
  330. package/lib/core/bff/hook-directory.js +9 -1
  331. package/lib/core/bff/lock.js +2 -1
  332. package/lib/core/bff/types.js +1 -1
  333. package/lib/core/bff/utils.js +3 -1
  334. package/lib/core/cross-db-analysis.js +1 -1
  335. package/lib/core/cross-db-relation.js +1 -1
  336. package/lib/core/db-resolver.js +2 -1
  337. package/lib/core/flow-config.js +49 -1
  338. package/lib/core/instant-api-policy/config.js +7 -1
  339. package/lib/core/instant-api-policy/endpoints.js +1 -1
  340. package/lib/core/kb-management-client.d.ts +11 -0
  341. package/lib/core/kb-management-client.js +4 -1
  342. package/lib/core/kb-search-client.js +3 -1
  343. package/lib/core/page/file-system.js +2 -1
  344. package/lib/core/page/hash.js +1 -1
  345. package/lib/core/page/lock.js +2 -1
  346. package/lib/core/page/lr-smart-jsx.js +4 -1
  347. package/lib/core/page/types.js +1 -1
  348. package/lib/core/sql-index-auditor.js +14 -1
  349. package/lib/core/sql-sync/config.js +1 -1
  350. package/lib/core/sql-sync/file-system.js +3 -1
  351. package/lib/core/sql-sync/hash.js +1 -1
  352. package/lib/core/sql-sync/lock.js +2 -1
  353. package/lib/core/sql-sync/types.js +1 -1
  354. package/lib/core/sql-sync/utils.js +2 -1
  355. package/lib/core/sql-validator.js +15 -1
  356. package/lib/errors.js +3 -1
  357. package/lib/framework/build-all-flags.js +1 -1
  358. package/lib/framework/error-output.js +1 -1
  359. package/lib/framework/explicit-yes.js +1 -1
  360. package/lib/framework/flags.js +1 -1
  361. package/lib/framework/help.js +2 -1
  362. package/lib/framework/index.js +1 -1
  363. package/lib/framework/output.js +2 -1
  364. package/lib/framework/response.js +1 -1
  365. package/lib/framework/runner-alias.js +2 -1
  366. package/lib/framework/runner.js +9 -1
  367. package/lib/framework/schema-export.js +1 -1
  368. package/lib/framework/supported-flags.js +2 -1
  369. package/lib/framework/types.js +1 -1
  370. package/lib/generated/build-info.d.ts +4 -4
  371. package/lib/generated/build-info.js +1 -1
  372. package/lib/generated/official-routing.js +3 -1
  373. package/lib/generated/routing-contract.js +1 -1
  374. package/lib/help.js +1 -1
  375. package/lib/runtime/confirmation.js +2 -1
  376. package/lib/runtime/event.js +1 -1
  377. package/lib/runtime/index.js +4 -1
  378. package/lib/runtime/queue.js +1 -1
  379. package/lib/runtime/resolve.js +2 -1
  380. package/lib/runtime/types.js +1 -1
  381. package/lib/services/dataset-design/checkpoint.js +2 -1
  382. package/lib/services/dataset-design/commands.js +14 -1
  383. package/lib/services/dataset-design/contract.js +8 -1
  384. package/lib/skills/builtin-skill.js +8 -1
  385. package/lib/skills/install-updated-skill.d.ts +8 -0
  386. package/lib/skills/install-updated-skill.js +3 -0
  387. package/lib/skills/local-skills-installer.d.ts +2 -0
  388. package/lib/skills/local-skills-installer.js +1 -0
  389. package/lib/skills/main.js +2 -1
  390. package/lib/skills/npx-skills-add.d.ts +6 -6
  391. package/lib/skills/npx-skills-add.js +5 -1
  392. package/lib/skills/skill-presence.d.ts +1 -30
  393. package/lib/skills/skill-presence.js +2 -1
  394. package/lib/telemetry/cli-command-trace.js +2 -1
  395. package/lib/telemetry/cli-help-trace.js +1 -1
  396. package/lib/telemetry/ensure-cli-otel-config.js +1 -1
  397. package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
  398. package/lib/telemetry/send-cli-trace-log.js +1 -1
  399. package/lib/types/index.js +1 -1
  400. package/lib/utils/ai_config.js +3 -1
  401. package/lib/utils/apply-jq-filter.js +1 -1
  402. package/lib/utils/cdn-config.js +1 -1
  403. package/lib/utils/check-sdk-version.js +5 -1
  404. package/lib/utils/cli-version-check.js +4 -1
  405. package/lib/utils/cli-version-policy.js +3 -1
  406. package/lib/utils/config.js +1 -1
  407. package/lib/utils/entity-with-id.js +1 -1
  408. package/lib/utils/file-utils.js +1 -1
  409. package/lib/utils/guides-cdn.js +3 -1
  410. package/lib/utils/http-client.js +2 -1
  411. package/lib/utils/is-non-interactive.js +1 -1
  412. package/lib/utils/logger.js +3 -1
  413. package/lib/utils/params.js +1 -1
  414. package/lib/utils/platform.js +1 -1
  415. package/lib/utils/sleep.js +1 -1
  416. package/lib/utils/template-replacer.js +5 -1
  417. package/lib/utils/update-notice.js +3 -1
  418. package/lib/utils/version.js +1 -1
  419. package/lib/utils/with-active-cookie.js +1 -1
  420. package/lib/utils/write-cli-side-channel.js +1 -1
  421. package/package.json +10 -7
  422. package/skills/rabetbase/SKILL.md +11 -7
  423. package/skills/rabetbase/guides/backend-function.md +3 -1
  424. package/skills/rabetbase/guides/data-api-guidelines.md +1 -1
  425. package/skills/rabetbase/guides/frontend-development.md +1 -0
  426. package/skills/rabetbase/guides/metric-development.md +185 -0
  427. package/skills/rabetbase/references/rabetbase-app-config.md +4 -3
  428. package/skills/rabetbase/references/rabetbase-cli-skill-install.md +5 -5
  429. package/skills/rabetbase/references/rabetbase-dataset-design.md +1 -1
  430. package/skills/rabetbase/references/rabetbase-kb.md +16 -0
  431. package/skills/rabetbase/references/rabetbase-metric.md +119 -0
  432. package/skills/rabetbase/references/rabetbase-update.md +7 -5
  433. package/skills/rabetbase-dataset-generation/SKILL.md +1 -1
  434. package/skills/rabetbase-dataset-generation/references/workflow.md +1 -1
  435. package/skills/rabetbase-metrics-generation/SKILL.md +22 -0
  436. package/skills/rabetbase-metrics-generation/references/verification.md +19 -0
  437. package/skills/rabetbase-metrics-generation/references/workflow.md +41 -0
  438. package/skills/rabetbase-metrics-generation/templates/statistics-delivery.md +11 -0
  439. package/skills/rabetbase-page-generation/SKILL.md +1 -1
  440. package/skills/rabetbase-page-generation/references/generation.md +1 -1
  441. package/skills/rabetbase.manifest.json +5 -3
  442. package/templates/metrics/definition.json +78 -0
  443. package/templates/metrics/metric-definition.schema.json +136 -0
  444. package/lib/postinstall.d.ts +0 -3
  445. package/lib/postinstall.js +0 -1
  446. package/scripts/postinstall.mjs +0 -24
package/README.md CHANGED
@@ -21,23 +21,34 @@ business Skills, use the Lovrabet runtime CLI (`@lovrabet/lovrabet-cli`).
21
21
 
22
22
  ## Install
23
23
 
24
+ Install the CLI, then explicitly install its matching Built-in Skill:
25
+
24
26
  ```bash
25
- npm install -g @lovrabet/rabetbase-cli@latest
27
+ npm install -g @lovrabet/rabetbase-cli@latest --ignore-scripts
28
+ rabetbase cli-skill install
26
29
  rabetbase --version
27
- rabetbase --help
30
+ rabetbase doctor
28
31
  ```
29
32
 
30
- To opt into the npm beta preview instead:
33
+ Use `@beta` for a beta preview, or pin an exact published version for a container
34
+ image. Run the Skill command as the user whose HOME the agent will use.
35
+ The npm package has no install lifecycle hooks. Help, version, and ordinary
36
+ commands do not install Skills automatically.
31
37
 
32
- ```bash
33
- npm install -g @lovrabet/rabetbase-cli@beta
34
- ```
38
+ The CLI uses its exact-version local `skills` dependency to install the Built-in
39
+ Skill shipped in the same npm package. Once npm has installed the dependencies,
40
+ Skill installation needs no installer or Skill-content download. No npm script
41
+ approval is needed for this flow.
35
42
 
36
- You can also run a specific version with npm tooling:
43
+ Treat installation as complete only when the explicit Skill command succeeds
44
+ and `doctor` reports the Built-in Skill as `current`. If the Skill step fails,
45
+ the CLI may already be installed; fix the reported cause and rerun
46
+ `rabetbase cli-skill install`. Do not substitute a remote repository's Skill.
37
47
 
38
- ```bash
39
- npx @lovrabet/rabetbase-cli@latest --help
40
- ```
48
+ `rabetbase update` installs the target CLI and invokes that new package's explicit
49
+ Skill installer before reporting success. A failed Skill step returns failure
50
+ without claiming that the CLI package was rolled back. With older updaters,
51
+ finish the transition by running `rabetbase cli-skill install` explicitly.
41
52
 
42
53
  ## Update and Verify
43
54
 
@@ -185,28 +196,38 @@ The generated project file always contains the two complete final URLs.
185
196
 
186
197
  ## AI Agent Skill
187
198
 
188
- Installing or upgrading the npm package automatically installs the same-version
189
- Rabetbase CLI Built-in Skill from the package-local source through the latest
190
- official Skills CLI. To diagnose or repair it:
199
+ After installing the npm package, explicitly install the same-version main
200
+ Rabetbase CLI Built-in Skill with the command below. It uses the package-local
201
+ source and the exact-version local official Skills CLI dependency.
202
+ `rabetbase update` installs the new CLI and invokes its Skill installer; the same
203
+ command also repairs the current installation:
191
204
 
192
205
  ```bash
193
206
  rabetbase cli-skill install
194
207
  ```
195
208
 
196
- The package also includes the independent `rabetbase-page-generation` and
197
- `rabetbase-dataset-generation` Skills. Install each one explicitly from the
209
+ The package also includes the independent `rabetbase-page-generation`,
210
+ `rabetbase-dataset-generation`, and `rabetbase-metrics-generation` Skills. Install each one explicitly from the
198
211
  installed CLI package directory:
199
212
 
200
213
  ```sh
201
214
  npx skills add /path/to/rabetbase-cli/skills/rabetbase-page-generation -g -y
202
215
  npx skills add /path/to/rabetbase-cli/skills/rabetbase-dataset-generation -g -y
216
+ npx skills add /path/to/rabetbase-cli/skills/rabetbase-metrics-generation -g -y
203
217
  ```
204
218
 
205
- Replace the paths with the actual package location. `postinstall`,
206
- `rabetbase cli-skill install`, and `rabetbase doctor` manage only the main
219
+ Replace the paths with the actual package location. `rabetbase cli-skill install`, and `rabetbase doctor` manage only the main
207
220
  `rabetbase` Built-in Skill; reinstall independent Skills explicitly after a CLI
208
221
  update when needed.
209
222
 
223
+ The metrics companion handles explicitly authorized development requests and
224
+ accepted report gaps. It reuses existing cloud metrics, verifies each delivery
225
+ stage, and returns references to the original report task. Local source files
226
+ are optional development aids. Operators do not need the developer CLI to ask
227
+ for reports; their environment administrator provisions `lovrabet-report-generation`.
228
+ Verify each companion's installed name, version and references in the intended
229
+ Agent host; a current main Skill does not certify companion installation.
230
+
210
231
  Runtime business Skills are installed with the Lovrabet runtime CLI after
211
232
  selecting the target runtime app:
212
233
 
@@ -314,3 +335,7 @@ rabetbase issue report --title "Page push failed" --description-file ./issue.md
314
335
 
315
336
  Preview the redacted content before submitting. On success, the command displays
316
337
  `Issue log submitted`.
338
+
339
+ ### 指标目录与本地校验
340
+
341
+ `rabetbase metric schema` 读取指标 JSON Schema;`rabetbase metric example` 返回单个自包含定义;`rabetbase metric validate --file <metric.json>` 检查定义、内嵌 JSON contract 及示例;`metric schema --kind contract` 读取 contract 结构。计算继续复用已有 SQL/BFF,运行态 `lovrabet metric exec` 负责调用前后校验。详见 [命令参考](skills/rabetbase/references/rabetbase-metric.md)、[定义结构](templates/metrics/metric-definition.schema.json)、[内置示例](templates/metrics/definition.json) 和 [操作指引](https://qizhiyuntu.feishu.cn/wiki/PY4DwJ2a8iyaf9koETicamgEnAf)。
@@ -1 +1,3 @@
1
- const a0_0x27fadd=a0_0x4ccf;function a0_0x4ccf(_0x1d4fe0,_0x432179){_0x1d4fe0=_0x1d4fe0-0xef;const _0x5c7e72=a0_0x5c7e();let _0x4ccf98=_0x5c7e72[_0x1d4fe0];return _0x4ccf98;}(function(_0x51a0c6,_0x8ce7f9){const _0x4b244e=a0_0x4ccf,_0x1e537f=_0x51a0c6();while(!![]){try{const _0x1b29a8=-parseInt(_0x4b244e(0xf1))/0x1*(-parseInt(_0x4b244e(0x10b))/0x2)+-parseInt(_0x4b244e(0x10a))/0x3+-parseInt(_0x4b244e(0xf3))/0x4+-parseInt(_0x4b244e(0xfc))/0x5*(-parseInt(_0x4b244e(0x103))/0x6)+parseInt(_0x4b244e(0x100))/0x7+parseInt(_0x4b244e(0xf6))/0x8+parseInt(_0x4b244e(0xf7))/0x9*(-parseInt(_0x4b244e(0xf0))/0xa);if(_0x1b29a8===_0x8ce7f9)break;else _0x1e537f['push'](_0x1e537f['shift']());}catch(_0x55c538){_0x1e537f['push'](_0x1e537f['shift']());}}}(a0_0x5c7e,0x26372));import{mkdirSync,writeFileSync}from'node:fs';import a0_0x5bb177 from'node:path';import{fetchDatasetDoc}from'../core/api-client.js';import{logger}from'../utils/logger.js';function a0_0x5c7e(){const _0xa3462d=['name','error','datasetCode','589386jJYyZl','tableName','push','1361418qREPMq','Waiting\x203\x20seconds...\x0a','./docs','.md','success','Generated\x20docs\x20successfully:\x20','.md\x20-\x20','129165IXCVIV','156bPCKyZ','✗\x20Failed:\x20','1160fdlplA','1427tKhGlb','✓\x20Generated:\x20','203956UzTkXt',']\x20Generating:\x20','api-doc','517528evzVNF','18351cAwPSo','utf8','length','\x20datasets\x20to\x20generate\x20docs\x20for\x0a','log','5miueMF'];a0_0x5c7e=function(){return _0xa3462d;};return a0_0x5c7e();}export{fetchDatasetDoc}from'../core/api-client.js';function delay(_0x26c007){return new Promise(_0x8950ca=>setTimeout(_0x8950ca,_0x26c007));}export async function generateDatasetDocs(_0x1ddda9,_0x5097f3,_0x180858,_0x193f44=a0_0x27fadd(0x105),_0x266478,_0x5a3e84){const _0x46eb00=a0_0x27fadd;mkdirSync(_0x193f44,{'recursive':!![]});const _0x195154=[],_0x22a7ee=_0x1ddda9[_0x46eb00(0xf9)];console[_0x46eb00(0xfb)]('\x0a'+_0x22a7ee+_0x46eb00(0xfa));for(let _0x18a639=0x0;_0x18a639<_0x1ddda9[_0x46eb00(0xf9)];_0x18a639++){const _0x4d311e=_0x1ddda9[_0x18a639],_0x4a2c4a=_0x18a639+0x1,_0x3f5d45=_0x4d311e[_0x46eb00(0x101)];try{console[_0x46eb00(0xfb)]('['+_0x4a2c4a+'/'+_0x22a7ee+_0x46eb00(0xf4)+_0x3f5d45+'.md\x20('+_0x4d311e[_0x46eb00(0xfd)]+')');if(_0x266478)_0x266478(_0x4a2c4a,_0x22a7ee,_0x3f5d45);const _0xc6e2ec=await fetchDatasetDoc({'appCode':_0x5097f3,'cookie':_0x180858,'datasetCode':_0x4d311e['datasetCode'],'datasetId':_0x4d311e['id'],'enableAI':![],'extraParams':_0x5a3e84}),_0x4a7b64=a0_0x5bb177['join'](_0x193f44,_0x3f5d45+_0x46eb00(0x106));writeFileSync(_0x4a7b64,_0xc6e2ec,{'encoding':_0x46eb00(0xf8)}),console[_0x46eb00(0xfb)](_0x46eb00(0xf2)+_0x3f5d45+_0x46eb00(0x106)),logger[_0x46eb00(0x107)](_0x46eb00(0xf5),_0x46eb00(0x108)+_0x3f5d45,undefined,{'datasetCode':_0x4d311e[_0x46eb00(0xff)],'datasetName':_0x4d311e['name'],'filePath':_0x4a7b64,'progress':_0x4a2c4a+'/'+_0x22a7ee}),_0x195154['push']({'datasetCode':_0x4d311e['datasetCode'],'datasetName':_0x4d311e[_0x46eb00(0xfd)],'filePath':_0x4a7b64,'success':!![]});if(_0x4a2c4a<_0x22a7ee)await delay(0x1388);}catch(_0x27cc11){const _0x303470=_0x27cc11 instanceof Error?_0x27cc11['message']:String(_0x27cc11);console['log'](_0x46eb00(0xef)+_0x3f5d45+_0x46eb00(0x109)+_0x303470),logger[_0x46eb00(0xfe)](_0x46eb00(0xf5),'Failed\x20to\x20generate\x20docs:\x20'+_0x4d311e['datasetCode'],{'datasetCode':_0x4d311e[_0x46eb00(0xff)],'datasetName':_0x4d311e[_0x46eb00(0xfd)],'error':_0x303470,'progress':_0x4a2c4a+'/'+_0x22a7ee}),_0x195154[_0x46eb00(0x102)]({'datasetCode':_0x4d311e[_0x46eb00(0xff)],'datasetName':_0x4d311e[_0x46eb00(0xfd)],'filePath':'','success':![],'error':_0x303470}),_0x4a2c4a<_0x22a7ee&&(console[_0x46eb00(0xfb)](_0x46eb00(0x104)),await delay(0xbb8));}}return _0x195154;}
1
+ import{mkdirSync,writeFileSync}from"node:fs";import path from"node:path";import{fetchDatasetDoc}from"../core/api-client.js";import{logger}from"../utils/logger.js";export{fetchDatasetDoc}from"../core/api-client.js";function delay(ms){return new Promise(resolve=>setTimeout(resolve,ms))}export async function generateDatasetDocs(datasets,appCode,cookie,outputDir="./docs",onProgress,extraParams){mkdirSync(outputDir,{recursive:true});const results=[];const totalCount=datasets.length;console.log(`\n${totalCount} datasets to generate docs for\n`);for(let i=0;i<datasets.length;i++){const dataset=datasets[i];const currentIndex=i+1;const fileName=dataset.tableName;try{console.log(`[${currentIndex}/${totalCount}] Generating: ${fileName}.md (${dataset.name})`);if(onProgress)onProgress(currentIndex,totalCount,fileName);const markdown=await fetchDatasetDoc({appCode:appCode,cookie:cookie,datasetCode:dataset.datasetCode,datasetId:dataset.id,enableAI:false,extraParams:extraParams})
2
+ ;const filePath=path.join(outputDir,`${fileName}.md`);writeFileSync(filePath,markdown,{encoding:"utf8"});console.log(`✓ Generated: ${fileName}.md`);logger.success("api-doc",`Generated docs successfully: ${fileName}`,undefined,{datasetCode:dataset.datasetCode,datasetName:dataset.name,filePath:filePath,progress:`${currentIndex}/${totalCount}`});results.push({datasetCode:dataset.datasetCode,datasetName:dataset.name,filePath:filePath,success:true});if(currentIndex<totalCount)await delay(5e3)}catch(err){const errorMessage=err instanceof Error?err.message:String(err);console.log(`✗ Failed: ${fileName}.md - ${errorMessage}`);logger.error("api-doc",`Failed to generate docs: ${dataset.datasetCode}`,{datasetCode:dataset.datasetCode,datasetName:dataset.name,error:errorMessage,progress:`${currentIndex}/${totalCount}`});results.push({datasetCode:dataset.datasetCode,datasetName:dataset.name,filePath:"",success:false,error:errorMessage});if(currentIndex<totalCount){
3
+ console.log("Waiting 3 seconds...\n");await delay(3e3)}}}return results}
@@ -1 +1,3 @@
1
- const a1_0x42edec=a1_0x1f60;(function(_0x45b387,_0x5134bc){const _0x3e88fa=a1_0x1f60,_0x2379fb=_0x45b387();while(!![]){try{const _0xa10755=parseInt(_0x3e88fa(0x19e))/0x1+-parseInt(_0x3e88fa(0x18c))/0x2+parseInt(_0x3e88fa(0x192))/0x3*(parseInt(_0x3e88fa(0x18d))/0x4)+-parseInt(_0x3e88fa(0x19f))/0x5*(-parseInt(_0x3e88fa(0x198))/0x6)+parseInt(_0x3e88fa(0x19c))/0x7+-parseInt(_0x3e88fa(0x199))/0x8+-parseInt(_0x3e88fa(0x189))/0x9*(parseInt(_0x3e88fa(0x1a2))/0xa);if(_0xa10755===_0x5134bc)break;else _0x2379fb['push'](_0x2379fb['shift']());}catch(_0x2b263c){_0x2379fb['push'](_0x2379fb['shift']());}}}(a1_0x2eb5,0xf30e8));import a1_0x3d8182 from'node:path';import{CliErrors}from'../errors.js';export function normalizeApiDir(_0x419279,_0xd4d08e=process['cwd']()){const _0x427427=a1_0x1f60;return a1_0x3d8182[_0x427427(0x18a)](_0xd4d08e,_0x419279);}function normalizedApiGroup(_0x567887){const _0x4894de=_0x567887?.['trim']();return _0x4894de||undefined;}export function resolveApiProfileLayouts(_0x6388fa,_0x1d3b2f,_0x20e3ec=process[a1_0x42edec(0x193)]()){const _0x4fa8d3=a1_0x42edec,_0x3c90b3=_0x6388fa[_0x4fa8d3(0x1a6)](_0x4764b9=>{const _0x45626f=_0x4fa8d3,_0x3266e3=_0x1d3b2f(_0x4764b9);return{'app':_0x4764b9,'outputDir':_0x3266e3,'normalizedApiDir':normalizeApiDir(_0x3266e3,_0x20e3ec),'apiGroup':normalizedApiGroup(_0x4764b9[_0x45626f(0x196)])};}),_0x31e026=new Map();for(const _0x5cdb6c of _0x3c90b3){if(!_0x5cdb6c[_0x4fa8d3(0x196)])continue;const _0x41ccd0=_0x31e026[_0x4fa8d3(0x19a)](_0x5cdb6c[_0x4fa8d3(0x196)])??new Set();_0x41ccd0['add'](_0x5cdb6c[_0x4fa8d3(0x1a0)]),_0x31e026['set'](_0x5cdb6c[_0x4fa8d3(0x196)],_0x41ccd0);}for(const [_0x2efecc,_0x2e296a]of _0x31e026){if(_0x2e296a[_0x4fa8d3(0x19b)]>0x1)throw CliErrors[_0x4fa8d3(0x197)](_0x4fa8d3(0x194)+_0x2efecc+_0x4fa8d3(0x187),_0x4fa8d3(0x1a3));}const _0x4fec8c=new Map();for(const _0x25007d of _0x3c90b3){const _0x5102b0=_0x4fec8c[_0x4fa8d3(0x19a)](_0x25007d[_0x4fa8d3(0x1a0)])??[];_0x5102b0['push'](_0x25007d),_0x4fec8c[_0x4fa8d3(0x191)](_0x25007d[_0x4fa8d3(0x1a0)],_0x5102b0);}for(const _0x2c712b of _0x4fec8c['values']()){const _0x555b20=new Set(_0x2c712b[_0x4fa8d3(0x195)](_0x4b01f6=>_0x4b01f6[_0x4fa8d3(0x196)]?[_0x4b01f6[_0x4fa8d3(0x196)]]:[]));if(_0x555b20[_0x4fa8d3(0x19b)]===0x0)continue;if(_0x555b20['size']>0x1||_0x2c712b[_0x4fa8d3(0x1a5)](_0x293cd8=>!_0x293cd8['apiGroup'])){const _0x5920c4=_0x2c712b[_0x4fa8d3(0x1a6)](_0x2af5ca=>_0x2af5ca[_0x4fa8d3(0x18b)][_0x4fa8d3(0x18f)])[_0x4fa8d3(0x186)](',\x20');throw CliErrors[_0x4fa8d3(0x197)](_0x4fa8d3(0x1a4)+_0x2c712b[0x0]['outputDir']+_0x4fa8d3(0x18e),_0x4fa8d3(0x190)+_0x5920c4+_0x4fa8d3(0x19d));}}return _0x3c90b3;}function a1_0x2eb5(){const _0x315159=['validation','9504102xWzotT','11587912rcsqhY','get','size','9037861IWQxfs','.\x20Use\x20a\x20different\x20apiDir\x20for\x20a\x20separate\x20API.','1464876ZYQKIz','5LABsfk','normalizedApiDir','filter','442330VShjBt','Profiles\x20in\x20the\x20same\x20API\x20group\x20must\x20use\x20the\x20same\x20apiDir.','API\x20directory\x20\x22','some','map','join','\x22\x20resolves\x20to\x20multiple\x20API\x20directories.','length','513lvhGqT','resolve','app','949302NhGRce','12fZnaYj','\x22\x20is\x20assigned\x20to\x20incompatible\x20API\x20groups.','name','Profiles\x20sharing\x20one\x20apiDir\x20must\x20use\x20the\x20same\x20explicit\x20apiGroup.\x20Conflicting\x20profiles:\x20','set','1099965fXXGUu','cwd','API\x20group\x20\x22','flatMap','apiGroup'];a1_0x2eb5=function(){return _0x315159;};return a1_0x2eb5();}function a1_0x1f60(_0x22c416,_0x5b91ff){_0x22c416=_0x22c416-0x186;const _0x2eb5eb=a1_0x2eb5();let _0x1f6048=_0x2eb5eb[_0x22c416];return _0x1f6048;}export function getRegistryGroup(_0x3195c8,_0x337e46){const _0x4fc392=a1_0x42edec;if(_0x337e46[_0x4fc392(0x196)])return _0x3195c8[_0x4fc392(0x1a1)](_0x15c442=>_0x15c442[_0x4fc392(0x196)]===_0x337e46['apiGroup']);const _0x1478e4=_0x3195c8['filter'](_0x5d8bd2=>_0x5d8bd2[_0x4fc392(0x1a0)]===_0x337e46[_0x4fc392(0x1a0)]);return _0x1478e4[_0x4fc392(0x188)]===0x1?_0x1478e4:undefined;}
1
+ import path from"node:path";import{CliErrors}from"../errors.js";export function normalizeApiDir(apiDir,baseDir=process.cwd()){return path.resolve(baseDir,apiDir)}function normalizedApiGroup(value){const normalized=value?.trim();return normalized||undefined}export function resolveApiProfileLayouts(apps,resolveOutputDir,baseDir=process.cwd()){const layouts=apps.map(app=>{const outputDir=resolveOutputDir(app);return{app:app,outputDir:outputDir,normalizedApiDir:normalizeApiDir(outputDir,baseDir),apiGroup:normalizedApiGroup(app.apiGroup)}});const directoriesByGroup=new Map;for(const layout of layouts){if(!layout.apiGroup)continue;const directories=directoriesByGroup.get(layout.apiGroup)??new Set;directories.add(layout.normalizedApiDir);directoriesByGroup.set(layout.apiGroup,directories)}for(const[apiGroup,directories]of directoriesByGroup){if(directories.size>1){
2
+ throw CliErrors.validation(`API group "${apiGroup}" resolves to multiple API directories.`,"Profiles in the same API group must use the same apiDir.")}}const layoutsByDirectory=new Map;for(const layout of layouts){const peers=layoutsByDirectory.get(layout.normalizedApiDir)??[];peers.push(layout);layoutsByDirectory.set(layout.normalizedApiDir,peers)}for(const peers of layoutsByDirectory.values()){const explicitGroups=new Set(peers.flatMap(layout=>layout.apiGroup?[layout.apiGroup]:[]));if(explicitGroups.size===0)continue;if(explicitGroups.size>1||peers.some(layout=>!layout.apiGroup)){const names=peers.map(layout=>layout.app.name).join(", ");throw CliErrors.validation(`API directory "${peers[0].outputDir}" is assigned to incompatible API groups.`,`Profiles sharing one apiDir must use the same explicit apiGroup. Conflicting profiles: ${names}. Use a different apiDir for a separate API.`)}}return layouts}export function getRegistryGroup(layouts,selected){if(selected.apiGroup){
3
+ return layouts.filter(layout=>layout.apiGroup===selected.apiGroup)}const directoryPeers=layouts.filter(layout=>layout.normalizedApiDir===selected.normalizedApiDir);return directoryPeers.length===1?directoryPeers:undefined}
@@ -1 +1 @@
1
- function a2_0x4cb7(){var _0x4ffcfc=['7149000zCdcCr','236wupasC','781936rzMrzd','2647604IhkSCM','3770956OUyqUy','6190XxvOcM','10qFtAkj','586287SiAqJH','1006BMTmmP','1170CNuGNw'];a2_0x4cb7=function(){return _0x4ffcfc;};return a2_0x4cb7();}function a2_0xae9a(_0x24b611,_0x1739a0){_0x24b611=_0x24b611-0x7b;var _0x4cb7f2=a2_0x4cb7();var _0xae9a79=_0x4cb7f2[_0x24b611];return _0xae9a79;}(function(_0x4ef47e,_0x89a2b8){var _0x3278f6=a2_0xae9a,_0x38efb2=_0x4ef47e();while(!![]){try{var _0x2d5c43=parseInt(_0x3278f6(0x7e))/0x1*(parseInt(_0x3278f6(0x7b))/0x2)+parseInt(_0x3278f6(0x84))/0x3+-parseInt(_0x3278f6(0x80))/0x4*(parseInt(_0x3278f6(0x83))/0x5)+parseInt(_0x3278f6(0x7d))/0x6+parseInt(_0x3278f6(0x81))/0x7+parseInt(_0x3278f6(0x7f))/0x8+-parseInt(_0x3278f6(0x7c))/0x9*(parseInt(_0x3278f6(0x82))/0xa);if(_0x2d5c43===_0x89a2b8)break;else _0x38efb2['push'](_0x38efb2['shift']());}catch(_0x18e6d6){_0x38efb2['push'](_0x38efb2['shift']());}}}(a2_0x4cb7,0xb4217));export{fetchModelList}from'../core/api-client.js';
1
+ export{fetchModelList}from"../core/api-client.js";
@@ -1 +1,8 @@
1
- (function(_0x2e41c5,_0x18d464){const _0x41748b=a3_0x2d83,_0x21eeb3=_0x2e41c5();while(!![]){try{const _0x4847b9=-parseInt(_0x41748b(0x121))/0x1+parseInt(_0x41748b(0x145))/0x2*(-parseInt(_0x41748b(0x154))/0x3)+parseInt(_0x41748b(0x129))/0x4+parseInt(_0x41748b(0x141))/0x5+parseInt(_0x41748b(0x134))/0x6+-parseInt(_0x41748b(0x153))/0x7+parseInt(_0x41748b(0x14a))/0x8*(-parseInt(_0x41748b(0x157))/0x9);if(_0x4847b9===_0x18d464)break;else _0x21eeb3['push'](_0x21eeb3['shift']());}catch(_0x308281){_0x21eeb3['push'](_0x21eeb3['shift']());}}}(a3_0x37c6,0x60dac));import a3_0xd7925c from'prettier';import{existsSync,mkdirSync,writeFileSync,readFileSync}from'node:fs';import a3_0x516eb5 from'node:path';function a3_0x37c6(){const _0x2aea3f=['preserved','refreshed','map','init-api','replaceApiContent','created','3642264fMUjpw','api','-client','../..','replace','-api','tableName','basename','format','templates/generate-api','\x20config\x20set\x20app\x20<value>`','test','defaultName','3323130yqIkRw','existed','dirname','key','5064yUIVSE','includes','none','datasetCode','.ts','8Wsbzkj','utf8','overwriteTypescript','default','Model\x20facts\x20refreshed.','runtimeDomain','scaffoldMode','LOVRABET_RUNTIME_DOMAIN','name','2979571PfbdLo','48qhWjpJ','Please\x20configure\x20app\x20code\x20first\x20via\x20`','join','7810983hvGMtO','allowEmptyModelReplacement','110042seeDsQ','modelRuntime','stringify','modelProfile','action','client','success','missing','2276560fhzVhS','CONFIG_NAMES.DEFAULT','path',',\x20env:\x20','alias'];a3_0x37c6=function(){return _0x2aea3f;};return a3_0x37c6();}import{fileURLToPath}from'node:url';import{TemplateReplacer}from'../utils/template-replacer.js';import{CLI_BIN_NAME}from'../constant/cli.js';import{logger}from'../utils/logger.js';function a3_0x2d83(_0x3cac0d,_0x598cfd){_0x3cac0d=_0x3cac0d-0x121;const _0x37c6c5=a3_0x37c6();let _0x2d83e7=_0x37c6c5[_0x3cac0d];return _0x2d83e7;}import{isProduction}from'../constant/env.js';import{generateSdkConfigFile}from'../api/generate-sdk-config-file.js';import{MODEL_REGISTRY_FILE_NAME,MODEL_RUNTIME_FILE_NAME,updateModelRegistry}from'../api/model-registry-file.js';import{renderModelRegistryScaffold}from'../api/model-registry-scaffold.js';function fileAction(_0x5874c6,_0x291241){const _0x8602c1=a3_0x2d83;if(!_0x291241)return _0x5874c6?_0x8602c1(0x12e):_0x8602c1(0x128);return _0x5874c6?'overwritten':'created';}export async function generateApiFile(_0xa7fba3,_0x23dcff,_0x2ad0dd,_0x22ecc8,_0x17ecfc,_0x47ffe8,_0x113263,_0x1e2ac0={},_0x1d549b={}){const _0x1a7a99=a3_0x2d83;if(!_0x2ad0dd)throw new Error(_0x1a7a99(0x155)+CLI_BIN_NAME+_0x1a7a99(0x13e));const _0x48b225=_0x22ecc8&&!_0x113263,_0x407b98=!!_0x1d549b[_0x1a7a99(0x124)],_0xe55f81=_0x407b98||_0x48b225,_0x4d1901=_0x113263||_0x2ad0dd,_0x236a7f=_0x407b98||_0x48b225?_0x1a7a99(0x14d):_0x4d1901,_0x4e7258=_0x407b98||_0x48b225?_0x1a7a99(0x12a):JSON[_0x1a7a99(0x123)](_0x4d1901),_0x50171e=!isProduction(_0x17ecfc),_0xdefa32=_0x50171e?_0x1a7a99(0x12c)+JSON[_0x1a7a99(0x123)](_0x17ecfc):'',_0x2be78d='{\x20apiConfigName:\x20'+_0x4e7258+_0xdefa32+',\x20...LOVRABET_SDK_CONFIG\x20}',_0x345820=_0x407b98?'':_0x23dcff,_0x3951ea=_0x345820?_0x345820+_0x1a7a99(0x139):'api',_0x4079aa=_0x345820?_0x345820+_0x1a7a99(0x136):_0x1a7a99(0x126),_0x5acf1b=_0x345820&&!/^app-[a-f0-9]+$/i[_0x1a7a99(0x13f)](_0x345820)?_0x345820[_0x1a7a99(0x138)](/-/g,'_')['toUpperCase']():'LOVRABET',_0x45715d=/^\d/['test'](_0x5acf1b)?'APP_'+_0x5acf1b:_0x5acf1b,_0x37eacf=_0xa7fba3[_0x1a7a99(0x130)](_0x47ab7e=>({'datasetCode':_0x47ab7e[_0x1a7a99(0x148)],'tableName':_0x47ab7e[_0x1a7a99(0x13a)],'name':_0x47ab7e[_0x1a7a99(0x152)]||'','alias':_0x47ab7e[_0x1a7a99(0x12d)]||_0x47ab7e[_0x1a7a99(0x144)]})),_0x41f658=fileURLToPath(import.meta.url),_0x191c1a=a3_0x516eb5['resolve'](a3_0x516eb5[_0x1a7a99(0x143)](_0x41f658),_0x1a7a99(0x137)),_0x38b215=a3_0x516eb5[_0x1a7a99(0x156)](_0x191c1a,_0x1a7a99(0x13d)),_0x4ac30f=a3_0x516eb5[_0x1a7a99(0x156)](_0x38b215,'api.ts.tpl'),_0xe71da2=a3_0x516eb5[_0x1a7a99(0x156)](_0x38b215,'client.ts.tpl'),_0x1c082b=_0x47ffe8;mkdirSync(_0x1c082b,{'recursive':!![]});const _0x5e8269=_0x407b98?{}:_0x1e2ac0,_0x3ab7d3=await generateSdkConfigFile(_0x1c082b,_0x5e8269,_0x345820),_0x1c70bb=a3_0x516eb5[_0x1a7a99(0x13b)](_0x3ab7d3,_0x1a7a99(0x149)),_0x4c53f2=a3_0x516eb5[_0x1a7a99(0x156)](_0x1c082b,_0x3951ea+_0x1a7a99(0x149)),_0x31f2d9=a3_0x516eb5['join'](_0x1c082b,_0x4079aa+_0x1a7a99(0x149)),_0x5e2fb6=_0x1d549b[_0x1a7a99(0x14c)]===!![],_0x2cfa70=existsSync(_0x4c53f2),_0x22e725=existsSync(_0x31f2d9),_0x16cb35=_0x1d549b[_0x1a7a99(0x150)]??(_0x5e2fb6?_0x1a7a99(0x138):_0x1a7a99(0x128)),_0x59a0dd=_0x16cb35===_0x1a7a99(0x138)||_0x16cb35===_0x1a7a99(0x128)&&!_0x2cfa70,_0x3e622e=_0x16cb35==='replace'||_0x16cb35===_0x1a7a99(0x128)&&!_0x22e725,_0x3794f1=_0x1d549b['modelProfile']?updateModelRegistry({'outputDir':_0x1c082b,'profileName':_0x1d549b[_0x1a7a99(0x124)]['name'],'defaultProfile':_0x1d549b[_0x1a7a99(0x124)][_0x1a7a99(0x140)],'appCode':_0x2ad0dd,'runtimeDomain':_0x1d549b[_0x1a7a99(0x124)][_0x1a7a99(0x14f)],'models':_0x37eacf,'allowEmptyReplacement':_0x1d549b[_0x1a7a99(0x158)]===!![]}):undefined,_0x501a92=_0x3794f1?a3_0x516eb5[_0x1a7a99(0x156)](_0x1c082b,MODEL_RUNTIME_FILE_NAME):undefined,_0x21d4b8=_0x501a92?existsSync(_0x501a92):![],_0x530059=_0x407b98&&_0x16cb35!==_0x1a7a99(0x147)?await renderModelRegistryScaffold(_0x1c082b):undefined;_0x501a92&&_0x530059&&writeFileSync(_0x501a92,_0x530059[_0x1a7a99(0x122)],_0x1a7a99(0x14b));const _0x2e3a45=_0x37eacf[0x0]?.[_0x1a7a99(0x12d)];if(_0x59a0dd){const _0x49a767=_0x530059?.[_0x1a7a99(0x135)]??readFileSync(_0x4ac30f,_0x1a7a99(0x14b)),_0x13aa31=_0x407b98?_0x49a767:TemplateReplacer[_0x1a7a99(0x132)](_0x49a767,_0x2ad0dd,_0x37eacf,_0x2e3a45,_0x3951ea,_0x4e7258,undefined,_0x45715d);writeFileSync(_0x4c53f2,await a3_0xd7925c[_0x1a7a99(0x13c)](_0x13aa31,{'parser':'typescript'}),{'encoding':'utf8'});}if(_0x3e622e){const _0x1819d4=_0x530059?.[_0x1a7a99(0x126)]??readFileSync(_0xe71da2,_0x1a7a99(0x14b)),_0x178fcf=_0x407b98?_0x1819d4:TemplateReplacer[_0x1a7a99(0x132)](_0x1819d4,_0x2ad0dd,_0x37eacf,_0x2e3a45,_0x3951ea,_0x4e7258,_0x2be78d,_0x45715d,_0x1c70bb);writeFileSync(_0x31f2d9,await a3_0xd7925c[_0x1a7a99(0x13c)](_0x178fcf,{'parser':'typescript'}),{'encoding':'utf8'});}const _0xc7079a=_0x37eacf['length'],_0x4f3dc0={'api':{'path':_0x4c53f2,'action':fileAction(_0x2cfa70,_0x59a0dd)},'client':{'path':_0x31f2d9,'action':fileAction(_0x22e725,_0x3e622e)},'sdkConfig':{'path':_0x3ab7d3,'action':_0x1a7a99(0x12f)},..._0x3794f1?{'modelRegistry':{'path':_0x3794f1[_0x1a7a99(0x12b)],'action':_0x3794f1[_0x1a7a99(0x142)]?'refreshed':_0x1a7a99(0x133)},'modelRuntime':{'path':_0x501a92,'action':_0x530059?_0x21d4b8?'refreshed':_0x1a7a99(0x133):_0x21d4b8?_0x1a7a99(0x12e):'missing'}}:{}},_0x424680=existsSync(_0x4c53f2)&&readFileSync(_0x4c53f2,_0x1a7a99(0x14b))[_0x1a7a99(0x146)](MODEL_REGISTRY_FILE_NAME[_0x1a7a99(0x138)](_0x1a7a99(0x149),'')),_0x1ec069=existsSync(_0x31f2d9)&&readFileSync(_0x31f2d9,_0x1a7a99(0x14b))[_0x1a7a99(0x146)](_0x1a7a99(0x151)),_0x333747=_0x407b98?!_0x424680||!_0x1ec069||!existsSync(_0x501a92):![],_0x445454=_0x407b98?_0x333747:_0x4f3dc0['api']['action']===_0x1a7a99(0x12e)||_0x4f3dc0[_0x1a7a99(0x126)][_0x1a7a99(0x125)]===_0x1a7a99(0x12e);return logger[_0x1a7a99(0x127)](_0x1a7a99(0x131),_0x445454?a3_0x516eb5[_0x1a7a99(0x13b)](_0x3ab7d3)+'\x20refreshed;\x20existing\x20TypeScript\x20left\x20unchanged.':_0x407b98?_0x1a7a99(0x14e):'API\x20scaffold\x20written.',undefined,{'apiFile':_0x4c53f2,'clientFile':_0x31f2d9,'sdkConfig':_0x3ab7d3,'modelCount':_0xc7079a,'configName':_0x236a7f,'isDefaultConfig':_0xe55f81,'needsAgentMerge':_0x445454,'needsProjectUpgrade':_0x333747,'files':_0x4f3dc0}),{'appCode':_0x2ad0dd,'modelCount':_0xc7079a,'models':_0x37eacf,'apiFilePath':_0x4c53f2,'clientFilePath':_0x31f2d9,'sdkConfigPath':_0x3ab7d3,'modelRegistryPath':_0x3794f1?.[_0x1a7a99(0x12b)],'modelRuntimePath':_0x501a92,'modelProfile':_0x1d549b['modelProfile']?.[_0x1a7a99(0x152)],'configName':_0x236a7f,'isDefaultConfig':_0xe55f81,'sdkRouting':_0x5e8269,'files':_0x4f3dc0,'needsAgentMerge':_0x445454,'needsProjectUpgrade':_0x333747};}
1
+ import prettier from"prettier";import{existsSync,mkdirSync,writeFileSync,readFileSync}from"node:fs";import path from"node:path";import{fileURLToPath}from"node:url";import{TemplateReplacer}from"../utils/template-replacer.js";import{CLI_BIN_NAME}from"../constant/cli.js";import{logger}from"../utils/logger.js";import{isProduction}from"../constant/env.js";import{generateSdkConfigFile}from"../api/generate-sdk-config-file.js";import{MODEL_REGISTRY_FILE_NAME,MODEL_RUNTIME_FILE_NAME,updateModelRegistry}from"../api/model-registry-file.js";import{renderModelRegistryScaffold}from"../api/model-registry-scaffold.js";function fileAction(existed,wrote){if(!wrote)return existed?"preserved":"missing";return existed?"overwritten":"created"}export async function generateApiFile(configArray,filePrefix,appCode,isFromDefaultConfig,env,outputDir,appName,sdkRouting={},options={}){if(!appCode){throw new Error(`Please configure app code first via \`${CLI_BIN_NAME} config set app <value>\``)}
2
+ const isDefaultConfig=isFromDefaultConfig&&!appName;const profileAware=!!options.modelProfile;const effectiveIsDefaultConfig=profileAware||isDefaultConfig;const effectiveName=appName||appCode;const publicConfigName=profileAware||isDefaultConfig?"default":effectiveName;const configNameExpression=profileAware||isDefaultConfig?"CONFIG_NAMES.DEFAULT":JSON.stringify(effectiveName);const needsEnvParam=!isProduction(env);const envPart=needsEnvParam?`, env: ${JSON.stringify(env)}`:"";const clientConfigParam=`{ apiConfigName: ${configNameExpression}${envPart}, ...LOVRABET_SDK_CONFIG }`;const effectiveFilePrefix=profileAware?"":filePrefix;const apiFileName=effectiveFilePrefix?`${effectiveFilePrefix}-api`:"api";const clientFileName=effectiveFilePrefix?`${effectiveFilePrefix}-client`:"client";const normalizedVarPrefix=effectiveFilePrefix&&!/^app-[a-f0-9]+$/i.test(effectiveFilePrefix)?effectiveFilePrefix.replace(/-/g,"_").toUpperCase():"LOVRABET"
3
+ ;const varPrefix=/^\d/.test(normalizedVarPrefix)?`APP_${normalizedVarPrefix}`:normalizedVarPrefix;const modelConfigs=configArray.map(item=>({datasetCode:item.datasetCode,tableName:item.tableName,name:item.name||"",alias:item.alias||item.key}));const currentFilePath=fileURLToPath(import.meta.url);const cliRootDir=path.resolve(path.dirname(currentFilePath),"../..");const templateDir=path.join(cliRootDir,"templates/generate-api");const apiTemplatePath=path.join(templateDir,"api.ts.tpl");const clientTemplatePath=path.join(templateDir,"client.ts.tpl");const normalizedOutputDir=outputDir;mkdirSync(normalizedOutputDir,{recursive:true});const generatedSdkRouting=profileAware?{}:sdkRouting;const sdkConfigPath=await generateSdkConfigFile(normalizedOutputDir,generatedSdkRouting,effectiveFilePrefix);const sdkConfigFileName=path.basename(sdkConfigPath,".ts");const apiFilePath=path.join(normalizedOutputDir,`${apiFileName}.ts`)
4
+ ;const clientFilePath=path.join(normalizedOutputDir,`${clientFileName}.ts`);const overwriteTypescript=options.overwriteTypescript===true;const apiExisted=existsSync(apiFilePath);const clientExisted=existsSync(clientFilePath);const scaffoldMode=options.scaffoldMode??(overwriteTypescript?"replace":"missing");const writeApi=scaffoldMode==="replace"||scaffoldMode==="missing"&&!apiExisted;const writeClient=scaffoldMode==="replace"||scaffoldMode==="missing"&&!clientExisted;const modelRegistry=options.modelProfile?updateModelRegistry({outputDir:normalizedOutputDir,profileName:options.modelProfile.name,defaultProfile:options.modelProfile.defaultName,appCode:appCode,runtimeDomain:options.modelProfile.runtimeDomain,models:modelConfigs,allowEmptyReplacement:options.allowEmptyModelReplacement===true}):undefined;const modelRuntimePath=modelRegistry?path.join(normalizedOutputDir,MODEL_RUNTIME_FILE_NAME):undefined;const modelRuntimeExisted=modelRuntimePath?existsSync(modelRuntimePath):false
5
+ ;const profileScaffold=profileAware&&scaffoldMode!=="none"?await renderModelRegistryScaffold(normalizedOutputDir):undefined;if(modelRuntimePath&&profileScaffold){writeFileSync(modelRuntimePath,profileScaffold.modelRuntime,"utf8")}const exampleModelName=modelConfigs[0]?.alias;if(writeApi){const apiTemplate=profileScaffold?.api??readFileSync(apiTemplatePath,"utf8");const apiContent=profileAware?apiTemplate:TemplateReplacer.replaceApiContent(apiTemplate,appCode,modelConfigs,exampleModelName,apiFileName,configNameExpression,undefined,varPrefix);writeFileSync(apiFilePath,await prettier.format(apiContent,{parser:"typescript"}),{encoding:"utf8"})}if(writeClient){const clientTemplate=profileScaffold?.client??readFileSync(clientTemplatePath,"utf8");const clientContent=profileAware?clientTemplate:TemplateReplacer.replaceApiContent(clientTemplate,appCode,modelConfigs,exampleModelName,apiFileName,configNameExpression,clientConfigParam,varPrefix,sdkConfigFileName)
6
+ ;writeFileSync(clientFilePath,await prettier.format(clientContent,{parser:"typescript"}),{encoding:"utf8"})}const modelCount=modelConfigs.length;const files={api:{path:apiFilePath,action:fileAction(apiExisted,writeApi)},client:{path:clientFilePath,action:fileAction(clientExisted,writeClient)},sdkConfig:{path:sdkConfigPath,action:"refreshed"},...modelRegistry?{modelRegistry:{path:modelRegistry.path,action:modelRegistry.existed?"refreshed":"created"},modelRuntime:{path:modelRuntimePath,action:profileScaffold?modelRuntimeExisted?"refreshed":"created":modelRuntimeExisted?"preserved":"missing"}}:{}};const apiUsesRegistry=existsSync(apiFilePath)&&readFileSync(apiFilePath,"utf8").includes(MODEL_REGISTRY_FILE_NAME.replace(".ts",""));const clientUsesRegistry=existsSync(clientFilePath)&&readFileSync(clientFilePath,"utf8").includes("LOVRABET_RUNTIME_DOMAIN");const needsProjectUpgrade=profileAware?!apiUsesRegistry||!clientUsesRegistry||!existsSync(modelRuntimePath):false
7
+ ;const needsAgentMerge=profileAware?needsProjectUpgrade:files.api.action==="preserved"||files.client.action==="preserved";logger.success("init-api",needsAgentMerge?`${path.basename(sdkConfigPath)} refreshed; existing TypeScript left unchanged.`:profileAware?"Model facts refreshed.":"API scaffold written.",undefined,{apiFile:apiFilePath,clientFile:clientFilePath,sdkConfig:sdkConfigPath,modelCount:modelCount,configName:publicConfigName,isDefaultConfig:effectiveIsDefaultConfig,needsAgentMerge:needsAgentMerge,needsProjectUpgrade:needsProjectUpgrade,files:files});return{appCode:appCode,modelCount:modelCount,models:modelConfigs,apiFilePath:apiFilePath,clientFilePath:clientFilePath,sdkConfigPath:sdkConfigPath,modelRegistryPath:modelRegistry?.path,modelRuntimePath:modelRuntimePath,modelProfile:options.modelProfile?.name,configName:publicConfigName,isDefaultConfig:effectiveIsDefaultConfig,sdkRouting:generatedSdkRouting,files:files,needsAgentMerge:needsAgentMerge,
8
+ needsProjectUpgrade:needsProjectUpgrade}}
@@ -1 +1 @@
1
- (function(_0x38be6b,_0x3a2158){const _0x5d9e30=a4_0x118d,_0x21a653=_0x38be6b();while(!![]){try{const _0x4207f5=parseInt(_0x5d9e30(0x1cf))/0x1*(-parseInt(_0x5d9e30(0x1c3))/0x2)+parseInt(_0x5d9e30(0x1c1))/0x3*(-parseInt(_0x5d9e30(0x1cc))/0x4)+-parseInt(_0x5d9e30(0x1c6))/0x5+parseInt(_0x5d9e30(0x1cb))/0x6+parseInt(_0x5d9e30(0x1c8))/0x7*(-parseInt(_0x5d9e30(0x1d2))/0x8)+-parseInt(_0x5d9e30(0x1d0))/0x9*(-parseInt(_0x5d9e30(0x1c5))/0xa)+parseInt(_0x5d9e30(0x1c7))/0xb;if(_0x4207f5===_0x3a2158)break;else _0x21a653['push'](_0x21a653['shift']());}catch(_0x11c121){_0x21a653['push'](_0x21a653['shift']());}}}(a4_0xcd48,0x92317));import{mkdirSync,writeFileSync}from'node:fs';import a4_0x568143 from'node:path';function a4_0xcd48(){const _0x5be3b2=['38712VBVgJG','length','3183LdiGwc','push','520pAZruW',',\x0a}','130180UxMGQD','5155075OBkWsB','13677840FxTwxH','77hhosDa','runtimeDomain','\x20as\x20const;\x0a','1229244NkRXnO','1348DgHuDl','stringify','typescript','1377BVXsbp','657GguhaG','{\x0a\x20\x20'];a4_0xcd48=function(){return _0x5be3b2;};return a4_0xcd48();}import a4_0x305760 from'prettier';export const SDK_CONFIG_FILE_NAME='sdk-config.ts';function a4_0x118d(_0x321327,_0x32cc56){_0x321327=_0x321327-0x1c1;const _0xcd4896=a4_0xcd48();let _0x118d61=_0xcd4896[_0x321327];return _0x118d61;}export function getSdkConfigFileName(_0x595cb2=''){return _0x595cb2?_0x595cb2+'-sdk-config.ts':SDK_CONFIG_FILE_NAME;}export async function generateSdkConfigFile(_0x271920,_0x55edd1={},_0x4ffa25=''){const _0x625b78=a4_0x118d,_0xafd50e=[];_0x55edd1[_0x625b78(0x1c9)]&&_0xafd50e[_0x625b78(0x1c2)]('runtimeDomain:\x20'+JSON[_0x625b78(0x1cd)](_0x55edd1[_0x625b78(0x1c9)]));const _0x239f19=_0xafd50e[_0x625b78(0x1d3)]>0x0?_0x625b78(0x1d1)+_0xafd50e['join'](',\x0a\x20\x20')+_0x625b78(0x1c4):'{}',_0x5d6697='/**\x0a\x20*\x20Lovrabet\x20SDK\x20runtime\x20routing.\x0a\x20*\x20Generated\x20by\x20Rabetbase\x20CLI.\x20Do\x20not\x20add\x20credentials\x20to\x20this\x20file.\x0a\x20*/\x0aexport\x20const\x20LOVRABET_SDK_CONFIG\x20=\x20'+_0x239f19+_0x625b78(0x1ca);mkdirSync(_0x271920,{'recursive':!![]});const _0x24af7d=a4_0x568143['join'](_0x271920,getSdkConfigFileName(_0x4ffa25));return writeFileSync(_0x24af7d,await a4_0x305760['format'](_0x5d6697,{'parser':_0x625b78(0x1ce)}),'utf8'),_0x24af7d;}
1
+ import{mkdirSync,writeFileSync}from"node:fs";import path from"node:path";import prettier from"prettier";export const SDK_CONFIG_FILE_NAME="sdk-config.ts";export function getSdkConfigFileName(filePrefix=""){return filePrefix?`${filePrefix}-sdk-config.ts`:SDK_CONFIG_FILE_NAME}export async function generateSdkConfigFile(outputDir,config={},filePrefix=""){const entries=[];if(config.runtimeDomain){entries.push(`runtimeDomain: ${JSON.stringify(config.runtimeDomain)}`)}const objectBody=entries.length>0?`{\n ${entries.join(",\n ")},\n}`:"{}";const content=`/**\n * Lovrabet SDK runtime routing.\n * Generated by Rabetbase CLI. Do not add credentials to this file.\n */\nexport const LOVRABET_SDK_CONFIG = ${objectBody} as const;\n`;mkdirSync(outputDir,{recursive:true});const filePath=path.join(outputDir,getSdkConfigFileName(filePrefix));writeFileSync(filePath,await prettier.format(content,{parser:"typescript"}),"utf8");return filePath}
@@ -1 +1,2 @@
1
- (function(_0x188061,_0x26b441){const _0x333cad=a5_0x2b45,_0x258595=_0x188061();while(!![]){try{const _0x2ff6e1=-parseInt(_0x333cad(0x1e3))/0x1*(-parseInt(_0x333cad(0x1d5))/0x2)+parseInt(_0x333cad(0x1cd))/0x3*(parseInt(_0x333cad(0x1e0))/0x4)+-parseInt(_0x333cad(0x1dc))/0x5*(-parseInt(_0x333cad(0x1dd))/0x6)+-parseInt(_0x333cad(0x1e1))/0x7*(parseInt(_0x333cad(0x1d4))/0x8)+parseInt(_0x333cad(0x1ce))/0x9+parseInt(_0x333cad(0x1df))/0xa*(-parseInt(_0x333cad(0x1d8))/0xb)+-parseInt(_0x333cad(0x1e7))/0xc;if(_0x2ff6e1===_0x26b441)break;else _0x258595['push'](_0x258595['shift']());}catch(_0x5f1b3f){_0x258595['push'](_0x258595['shift']());}}}(a5_0x410a,0xb3fed));export function parseLegacyApiModels(_0x1061f6){const _0x456ad1=a5_0x2b45,_0x3701ac=[],_0x155d97=/\{\s*datasetCode:\s*"([^"]+)"\s*,\s*tableName:\s*"([^"]+)"\s*,\s*name:\s*"([^"]*?)"\s*,\s*alias:\s*"([^"]+)"\s*,?\s*\}/g;let _0x292dbc;while((_0x292dbc=_0x155d97[_0x456ad1(0x1d2)](_0x1061f6))!==null){_0x3701ac[_0x456ad1(0x1d9)]({'datasetCode':_0x292dbc[0x1],'tableName':_0x292dbc[0x2],'name':_0x292dbc[0x3],'alias':_0x292dbc[0x4]});}return _0x3701ac;}export function parseLegacyApiAppCode(_0x20fafb){const _0x3abe5d=a5_0x2b45;return _0x20fafb[_0x3abe5d(0x1de)](/export\s+const\s+[A-Z0-9_]*APP_CODE(?:\s*:\s*string)?\s*=\s*["']([^"']+)["']/)?.[0x1];}function stripComments(_0x108ab1){const _0x1ed78d=a5_0x2b45;return _0x108ab1[_0x1ed78d(0x1e4)](/\/\*[\s\S]*?\*\//g,'')[_0x1ed78d(0x1e4)](/\/\/.*$/gm,'');}function a5_0x410a(){const _0x1561d4=['replace','map','some','10014252VXzqWY','registerModels','MODELS_CONFIG','56733lUKADI','26595EwqeFu','@lovrabet/sdk','lovrabetClient','includes','exec','length','8poIshB','2516398DdsVvl','test','Generated\x20by\x20Rabetbase\x20CLI','201311qmYYlc','push','APP_CODE','endsWith','5caGndJ','2988378glhkzr','match','200XqJrtp','116YrbLWM','2588838AaeRdr','matchAll','1CQrtSn'];a5_0x410a=function(){return _0x1561d4;};return a5_0x410a();}export function isLegacyGeneratedApiScaffold(_0x5250db){const _0x76d3b2=a5_0x2b45;if(!_0x5250db[_0x76d3b2(0x1d1)]('Generated\x20by\x20Rabetbase\x20CLI'))return![];const _0x35118d=stripComments(_0x5250db),_0x4d6d22=[..._0x35118d[_0x76d3b2(0x1e2)](/^import[\s\S]*?from\s+["']([^"']+)["'];?$/gm)]['map'](_0x49d6b5=>_0x49d6b5[0x1]);if(_0x4d6d22[_0x76d3b2(0x1d3)]!==0x1||_0x4d6d22[0x0]!==_0x76d3b2(0x1cf))return![];const _0x437ab=[..._0x35118d[_0x76d3b2(0x1e2)](/^(?:export\s+)?const\s+([A-Za-z_$][\w$]*)/gm)][_0x76d3b2(0x1e5)](_0x10b966=>_0x10b966[0x1]);if(_0x437ab[_0x76d3b2(0x1d3)]!==0x2||!_0x437ab[_0x76d3b2(0x1e6)](_0x278dc6=>_0x278dc6[_0x76d3b2(0x1db)](_0x76d3b2(0x1da)))||!_0x437ab['some'](_0xe907e9=>_0xe907e9['endsWith'](_0x76d3b2(0x1cc))))return![];const _0x5a32dd=[..._0x35118d['matchAll'](/^([A-Za-z_$][\w$]*)\s*\(/gm)]['map'](_0x16f361=>_0x16f361[0x1]);return _0x5a32dd[_0x76d3b2(0x1d3)]===0x1&&_0x5a32dd[0x0]===_0x76d3b2(0x1e8);}function a5_0x2b45(_0x49a4c7,_0x1b1d50){_0x49a4c7=_0x49a4c7-0x1cc;const _0x410a62=a5_0x410a();let _0x2b452d=_0x410a62[_0x49a4c7];return _0x2b452d;}export function isLegacyGeneratedClientScaffold(_0x258f53){const _0x41ac40=a5_0x2b45;if(!_0x258f53[_0x41ac40(0x1d1)](_0x41ac40(0x1d7)))return![];const _0x23d2c4=stripComments(_0x258f53),_0x2dd343=[..._0x23d2c4[_0x41ac40(0x1e2)](/^(?:import[\s\S]*?from\s+|import\s+)["']([^"']+)["'];?$/gm)][_0x41ac40(0x1e5)](_0x3d359c=>_0x3d359c[0x1]);if(_0x2dd343[_0x41ac40(0x1e6)](_0xe20513=>_0xe20513!==_0x41ac40(0x1cf)&&!/^\.\/(?:[\w-]+-)?(?:api|sdk-config)$/[_0x41ac40(0x1d6)](_0xe20513??'')))return![];const _0x54ff24=[..._0x23d2c4[_0x41ac40(0x1e2)](/^(?:export\s+)?const\s+([A-Za-z_$][\w$]*)/gm)]['map'](_0x296985=>_0x296985[0x1]);return _0x54ff24[_0x41ac40(0x1d3)]===0x1&&_0x54ff24[0x0]===_0x41ac40(0x1d0);}
1
+ export function parseLegacyApiModels(content){const models=[];const modelRe=/\{\s*datasetCode:\s*"([^"]+)"\s*,\s*tableName:\s*"([^"]+)"\s*,\s*name:\s*"([^"]*?)"\s*,\s*alias:\s*"([^"]+)"\s*,?\s*\}/g;let match;while((match=modelRe.exec(content))!==null){models.push({datasetCode:match[1],tableName:match[2],name:match[3],alias:match[4]})}return models}export function parseLegacyApiAppCode(content){return content.match(/export\s+const\s+[A-Z0-9_]*APP_CODE(?:\s*:\s*string)?\s*=\s*["']([^"']+)["']/)?.[1]}function stripComments(content){return content.replace(/\/\*[\s\S]*?\*\//g,"").replace(/\/\/.*$/gm,"")}export function isLegacyGeneratedApiScaffold(content){if(!content.includes("Generated by Rabetbase CLI"))return false;const source=stripComments(content);const imports=[...source.matchAll(/^import[\s\S]*?from\s+["']([^"']+)["'];?$/gm)].map(match=>match[1]);if(imports.length!==1||imports[0]!=="@lovrabet/sdk")return false
2
+ ;const variables=[...source.matchAll(/^(?:export\s+)?const\s+([A-Za-z_$][\w$]*)/gm)].map(match=>match[1]);if(variables.length!==2||!variables.some(name=>name.endsWith("APP_CODE"))||!variables.some(name=>name.endsWith("MODELS_CONFIG"))){return false}const topLevelCalls=[...source.matchAll(/^([A-Za-z_$][\w$]*)\s*\(/gm)].map(match=>match[1]);return topLevelCalls.length===1&&topLevelCalls[0]==="registerModels"}export function isLegacyGeneratedClientScaffold(content){if(!content.includes("Generated by Rabetbase CLI"))return false;const source=stripComments(content);const imports=[...source.matchAll(/^(?:import[\s\S]*?from\s+|import\s+)["']([^"']+)["'];?$/gm)].map(match=>match[1]);if(imports.some(moduleName=>moduleName!=="@lovrabet/sdk"&&!/^\.\/(?:[\w-]+-)?(?:api|sdk-config)$/.test(moduleName??""))){return false}const variables=[...source.matchAll(/^(?:export\s+)?const\s+([A-Za-z_$][\w$]*)/gm)].map(match=>match[1]);return variables.length===1&&variables[0]==="lovrabetClient"}
@@ -1 +1,11 @@
1
- const a6_0x60e9b6=a6_0x4831;(function(_0x3bbfd5,_0x96e26c){const _0x4e6b5d=a6_0x4831,_0x24b7cd=_0x3bbfd5();while(!![]){try{const _0x259f3d=parseInt(_0x4e6b5d(0x107))/0x1+-parseInt(_0x4e6b5d(0x104))/0x2*(-parseInt(_0x4e6b5d(0xe3))/0x3)+-parseInt(_0x4e6b5d(0x105))/0x4*(-parseInt(_0x4e6b5d(0xe0))/0x5)+-parseInt(_0x4e6b5d(0xd6))/0x6*(parseInt(_0x4e6b5d(0xfe))/0x7)+-parseInt(_0x4e6b5d(0xe8))/0x8+parseInt(_0x4e6b5d(0xd8))/0x9+-parseInt(_0x4e6b5d(0xc9))/0xa;if(_0x259f3d===_0x96e26c)break;else _0x24b7cd['push'](_0x24b7cd['shift']());}catch(_0x1cdfc4){_0x24b7cd['push'](_0x24b7cd['shift']());}}}(a6_0x58ae,0x3beb4));function a6_0x58ae(){const _0x340d10=['split','find','test','2085328MpAEmJ','includes','protocol','.tmp','string','\x22\x20maps\x20to\x20both\x20aliases\x20\x22','datasetCode','object','Refusing\x20to\x20replace\x20','alias','join','\x22\x20maps\x20to\x20both\x20\x22','defaultProfile','profiles','every','models','push','utf8','map','set','now','tableName','301cvcEgI','length','value','indexOf','\x20model(s)\x20in\x20profile\x20\x22','lovrabet-model-registry/v1','26ZMPzHx','68muhtAH','entries','373642NpkvIa','stringify','pid','appCode','filter','outputDir','\x22\x20with\x20an\x20empty\x20result.\x20','name','5091100tlCKzS','\x0aexport\x20const\x20LOVRABET_MODEL_REGISTRY\x20=\x0a\x20\x20','flatMap','Model\x20alias\x20\x22','parse','profileName','\x22\x20and\x20\x22','/*\x20rabetbase-model-registry:start\x20*/','keys','NOT-SET','model-runtime.ts','/**\x0a\x20*\x20Dataset\x20model\x20facts\x20generated\x20by\x20Rabetbase\x20CLI.\x0a\x20*\x0a\x20*\x20This\x20file\x20is\x20safe\x20to\x20commit.\x20Do\x20not\x20edit\x20it\x20manually\x20and\x20never\x20add\x20credentials.\x0a\x20*/\x0a\x0aexport\x20interface\x20LovrabetModelProfile\x20{\x0a\x20\x20appCode:\x20string;\x0a\x20\x20runtimeDomain:\x20string;\x0a}\x0a\x0aexport\x20interface\x20LovrabetModelEntryMetadata\x20{\x0a\x20\x20alias:\x20string;\x0a\x20\x20tableName:\x20string;\x0a\x20\x20name:\x20string;\x0a}\x0a\x0aexport\x20type\x20LovrabetModelEntry\x20=\x20LovrabetModelEntryMetadata\x20&\x20(\x0a\x20\x20|\x20{\x20datasetCode:\x20string;\x20datasetCodes?:\x20never\x20}\x0a\x20\x20|\x20{\x20datasetCode?:\x20never;\x20datasetCodes:\x20Record<string,\x20string>\x20}\x0a);\x0a\x0aexport\x20interface\x20LovrabetModelRegistry\x20{\x0a\x20\x20defaultProfile:\x20string;\x0a\x20\x20profiles:\x20Record<string,\x20LovrabetModelProfile>;\x0a\x20\x20models:\x20LovrabetModelEntry[];\x0a}\x0a\x0a','\x22\x20in\x20the\x20registry\x20but\x20\x22','6krmimZ','replace','4319766YAJGGq','models.generated.ts','Table\x20\x22','get','datasetCodes','isArray','slice','\x22\x20maps\x20to\x20alias\x20\x22','38320GorXGn','\x20is\x20not\x20a\x20valid\x20Rabetbase\x20generated\x20file.\x20Move\x20or\x20repair\x20it\x20before\x20pulling\x20models\x20again.','runtimeDomain','7233rbAXYG','\x22\x20in\x20profile\x20\x22'];a6_0x58ae=function(){return _0x340d10;};return a6_0x58ae();}import{existsSync,mkdirSync,readFileSync,renameSync,unlinkSync,writeFileSync}from'node:fs';import a6_0x5ec771 from'node:path';export const MODEL_REGISTRY_FILE_NAME=a6_0x60e9b6(0xd9);export const MODEL_RUNTIME_FILE_NAME=a6_0x60e9b6(0xd3);export const MODEL_REGISTRY_VERSION_MARKER='/*\x20rabetbase-model-registry:v2\x20*/';const LEGACY_MODEL_REGISTRY_V2_PROTOCOL='lovrabet-model-registry/v2',REGISTRY_START=a6_0x60e9b6(0xd0),REGISTRY_END='/*\x20rabetbase-model-registry:end\x20*/';function emptyRegistry(_0x2f070e){return{'defaultProfile':_0x2f070e,'profiles':{},'models':[]};}function extractRegistryJson(_0x38b8af){const _0x34d787=a6_0x60e9b6,_0x345900=_0x38b8af[_0x34d787(0x101)](REGISTRY_START),_0xf7a373=_0x38b8af[_0x34d787(0x101)](REGISTRY_END);if(_0x345900<0x0||_0xf7a373<=_0x345900)return undefined;return _0x38b8af[_0x34d787(0xde)](_0x345900+REGISTRY_START[_0x34d787(0xff)],_0xf7a373)['trim']()[_0x34d787(0xd7)](/\s+as const satisfies LovrabetModelRegistry;?$/,'')['replace'](/;$/,'');}function migrateLegacyRegistry(_0x3fff9e){const _0xe0d59a=a6_0x60e9b6,_0x4d0877=emptyRegistry(_0x3fff9e[_0xe0d59a(0xf4)]);for(const [_0x457ec0,_0x22722a]of Object[_0xe0d59a(0x106)](_0x3fff9e[_0xe0d59a(0xf5)])){_0x4d0877['profiles'][_0x457ec0]={'appCode':_0x22722a[_0xe0d59a(0x10a)],'runtimeDomain':_0x22722a[_0xe0d59a(0xe2)]},mergeProfileModels(_0x4d0877,_0x457ec0,_0x22722a[_0xe0d59a(0xf7)]);}return _0x4d0877;}function generatedObjectLiteralToJson(_0x3bda03){const _0x5e7734=a6_0x60e9b6;let _0x2aac74='',_0x19197,_0x1670ce=![],_0x5b282b;for(let _0x36d81e=0x0;_0x36d81e<_0x3bda03['length'];_0x36d81e++){const _0xaff153=_0x3bda03[_0x36d81e];if(_0x19197){_0x2aac74+=_0xaff153;if(_0x1670ce)_0x1670ce=![];else{if(_0xaff153==='\x5c')_0x1670ce=!![];else{if(_0xaff153===_0x19197)_0x19197=undefined;}}continue;}if(_0xaff153==='\x22'){_0x19197=_0xaff153,_0x2aac74+=_0xaff153,_0x5b282b=_0x5e7734(0x100);continue;}if(_0xaff153===','){let _0x5ac4ab=_0x36d81e+0x1;while(/\s/[_0x5e7734(0xe7)](_0x3bda03[_0x5ac4ab]??''))_0x5ac4ab++;if(_0x3bda03[_0x5ac4ab]==='}'||_0x3bda03[_0x5ac4ab]===']')continue;_0x2aac74+=_0xaff153,_0x5b282b=',';continue;}if(_0xaff153==='{'||_0xaff153==='['){_0x2aac74+=_0xaff153,_0x5b282b=_0xaff153;continue;}if(_0xaff153==='}'||_0xaff153===']'){_0x2aac74+=_0xaff153,_0x5b282b=_0xaff153;continue;}if((_0x5b282b==='{'||_0x5b282b===',')&&/[A-Za-z_$]/['test'](_0xaff153)){let _0x1ad8fc=_0x36d81e+0x1;while(/[A-Za-z0-9_$]/[_0x5e7734(0xe7)](_0x3bda03[_0x1ad8fc]??''))_0x1ad8fc++;let _0x2fc84b=_0x1ad8fc;while(/\s/[_0x5e7734(0xe7)](_0x3bda03[_0x2fc84b]??''))_0x2fc84b++;if(_0x3bda03[_0x2fc84b]===':'){_0x2aac74+=JSON[_0x5e7734(0x108)](_0x3bda03[_0x5e7734(0xde)](_0x36d81e,_0x1ad8fc)),_0x36d81e=_0x1ad8fc-0x1,_0x5b282b='key';continue;}}_0x2aac74+=_0xaff153;if(!/\s/[_0x5e7734(0xe7)](_0xaff153)&&_0xaff153!==':')_0x5b282b=_0x5e7734(0x100);}return _0x2aac74;}function parseGeneratedRegistryJson(_0x2bcdd2){const _0x94d045=a6_0x60e9b6;try{return JSON[_0x94d045(0xcd)](_0x2bcdd2);}catch{return JSON['parse'](generatedObjectLiteralToJson(_0x2bcdd2));}}function normalizeModelEntries(_0x42fa6d,_0xe8f4f6){const _0xf69f12=a6_0x60e9b6,_0x5c9a26=Object['keys'](_0x42fa6d),_0x488db3=[];for(const _0xff9b88 of _0xe8f4f6){if(!_0xff9b88||typeof _0xff9b88!=='object'||Array['isArray'](_0xff9b88))return undefined;const _0x5e8bca=_0xff9b88;if(typeof _0x5e8bca[_0xf69f12(0xf1)]!==_0xf69f12(0xec)||typeof _0x5e8bca[_0xf69f12(0xfd)]!==_0xf69f12(0xec)||typeof _0x5e8bca[_0xf69f12(0xc8)]!=='string')return undefined;let _0xf91122;if(typeof _0x5e8bca['datasetCode']===_0xf69f12(0xec)&&_0x5e8bca['datasetCodes']===undefined)_0xf91122=Object['fromEntries'](_0x5c9a26['map'](_0x50ba61=>[_0x50ba61,_0x5e8bca[_0xf69f12(0xee)]]));else{if(_0x5e8bca[_0xf69f12(0xee)]===undefined&&_0x5e8bca[_0xf69f12(0xdc)]&&typeof _0x5e8bca[_0xf69f12(0xdc)]===_0xf69f12(0xef)&&!Array[_0xf69f12(0xdd)](_0x5e8bca['datasetCodes'])&&Object['values'](_0x5e8bca[_0xf69f12(0xdc)])[_0xf69f12(0xf6)](_0x2d415d=>typeof _0x2d415d===_0xf69f12(0xec)))_0xf91122={..._0x5e8bca[_0xf69f12(0xdc)]};else return undefined;}_0x488db3[_0xf69f12(0xf8)]({'alias':_0x5e8bca[_0xf69f12(0xf1)],'tableName':_0x5e8bca[_0xf69f12(0xfd)],'name':_0x5e8bca[_0xf69f12(0xc8)],'datasetCodes':_0xf91122});}return _0x488db3;}export function parseModelRegistry(_0x232871){const _0x4aa111=a6_0x60e9b6,_0x18f59d=extractRegistryJson(_0x232871);if(!_0x18f59d)return undefined;try{const _0x4137bc=parseGeneratedRegistryJson(_0x18f59d);if(typeof _0x4137bc[_0x4aa111(0xf4)]!=='string'||!_0x4137bc[_0x4aa111(0xf5)]||typeof _0x4137bc[_0x4aa111(0xf5)]!==_0x4aa111(0xef))return undefined;if(_0x4137bc[_0x4aa111(0xea)]===_0x4aa111(0x103))return migrateLegacyRegistry(_0x4137bc);if(!(_0x4137bc[_0x4aa111(0xea)]===LEGACY_MODEL_REGISTRY_V2_PROTOCOL||_0x4137bc[_0x4aa111(0xea)]===undefined&&_0x232871[_0x4aa111(0xe9)](MODEL_REGISTRY_VERSION_MARKER))||!Array['isArray'](_0x4137bc[_0x4aa111(0xf7)]))return undefined;const _0x10bf34=_0x4137bc[_0x4aa111(0xf5)],_0x44786a=normalizeModelEntries(_0x10bf34,_0x4137bc[_0x4aa111(0xf7)]);if(!_0x44786a)return undefined;return{'defaultProfile':_0x4137bc[_0x4aa111(0xf4)],'profiles':_0x10bf34,'models':_0x44786a};}catch{return undefined;}}export function readModelRegistry(_0x127f5e){const _0x4c4724=a6_0x60e9b6;if(!existsSync(_0x127f5e))return undefined;try{return parseModelRegistry(readFileSync(_0x127f5e,_0x4c4724(0xf9)));}catch{return undefined;}}function a6_0x4831(_0x25f425,_0x449d92){_0x25f425=_0x25f425-0xc8;const _0x58aeb2=a6_0x58ae();let _0x4831f6=_0x58aeb2[_0x25f425];return _0x4831f6;}function registrySource(_0x52574a){const _0x19c392=a6_0x60e9b6,_0x29f212=Object[_0x19c392(0xd1)](_0x52574a[_0x19c392(0xf5)]),_0x332573=_0x52574a[_0x19c392(0xf7)]['map'](_0x4cc8c9=>{const _0x2d63e7=_0x19c392,_0x3183ab=_0x29f212['map'](_0x4f06ec=>_0x4cc8c9[_0x2d63e7(0xdc)][_0x4f06ec]),_0x2be0e0=_0x3183ab[0x0],_0x4c2ae6=_0x2be0e0!==undefined&&_0x3183ab[_0x2d63e7(0xf6)](_0x387a80=>_0x387a80===_0x2be0e0),_0x1f2cd1={'alias':_0x4cc8c9[_0x2d63e7(0xf1)],'tableName':_0x4cc8c9[_0x2d63e7(0xfd)],'name':_0x4cc8c9[_0x2d63e7(0xc8)]};return _0x4c2ae6?{..._0x1f2cd1,'datasetCode':_0x2be0e0}:{..._0x1f2cd1,'datasetCodes':_0x4cc8c9['datasetCodes']};}),_0x4d6a7f=JSON['stringify']({'defaultProfile':_0x52574a[_0x19c392(0xf4)],'profiles':_0x52574a['profiles'],'models':_0x332573},null,0x2)[_0x19c392(0xe5)]('\x0a')[_0x19c392(0xfa)](_0x1ec64c=>'\x20\x20'+_0x1ec64c)['join']('\x0a');return _0x19c392(0xd4)+MODEL_REGISTRY_VERSION_MARKER+_0x19c392(0xca)+REGISTRY_START+'\x0a'+_0x4d6a7f+'\x20as\x20const\x20satisfies\x20LovrabetModelRegistry;\x0a'+REGISTRY_END+'\x0a';}function mergeProfileModels(_0x4dc7ed,_0x44ddbf,_0x30c74f){const _0x4fb574=a6_0x60e9b6,_0x42f8b7=_0x30c74f[_0x4fb574(0xfa)](_0x28e898=>({..._0x28e898,'alias':_0x28e898[_0x4fb574(0xf1)]||_0x28e898[_0x4fb574(0xfd)]})),_0x403950=new Map(),_0x3747a8=new Map();for(const _0x5e3ef4 of _0x42f8b7){const _0x217c6b=_0x403950[_0x4fb574(0xdb)](_0x5e3ef4['alias']);if(_0x217c6b&&_0x217c6b!==_0x5e3ef4['tableName'])throw new Error(_0x4fb574(0xcc)+_0x5e3ef4[_0x4fb574(0xf1)]+_0x4fb574(0xf3)+_0x217c6b+_0x4fb574(0xcf)+_0x5e3ef4[_0x4fb574(0xfd)]+_0x4fb574(0xe4)+_0x44ddbf+'\x22.');const _0xd4a339=_0x3747a8['get'](_0x5e3ef4[_0x4fb574(0xfd)]);if(_0xd4a339&&_0xd4a339!==_0x5e3ef4[_0x4fb574(0xf1)])throw new Error(_0x4fb574(0xda)+_0x5e3ef4['tableName']+_0x4fb574(0xed)+_0xd4a339+'\x22\x20and\x20\x22'+_0x5e3ef4[_0x4fb574(0xf1)]+_0x4fb574(0xe4)+_0x44ddbf+'\x22.');_0x403950[_0x4fb574(0xfb)](_0x5e3ef4[_0x4fb574(0xf1)],_0x5e3ef4[_0x4fb574(0xfd)]),_0x3747a8[_0x4fb574(0xfb)](_0x5e3ef4[_0x4fb574(0xfd)],_0x5e3ef4['alias']);const _0x642ead=_0x4dc7ed[_0x4fb574(0xf7)]['find'](_0x341bd8=>_0x341bd8[_0x4fb574(0xf1)]===_0x5e3ef4[_0x4fb574(0xf1)]);if(_0x642ead&&_0x642ead[_0x4fb574(0xfd)]!==_0x5e3ef4['tableName'])throw new Error(_0x4fb574(0xcc)+_0x5e3ef4[_0x4fb574(0xf1)]+'\x22\x20maps\x20to\x20table\x20\x22'+_0x642ead[_0x4fb574(0xfd)]+_0x4fb574(0xd5)+_0x5e3ef4[_0x4fb574(0xfd)]+_0x4fb574(0xe4)+_0x44ddbf+'\x22.');const _0x3cb446=_0x4dc7ed[_0x4fb574(0xf7)][_0x4fb574(0xe6)](_0x31b5c8=>_0x31b5c8['tableName']===_0x5e3ef4['tableName']);if(_0x3cb446&&_0x3cb446['alias']!==_0x5e3ef4[_0x4fb574(0xf1)])throw new Error(_0x4fb574(0xda)+_0x5e3ef4['tableName']+_0x4fb574(0xdf)+_0x3cb446[_0x4fb574(0xf1)]+_0x4fb574(0xd5)+_0x5e3ef4[_0x4fb574(0xf1)]+'\x22\x20in\x20profile\x20\x22'+_0x44ddbf+'\x22.');}for(const _0x11cac1 of _0x4dc7ed[_0x4fb574(0xf7)]){delete _0x11cac1[_0x4fb574(0xdc)][_0x44ddbf];}for(const _0x231c79 of _0x42f8b7){let _0x4d69cd=_0x4dc7ed['models']['find'](_0x62cfb7=>_0x62cfb7['alias']===_0x231c79[_0x4fb574(0xf1)]);!_0x4d69cd&&(_0x4d69cd={'alias':_0x231c79[_0x4fb574(0xf1)],'tableName':_0x231c79[_0x4fb574(0xfd)],'name':_0x231c79['name'],'datasetCodes':{}},_0x4dc7ed[_0x4fb574(0xf7)][_0x4fb574(0xf8)](_0x4d69cd)),(_0x44ddbf===_0x4dc7ed[_0x4fb574(0xf4)]||!_0x4d69cd['datasetCodes'][_0x4dc7ed[_0x4fb574(0xf4)]])&&(_0x4d69cd[_0x4fb574(0xf1)]=_0x231c79[_0x4fb574(0xf1)],_0x4d69cd[_0x4fb574(0xfd)]=_0x231c79['tableName'],_0x4d69cd['name']=_0x231c79[_0x4fb574(0xc8)]),_0x4d69cd['datasetCodes'][_0x44ddbf]=_0x231c79[_0x4fb574(0xee)];}_0x4dc7ed[_0x4fb574(0xf7)]=_0x4dc7ed[_0x4fb574(0xf7)][_0x4fb574(0x10b)](_0x1ceca1=>Object[_0x4fb574(0xd1)](_0x1ceca1['datasetCodes'])['length']>0x0);}function removeUnboundProfiles(_0x46e1e9){const _0xea414d=a6_0x60e9b6,_0x59f220=Object['entries'](_0x46e1e9[_0xea414d(0xf5)])[_0xea414d(0x10b)](([,_0xc6b488])=>_0xc6b488[_0xea414d(0x10a)]===_0xea414d(0xd2))[_0xea414d(0xfa)](([_0x43e65d])=>_0x43e65d);if(_0x59f220[_0xea414d(0xff)]===0x0)return;for(const _0xea2a08 of _0x59f220){delete _0x46e1e9[_0xea414d(0xf5)][_0xea2a08];for(const _0x1ff897 of _0x46e1e9[_0xea414d(0xf7)]){delete _0x1ff897[_0xea414d(0xdc)][_0xea2a08];}}_0x46e1e9[_0xea414d(0xf7)]=_0x46e1e9['models']['filter'](_0x1dc252=>Object[_0xea414d(0xd1)](_0x1dc252[_0xea414d(0xdc)])[_0xea414d(0xff)]>0x0);}export function getProfileModels(_0x59480d,_0x5131ad){const _0x2a756f=a6_0x60e9b6;return _0x59480d[_0x2a756f(0xf7)][_0x2a756f(0xcb)](_0x423ab8=>{const _0x246599=_0x2a756f,_0x243949=_0x423ab8[_0x246599(0xdc)][_0x5131ad];return _0x243949?[{'datasetCode':_0x243949,'tableName':_0x423ab8['tableName'],'name':_0x423ab8['name'],'alias':_0x423ab8['alias']}]:[];});}export function updateModelRegistry(_0x14a7fc){const _0x40100c=a6_0x60e9b6,_0x13876f=a6_0x5ec771[_0x40100c(0xf2)](_0x14a7fc[_0x40100c(0x10c)],MODEL_REGISTRY_FILE_NAME),_0x1985fa=existsSync(_0x13876f),_0x3abe65=readModelRegistry(_0x13876f);if(_0x1985fa&&!_0x3abe65)throw new Error(MODEL_REGISTRY_FILE_NAME+_0x40100c(0xe1));const _0x910e46=_0x3abe65??emptyRegistry(_0x14a7fc[_0x40100c(0xf4)]);if(_0x14a7fc[_0x40100c(0x10a)]!==_0x40100c(0xd2))removeUnboundProfiles(_0x910e46);const _0x55e030=_0x3abe65?getProfileModels(_0x3abe65,_0x14a7fc[_0x40100c(0xce)])['length']:0x0;if(_0x55e030>0x0&&_0x14a7fc[_0x40100c(0xf7)][_0x40100c(0xff)]===0x0&&!_0x14a7fc['allowEmptyReplacement'])throw new Error(_0x40100c(0xf0)+_0x55e030+_0x40100c(0x102)+_0x14a7fc[_0x40100c(0xce)]+_0x40100c(0x10d)+'Verify\x20the\x20selected\x20app\x20and\x20login,\x20or\x20rerun\x20with\x20--force\x20--yes\x20if\x20the\x20profile\x20is\x20intentionally\x20empty.');_0x910e46['defaultProfile']=_0x14a7fc[_0x40100c(0xf4)],_0x910e46['profiles'][_0x14a7fc[_0x40100c(0xce)]]={'appCode':_0x14a7fc[_0x40100c(0x10a)],'runtimeDomain':_0x14a7fc[_0x40100c(0xe2)]},mergeProfileModels(_0x910e46,_0x14a7fc[_0x40100c(0xce)],_0x14a7fc[_0x40100c(0xf7)]),mkdirSync(_0x14a7fc['outputDir'],{'recursive':!![]});const _0x1da86f=_0x13876f+'.'+process[_0x40100c(0x109)]+'.'+Date[_0x40100c(0xfc)]()+_0x40100c(0xeb);try{writeFileSync(_0x1da86f,registrySource(_0x910e46),{'encoding':_0x40100c(0xf9),'mode':0x1a4}),renameSync(_0x1da86f,_0x13876f);}catch(_0xa854ac){try{unlinkSync(_0x1da86f);}catch{}throw _0xa854ac;}return{'path':_0x13876f,'registry':_0x910e46,'existed':_0x1985fa};}
1
+ import{existsSync,mkdirSync,readFileSync,renameSync,unlinkSync,writeFileSync}from"node:fs";import path from"node:path";export const MODEL_REGISTRY_FILE_NAME="models.generated.ts";export const MODEL_RUNTIME_FILE_NAME="model-runtime.ts";export const MODEL_REGISTRY_VERSION_MARKER="/* rabetbase-model-registry:v2 */";const LEGACY_MODEL_REGISTRY_V2_PROTOCOL="lovrabet-model-registry/v2";const REGISTRY_START="/* rabetbase-model-registry:start */";const REGISTRY_END="/* rabetbase-model-registry:end */";function emptyRegistry(defaultProfile){return{defaultProfile:defaultProfile,profiles:{},models:[]}}function extractRegistryJson(content){const start=content.indexOf(REGISTRY_START);const end=content.indexOf(REGISTRY_END);if(start<0||end<=start)return undefined;return content.slice(start+REGISTRY_START.length,end).trim().replace(/\s+as const satisfies LovrabetModelRegistry;?$/,"").replace(/;$/,"")}function migrateLegacyRegistry(legacy){const registry=emptyRegistry(legacy.defaultProfile)
2
+ ;for(const[profileName,profile]of Object.entries(legacy.profiles)){registry.profiles[profileName]={appCode:profile.appCode,runtimeDomain:profile.runtimeDomain};mergeProfileModels(registry,profileName,profile.models)}return registry}function generatedObjectLiteralToJson(source){let result="";let quote;let escaped=false;let previousToken;for(let index=0;index<source.length;index++){const char=source[index];if(quote){result+=char;if(escaped)escaped=false;else if(char==="\\")escaped=true;else if(char===quote)quote=undefined;continue}if(char==='"'){quote=char;result+=char;previousToken="value";continue}if(char===","){let cursor=index+1;while(/\s/.test(source[cursor]??""))cursor++;if(source[cursor]==="}"||source[cursor]==="]")continue;result+=char;previousToken=",";continue}if(char==="{"||char==="["){result+=char;previousToken=char;continue}if(char==="}"||char==="]"){result+=char;previousToken=char;continue}if((previousToken==="{"||previousToken===",")&&/[A-Za-z_$]/.test(char)){
3
+ let cursor=index+1;while(/[A-Za-z0-9_$]/.test(source[cursor]??""))cursor++;let colon=cursor;while(/\s/.test(source[colon]??""))colon++;if(source[colon]===":"){result+=JSON.stringify(source.slice(index,cursor));index=cursor-1;previousToken="key";continue}}result+=char;if(!/\s/.test(char)&&char!==":")previousToken="value"}return result}function parseGeneratedRegistryJson(json){try{return JSON.parse(json)}catch{return JSON.parse(generatedObjectLiteralToJson(json))}}function normalizeModelEntries(profiles,models){const profileNames=Object.keys(profiles);const normalized=[];for(const value of models){if(!value||typeof value!=="object"||Array.isArray(value))return undefined;const entry=value;if(typeof entry.alias!=="string"||typeof entry.tableName!=="string"||typeof entry.name!=="string"){return undefined}let datasetCodes;if(typeof entry.datasetCode==="string"&&entry.datasetCodes===undefined){datasetCodes=Object.fromEntries(profileNames.map(profileName=>[profileName,entry.datasetCode]))
4
+ }else if(entry.datasetCode===undefined&&entry.datasetCodes&&typeof entry.datasetCodes==="object"&&!Array.isArray(entry.datasetCodes)&&Object.values(entry.datasetCodes).every(code=>typeof code==="string")){datasetCodes={...entry.datasetCodes}}else{return undefined}normalized.push({alias:entry.alias,tableName:entry.tableName,name:entry.name,datasetCodes:datasetCodes})}return normalized}export function parseModelRegistry(content){const json=extractRegistryJson(content);if(!json)return undefined;try{const parsed=parseGeneratedRegistryJson(json);if(typeof parsed.defaultProfile!=="string"||!parsed.profiles||typeof parsed.profiles!=="object"){return undefined}if(parsed.protocol==="lovrabet-model-registry/v1"){return migrateLegacyRegistry(parsed)}if(!(parsed.protocol===LEGACY_MODEL_REGISTRY_V2_PROTOCOL||parsed.protocol===undefined&&content.includes(MODEL_REGISTRY_VERSION_MARKER))||!Array.isArray(parsed.models)){return undefined}const profiles=parsed.profiles
5
+ ;const models=normalizeModelEntries(profiles,parsed.models);if(!models)return undefined;return{defaultProfile:parsed.defaultProfile,profiles:profiles,models:models}}catch{return undefined}}export function readModelRegistry(filePath){if(!existsSync(filePath))return undefined;try{return parseModelRegistry(readFileSync(filePath,"utf8"))}catch{return undefined}}function registrySource(registry){const profileNames=Object.keys(registry.profiles);const persistedModels=registry.models.map(model=>{const codes=profileNames.map(profileName=>model.datasetCodes[profileName]);const commonDatasetCode=codes[0];const isCommon=commonDatasetCode!==undefined&&codes.every(code=>code===commonDatasetCode);const metadata={alias:model.alias,tableName:model.tableName,name:model.name};return isCommon?{...metadata,datasetCode:commonDatasetCode}:{...metadata,datasetCodes:model.datasetCodes}});const serialized=JSON.stringify({defaultProfile:registry.defaultProfile,profiles:registry.profiles,models:persistedModels
6
+ },null,2).split("\n").map(line=>` ${line}`).join("\n");return`/**\n * Dataset model facts generated by Rabetbase CLI.\n *\n * This file is safe to commit. Do not edit it manually and never add credentials.\n */\n\nexport interface LovrabetModelProfile {\n appCode: string;\n runtimeDomain: string;\n}\n\nexport interface LovrabetModelEntryMetadata {\n alias: string;\n tableName: string;\n name: string;\n}\n\nexport type LovrabetModelEntry = LovrabetModelEntryMetadata & (\n | { datasetCode: string; datasetCodes?: never }\n | { datasetCode?: never; datasetCodes: Record<string, string> }\n);\n\nexport interface LovrabetModelRegistry {\n defaultProfile: string;\n profiles: Record<string, LovrabetModelProfile>;\n models: LovrabetModelEntry[];\n}\n\n${MODEL_REGISTRY_VERSION_MARKER}\nexport const LOVRABET_MODEL_REGISTRY =\n ${REGISTRY_START}\n${serialized} as const satisfies LovrabetModelRegistry;\n${REGISTRY_END}\n`}function mergeProfileModels(registry,profileName,incomingModels){
7
+ const normalizedIncoming=incomingModels.map(incoming=>({...incoming,alias:incoming.alias||incoming.tableName}));const incomingAliases=new Map;const incomingTables=new Map;for(const incoming of normalizedIncoming){const aliasTable=incomingAliases.get(incoming.alias);if(aliasTable&&aliasTable!==incoming.tableName){throw new Error(`Model alias "${incoming.alias}" maps to both "${aliasTable}" and "${incoming.tableName}" in profile "${profileName}".`)}const tableAlias=incomingTables.get(incoming.tableName);if(tableAlias&&tableAlias!==incoming.alias){throw new Error(`Table "${incoming.tableName}" maps to both aliases "${tableAlias}" and "${incoming.alias}" in profile "${profileName}".`)}incomingAliases.set(incoming.alias,incoming.tableName);incomingTables.set(incoming.tableName,incoming.alias);const aliasEntry=registry.models.find(model=>model.alias===incoming.alias);if(aliasEntry&&aliasEntry.tableName!==incoming.tableName){
8
+ throw new Error(`Model alias "${incoming.alias}" maps to table "${aliasEntry.tableName}" in the registry but "${incoming.tableName}" in profile "${profileName}".`)}const tableEntry=registry.models.find(model=>model.tableName===incoming.tableName);if(tableEntry&&tableEntry.alias!==incoming.alias){throw new Error(`Table "${incoming.tableName}" maps to alias "${tableEntry.alias}" in the registry but "${incoming.alias}" in profile "${profileName}".`)}}for(const model of registry.models){delete model.datasetCodes[profileName]}for(const incoming of normalizedIncoming){let entry=registry.models.find(model=>model.alias===incoming.alias);if(!entry){entry={alias:incoming.alias,tableName:incoming.tableName,name:incoming.name,datasetCodes:{}};registry.models.push(entry)}if(profileName===registry.defaultProfile||!entry.datasetCodes[registry.defaultProfile]){entry.alias=incoming.alias;entry.tableName=incoming.tableName;entry.name=incoming.name}entry.datasetCodes[profileName]=incoming.datasetCode}
9
+ registry.models=registry.models.filter(model=>Object.keys(model.datasetCodes).length>0)}function removeUnboundProfiles(registry){const unboundProfileNames=Object.entries(registry.profiles).filter(([,profile])=>profile.appCode==="NOT-SET").map(([profileName])=>profileName);if(unboundProfileNames.length===0)return;for(const profileName of unboundProfileNames){delete registry.profiles[profileName];for(const model of registry.models){delete model.datasetCodes[profileName]}}registry.models=registry.models.filter(model=>Object.keys(model.datasetCodes).length>0)}export function getProfileModels(registry,profileName){return registry.models.flatMap(model=>{const datasetCode=model.datasetCodes[profileName];return datasetCode?[{datasetCode:datasetCode,tableName:model.tableName,name:model.name,alias:model.alias}]:[]})}export function updateModelRegistry(options){const filePath=path.join(options.outputDir,MODEL_REGISTRY_FILE_NAME);const existed=existsSync(filePath)
10
+ ;const existing=readModelRegistry(filePath);if(existed&&!existing){throw new Error(`${MODEL_REGISTRY_FILE_NAME} is not a valid Rabetbase generated file. Move or repair it before pulling models again.`)}const registry=existing??emptyRegistry(options.defaultProfile);if(options.appCode!=="NOT-SET")removeUnboundProfiles(registry);const existingProfileModelCount=existing?getProfileModels(existing,options.profileName).length:0;if(existingProfileModelCount>0&&options.models.length===0&&!options.allowEmptyReplacement){throw new Error(`Refusing to replace ${existingProfileModelCount} model(s) in profile "${options.profileName}" with an empty result. `+"Verify the selected app and login, or rerun with --force --yes if the profile is intentionally empty.")}registry.defaultProfile=options.defaultProfile;registry.profiles[options.profileName]={appCode:options.appCode,runtimeDomain:options.runtimeDomain};mergeProfileModels(registry,options.profileName,options.models);mkdirSync(options.outputDir,{
11
+ recursive:true});const tempPath=`${filePath}.${process.pid}.${Date.now()}.tmp`;try{writeFileSync(tempPath,registrySource(registry),{encoding:"utf8",mode:420});renameSync(tempPath,filePath)}catch(error){try{unlinkSync(tempPath)}catch{}throw error}return{path:filePath,registry:registry,existed:existed}}
@@ -1 +1,2 @@
1
- function a7_0x330c(){const _0x2dfc78=['all','292617SlQePW','793763OtakAx','2457240OxtmBx','cwd','startsWith','37516fPWbFQ','profile-api.ts.tpl','replace','4473009cICQvG','typescript','7HJmihz','655LlXlFh','250vdNJZd','format','join','1958150ljltYQ','utf8','dirname','{ProjectRoutingImport}','profile-client.ts.tpl','resolve','4745912lbbtrH'];a7_0x330c=function(){return _0x2dfc78;};return a7_0x330c();}const a7_0x4e8ddc=a7_0x9459;(function(_0x19a656,_0xc09246){const _0x32d804=a7_0x9459,_0x92bfdf=_0x19a656();while(!![]){try{const _0x450db5=-parseInt(_0x32d804(0x1a2))/0x1+-parseInt(_0x32d804(0x199))/0x2+parseInt(_0x32d804(0x192))/0x3+-parseInt(_0x32d804(0x1a6))/0x4*(-parseInt(_0x32d804(0x195))/0x5)+-parseInt(_0x32d804(0x1a3))/0x6+-parseInt(_0x32d804(0x194))/0x7*(parseInt(_0x32d804(0x19f))/0x8)+parseInt(_0x32d804(0x1a1))/0x9*(parseInt(_0x32d804(0x196))/0xa);if(_0x450db5===_0xc09246)break;else _0x92bfdf['push'](_0x92bfdf['shift']());}catch(_0x89cbf7){_0x92bfdf['push'](_0x92bfdf['shift']());}}}(a7_0x330c,0xb8c7c));import{readFileSync}from'node:fs';import a7_0x1d611a from'node:path';function a7_0x9459(_0x26c898,_0x40bb68){_0x26c898=_0x26c898-0x191;const _0x330cb9=a7_0x330c();let _0x9459ca=_0x330cb9[_0x26c898];return _0x9459ca;}import{fileURLToPath}from'node:url';import a7_0x225018 from'prettier';import{PROJECT_DOMAIN_ROUTING_FILE_NAME}from'../config/project-domain-routing.js';function relativeImport(_0x55c555,_0x5c6d04){const _0x2b6cec=a7_0x9459;let _0x4186ee=a7_0x1d611a['relative'](_0x55c555,_0x5c6d04)[_0x2b6cec(0x191)](/\\/g,'/');if(!_0x4186ee[_0x2b6cec(0x1a5)]('.'))_0x4186ee='./'+_0x4186ee;return _0x4186ee;}export async function renderModelRegistryScaffold(_0x2847f6,_0x166e1c=process[a7_0x4e8ddc(0x1a4)]()){const _0x341c27=a7_0x4e8ddc,_0x14a24a=fileURLToPath(import.meta.url),_0x1f9119=a7_0x1d611a[_0x341c27(0x19e)](a7_0x1d611a[_0x341c27(0x19b)](_0x14a24a),'../../templates/generate-api'),_0x9a9a6=relativeImport(a7_0x1d611a['resolve'](_0x2847f6),a7_0x1d611a[_0x341c27(0x19e)](_0x166e1c,PROJECT_DOMAIN_ROUTING_FILE_NAME)),_0x80120c=readFileSync(a7_0x1d611a[_0x341c27(0x198)](_0x1f9119,_0x341c27(0x1a7)),'utf8')[_0x341c27(0x191)](_0x341c27(0x19c),_0x9a9a6),[_0x3dc008,_0x5c32cc,_0x9f402a]=await Promise[_0x341c27(0x1a0)]([a7_0x225018[_0x341c27(0x197)](_0x80120c,{'parser':'typescript'}),a7_0x225018[_0x341c27(0x197)](readFileSync(a7_0x1d611a['join'](_0x1f9119,_0x341c27(0x19d)),_0x341c27(0x19a)),{'parser':_0x341c27(0x193)}),a7_0x225018[_0x341c27(0x197)](readFileSync(a7_0x1d611a['join'](_0x1f9119,'model-runtime.ts.tpl'),'utf8'),{'parser':_0x341c27(0x193)})]);return{'api':_0x3dc008,'client':_0x5c32cc,'modelRuntime':_0x9f402a};}
1
+ import{readFileSync}from"node:fs";import path from"node:path";import{fileURLToPath}from"node:url";import prettier from"prettier";import{PROJECT_DOMAIN_ROUTING_FILE_NAME}from"../config/project-domain-routing.js";function relativeImport(fromDir,targetPath){let value=path.relative(fromDir,targetPath).replace(/\\/g,"/");if(!value.startsWith("."))value=`./${value}`;return value}export async function renderModelRegistryScaffold(outputDir,projectRoot=process.cwd()){const currentFilePath=fileURLToPath(import.meta.url);const templateDir=path.resolve(path.dirname(currentFilePath),"../../templates/generate-api");const routingImport=relativeImport(path.resolve(outputDir),path.resolve(projectRoot,PROJECT_DOMAIN_ROUTING_FILE_NAME));const apiTemplate=readFileSync(path.join(templateDir,"profile-api.ts.tpl"),"utf8").replace("{ProjectRoutingImport}",routingImport);const[api,client,modelRuntime]=await Promise.all([prettier.format(apiTemplate,{parser:"typescript"
2
+ }),prettier.format(readFileSync(path.join(templateDir,"profile-client.ts.tpl"),"utf8"),{parser:"typescript"}),prettier.format(readFileSync(path.join(templateDir,"model-runtime.ts.tpl"),"utf8"),{parser:"typescript"})]);return{api:api,client:client,modelRuntime:modelRuntime}}
@@ -1 +1,3 @@
1
- (function(_0x592384,_0x1c6139){const _0x356572=a8_0x538b,_0xa3a32d=_0x592384();while(!![]){try{const _0x4e3ef5=-parseInt(_0x356572(0xcc))/0x1*(parseInt(_0x356572(0xb7))/0x2)+parseInt(_0x356572(0xb1))/0x3*(parseInt(_0x356572(0xb6))/0x4)+parseInt(_0x356572(0xca))/0x5+-parseInt(_0x356572(0xb4))/0x6*(-parseInt(_0x356572(0xb3))/0x7)+parseInt(_0x356572(0xc4))/0x8+parseInt(_0x356572(0xc3))/0x9+-parseInt(_0x356572(0xc1))/0xa;if(_0x4e3ef5===_0x1c6139)break;else _0xa3a32d['push'](_0xa3a32d['shift']());}catch(_0x1025a6){_0xa3a32d['push'](_0xa3a32d['shift']());}}}(a8_0x42bb,0x9ced5));function a8_0x538b(_0x100eec,_0x5b5c6a){_0x100eec=_0x100eec-0xac;const _0x42bb73=a8_0x42bb();let _0x538b3d=_0x42bb73[_0x100eec];return _0x538b3d;}import{existsSync}from'node:fs';import a8_0x1e5810 from'node:path';import{readRawConfig}from'../context/config-loader.js';import{MODEL_REGISTRY_FILE_NAME,readModelRegistry}from'../api/model-registry-file.js';import{CliErrors}from'../errors.js';function a8_0x42bb(){const _0x442f80=['\x22\x20is\x20missing\x20from\x20','entries','length','1581060uytxOF','defaultApp','31204WNaRAe','AppCode\x20\x22','`\x20first.','cwd','apps','Select\x20the\x20target\x20explicitly\x20with\x20--app\x20<profile>.','6aKElAI','\x22\x20belongs\x20to\x20multiple\x20model\x20profiles:\x20','5873259iUZvqd','6ashqay','appCode','2373148uspeDn','4XVGAZu','resolve','\x20api\x20pull\x20--app\x20','-api.ts','validation','find','profiles','map','Model\x20profile\x20\x22','api.ts','28827780zkLZRG','string','8312994lStCGg','2579760EKQiPC','join','defaultProfile'];a8_0x42bb=function(){return _0x442f80;};return a8_0x42bb();}import{CLI_BIN_NAME}from'../constant/cli.js';export function resolveApiModelSource(_0x3d9106,_0x4fdfd7,_0xcad0fe){const _0x5eacff=a8_0x538b,_0x24e988=a8_0x1e5810[_0x5eacff(0xb8)](process[_0x5eacff(0xae)](),_0x3d9106),_0x28341d=a8_0x1e5810[_0x5eacff(0xb8)](_0x24e988,_0x5eacff(0xc0)),_0x38b2eb=a8_0x1e5810[_0x5eacff(0xb8)](_0x24e988,MODEL_REGISTRY_FILE_NAME),_0x1a1455=readModelRegistry(_0x38b2eb);if(_0x1a1455){const _0x3d3e1d=_0x4fdfd7?Object[_0x5eacff(0xc8)](_0x1a1455['profiles'])['filter'](([,_0x409570])=>_0x409570[_0x5eacff(0xb5)]===_0x4fdfd7):[];if(_0xcad0fe){if(_0x1a1455[_0x5eacff(0xbd)][_0xcad0fe])return{'filePath':_0x38b2eb,'profileName':_0xcad0fe};if(_0x3d3e1d[_0x5eacff(0xc9)]>0x0)throw CliErrors[_0x5eacff(0xbb)](_0x5eacff(0xbf)+_0xcad0fe+_0x5eacff(0xc7)+MODEL_REGISTRY_FILE_NAME+'.','Run\x20`'+CLI_BIN_NAME+_0x5eacff(0xb9)+_0xcad0fe+_0x5eacff(0xad));}else{if(_0x3d3e1d['length']===0x1)return{'filePath':_0x38b2eb,'profileName':_0x3d3e1d[0x0][0x0]};if(_0x3d3e1d[_0x5eacff(0xc9)]>0x1)throw new Error(_0x5eacff(0xac)+_0x4fdfd7+_0x5eacff(0xb2)+_0x3d3e1d[_0x5eacff(0xbe)](([_0x181845])=>_0x181845)[_0x5eacff(0xc5)](',\x20')+'.\x20'+_0x5eacff(0xb0));if(_0x1a1455[_0x5eacff(0xbd)][_0x1a1455['defaultProfile']]&&!_0x4fdfd7)return{'filePath':_0x38b2eb,'profileName':_0x1a1455[_0x5eacff(0xc6)]};}}if(!_0x4fdfd7&&!_0xcad0fe)return{'filePath':_0x28341d};const _0x58b1a8=readRawConfig(),_0x484a2b=_0x58b1a8['apps']&&typeof _0x58b1a8[_0x5eacff(0xaf)]==='object'?_0x58b1a8[_0x5eacff(0xaf)]:{},_0x2aeb30=_0xcad0fe&&_0x484a2b[_0xcad0fe]?[_0xcad0fe,_0x484a2b[_0xcad0fe]]:Object['entries'](_0x484a2b)[_0x5eacff(0xbc)](([,_0x30ca96])=>_0x30ca96?.['appcode']===_0x4fdfd7);if(!_0x2aeb30)return{'filePath':_0x28341d};const [_0x168232,_0x2c8b0b]=_0x2aeb30,_0x1da7e8=typeof _0x58b1a8[_0x5eacff(0xcb)]===_0x5eacff(0xc2)?_0x58b1a8[_0x5eacff(0xcb)]:undefined;if(_0x2c8b0b?.['apiDir'])return{'filePath':_0x28341d};if(_0x1da7e8&&_0x168232!==_0x1da7e8){const _0x2448a3=a8_0x1e5810[_0x5eacff(0xb8)](_0x24e988,_0x168232+_0x5eacff(0xba));if(existsSync(_0x2448a3))return{'filePath':_0x2448a3};}return{'filePath':_0x28341d};}
1
+ import{existsSync}from"node:fs";import path from"node:path";import{readRawConfig}from"../context/config-loader.js";import{MODEL_REGISTRY_FILE_NAME,readModelRegistry}from"../api/model-registry-file.js";import{CliErrors}from"../errors.js";import{CLI_BIN_NAME}from"../constant/cli.js";export function resolveApiModelSource(apiDir,appCode,selectedAppName){const absDir=path.resolve(process.cwd(),apiDir);const defaultPath=path.resolve(absDir,"api.ts");const registryPath=path.resolve(absDir,MODEL_REGISTRY_FILE_NAME);const registry=readModelRegistry(registryPath);if(registry){const matches=appCode?Object.entries(registry.profiles).filter(([,profile])=>profile.appCode===appCode):[];if(selectedAppName){if(registry.profiles[selectedAppName]){return{filePath:registryPath,profileName:selectedAppName}}if(matches.length>0){throw CliErrors.validation(`Model profile "${selectedAppName}" is missing from ${MODEL_REGISTRY_FILE_NAME}.`,`Run \`${CLI_BIN_NAME} api pull --app ${selectedAppName}\` first.`)}
2
+ }else{if(matches.length===1){return{filePath:registryPath,profileName:matches[0][0]}}if(matches.length>1){throw new Error(`AppCode "${appCode}" belongs to multiple model profiles: ${matches.map(([name])=>name).join(", ")}. `+"Select the target explicitly with --app <profile>.")}if(registry.profiles[registry.defaultProfile]&&!appCode){return{filePath:registryPath,profileName:registry.defaultProfile}}}}if(!appCode&&!selectedAppName)return{filePath:defaultPath};const config=readRawConfig();const apps=config.apps&&typeof config.apps==="object"?config.apps:{};const matchedEntry=selectedAppName&&apps[selectedAppName]?[selectedAppName,apps[selectedAppName]]:Object.entries(apps).find(([,profile])=>profile?.appcode===appCode);if(!matchedEntry)return{filePath:defaultPath};const[appName,profile]=matchedEntry;const defaultApp=typeof config.defaultApp==="string"?config.defaultApp:undefined;if(profile?.apiDir)return{filePath:defaultPath};if(defaultApp&&appName!==defaultApp){
3
+ const namedPath=path.resolve(absDir,`${appName}-api.ts`);if(existsSync(namedPath))return{filePath:namedPath}}return{filePath:defaultPath}}
@@ -1 +1,2 @@
1
- function a9_0x10d6(){const _0x57f6a9=['Run\x20`','start','10197234HqaPhc','3370713HvNfRy','62376bpGlHS','6782cbcxxD','8SJVTLw','No\x20valid\x20session.\x20Login\x20now?','54056552ivXhLd','12032289LmVRRt','505qQpkLp','!\x20Login\x20failed.','autoYes','log','Logging\x20in...\x20Please\x20complete\x20login\x20in\x20your\x20browser.','Browser\x20login\x20cannot\x20run\x20in\x20non-interactive\x20mode.','validation','√\x20Valid\x20session\x20detected,\x20no\x20login\x20required.','10aNGHxm','365QPFUTM','stop','Starting\x20browser\x20login.\x20Share\x20the\x20printed\x20URL\x20with\x20the\x20user.','2963499EDlqbp','nonInteractive'];a9_0x10d6=function(){return _0x57f6a9;};return a9_0x10d6();}(function(_0x2ab497,_0x54ec4f){const _0x1e0ee7=a9_0x4336,_0x145f99=_0x2ab497();while(!![]){try{const _0x5b7156=parseInt(_0x1e0ee7(0x169))/0x1*(-parseInt(_0x1e0ee7(0x164))/0x2)+-parseInt(_0x1e0ee7(0x162))/0x3+-parseInt(_0x1e0ee7(0x163))/0x4*(parseInt(_0x1e0ee7(0x15a))/0x5)+parseInt(_0x1e0ee7(0x161))/0x6+-parseInt(_0x1e0ee7(0x15d))/0x7+-parseInt(_0x1e0ee7(0x165))/0x8*(parseInt(_0x1e0ee7(0x168))/0x9)+-parseInt(_0x1e0ee7(0x171))/0xa*(-parseInt(_0x1e0ee7(0x167))/0xb);if(_0x5b7156===_0x54ec4f)break;else _0x145f99['push'](_0x145f99['shift']());}catch(_0x2c170f){_0x145f99['push'](_0x145f99['shift']());}}}(a9_0x10d6,0xd6a01));import{getIsSessionValid}from'../auth/is-session-valid.js';function a9_0x4336(_0x2c7c92,_0x683364){_0x2c7c92=_0x2c7c92-0x15a;const _0x10d643=a9_0x10d6();let _0x433602=_0x10d643[_0x2c7c92];return _0x433602;}import{authServer}from'../auth/auth-server.js';import{CLI_BIN_NAME}from'../constant/cli.js';import{CliErrors}from'../errors.js';import{confirm}from'@inquirer/prompts';import a9_0x2c3736 from'ora';export async function runAuthServer(_0x103ee5){const _0x24bf56=a9_0x4336,_0x58a310=await getIsSessionValid();if(_0x58a310){console[_0x24bf56(0x16c)](_0x24bf56(0x170));return;}if(_0x103ee5?.['nonInteractive']&&!_0x103ee5[_0x24bf56(0x16b)])throw CliErrors[_0x24bf56(0x16f)](_0x24bf56(0x16e),_0x24bf56(0x15f)+CLI_BIN_NAME+'\x20auth\x20login\x20--yes`\x20and\x20open\x20the\x20printed\x20URL\x20in\x20your\x20browser.');const _0x1accc1=_0x103ee5?.[_0x24bf56(0x16b)]?!![]:await confirm({'message':_0x24bf56(0x166),'default':!![]});if(!_0x1accc1)return;if(_0x103ee5?.[_0x24bf56(0x15e)]){console['log'](_0x24bf56(0x15c));const _0x8accea=await authServer({'silent':![],'openBrowser':![]});_0x8accea?console[_0x24bf56(0x16c)]('*\x20Login\x20successful!'):console['log'](_0x24bf56(0x16a));return;}const _0x1f8226=a9_0x2c3736(_0x24bf56(0x16d))[_0x24bf56(0x160)](),_0x411ff4=await authServer({'silent':!![],'openBrowser':!![]});_0x1f8226[_0x24bf56(0x15b)](),_0x411ff4?console[_0x24bf56(0x16c)]('*\x20Login\x20successful!'):console[_0x24bf56(0x16c)]('!\x20Login\x20failed.');}
1
+ import{getIsSessionValid}from"../auth/is-session-valid.js";import{authServer}from"../auth/auth-server.js";import{CLI_BIN_NAME}from"../constant/cli.js";import{CliErrors}from"../errors.js";import{confirm}from"@inquirer/prompts";import ora from"ora";export async function runAuthServer(options){const isValid=await getIsSessionValid();if(isValid){console.log("√ Valid session detected, no login required.");return}if(options?.nonInteractive&&!options.autoYes){throw CliErrors.validation("Browser login cannot run in non-interactive mode.",`Run \`${CLI_BIN_NAME} auth login --yes\` and open the printed URL in your browser.`)}const shouldLogin=options?.autoYes?true:await confirm({message:"No valid session. Login now?",default:true});if(!shouldLogin)return;if(options?.nonInteractive){console.log("Starting browser login. Share the printed URL with the user.");const success=await authServer({silent:false,openBrowser:false});if(success){console.log("* Login successful!")}else{
2
+ console.log("! Login failed.")}return}const spinner=ora("Logging in... Please complete login in your browser.").start();const success=await authServer({silent:true,openBrowser:true});spinner.stop();if(success){console.log("* Login successful!")}else{console.log("! Login failed.")}}
@@ -1 +1,5 @@
1
- const a10_0x1a555b=a10_0x963e;(function(_0x5b70fd,_0x669334){const _0x4ddb22=a10_0x963e,_0x3cfd09=_0x5b70fd();while(!![]){try{const _0x3431e7=-parseInt(_0x4ddb22(0xe8))/0x1+-parseInt(_0x4ddb22(0xda))/0x2*(parseInt(_0x4ddb22(0xdb))/0x3)+-parseInt(_0x4ddb22(0xf7))/0x4+parseInt(_0x4ddb22(0xec))/0x5*(-parseInt(_0x4ddb22(0xf8))/0x6)+parseInt(_0x4ddb22(0xe9))/0x7*(-parseInt(_0x4ddb22(0xe1))/0x8)+parseInt(_0x4ddb22(0xd4))/0x9*(parseInt(_0x4ddb22(0xf0))/0xa)+-parseInt(_0x4ddb22(0xf5))/0xb*(-parseInt(_0x4ddb22(0xf9))/0xc);if(_0x3431e7===_0x669334)break;else _0x3cfd09['push'](_0x3cfd09['shift']());}catch(_0x141d28){_0x3cfd09['push'](_0x3cfd09['shift']());}}}(a10_0x5d2f,0x931c7));import{writeFileSync}from'node:fs';import a10_0x378902 from'node:http';import a10_0x4d958d from'node:https';function a10_0x5d2f(){const _0x1edd4d=['/cert/lovrabet-dev.json','object','🔐\x20Starting\x20login\x20service...','utf-8','!\x20Login\x20URL\x20expired\x20after\x2010\x20minutes.\x20Run\x20the\x20login\x20command\x20again\x20to\x20get\x20a\x20new\x20URL.','port','win32','headers','timeoutMs','lovrabet','origin','153VAqRUS','127.0.0.1','error','writeHead','createServer','then','244MpNIuv','23082AjUGqD','/api/auth/get-session','user','cookie','certificateUrl','json','827256KUviGu','close','💡\x20If\x20the\x20browser\x20does\x20not\x20open\x20automatically,\x20copy\x20the\x20login\x20URL\x20above\x20into\x20your\x20browser.','text/html;\x20charset=utf-8','⚠️\x20\x20Failed\x20to\x20open\x20browser\x20automatically','💡\x20Open\x20the\x20login\x20URL\x20above\x20in\x20your\x20browser\x20to\x20complete\x20authorization.','platform','247997JTvhFN','77sDmwWD','end','open\x20\x22','170ZRplOg','🔗\x20Please\x20copy\x20the\x20login\x20URL\x20into\x20your\x20browser:','openBrowser','/sign-in?redirect=','119430crQpyt','isAuth','📍\x20Login\x20URL:','log','local','11bYSbhs','session','2347428yUFQiU','91038gtsyeX','45917004OHNYfF','silent','Auth\x20server\x20error:'];a10_0x5d2f=function(){return _0x1edd4d;};return a10_0x5d2f();}function a10_0x963e(_0x39ad2f,_0x1aa528){_0x39ad2f=_0x39ad2f-0xc8;const _0x5d2f57=a10_0x5d2f();let _0x963e99=_0x5d2f57[_0x39ad2f];return _0x963e99;}import{getUserDomain}from'../constant/domain.js';import{getOfficialRoutingCdn,getOfficialRoutingProfile}from'../constant/routing-profile.js';import{getProjectDomainRoutingManifest}from'../config/project-domain-routing.js';import{exec}from'node:child_process';import{getIsSessionValid}from'../auth/is-session-valid.js';import{cookieFile}from'../auth/constant.js';import{buildLoginSuccessHtml}from'../auth/login-success-html.js';export const AUTH_LOGIN_TIMEOUT_MS=0xa*0x3c*0x3e8;export function resolveAuthCallbackRouting(_0xb7a858){const _0x4220d0=a10_0x963e;if(!_0xb7a858)return getProjectDomainRoutingManifest()[_0x4220d0(0xf4)];const _0x4d12a7=getOfficialRoutingProfile(_0xb7a858),_0x58c08e=getOfficialRoutingCdn(_0xb7a858);return{'origin':_0x4d12a7[_0x4220d0(0xf4)][_0x4220d0(0xd3)],'certificateUrl':_0x58c08e[_0x4220d0(0xd2)]+_0x4220d0(0xc9)};}function withPort(_0x3bb38d,_0x583f96){const _0x44e0ee=a10_0x963e,_0x1179c1=new URL(_0x3bb38d);return _0x1179c1[_0x44e0ee(0xce)]=String(_0x583f96),_0x1179c1[_0x44e0ee(0xd3)];}export async function authServer(_0x226ef0){const _0x572d31=a10_0x963e,_0x4e5e35=_0x226ef0?.[_0x572d31(0xfa)]||![],_0x27e366=_0x226ef0?.[_0x572d31(0xee)]??!![],_0x6166e=_0x226ef0?.[_0x572d31(0xd1)]??AUTH_LOGIN_TIMEOUT_MS;if(await getIsSessionValid())return!![];const _0x31386f=resolveAuthCallbackRouting(),_0x518b8c=_0x31386f[_0x572d31(0xdf)]?await(await fetch(_0x31386f[_0x572d31(0xdf)]))[_0x572d31(0xe0)]():undefined;return new Promise(async(_0x1ba1eb,_0x184c6d)=>{const _0x483e4b=_0x572d31;let _0x51e56f=0x0,_0x30c635=![],_0x2c1365;const _0x23b02c=async(_0x1a4b7c,_0x1ed5be)=>{const _0x1e79f2=a10_0x963e,_0x38206a=getUserDomain(),_0x5ec7b5=_0x1a4b7c[_0x1e79f2(0xd0)][_0x1e79f2(0xde)]||'',_0x54aa31=await fetch(_0x38206a+_0x1e79f2(0xdc),{'headers':{'cookie':_0x5ec7b5}})[_0x1e79f2(0xd9)](_0x737891=>_0x737891[_0x1e79f2(0xe0)]()),_0x3b9f90=_0x54aa31&&_0x54aa31[_0x1e79f2(0xf6)]&&_0x54aa31[_0x1e79f2(0xdd)];if(_0x3b9f90){writeFileSync(cookieFile,_0x5ec7b5,_0x1e79f2(0xcc));const _0x328233=buildLoginSuccessHtml();_0x1ed5be[_0x1e79f2(0xd7)](0xc8,{'Content-Type':_0x1e79f2(0xe4)}),_0x1ed5be[_0x1e79f2(0xea)](_0x328233),_0x2881c8(!![]);}else{const _0xe5dd3d=encodeURIComponent(withPort(_0x31386f[_0x1e79f2(0xd3)],_0x51e56f));_0x1ed5be[_0x1e79f2(0xd7)](0x12e,{'location':_0x38206a+_0x1e79f2(0xef)+_0xe5dd3d}),_0x1ed5be[_0x1e79f2(0xea)]();return;}},_0x24afd4=_0x518b8c?a10_0x4d958d[_0x483e4b(0xd8)](_0x518b8c,_0x23b02c):a10_0x378902[_0x483e4b(0xd8)](_0x23b02c);function _0x2881c8(_0x35bc47){const _0x7cde95=_0x483e4b;if(_0x30c635)return;_0x30c635=!![],_0x2c1365&&clearTimeout(_0x2c1365),_0x24afd4[_0x7cde95(0xe2)](),_0x1ba1eb(_0x35bc47);}_0x24afd4['listen'](0x0,_0x483e4b(0xd5),()=>{const _0x4c3c07=_0x483e4b,_0x4f03cf=_0x24afd4['address']();_0x51e56f=typeof _0x4f03cf===_0x4c3c07(0xca)&&_0x4f03cf?_0x4f03cf[_0x4c3c07(0xce)]:Number(_0x4f03cf);const _0x441e4f=withPort(_0x31386f['origin'],_0x51e56f);_0x2c1365=setTimeout(()=>{const _0x28751=_0x4c3c07;!_0x4e5e35&&console['log'](_0x28751(0xcd)),_0x2881c8(![]);},_0x6166e);!_0x4e5e35&&(console[_0x4c3c07(0xf3)](_0x4c3c07(0xcb)),console['log'](_0x4c3c07(0xf2),_0x441e4f),_0x27e366?(console['log']('🌐\x20Attempting\x20to\x20open\x20browser\x20automatically...'),console[_0x4c3c07(0xf3)](''),console[_0x4c3c07(0xf3)](_0x4c3c07(0xe3))):console[_0x4c3c07(0xf3)](_0x4c3c07(0xe6)),console[_0x4c3c07(0xf3)](''));if(!_0x27e366)return;openInBrowser(_0x441e4f)['then'](_0x13670e=>{const _0x22ebb6=_0x4c3c07;!_0x4e5e35&&(_0x13670e?console[_0x22ebb6(0xf3)]('✅\x20Browser\x20opened.\x20Please\x20complete\x20login\x20in\x20the\x20browser.'):(console[_0x22ebb6(0xf3)](_0x22ebb6(0xe5)),console[_0x22ebb6(0xf3)](_0x22ebb6(0xed),_0x441e4f)),console['log'](''));})['catch'](()=>{const _0x27ca2e=_0x4c3c07;!_0x4e5e35&&(console[_0x27ca2e(0xf3)]('⚠️\x20\x20Failed\x20to\x20open\x20browser\x20automatically'),console['log'](_0x27ca2e(0xed),_0x441e4f),console['log'](''));});}),_0x24afd4['on'](_0x483e4b(0xd6),_0x214a8d=>{const _0x47a3f3=_0x483e4b;if(_0x30c635)return;_0x30c635=!![],_0x2c1365&&clearTimeout(_0x2c1365),!_0x4e5e35&&console[_0x47a3f3(0xd6)](_0x47a3f3(0xc8),_0x214a8d),_0x24afd4[_0x47a3f3(0xe2)](),_0x184c6d(_0x214a8d);});});}function openInBrowser(_0x2abc0d){return new Promise(_0x4d16f9=>{const _0x59c537=a10_0x963e,_0x39bf7c=process[_0x59c537(0xe7)];let _0x48961b;if(_0x39bf7c===_0x59c537(0xcf))_0x48961b='cmd\x20/c\x20start\x20\x22\x22\x20\x22'+_0x2abc0d+'\x22';else _0x39bf7c==='darwin'?_0x48961b=_0x59c537(0xeb)+_0x2abc0d+'\x22':_0x48961b='xdg-open\x20\x22'+_0x2abc0d+'\x22';exec(_0x48961b,_0x4c33b3=>{_0x4c33b3?_0x4d16f9(![]):_0x4d16f9(!![]);});});}if(import.meta.main){const isAuth=await authServer();console[a10_0x1a555b(0xf3)](a10_0x1a555b(0xf1),isAuth);}
1
+ import{writeFileSync}from"node:fs";import http from"node:http";import https from"node:https";import{getUserDomain}from"../constant/domain.js";import{getOfficialRoutingCdn,getOfficialRoutingProfile}from"../constant/routing-profile.js";import{getProjectDomainRoutingManifest}from"../config/project-domain-routing.js";import{exec}from"node:child_process";import{getIsSessionValid}from"../auth/is-session-valid.js";import{cookieFile}from"../auth/constant.js";import{buildLoginSuccessHtml}from"../auth/login-success-html.js";export const AUTH_LOGIN_TIMEOUT_MS=10*60*1e3;export function resolveAuthCallbackRouting(region){if(!region)return getProjectDomainRoutingManifest().local;const profile=getOfficialRoutingProfile(region);const cdn=getOfficialRoutingCdn(region);return{origin:profile.local.origin,certificateUrl:`${cdn.lovrabet}/cert/lovrabet-dev.json`}}function withPort(origin,port){const url=new URL(origin);url.port=String(port);return url.origin}export async function authServer(params){
2
+ const silent=params?.silent||false;const openBrowser=params?.openBrowser??true;const timeoutMs=params?.timeoutMs??AUTH_LOGIN_TIMEOUT_MS;if(await getIsSessionValid()){return true}const callbackRouting=resolveAuthCallbackRouting();const ssl=callbackRouting.certificateUrl?await(await fetch(callbackRouting.certificateUrl)).json():undefined;return new Promise(async(resolve,reject)=>{let port=0;let settled=false;let timeout;const handleRequest=async(req,res)=>{const userDomain=getUserDomain();const cookie=req.headers.cookie||"";const session=await fetch(`${userDomain}/api/auth/get-session`,{headers:{cookie:cookie}}).then(r=>r.json());const isSuccess=session&&session.session&&session.user;if(isSuccess){writeFileSync(cookieFile,cookie,"utf-8");const html=buildLoginSuccessHtml();res.writeHead(200,{"Content-Type":"text/html; charset=utf-8"});res.end(html);finish(true)}else{const redirect=encodeURIComponent(withPort(callbackRouting.origin,port));res.writeHead(302,{
3
+ location:`${userDomain}/sign-in?redirect=${redirect}`});res.end();return}};const server=ssl?https.createServer(ssl,handleRequest):http.createServer(handleRequest);function finish(success){if(settled)return;settled=true;if(timeout){clearTimeout(timeout)}server.close();resolve(success)}server.listen(0,"127.0.0.1",()=>{const addr=server.address();port=typeof addr==="object"&&addr?addr.port:Number(addr);const loginUrl=withPort(callbackRouting.origin,port);timeout=setTimeout(()=>{if(!silent){console.log("! Login URL expired after 10 minutes. Run the login command again to get a new URL.")}finish(false)},timeoutMs);if(!silent){console.log("🔐 Starting login service...");console.log("📍 Login URL:",loginUrl);if(openBrowser){console.log("🌐 Attempting to open browser automatically...");console.log("");console.log("💡 If the browser does not open automatically, copy the login URL above into your browser.")}else{
4
+ console.log("💡 Open the login URL above in your browser to complete authorization.")}console.log("")}if(!openBrowser){return}openInBrowser(loginUrl).then(success=>{if(!silent){if(success){console.log("✅ Browser opened. Please complete login in the browser.")}else{console.log("⚠️ Failed to open browser automatically");console.log("🔗 Please copy the login URL into your browser:",loginUrl)}console.log("")}}).catch(()=>{if(!silent){console.log("⚠️ Failed to open browser automatically");console.log("🔗 Please copy the login URL into your browser:",loginUrl);console.log("")}})});server.on("error",e=>{if(settled)return;settled=true;if(timeout){clearTimeout(timeout)}if(!silent){console.error("Auth server error:",e)}server.close();reject(e)})})}function openInBrowser(url){return new Promise(resolve=>{const platform=process.platform;let cmd;if(platform==="win32"){cmd=`cmd /c start "" "${url}"`}else if(platform==="darwin"){cmd=`open "${url}"`}else{cmd=`xdg-open "${url}"`}exec(cmd,err=>{
5
+ if(err){resolve(false)}else{resolve(true)}})})}if(import.meta.main){const isAuth=await authServer();console.log("isAuth",isAuth)}
@@ -1 +1 @@
1
- const a11_0x13e506=a11_0x172b;(function(_0x5a74bd,_0x572929){const _0x4d2608=a11_0x172b,_0x4b3b5e=_0x5a74bd();while(!![]){try{const _0x384236=parseInt(_0x4d2608(0x17b))/0x1+-parseInt(_0x4d2608(0x176))/0x2*(-parseInt(_0x4d2608(0x175))/0x3)+parseInt(_0x4d2608(0x173))/0x4+-parseInt(_0x4d2608(0x179))/0x5+-parseInt(_0x4d2608(0x177))/0x6*(parseInt(_0x4d2608(0x17a))/0x7)+parseInt(_0x4d2608(0x17c))/0x8+parseInt(_0x4d2608(0x174))/0x9;if(_0x384236===_0x572929)break;else _0x4b3b5e['push'](_0x4b3b5e['shift']());}catch(_0x49fcf1){_0x4b3b5e['push'](_0x4b3b5e['shift']());}}}(a11_0x8bc8,0xa6f0e));import{mkdirSync}from'node:fs';import{homedir}from'node:os';import{join}from'node:path';export const configDir=join(homedir(),a11_0x13e506(0x172));function a11_0x172b(_0x495b65,_0x15fd28){_0x495b65=_0x495b65-0x172;const _0x8bc82b=a11_0x8bc8();let _0x172bf3=_0x8bc82b[_0x495b65];return _0x172bf3;}export const cookieFile=join(configDir,a11_0x13e506(0x178));mkdirSync(configDir,{'recursive':!![]});function a11_0x8bc8(){const _0x1e2f2f=['1158FlHrFu','cookie','2325965FfwSfI','13958zlusyq','771953XkmvRC','3108400KhogkG','.lovrabet','17824SzWfkC','1670103wqipBy','3HAzliJ','366598NqPvKV'];a11_0x8bc8=function(){return _0x1e2f2f;};return a11_0x8bc8();}
1
+ import{mkdirSync}from"node:fs";import{homedir}from"node:os";import{join}from"node:path";export const configDir=join(homedir(),".lovrabet");export const cookieFile=join(configDir,"cookie");mkdirSync(configDir,{recursive:true});
@@ -1 +1 @@
1
- (function(_0x36b05d,_0x49e62a){var _0x2507f6=a12_0x5e6e,_0x1bcbee=_0x36b05d();while(!![]){try{var _0x41b9fe=-parseInt(_0x2507f6(0x14f))/0x1*(-parseInt(_0x2507f6(0x14d))/0x2)+parseInt(_0x2507f6(0x154))/0x3+-parseInt(_0x2507f6(0x14c))/0x4+-parseInt(_0x2507f6(0x150))/0x5*(-parseInt(_0x2507f6(0x152))/0x6)+-parseInt(_0x2507f6(0x14e))/0x7*(parseInt(_0x2507f6(0x14a))/0x8)+-parseInt(_0x2507f6(0x153))/0x9+parseInt(_0x2507f6(0x14b))/0xa*(parseInt(_0x2507f6(0x151))/0xb);if(_0x41b9fe===_0x49e62a)break;else _0x1bcbee['push'](_0x1bcbee['shift']());}catch(_0x4b60da){_0x1bcbee['push'](_0x1bcbee['shift']());}}}(a12_0x36d8,0x2dc9a));function a12_0x5e6e(_0x2a240d,_0x16cab5){_0x2a240d=_0x2a240d-0x14a;var _0x36d8bc=a12_0x36d8();var _0x5e6ee0=_0x36d8bc[_0x2a240d];return _0x5e6ee0;}import{readFileSync}from'node:fs';import{cookieFile}from'../auth/constant.js';export function getCookie(){try{return readFileSync(cookieFile,'utf-8');}catch{}return'';}function a12_0x36d8(){var _0x1e507b=['3028023VYLmOu','385986LSFqNa','111968VdzwfC','40YvEmMY','1226544FeVram','4176ewgOqz','147XBJcXO','73IZMWwG','1195QrBkbb','2008633IODSsn','2838mxdzGC'];a12_0x36d8=function(){return _0x1e507b;};return a12_0x36d8();}
1
+ import{readFileSync}from"node:fs";import{cookieFile}from"../auth/constant.js";export function getCookie(){try{return readFileSync(cookieFile,"utf-8")}catch{}return""}
@@ -1 +1 @@
1
- function a13_0x88d8(_0x10ede1,_0x2f172f){_0x10ede1=_0x10ede1-0x10c;const _0x71771b=a13_0x7177();let _0x88d8fd=_0x71771b[_0x10ede1];return _0x88d8fd;}function a13_0x7177(){const _0x51e8df=['json','216ZPRIHH','10lVqTKE','1248201gsSuUI','user','214506NProkB','1167728VYdzfq','36BPGJAG','932246SPCHKw','901402KoJVIs','session','6888244LjgEKa','utf-8','/api/auth/get-session','5Lzddos','2097436XblSxW'];a13_0x7177=function(){return _0x51e8df;};return a13_0x7177();}(function(_0x4100b9,_0x52e8d4){const _0x507cbd=a13_0x88d8,_0x4252b7=_0x4100b9();while(!![]){try{const _0x4f3701=parseInt(_0x507cbd(0x115))/0x1+-parseInt(_0x507cbd(0x112))/0x2+parseInt(_0x507cbd(0x10f))/0x3+parseInt(_0x507cbd(0x11b))/0x4*(parseInt(_0x507cbd(0x11a))/0x5)+parseInt(_0x507cbd(0x113))/0x6*(parseInt(_0x507cbd(0x114))/0x7)+-parseInt(_0x507cbd(0x10d))/0x8*(parseInt(_0x507cbd(0x111))/0x9)+-parseInt(_0x507cbd(0x10e))/0xa*(parseInt(_0x507cbd(0x117))/0xb);if(_0x4f3701===_0x52e8d4)break;else _0x4252b7['push'](_0x4252b7['shift']());}catch(_0x23881d){_0x4252b7['push'](_0x4252b7['shift']());}}}(a13_0x7177,0xc036e));import{existsSync,readFileSync}from'node:fs';import{getUserDomain}from'../constant/domain.js';import{cookieFile}from'../auth/constant.js';export async function getSessionUserInfo(_0x3c4a1d){const _0x32a154=a13_0x88d8;try{if(_0x3c4a1d===undefined){if(!existsSync(cookieFile))return null;_0x3c4a1d=readFileSync(cookieFile,_0x32a154(0x118));}if(!_0x3c4a1d)return null;const _0xda827f=await fetch(getUserDomain()+_0x32a154(0x119),{'headers':{'cookie':_0x3c4a1d}});if(!_0xda827f['ok'])return null;const _0x5a96b4=await _0xda827f[_0x32a154(0x10c)]();if(!_0x5a96b4[_0x32a154(0x116)]||!_0x5a96b4[_0x32a154(0x110)])return null;return _0x5a96b4;}catch{return null;}}
1
+ import{existsSync,readFileSync}from"node:fs";import{getUserDomain}from"../constant/domain.js";import{cookieFile}from"../auth/constant.js";export async function getSessionUserInfo(cookie){try{if(cookie===undefined){if(!existsSync(cookieFile))return null;cookie=readFileSync(cookieFile,"utf-8")}if(!cookie)return null;const res=await fetch(`${getUserDomain()}/api/auth/get-session`,{headers:{cookie:cookie}});if(!res.ok){return null}const body=await res.json();if(!body.session||!body.user){return null}return body}catch{return null}}
@@ -1 +1 @@
1
- (function(_0x10e56f,_0x3bf7e3){const _0x2f1921=a14_0x19cb,_0x2ded12=_0x10e56f();while(!![]){try{const _0x21d87a=parseInt(_0x2f1921(0x1c5))/0x1+-parseInt(_0x2f1921(0x1cc))/0x2+-parseInt(_0x2f1921(0x1c0))/0x3+parseInt(_0x2f1921(0x1c6))/0x4+-parseInt(_0x2f1921(0x1bf))/0x5+parseInt(_0x2f1921(0x1ca))/0x6*(-parseInt(_0x2f1921(0x1c4))/0x7)+parseInt(_0x2f1921(0x1c1))/0x8*(parseInt(_0x2f1921(0x1c7))/0x9);if(_0x21d87a===_0x3bf7e3)break;else _0x2ded12['push'](_0x2ded12['shift']());}catch(_0xba8e0c){_0x2ded12['push'](_0x2ded12['shift']());}}}(a14_0x13f8,0x8baa6));function a14_0x19cb(_0x39f600,_0x170ebb){_0x39f600=_0x39f600-0x1bf;const _0x13f8d6=a14_0x13f8();let _0x19cb6d=_0x13f8d6[_0x39f600];return _0x19cb6d;}function a14_0x13f8(){const _0xc5306d=['13250007ASfKWS','user','json','108alrMfg','utf-8','1522288mGIhsR','/api/auth/get-session','662015QdMIAx','1226358iYQQgs','8gtPPPN','session','then','441581gRVdFf','1109054CFVQkp','1714480qZJStI'];a14_0x13f8=function(){return _0xc5306d;};return a14_0x13f8();}import{existsSync,readFileSync}from'node:fs';import{getUserDomain}from'../constant/domain.js';import{cookieFile}from'../auth/constant.js';export async function getIsSessionValid(){const _0x395192=a14_0x19cb;try{if(!existsSync(cookieFile))return![];const _0x17145c=readFileSync(cookieFile,_0x395192(0x1cb)),_0x33c0a3=await fetch(getUserDomain()+_0x395192(0x1cd),{'headers':{'cookie':_0x17145c}})[_0x395192(0x1c3)](_0x510bba=>_0x510bba[_0x395192(0x1c9)]());return _0x33c0a3&&_0x33c0a3[_0x395192(0x1c2)]&&_0x33c0a3[_0x395192(0x1c8)];}catch{}return![];}
1
+ import{existsSync,readFileSync}from"node:fs";import{getUserDomain}from"../constant/domain.js";import{cookieFile}from"../auth/constant.js";export async function getIsSessionValid(){try{if(!existsSync(cookieFile)){return false}const cookie=readFileSync(cookieFile,"utf-8");const session=await fetch(`${getUserDomain()}/api/auth/get-session`,{headers:{cookie:cookie}}).then(r=>r.json());return session&&session.session&&session.user}catch{}return false}
@@ -1 +1,3 @@
1
- function a15_0x306e(){const _0x4919ab=['155812rUnLze','6275796HknDco','1911189JhnBtp','</div>\x0a\x20\x20\x20\x20<p\x20class=\x22cli-hint\x22>Rabetbase\x20CLI\x20·\x20session\x20saved\x20locally</p>\x0a\x20\x20</div>\x0a\x20\x20<script>\x0a\x20\x20(function(){\x0a\x20\x20\x20\x20var\x20t\x20=\x205;\x0a\x20\x20\x20\x20var\x20el\x20=\x20document.getElementById(\x27t\x27);\x0a\x20\x20\x20\x20var\x20manual\x20=\x20document.getElementById(\x27manualMsg\x27);\x0a\x20\x20\x20\x20var\x20id\x20=\x20setInterval(function(){\x0a\x20\x20\x20\x20\x20\x20t--;\x0a\x20\x20\x20\x20\x20\x20if\x20(t\x20<=\x200)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20clearInterval(id);\x0a\x20\x20\x20\x20\x20\x20\x20\x20el.textContent\x20=\x20\x270\x27;\x0a\x20\x20\x20\x20\x20\x20\x20\x20try\x20{\x20window.close();\x20}\x20catch(e)\x20{}\x0a\x20\x20\x20\x20\x20\x20\x20\x20setTimeout(function(){\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20if\x20(!window.closed)\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20manual.style.display\x20=\x20\x27block\x27;\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20\x20\x20\x20\x20},\x20300);\x0a\x20\x20\x20\x20\x20\x20}\x20else\x20{\x0a\x20\x20\x20\x20\x20\x20\x20\x20el.textContent\x20=\x20String(t);\x0a\x20\x20\x20\x20\x20\x20}\x0a\x20\x20\x20\x20},\x201000);\x0a\x20\x20})();\x0a\x20\x20</script>\x0a</body>\x0a</html>','3VxWDPd','<!doctype\x20html>\x0a<html\x20lang=\x22en\x22>\x0a<head>\x0a\x20\x20<meta\x20charset=\x22utf-8\x22>\x0a\x20\x20<meta\x20name=\x22viewport\x22\x20content=\x22width=device-width,\x20initial-scale=1\x22>\x0a\x20\x20<title>Login\x20successful\x20·\x20Rabetbase\x20CLI</title>\x0a\x20\x20<style>\x0a\x20\x20\x20\x20:root\x20{\x0a\x20\x20\x20\x20\x20\x20--bg0:\x20#0f1419;\x0a\x20\x20\x20\x20\x20\x20--bg1:\x20#1a2332;\x0a\x20\x20\x20\x20\x20\x20--card:\x20#ffffff;\x0a\x20\x20\x20\x20\x20\x20--text:\x20#1c2128;\x0a\x20\x20\x20\x20\x20\x20--muted:\x20#5c6570;\x0a\x20\x20\x20\x20\x20\x20--accent:\x20#2563eb;\x0a\x20\x20\x20\x20\x20\x20--accent-soft:\x20#eff6ff;\x0a\x20\x20\x20\x20\x20\x20--success:\x20#059669;\x0a\x20\x20\x20\x20\x20\x20--radius:\x2016px;\x0a\x20\x20\x20\x20\x20\x20--shadow:\x200\x2025px\x2050px\x20-12px\x20rgba(15,\x2020,\x2025,\x200.35);\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20*\x20{\x20box-sizing:\x20border-box;\x20}\x0a\x20\x20\x20\x20body\x20{\x0a\x20\x20\x20\x20\x20\x20margin:\x200;\x0a\x20\x20\x20\x20\x20\x20min-height:\x20100vh;\x0a\x20\x20\x20\x20\x20\x20display:\x20flex;\x0a\x20\x20\x20\x20\x20\x20align-items:\x20center;\x0a\x20\x20\x20\x20\x20\x20justify-content:\x20center;\x0a\x20\x20\x20\x20\x20\x20padding:\x2024px;\x0a\x20\x20\x20\x20\x20\x20font-family:\x20ui-sans-serif,\x20system-ui,\x20-apple-system,\x20\x22Segoe\x20UI\x22,\x20Roboto,\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x22Helvetica\x20Neue\x22,\x20Arial,\x20\x22Noto\x20Sans\x22,\x20\x22PingFang\x20SC\x22,\x20\x22Microsoft\x20YaHei\x22,\x20sans-serif;\x0a\x20\x20\x20\x20\x20\x20background:\x20linear-gradient(160deg,\x20var(--bg0)\x200%,\x20var(--bg1)\x2045%,\x20#243047\x20100%);\x0a\x20\x20\x20\x20\x20\x20color:\x20var(--text);\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20.card\x20{\x0a\x20\x20\x20\x20\x20\x20width:\x20100%;\x0a\x20\x20\x20\x20\x20\x20max-width:\x20420px;\x0a\x20\x20\x20\x20\x20\x20background:\x20var(--card);\x0a\x20\x20\x20\x20\x20\x20border-radius:\x20var(--radius);\x0a\x20\x20\x20\x20\x20\x20box-shadow:\x20var(--shadow);\x0a\x20\x20\x20\x20\x20\x20padding:\x2040px\x2036px\x2032px;\x0a\x20\x20\x20\x20\x20\x20text-align:\x20center;\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20.icon\x20{\x0a\x20\x20\x20\x20\x20\x20width:\x2064px;\x0a\x20\x20\x20\x20\x20\x20height:\x2064px;\x0a\x20\x20\x20\x20\x20\x20margin:\x200\x20auto\x2020px;\x0a\x20\x20\x20\x20\x20\x20border-radius:\x2050%;\x0a\x20\x20\x20\x20\x20\x20background:\x20var(--accent-soft);\x0a\x20\x20\x20\x20\x20\x20display:\x20flex;\x0a\x20\x20\x20\x20\x20\x20align-items:\x20center;\x0a\x20\x20\x20\x20\x20\x20justify-content:\x20center;\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20.icon\x20svg\x20{\x20width:\x2036px;\x20height:\x2036px;\x20}\x0a\x20\x20\x20\x20h1\x20{\x0a\x20\x20\x20\x20\x20\x20margin:\x200\x200\x2012px;\x0a\x20\x20\x20\x20\x20\x20font-size:\x201.375rem;\x0a\x20\x20\x20\x20\x20\x20font-weight:\x20600;\x0a\x20\x20\x20\x20\x20\x20letter-spacing:\x20-0.02em;\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20p.lead\x20{\x0a\x20\x20\x20\x20\x20\x20margin:\x200\x200\x208px;\x0a\x20\x20\x20\x20\x20\x20font-size:\x200.9375rem;\x0a\x20\x20\x20\x20\x20\x20color:\x20var(--muted);\x0a\x20\x20\x20\x20\x20\x20line-height:\x201.55;\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20.countdown\x20{\x0a\x20\x20\x20\x20\x20\x20display:\x20inline-flex;\x0a\x20\x20\x20\x20\x20\x20align-items:\x20center;\x0a\x20\x20\x20\x20\x20\x20gap:\x206px;\x0a\x20\x20\x20\x20\x20\x20margin-top:\x2016px;\x0a\x20\x20\x20\x20\x20\x20padding:\x208px\x2014px;\x0a\x20\x20\x20\x20\x20\x20font-size:\x200.875rem;\x0a\x20\x20\x20\x20\x20\x20font-variant-numeric:\x20tabular-nums;\x0a\x20\x20\x20\x20\x20\x20color:\x20var(--accent);\x0a\x20\x20\x20\x20\x20\x20background:\x20var(--accent-soft);\x0a\x20\x20\x20\x20\x20\x20border-radius:\x20999px;\x0a\x20\x20\x20\x20\x20\x20font-weight:\x20500;\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20#manualMsg\x20{\x0a\x20\x20\x20\x20\x20\x20display:\x20none;\x0a\x20\x20\x20\x20\x20\x20margin-top:\x2020px;\x0a\x20\x20\x20\x20\x20\x20font-size:\x200.8125rem;\x0a\x20\x20\x20\x20\x20\x20color:\x20#b91c1c;\x0a\x20\x20\x20\x20\x20\x20line-height:\x201.45;\x0a\x20\x20\x20\x20}\x0a\x20\x20\x20\x20.cli-hint\x20{\x0a\x20\x20\x20\x20\x20\x20margin-top:\x2028px;\x0a\x20\x20\x20\x20\x20\x20padding-top:\x2024px;\x0a\x20\x20\x20\x20\x20\x20border-top:\x201px\x20solid\x20#e8ecf0;\x0a\x20\x20\x20\x20\x20\x20font-size:\x200.75rem;\x0a\x20\x20\x20\x20\x20\x20color:\x20#8b949e;\x0a\x20\x20\x20\x20}\x0a\x20\x20</style>\x0a</head>\x0a<body>\x0a\x20\x20<div\x20class=\x22card\x22\x20role=\x22status\x22\x20aria-live=\x22polite\x22>\x0a\x20\x20\x20\x20<div\x20class=\x22icon\x22\x20aria-hidden=\x22true\x22>\x0a\x20\x20\x20\x20\x20\x20<svg\x20viewBox=\x220\x200\x2024\x2024\x22\x20fill=\x22none\x22\x20xmlns=\x22http://www.w3.org/2000/svg\x22>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<circle\x20cx=\x2212\x22\x20cy=\x2212\x22\x20r=\x2210\x22\x20stroke=\x22#059669\x22\x20stroke-width=\x222\x22\x20fill=\x22none\x22/>\x0a\x20\x20\x20\x20\x20\x20\x20\x20<path\x20d=\x22M8\x2012.5l2.5\x202.5L16\x209\x22\x20stroke=\x22#059669\x22\x20stroke-width=\x222\x22\x20stroke-linecap=\x22round\x22\x20stroke-linejoin=\x22round\x22/>\x0a\x20\x20\x20\x20\x20\x20</svg>\x0a\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20<h1>Login\x20successful</h1>\x0a\x20\x20\x20\x20<p\x20class=\x22lead\x22>You\x20can\x20return\x20to\x20the\x20terminal\x20to\x20continue.\x20This\x20window\x20will\x20try\x20to\x20close\x20automatically.</p>\x0a\x20\x20\x20\x20<div\x20class=\x22countdown\x22>\x0a\x20\x20\x20\x20\x20\x20Closing\x20in\x20<span\x20id=\x22t\x22>5</span>s\x0a\x20\x20\x20\x20</div>\x0a\x20\x20\x20\x20<div\x20id=\x22manualMsg\x22>','2053089yqoBNo','5ewmMFe','278402bpNvmr','10HDFCzo','902744bpOfRq','Unable\x20to\x20close\x20automatically.\x20Please\x20close\x20this\x20tab\x20or\x20window\x20manually.','493720fsniUE'];a15_0x306e=function(){return _0x4919ab;};return a15_0x306e();}function a15_0x4ad9(_0x232206,_0x2dbb3f){_0x232206=_0x232206-0x1d8;const _0x306e58=a15_0x306e();let _0x4ad989=_0x306e58[_0x232206];return _0x4ad989;}(function(_0x131970,_0xe1453b){const _0x1235d2=a15_0x4ad9,_0x3a5c0a=_0x131970();while(!![]){try{const _0x3ef530=-parseInt(_0x1235d2(0x1e2))/0x1+-parseInt(_0x1235d2(0x1e4))/0x2*(-parseInt(_0x1235d2(0x1de))/0x3)+-parseInt(_0x1235d2(0x1da))/0x4*(-parseInt(_0x1235d2(0x1e1))/0x5)+parseInt(_0x1235d2(0x1db))/0x6+-parseInt(_0x1235d2(0x1dc))/0x7+parseInt(_0x1235d2(0x1d9))/0x8+parseInt(_0x1235d2(0x1e0))/0x9*(-parseInt(_0x1235d2(0x1e3))/0xa);if(_0x3ef530===_0xe1453b)break;else _0x3a5c0a['push'](_0x3a5c0a['shift']());}catch(_0x166c9d){_0x3a5c0a['push'](_0x3a5c0a['shift']());}}}(a15_0x306e,0xc7d18));export function buildLoginSuccessHtml(){const _0x1431dc=a15_0x4ad9,_0x204f2c=_0x1431dc(0x1d8);return _0x1431dc(0x1df)+_0x204f2c+_0x1431dc(0x1dd);}
1
+ export function buildLoginSuccessHtml(){const manualClose="Unable to close automatically. Please close this tab or window manually."
2
+ ;return`<!doctype html>\n<html lang="en">\n<head>\n <meta charset="utf-8">\n <meta name="viewport" content="width=device-width, initial-scale=1">\n <title>Login successful · Rabetbase CLI</title>\n <style>\n :root {\n --bg0: #0f1419;\n --bg1: #1a2332;\n --card: #ffffff;\n --text: #1c2128;\n --muted: #5c6570;\n --accent: #2563eb;\n --accent-soft: #eff6ff;\n --success: #059669;\n --radius: 16px;\n --shadow: 0 25px 50px -12px rgba(15, 20, 25, 0.35);\n }\n * { box-sizing: border-box; }\n body {\n margin: 0;\n min-height: 100vh;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: 24px;\n font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,\n "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif;\n background: linear-gradient(160deg, var(--bg0) 0%, var(--bg1) 45%, #243047 100%);\n color: var(--text);\n }\n .card {\n width: 100%;\n max-width: 420px;\n background: var(--card);\n border-radius: var(--radius);\n box-shadow: var(--shadow);\n padding: 40px 36px 32px;\n text-align: center;\n }\n .icon {\n width: 64px;\n height: 64px;\n margin: 0 auto 20px;\n border-radius: 50%;\n background: var(--accent-soft);\n display: flex;\n align-items: center;\n justify-content: center;\n }\n .icon svg { width: 36px; height: 36px; }\n h1 {\n margin: 0 0 12px;\n font-size: 1.375rem;\n font-weight: 600;\n letter-spacing: -0.02em;\n }\n p.lead {\n margin: 0 0 8px;\n font-size: 0.9375rem;\n color: var(--muted);\n line-height: 1.55;\n }\n .countdown {\n display: inline-flex;\n align-items: center;\n gap: 6px;\n margin-top: 16px;\n padding: 8px 14px;\n font-size: 0.875rem;\n font-variant-numeric: tabular-nums;\n color: var(--accent);\n background: var(--accent-soft);\n border-radius: 999px;\n font-weight: 500;\n }\n #manualMsg {\n display: none;\n margin-top: 20px;\n font-size: 0.8125rem;\n color: #b91c1c;\n line-height: 1.45;\n }\n .cli-hint {\n margin-top: 28px;\n padding-top: 24px;\n border-top: 1px solid #e8ecf0;\n font-size: 0.75rem;\n color: #8b949e;\n }\n </style>\n</head>\n<body>\n <div class="card" role="status" aria-live="polite">\n <div class="icon" aria-hidden="true">\n <svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">\n <circle cx="12" cy="12" r="10" stroke="#059669" stroke-width="2" fill="none"/>\n <path d="M8 12.5l2.5 2.5L16 9" stroke="#059669" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>\n </svg>\n </div>\n <h1>Login successful</h1>\n <p class="lead">You can return to the terminal to continue. This window will try to close automatically.</p>\n <div class="countdown">\n Closing in <span id="t">5</span>s\n </div>\n <div id="manualMsg">${manualClose}</div>\n <p class="cli-hint">Rabetbase CLI · session saved locally</p>\n </div>\n <script>\n (function(){\n var t = 5;\n var el = document.getElementById('t');\n var manual = document.getElementById('manualMsg');\n var id = setInterval(function(){\n t--;\n if (t <= 0) {\n clearInterval(id);\n el.textContent = '0';\n try { window.close(); } catch(e) {}\n setTimeout(function(){\n if (!window.closed) {\n manual.style.display = 'block';\n }\n }, 300);\n } else {\n el.textContent = String(t);\n }\n }, 1000);\n })();\n <\/script>\n</body>\n</html>`
3
+ }
@@ -1 +1 @@
1
- (function(_0x31d154,_0x2b430c){var _0x23e873=a16_0x49e7,_0x3f0d96=_0x31d154();while(!![]){try{var _0x2dc466=parseInt(_0x23e873(0xeb))/0x1+parseInt(_0x23e873(0xed))/0x2*(parseInt(_0x23e873(0xee))/0x3)+parseInt(_0x23e873(0xf0))/0x4+parseInt(_0x23e873(0xef))/0x5+-parseInt(_0x23e873(0xf1))/0x6+-parseInt(_0x23e873(0xf2))/0x7+parseInt(_0x23e873(0xea))/0x8*(-parseInt(_0x23e873(0xec))/0x9);if(_0x2dc466===_0x2b430c)break;else _0x3f0d96['push'](_0x3f0d96['shift']());}catch(_0xde57a0){_0x3f0d96['push'](_0x3f0d96['shift']());}}}(a16_0x237b,0x6bd0b));import{unlinkSync,existsSync}from'node:fs';import{cookieFile}from'../auth/constant.js';function a16_0x49e7(_0x5283be,_0x50508a){_0x5283be=_0x5283be-0xe8;var _0x237bd9=a16_0x237b();var _0x49e721=_0x237bd9[_0x5283be];return _0x49e721;}export function logout(){var _0x1e69ad=a16_0x49e7;existsSync(cookieFile)?(unlinkSync(cookieFile),console[_0x1e69ad(0xe9)]('✓\x20Logged\x20out')):console['log'](_0x1e69ad(0xe8));}function a16_0x237b(){var _0x5ca9fc=['1321792Sgadwo','2642406hreGzl','4156383UowuMV','!\x20Not\x20logged\x20in','log','32CHkwWg','268734dOXSez','122427WpFtQb','512wAvEIj','4554AjcrGb','2712015bIuakI'];a16_0x237b=function(){return _0x5ca9fc;};return a16_0x237b();}
1
+ import{unlinkSync,existsSync}from"node:fs";import{cookieFile}from"../auth/constant.js";export function logout(){if(existsSync(cookieFile)){unlinkSync(cookieFile);console.log("✓ Logged out")}else{console.log("! Not logged in")}}
package/lib/cli-flags.js CHANGED
@@ -1 +1 @@
1
- function a17_0x4978(_0x1bb62e,_0x87037c){_0x1bb62e=_0x1bb62e-0x1aa;const _0x56fab3=a17_0x56fa();let _0x49789b=_0x56fab3[_0x1bb62e];return _0x49789b;}function a17_0x56fa(){const _0x3da5d0=['767338yYmCms','144zwmipM','1728llEirf','2064590ZEONlB','44332izcLds','36030ZVaoco','boolean','28906jGvsdk','91TnrPLI','225AsTypw','34960evevUj','728008HPzRly','45SiBxAr'];a17_0x56fa=function(){return _0x3da5d0;};return a17_0x56fa();}const a17_0x4a09e5=a17_0x4978;(function(_0x45d12c,_0x2cc659){const _0x142953=a17_0x4978,_0x4cc127=_0x45d12c();while(!![]){try{const _0x2e942c=-parseInt(_0x142953(0x1b2))/0x1*(parseInt(_0x142953(0x1ad))/0x2)+-parseInt(_0x142953(0x1af))/0x3*(parseInt(_0x142953(0x1aa))/0x4)+parseInt(_0x142953(0x1b6))/0x5+-parseInt(_0x142953(0x1ab))/0x6*(-parseInt(_0x142953(0x1ae))/0x7)+-parseInt(_0x142953(0x1b1))/0x8+parseInt(_0x142953(0x1b5))/0x9*(parseInt(_0x142953(0x1b0))/0xa)+-parseInt(_0x142953(0x1b3))/0xb*(-parseInt(_0x142953(0x1b4))/0xc);if(_0x2e942c===_0x2cc659)break;else _0x4cc127['push'](_0x4cc127['shift']());}catch(_0x4aa585){_0x4cc127['push'](_0x4cc127['shift']());}}}(a17_0x56fa,0x682cc));export const dynamicCliFlags={'enableBffSave':{'type':a17_0x4a09e5(0x1ac)}};
1
+ export const dynamicCliFlags={enableBffSave:{type:"boolean"}};
package/lib/cli.js CHANGED
@@ -1,2 +1,6 @@
1
1
  #!/usr/bin/env node
2
- const a18_0x5bbe9d=a18_0x2c0a;(function(_0x219f64,_0x43919d){const _0x5776d4=a18_0x2c0a,_0x35b937=_0x219f64();while(!![]){try{const _0x4ecdde=parseInt(_0x5776d4(0x157))/0x1*(parseInt(_0x5776d4(0x155))/0x2)+-parseInt(_0x5776d4(0x15e))/0x3+-parseInt(_0x5776d4(0x149))/0x4*(parseInt(_0x5776d4(0x15a))/0x5)+parseInt(_0x5776d4(0x137))/0x6+-parseInt(_0x5776d4(0x152))/0x7*(parseInt(_0x5776d4(0x15b))/0x8)+parseInt(_0x5776d4(0x136))/0x9+-parseInt(_0x5776d4(0x142))/0xa*(parseInt(_0x5776d4(0x147))/0xb);if(_0x4ecdde===_0x43919d)break;else _0x35b937['push'](_0x35b937['shift']());}catch(_0x10940a){_0x35b937['push'](_0x35b937['shift']());}}}(a18_0x3a68,0x7d6cb));import a18_0x50b077 from'meow';import{showHelp}from'./help.js';import{CliError,CliErrors}from'./errors.js';function a18_0x3a68(){const _0x487ae0=['24408LseJvt','help','49mQMCJr','./context.js','error','55ughhhd','6449968BHCDJn','def','service','507807FMNfQo','exitCode','\x0aCancelled.\x0a','6965532BsApGY','6108846mypGdz','input','now','Hint:\x20','catch','code','string','hint','ExitPromptError','command','unknown','530KmYhUh','validation','defaultCommand','format','flags','173833mJBgiP','write','23008qXINVU','risk','./cli-flags.js','slice','dynamicCliFlags','global','stderr','message','log','7CLTuwE','wildcardDef','cancelled'];a18_0x3a68=function(){return _0x487ae0;};return a18_0x3a68();}import{isKnownService,getServiceEntry,findDefinition,resolveRemovedCommand}from'./commands/registry.js';import{runCommand,createPipelineEnv}from'./framework/runner.js';import{formatCliError}from'./framework/output.js';import{resolveErrorOutputFormat,usesStructuredErrorOutput}from'./framework/error-output.js';import{generateCommandHelp,generateServiceHelp,generateFullHelp}from'./framework/help.js';import{CLI_BIN_NAME,buildMeowFlags}from'./constant/cli.js';import{VERSION,GIT_COMMIT,BUILD_TIME}from'./generated/build-info.js';import{reportCliHelpTrace}from'./telemetry/cli-help-trace.js';import{reportCommandTrace}from'./telemetry/cli-command-trace.js';import{registerOtelShutdownOnExit,exitWithOtelShutdown}from'./telemetry/register-otel-exit-shutdown.js';import{printIssueReportNudgeForError}from'./commands/issue/nudge.js';import{assertSupportedCommandFlags}from'./framework/supported-flags.js';let dynamicCliFlags=null;try{dynamicCliFlags=(await import(a18_0x5bbe9d(0x14b)))[a18_0x5bbe9d(0x14d)];}catch{}const helpText=generateFullHelp(),cliVersion=GIT_COMMIT!==a18_0x5bbe9d(0x141)?VERSION+'\x20('+GIT_COMMIT+',\x20'+BUILD_TIME[a18_0x5bbe9d(0x14c)](0x0,0xa)+')':VERSION,cli=a18_0x50b077(helpText,{'importMeta':import.meta,'version':cliVersion,'flags':{...buildMeowFlags(),...dynamicCliFlags||{}}});registerOtelShutdownOnExit(),await run()[a18_0x5bbe9d(0x13b)](handleErrorAsync);async function run(){const _0x33a856=a18_0x5bbe9d;let _0x5ca36e=cli[_0x33a856(0x138)][0x0],_0x423ad4=cli[_0x33a856(0x138)][0x1];const _0x18e757=cli[_0x33a856(0x146)];if(!_0x5ca36e){await reportCliHelpTrace(_0x33a856(0x14e)),showHelp();return;}const _0x3ef3aa=resolveRemovedCommand(_0x5ca36e,_0x423ad4);_0x3ef3aa&&await handleErrorAsync(CliErrors[_0x33a856(0x143)](_0x3ef3aa[_0x33a856(0x150)],_0x3ef3aa[_0x33a856(0x13e)]));if(!isKnownService(_0x5ca36e)){await reportCliHelpTrace('unknown_service',{'service':_0x5ca36e}),showHelp();return;}const _0x37927d=getServiceEntry(_0x5ca36e);if(!_0x423ad4){if(_0x18e757[_0x33a856(0x156)]){printServiceHelp(_0x5ca36e);return;}if(_0x37927d[_0x33a856(0x144)])_0x423ad4=_0x37927d[_0x33a856(0x144)];else{if(_0x37927d[_0x33a856(0x153)]){const {buildConfigFromFlags:_0x2ff87e,initGlobalEnvironment:_0x2cd2a2}=await import(_0x33a856(0x158)),_0x32c08e=_0x2ff87e(_0x18e757);await _0x2cd2a2(_0x32c08e),await dispatchDeclarative(_0x37927d[_0x33a856(0x153)],_0x5ca36e,'',[],_0x18e757,_0x32c08e);return;}else{printServiceHelp(_0x5ca36e);return;}}}{let _0x301fad=findDefinition(_0x5ca36e,_0x423ad4),_0x417d83=cli[_0x33a856(0x138)][_0x33a856(0x14c)](0x2);if(!_0x301fad){if(_0x37927d[_0x33a856(0x153)]){if(_0x18e757['help']){console['log'](generateCommandHelp(_0x37927d[_0x33a856(0x153)]));return;}_0x301fad=_0x37927d['wildcardDef'],_0x417d83=[_0x423ad4,...cli[_0x33a856(0x138)]['slice'](0x2)];}else{printServiceHelp(_0x5ca36e),await handleErrorAsync(CliErrors['unknownCommand'](_0x5ca36e+'\x20'+_0x423ad4));return;}}assertSupportedCommandFlags(_0x301fad,_0x18e757);if(_0x18e757['help']){console['log'](generateCommandHelp(_0x301fad));return;}const {buildConfigFromFlags:_0x4bce64,initGlobalEnvironment:_0x21568d,isRoutingRecoveryService:_0x3e2a4a}=await import(_0x33a856(0x158)),_0x40e149=_0x4bce64(_0x18e757);!_0x3e2a4a(_0x5ca36e)&&await _0x21568d(_0x40e149),await dispatchDeclarative(_0x301fad,_0x5ca36e,_0x423ad4,_0x417d83,_0x18e757,_0x40e149);}}async function dispatchDeclarative(_0x594498,_0xb20267,_0x57aa2b,_0x2c7793,_0x2600b7,_0x58e594){const _0x3cb3f5=a18_0x5bbe9d,_0x5eca41=Date['now']();let _0x4d6d56;try{await runCommand(_0x594498,createPipelineEnv(_0x58e594,_0x2600b7,_0x2c7793));}catch(_0xa8ec){_0x4d6d56=_0xa8ec;}await reportCommandTrace({'service':_0xb20267,'command':_0x57aa2b,'flags':_0x2600b7,'durationMs':Date[_0x3cb3f5(0x139)]()-_0x5eca41,'error':_0x4d6d56}),_0x4d6d56&&await handleErrorAsync(_0x4d6d56,{'service':_0xb20267,'command':_0x57aa2b,'def':_0x594498,'flags':_0x2600b7,'defaultFormat':_0x58e594[_0x3cb3f5(0x145)]});}function printServiceHelp(_0x2fb1d4){const _0x10fe79=a18_0x5bbe9d;console[_0x10fe79(0x151)](generateServiceHelp(_0x2fb1d4));}function a18_0x2c0a(_0x555ff6,_0x4de3ae){_0x555ff6=_0x555ff6-0x135;const _0x3a68b3=a18_0x3a68();let _0x2c0a97=_0x3a68b3[_0x555ff6];return _0x2c0a97;}async function handleErrorAsync(_0x11dac3,_0x2f45ad){const _0x5ef540=a18_0x5bbe9d;if(_0x11dac3 instanceof Error&&_0x11dac3['name']===_0x5ef540(0x13f))return process[_0x5ef540(0x14f)][_0x5ef540(0x148)](_0x5ef540(0x135)),await exitWithOtelShutdown(0x0);if(_0x11dac3 instanceof CliError){if(_0x11dac3[_0x5ef540(0x13c)]===_0x5ef540(0x154))return process[_0x5ef540(0x14f)][_0x5ef540(0x148)]('\x0a'+_0x11dac3['message']+'\x0a'),await exitWithOtelShutdown(0x0);let _0x132851=![];_0x2f45ad&&usesStructuredErrorOutput(_0x2f45ad[_0x5ef540(0x15c)])&&(_0x132851=formatCliError(_0x11dac3,{'command':CLI_BIN_NAME+'\x20'+_0x2f45ad[_0x5ef540(0x15c)][_0x5ef540(0x15d)]+'\x20'+_0x2f45ad[_0x5ef540(0x15c)][_0x5ef540(0x140)],'risk':_0x2f45ad[_0x5ef540(0x15c)][_0x5ef540(0x14a)],'format':resolveErrorOutputFormat(_0x2f45ad),'jqFilter':typeof _0x2f45ad[_0x5ef540(0x146)]?.['jq']===_0x5ef540(0x13d)?_0x2f45ad[_0x5ef540(0x146)]['jq']:undefined}));if(!_0x132851){console[_0x5ef540(0x159)]('Error:\x20'+_0x11dac3['message']);if(_0x11dac3['hint'])console[_0x5ef540(0x159)](_0x5ef540(0x13a)+_0x11dac3[_0x5ef540(0x13e)]);if(_0x2f45ad)printIssueReportNudgeForError(_0x11dac3,_0x2f45ad);}return await exitWithOtelShutdown(_0x11dac3[_0x5ef540(0x15f)]);}console[_0x5ef540(0x159)]('Unexpected\x20error:',_0x11dac3);if(_0x2f45ad)printIssueReportNudgeForError(_0x11dac3,_0x2f45ad);return await exitWithOtelShutdown(0x1);}
2
+ import meow from"meow";import{showHelp}from"./help.js";import{CliError,CliErrors}from"./errors.js";import{isKnownService,getServiceEntry,findDefinition,resolveRemovedCommand}from"./commands/registry.js";import{runCommand,createPipelineEnv}from"./framework/runner.js";import{formatCliError}from"./framework/output.js";import{resolveErrorOutputFormat,usesStructuredErrorOutput}from"./framework/error-output.js";import{generateCommandHelp,generateServiceHelp,generateFullHelp}from"./framework/help.js";import{CLI_BIN_NAME,buildMeowFlags}from"./constant/cli.js";import{VERSION,GIT_COMMIT,BUILD_TIME}from"./generated/build-info.js";import{reportCliHelpTrace}from"./telemetry/cli-help-trace.js";import{reportCommandTrace}from"./telemetry/cli-command-trace.js";import{registerOtelShutdownOnExit,exitWithOtelShutdown}from"./telemetry/register-otel-exit-shutdown.js";import{printIssueReportNudgeForError}from"./commands/issue/nudge.js";import{assertSupportedCommandFlags}from"./framework/supported-flags.js"
3
+ ;let dynamicCliFlags=null;try{dynamicCliFlags=(await(import("./cli-flags.js"))).dynamicCliFlags}catch{}const helpText=generateFullHelp();const cliVersion=GIT_COMMIT!=="unknown"?`${VERSION} (${GIT_COMMIT}, ${BUILD_TIME.slice(0,10)})`:VERSION;const cli=meow(helpText,{importMeta:import.meta,version:cliVersion,flags:{...buildMeowFlags(),...dynamicCliFlags||{}}});registerOtelShutdownOnExit();await run().catch(handleErrorAsync);async function run(){let service=cli.input[0];let command=cli.input[1];const flags=cli.flags;if(!service){await reportCliHelpTrace("global");showHelp();return}const removedCommand=resolveRemovedCommand(service,command);if(removedCommand){await handleErrorAsync(CliErrors.validation(removedCommand.message,removedCommand.hint))}if(!isKnownService(service)){await reportCliHelpTrace("unknown_service",{service:service});showHelp();return}const entry=getServiceEntry(service);if(!command){if(flags.help){printServiceHelp(service);return}if(entry.defaultCommand){
4
+ command=entry.defaultCommand}else if(entry.wildcardDef){const{buildConfigFromFlags:buildConfigFromFlags,initGlobalEnvironment:initGlobalEnvironment}=await(import("./context.js"));const cliConfig=buildConfigFromFlags(flags);await initGlobalEnvironment(cliConfig);await dispatchDeclarative(entry.wildcardDef,service,"",[],flags,cliConfig);return}else{printServiceHelp(service);return}}{let def=findDefinition(service,command);let pipelineArgs=cli.input.slice(2);if(!def){if(entry.wildcardDef){if(flags.help){console.log(generateCommandHelp(entry.wildcardDef));return}def=entry.wildcardDef;pipelineArgs=[command,...cli.input.slice(2)]}else{printServiceHelp(service);await handleErrorAsync(CliErrors.unknownCommand(`${service} ${command}`));return}}assertSupportedCommandFlags(def,flags);if(flags.help){console.log(generateCommandHelp(def));return}
5
+ const{buildConfigFromFlags:buildConfigFromFlags,initGlobalEnvironment:initGlobalEnvironment,isRoutingRecoveryService:isRoutingRecoveryService}=await(import("./context.js"));const cliConfig=buildConfigFromFlags(flags);if(!isRoutingRecoveryService(service)){await initGlobalEnvironment(cliConfig)}await dispatchDeclarative(def,service,command,pipelineArgs,flags,cliConfig)}}async function dispatchDeclarative(def,service,command,pipelineArgs,flags,cliConfig){const startTime=Date.now();let cmdErr;try{await runCommand(def,createPipelineEnv(cliConfig,flags,pipelineArgs))}catch(err){cmdErr=err}await reportCommandTrace({service:service,command:command,flags:flags,durationMs:Date.now()-startTime,error:cmdErr});if(cmdErr){await handleErrorAsync(cmdErr,{service:service,command:command,def:def,flags:flags,defaultFormat:cliConfig.format})}}function printServiceHelp(service){console.log(generateServiceHelp(service))}async function handleErrorAsync(err,currentCommand){
6
+ if(err instanceof Error&&err.name==="ExitPromptError"){process.stderr.write("\nCancelled.\n");return await exitWithOtelShutdown(0)}if(err instanceof CliError){if(err.code==="cancelled"){process.stderr.write(`\n${err.message}\n`);return await exitWithOtelShutdown(0)}let structured=false;if(currentCommand&&usesStructuredErrorOutput(currentCommand.def)){structured=formatCliError(err,{command:`${CLI_BIN_NAME} ${currentCommand.def.service} ${currentCommand.def.command}`,risk:currentCommand.def.risk,format:resolveErrorOutputFormat(currentCommand),jqFilter:typeof currentCommand.flags?.jq==="string"?currentCommand.flags.jq:undefined})}if(!structured){console.error(`Error: ${err.message}`);if(err.hint)console.error(`Hint: ${err.hint}`);if(currentCommand)printIssueReportNudgeForError(err,currentCommand)}return await exitWithOtelShutdown(err.exitCode)}console.error("Unexpected error:",err);if(currentCommand)printIssueReportNudgeForError(err,currentCommand);return await exitWithOtelShutdown(1)}
@@ -1 +1,4 @@
1
- const a19_0x11229f=a19_0x2c32;function a19_0x4fed(){const _0x2e6247=['376014rYPkSh','length','Doc\x20generation\x20complete:\x20','7aSGbAs','fail','✓\x20Generated\x20','read','must\x20be\x20a\x20JSON\x20object','Filter:\x20comma-separated\x20dataset\x20codes\x20to\x20generate\x20docs\x20for','datasetcode','join','validation','\x1b[33m!\x20The\x20following\x20dataset\x20codes\x20do\x20not\x20exist:\x20','split','some','\x20dataset(s)','\x20doc(s)\x20in\x20','\x1b[0m','!\x20No\x20datasets\x20found.','234020vxJtEW','padStart','./docs','generate','60UAwwaq','filter','\x20\x20•\x20','start','Output\x20directory\x20(default:\x20./docs)','datasetCode','9YQZiAr','string','write','15411oiHHzS','datasetName','Fetching\x20dataset\x20list\x20for\x20','\x20file(s)','appCode','cookie','\x20doc(s)\x20failed','error','api','.md','\x1b[90m*\x20Generating\x20docs\x20for:\x20','\x20failed','None\x20of\x20the\x20specified\x20dataset\x20codes\x20exist:\x20','isArray','\x20succeeded,\x20','params','758650gJWNHl','\x1b[90m*\x20Filtered\x20','1266831ZeyXZp','\x0d\x20\x20[','output','object','):\x20','491350oYkGxf','str','message','Provide\x20a\x20valid\x20JSON\x20object,\x20e.g.\x20--params\x20\x27{\x22key\x22:\x22value\x22}\x27','map','Extra\x20params\x20passed\x20to\x20the\x20doc\x20generator\x20(JSON\x20object)','parse','...','Doc\x20generation:\x20','stdout','3631576RIMMoM','Fetched\x20'];a19_0x4fed=function(){return _0x2e6247;};return a19_0x4fed();}(function(_0x57ecaa,_0x4f8ad7){const _0x522f23=a19_0x2c32,_0x463965=_0x57ecaa();while(!![]){try{const _0x46b8d4=-parseInt(_0x522f23(0x13a))/0x1+parseInt(_0x522f23(0x151))/0x2+parseInt(_0x522f23(0x137))/0x3*(-parseInt(_0x522f23(0x12d))/0x4)+-parseInt(_0x522f23(0x14a))/0x5+-parseInt(_0x522f23(0x15d))/0x6+-parseInt(_0x522f23(0x11d))/0x7*(parseInt(_0x522f23(0x15b))/0x8)+-parseInt(_0x522f23(0x14c))/0x9*(-parseInt(_0x522f23(0x131))/0xa);if(_0x46b8d4===_0x4f8ad7)break;else _0x463965['push'](_0x463965['shift']());}catch(_0x4d6d8f){_0x463965['push'](_0x463965['shift']());}}}(a19_0x4fed,0x3862d));function a19_0x2c32(_0x1bb84f,_0x24df3f){_0x1bb84f=_0x1bb84f-0x11b;const _0x4fed18=a19_0x4fed();let _0x2c32d8=_0x4fed18[_0x1bb84f];return _0x2c32d8;}import a19_0x237a61 from'ora';import{fetchModelList}from'../../core/api-client.js';import{generateDatasetDocs}from'../../api/api-doc.js';import{CliErrors}from'../../errors.js';import{APPCODE_FLAG_OPTIONAL}from'../../commands/common/flags.js';import{writeCliSideChannelLine}from'../../utils/write-cli-side-channel.js';export const apiGenerate={'service':a19_0x11229f(0x142),'command':a19_0x11229f(0x130),'description':'Generate\x20markdown\x20documentation\x20for\x20all\x20datasets','risk':a19_0x11229f(0x120),'requiresAppCode':!![],'hasFormat':![],'flags':[{...APPCODE_FLAG_OPTIONAL,'hidden':!![]},{'name':a19_0x11229f(0x14e),'type':a19_0x11229f(0x138),'description':a19_0x11229f(0x135)},{'name':a19_0x11229f(0x123),'type':a19_0x11229f(0x138),'description':a19_0x11229f(0x122)},{'name':a19_0x11229f(0x149),'type':a19_0x11229f(0x138),'description':a19_0x11229f(0x156)}],async 'execute'(_0x4cba5e){const _0x52b34f=a19_0x11229f,_0x53b261=_0x4cba5e[_0x52b34f(0x152)]('output')||_0x52b34f(0x12f),_0x4530d8=_0x4cba5e['str'](_0x52b34f(0x123)),_0x320106=_0x4cba5e['str']('params');let _0x344c66;if(_0x320106)try{_0x344c66=JSON[_0x52b34f(0x157)](_0x320106);if(typeof _0x344c66!==_0x52b34f(0x14f)||_0x344c66===null||Array[_0x52b34f(0x147)](_0x344c66))throw new Error(_0x52b34f(0x121));}catch(_0x4f4646){throw CliErrors['validation']('Invalid\x20--params:\x20'+(_0x4f4646 instanceof Error?_0x4f4646[_0x52b34f(0x153)]:String(_0x4f4646)),_0x52b34f(0x154));}let _0x2cefea;if(_0x4530d8){const _0x3ac902=_0x4530d8[_0x52b34f(0x127)](',')[_0x52b34f(0x155)](_0x5d1b8a=>_0x5d1b8a['trim']())['filter'](_0x58fbf0=>_0x58fbf0[_0x52b34f(0x11b)]>0x0);if(_0x3ac902[_0x52b34f(0x11b)]===0x0)throw CliErrors['validation']('--datasetcode\x20cannot\x20be\x20empty.');_0x2cefea=new Set(_0x3ac902),writeCliSideChannelLine(_0x52b34f(0x144)+_0x3ac902[_0x52b34f(0x124)](',\x20')+_0x52b34f(0x12b));}const _0x11a320=a19_0x237a61(_0x52b34f(0x13c)+_0x4cba5e[_0x52b34f(0x13e)]+_0x52b34f(0x158))[_0x52b34f(0x134)]();let _0xcfb52c;try{({configArray:_0xcfb52c}=await fetchModelList(_0x4cba5e[_0x52b34f(0x13e)],_0x4cba5e['cookie']),_0x11a320['succeed'](_0x52b34f(0x15c)+_0xcfb52c[_0x52b34f(0x11b)]+_0x52b34f(0x129)));}catch(_0x33d8eb){_0x11a320[_0x52b34f(0x11e)]('Failed\x20to\x20fetch\x20datasets');throw _0x33d8eb;}if(_0xcfb52c[_0x52b34f(0x11b)]===0x0)return writeCliSideChannelLine(_0x52b34f(0x12c)),{'ok':!![]};let _0x47b36f=_0xcfb52c;if(_0x2cefea){_0x47b36f=_0xcfb52c[_0x52b34f(0x132)](_0x4f7a0e=>_0x2cefea['has'](_0x4f7a0e[_0x52b34f(0x136)]));const _0x10fe1b=[..._0x2cefea][_0x52b34f(0x132)](_0x213b81=>!_0xcfb52c[_0x52b34f(0x128)](_0x3713f8=>_0x3713f8[_0x52b34f(0x136)]===_0x213b81));_0x10fe1b[_0x52b34f(0x11b)]>0x0&&writeCliSideChannelLine(_0x52b34f(0x126)+_0x10fe1b[_0x52b34f(0x124)](',\x20')+_0x52b34f(0x12b));if(_0x47b36f[_0x52b34f(0x11b)]===0x0)throw CliErrors[_0x52b34f(0x125)](_0x52b34f(0x146)+[..._0x2cefea][_0x52b34f(0x124)](',\x20'));writeCliSideChannelLine(_0x52b34f(0x14b)+_0x47b36f[_0x52b34f(0x11b)]+'\x20of\x20'+_0xcfb52c[_0x52b34f(0x11b)]+'\x20dataset(s)\x1b[0m');}let _0x7e5d5e=0x0;const _0xc33b47=await generateDatasetDocs(_0x47b36f,_0x4cba5e['appCode'],_0x4cba5e[_0x52b34f(0x13f)],_0x53b261,(_0x2cccca,_0xc94e1a,_0x24f934)=>{const _0x1f1d6a=_0x52b34f;_0x7e5d5e=_0x2cccca,process[_0x1f1d6a(0x15a)][_0x1f1d6a(0x139)](_0x1f1d6a(0x14d)+String(_0x2cccca)[_0x1f1d6a(0x12e)](String(_0xc94e1a)['length'])+'/'+_0xc94e1a+']\x20'+_0x24f934+_0x1f1d6a(0x143));},_0x344c66);if(_0x7e5d5e>0x0)process[_0x52b34f(0x15a)]['write']('\x0a');const _0x59944b=_0xc33b47[_0x52b34f(0x132)](_0xecbb08=>_0xecbb08['success'])['length'],_0x319050=_0xc33b47[_0x52b34f(0x132)](_0x1e0857=>!_0x1e0857['success'])[_0x52b34f(0x11b)];writeCliSideChannelLine(''),writeCliSideChannelLine(_0x52b34f(0x11f)+_0x59944b+_0x52b34f(0x12a)+_0x53b261);if(_0x319050>0x0){writeCliSideChannelLine('!\x20'+_0x319050+_0x52b34f(0x140));for(const _0x36b1da of _0xc33b47[_0x52b34f(0x132)](_0xd67259=>!_0xd67259['success'])){writeCliSideChannelLine(_0x52b34f(0x133)+_0x36b1da[_0x52b34f(0x13b)]+'\x20('+_0x36b1da[_0x52b34f(0x136)]+_0x52b34f(0x150)+_0x36b1da[_0x52b34f(0x141)]);}}return{'ok':_0x319050===0x0,'message':_0x319050>0x0?_0x52b34f(0x159)+_0x59944b+_0x52b34f(0x148)+_0x319050+_0x52b34f(0x145):_0x52b34f(0x11c)+_0x59944b+_0x52b34f(0x13d)};}};
1
+ import ora from"ora";import{fetchModelList}from"../../core/api-client.js";import{generateDatasetDocs}from"../../api/api-doc.js";import{CliErrors}from"../../errors.js";import{APPCODE_FLAG_OPTIONAL}from"../../commands/common/flags.js";import{writeCliSideChannelLine}from"../../utils/write-cli-side-channel.js";export const apiGenerate={service:"api",command:"generate",description:"Generate markdown documentation for all datasets",risk:"read",requiresAppCode:true,hasFormat:false,flags:[{...APPCODE_FLAG_OPTIONAL,hidden:true},{name:"output",type:"string",description:"Output directory (default: ./docs)"},{name:"datasetcode",type:"string",description:"Filter: comma-separated dataset codes to generate docs for"},{name:"params",type:"string",description:"Extra params passed to the doc generator (JSON object)"}],async execute(ctx){const outputDir=ctx.str("output")||"./docs";const datasetcodeStr=ctx.str("datasetcode");const paramsStr=ctx.str("params");let extraParams;if(paramsStr){try{
2
+ extraParams=JSON.parse(paramsStr);if(typeof extraParams!=="object"||extraParams===null||Array.isArray(extraParams)){throw new Error("must be a JSON object")}}catch(err){throw CliErrors.validation(`Invalid --params: ${err instanceof Error?err.message:String(err)}`,`Provide a valid JSON object, e.g. --params '{"key":"value"}'`)}}let filterCodes;if(datasetcodeStr){const codes=datasetcodeStr.split(",").map(c=>c.trim()).filter(c=>c.length>0);if(codes.length===0){throw CliErrors.validation("--datasetcode cannot be empty.")}filterCodes=new Set(codes);writeCliSideChannelLine(`* Generating docs for: ${codes.join(", ")}`)}const spinner=ora(`Fetching dataset list for ${ctx.appCode}...`).start();let configArray;try{({configArray:configArray}=await fetchModelList(ctx.appCode,ctx.cookie));spinner.succeed(`Fetched ${configArray.length} dataset(s)`)}catch(err){spinner.fail("Failed to fetch datasets");throw err}if(configArray.length===0){writeCliSideChannelLine("! No datasets found.");return{
3
+ ok:true}}let datasetsToGenerate=configArray;if(filterCodes){datasetsToGenerate=configArray.filter(d=>filterCodes.has(d.datasetCode));const notFound=[...filterCodes].filter(c=>!configArray.some(d=>d.datasetCode===c));if(notFound.length>0){writeCliSideChannelLine(`! The following dataset codes do not exist: ${notFound.join(", ")}`)}if(datasetsToGenerate.length===0){throw CliErrors.validation(`None of the specified dataset codes exist: ${[...filterCodes].join(", ")}`)}writeCliSideChannelLine(`* Filtered ${datasetsToGenerate.length} of ${configArray.length} dataset(s)`)}let current=0;const results=await generateDatasetDocs(datasetsToGenerate,ctx.appCode,ctx.cookie,outputDir,(idx,total,fileName)=>{current=idx;process.stdout.write(`\r [${String(idx).padStart(String(total).length)}/${total}] ${fileName}.md`)},extraParams);if(current>0)process.stdout.write("\n");const succeeded=results.filter(r=>r.success).length;const failed=results.filter(r=>!r.success).length
4
+ ;writeCliSideChannelLine("");writeCliSideChannelLine(`✓ Generated ${succeeded} doc(s) in ${outputDir}`);if(failed>0){writeCliSideChannelLine(`! ${failed} doc(s) failed`);for(const r of results.filter(r=>!r.success)){writeCliSideChannelLine(` • ${r.datasetName} (${r.datasetCode}): ${r.error}`)}}return{ok:failed===0,message:failed>0?`Doc generation: ${succeeded} succeeded, ${failed} failed`:`Doc generation complete: ${succeeded} file(s)`}}};