@lovrabet/rabetbase-cli 2.5.4 → 2.5.5-beta.2

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 (379) hide show
  1. package/lib/api/api-doc.js +1 -1
  2. package/lib/api/api-group.js +1 -1
  3. package/lib/api/fetch-model-list.js +1 -1
  4. package/lib/api/generate-api-file.js +1 -1
  5. package/lib/api/generate-sdk-config-file.js +1 -1
  6. package/lib/api/legacy-api-file.js +1 -1
  7. package/lib/api/model-registry-file.js +1 -1
  8. package/lib/api/model-registry-scaffold.js +1 -1
  9. package/lib/api/model-source.js +1 -1
  10. package/lib/auth/auth-server-ui.js +1 -1
  11. package/lib/auth/auth-server.js +1 -1
  12. package/lib/auth/constant.js +1 -1
  13. package/lib/auth/get-cookie.js +1 -1
  14. package/lib/auth/get-session-user.js +1 -1
  15. package/lib/auth/is-session-valid.js +1 -1
  16. package/lib/auth/login-success-html.js +1 -1
  17. package/lib/auth/logout.js +1 -1
  18. package/lib/cli-flags.js +1 -1
  19. package/lib/cli.js +1 -1
  20. package/lib/commands/api/generate.js +1 -1
  21. package/lib/commands/api/index.js +1 -1
  22. package/lib/commands/api/list.js +1 -1
  23. package/lib/commands/api/pull.js +1 -1
  24. package/lib/commands/api/shared.js +1 -1
  25. package/lib/commands/app/detail.js +1 -1
  26. package/lib/commands/app/index.js +1 -1
  27. package/lib/commands/app/list.js +1 -1
  28. package/lib/commands/app/members-list.js +1 -1
  29. package/lib/commands/app/remote-directory.js +1 -1
  30. package/lib/commands/app/shared.js +1 -1
  31. package/lib/commands/app-config/delete.js +1 -1
  32. package/lib/commands/app-config/get.js +1 -1
  33. package/lib/commands/app-config/index.js +1 -1
  34. package/lib/commands/app-config/list.js +1 -1
  35. package/lib/commands/app-config/set.js +1 -1
  36. package/lib/commands/app-config/shared.js +1 -1
  37. package/lib/commands/auth/index.js +1 -1
  38. package/lib/commands/bff/create.js +1 -1
  39. package/lib/commands/bff/delete.js +1 -1
  40. package/lib/commands/bff/detail.js +1 -1
  41. package/lib/commands/bff/index.js +1 -1
  42. package/lib/commands/bff/list.js +1 -1
  43. package/lib/commands/bff/logs.js +1 -1
  44. package/lib/commands/bff/pull.js +1 -1
  45. package/lib/commands/bff/push.js +1 -1
  46. package/lib/commands/bff/status.js +1 -1
  47. package/lib/commands/cli-skill/index.js +1 -1
  48. package/lib/commands/cli-update.js +1 -1
  49. package/lib/commands/codegen/index.js +1 -1
  50. package/lib/commands/codegen/sdk.js +1 -1
  51. package/lib/commands/codegen/sql.js +1 -1
  52. package/lib/commands/common/app-registry.js +1 -1
  53. package/lib/commands/common/app-selector.js +1 -1
  54. package/lib/commands/common/async-task.js +1 -1
  55. package/lib/commands/common/dry-run.js +1 -1
  56. package/lib/commands/common/flags.js +1 -1
  57. package/lib/commands/common/local-file.js +1 -1
  58. package/lib/commands/common/validate.js +1 -1
  59. package/lib/commands/config/delete.js +1 -1
  60. package/lib/commands/config/get.js +1 -1
  61. package/lib/commands/config/index.js +1 -1
  62. package/lib/commands/config/init.js +1 -1
  63. package/lib/commands/config/list.js +1 -1
  64. package/lib/commands/config/set.js +1 -1
  65. package/lib/commands/config/shared.js +1 -1
  66. package/lib/commands/dataset/batch-design.js +1 -1
  67. package/lib/commands/dataset/business-group-update.js +1 -1
  68. package/lib/commands/dataset/business-groups.js +1 -1
  69. package/lib/commands/dataset/capability.js +1 -1
  70. package/lib/commands/dataset/cross-relation-create.js +1 -1
  71. package/lib/commands/dataset/cross-relation-delete.js +1 -1
  72. package/lib/commands/dataset/cross-relation-list.js +1 -1
  73. package/lib/commands/dataset/cross-relation-shared.js +1 -1
  74. package/lib/commands/dataset/cross-relation-update.js +1 -1
  75. package/lib/commands/dataset/delete.js +1 -1
  76. package/lib/commands/dataset/detail.js +1 -1
  77. package/lib/commands/dataset/extend-update.js +1 -1
  78. package/lib/commands/dataset/field-restore.js +1 -1
  79. package/lib/commands/dataset/field-update.js +1 -1
  80. package/lib/commands/dataset/generate.js +1 -1
  81. package/lib/commands/dataset/index.js +1 -1
  82. package/lib/commands/dataset/list.js +1 -1
  83. package/lib/commands/dataset/operations.js +1 -1
  84. package/lib/commands/dataset/relation-audit.js +1 -1
  85. package/lib/commands/dataset/relation-create.js +1 -1
  86. package/lib/commands/dataset/relation-delete.js +1 -1
  87. package/lib/commands/dataset/relation-shared.js +1 -1
  88. package/lib/commands/dataset/relation-update.js +1 -1
  89. package/lib/commands/dataset/relations.js +1 -1
  90. package/lib/commands/dataset/rename.js +1 -1
  91. package/lib/commands/dataset/restore.js +1 -1
  92. package/lib/commands/dataset/user-deleted-field-list.js +1 -1
  93. package/lib/commands/db/analysis-batching.js +1 -1
  94. package/lib/commands/db/analyze-batch-plan.js +1 -1
  95. package/lib/commands/db/analyze-cancel.js +1 -1
  96. package/lib/commands/db/analyze-start.js +1 -1
  97. package/lib/commands/db/analyze-status.js +1 -1
  98. package/lib/commands/db/create.js +1 -1
  99. package/lib/commands/db/delete.js +1 -1
  100. package/lib/commands/db/detail.js +1 -1
  101. package/lib/commands/db/diff-refresh-start.js +1 -1
  102. package/lib/commands/db/diff-refresh-status.js +1 -1
  103. package/lib/commands/db/diff.js +1 -1
  104. package/lib/commands/db/index.js +1 -1
  105. package/lib/commands/db/list.js +1 -1
  106. package/lib/commands/db/shared.js +1 -1
  107. package/lib/commands/db/table-diff-shared.js +1 -1
  108. package/lib/commands/db/tables.js +1 -1
  109. package/lib/commands/db/test.js +1 -1
  110. package/lib/commands/db/update.js +1 -1
  111. package/lib/commands/deployment/index.js +1 -1
  112. package/lib/commands/deployment/sync-all.js +1 -1
  113. package/lib/commands/deployment/sync-jobs.js +1 -1
  114. package/lib/commands/deployment/sync-status.js +1 -1
  115. package/lib/commands/doctor.js +1 -1
  116. package/lib/commands/file/index.js +1 -1
  117. package/lib/commands/flow/create.js +1 -1
  118. package/lib/commands/flow/detail.js +1 -1
  119. package/lib/commands/flow/index.js +1 -1
  120. package/lib/commands/flow/list.js +1 -1
  121. package/lib/commands/flow/publish.js +1 -1
  122. package/lib/commands/flow/runtime-resources-shared.js +1 -1
  123. package/lib/commands/flow/runtime-role-list.js +1 -1
  124. package/lib/commands/flow/runtime-role-user-list.js +1 -1
  125. package/lib/commands/flow/runtime-user-search.js +1 -1
  126. package/lib/commands/flow/shared.js +1 -1
  127. package/lib/commands/flow/update.js +1 -1
  128. package/lib/commands/flow/validate.js +1 -1
  129. package/lib/commands/instant-api-policy/current.js +1 -1
  130. package/lib/commands/instant-api-policy/index.js +1 -1
  131. package/lib/commands/instant-api-policy/init.js +1 -1
  132. package/lib/commands/instant-api-policy/publish.js +1 -1
  133. package/lib/commands/instant-api-policy/pull.js +1 -1
  134. package/lib/commands/instant-api-policy/revision.js +1 -1
  135. package/lib/commands/instant-api-policy/revisions.js +1 -1
  136. package/lib/commands/instant-api-policy/rollback.js +1 -1
  137. package/lib/commands/instant-api-policy/shared.js +1 -1
  138. package/lib/commands/instant-api-policy/validate.js +1 -1
  139. package/lib/commands/issue/index.js +1 -1
  140. package/lib/commands/issue/nudge.js +1 -1
  141. package/lib/commands/issue/report.js +1 -1
  142. package/lib/commands/issue/shared.js +1 -1
  143. package/lib/commands/kb/create.js +1 -1
  144. package/lib/commands/kb/delete.js +1 -1
  145. package/lib/commands/kb/detail.js +1 -1
  146. package/lib/commands/kb/index.js +1 -1
  147. package/lib/commands/kb/list.js +1 -1
  148. package/lib/commands/kb/search.js +1 -1
  149. package/lib/commands/kb/shared.js +1 -1
  150. package/lib/commands/kb/update.js +1 -1
  151. package/lib/commands/logs/index.js +1 -1
  152. package/lib/commands/menu/asset-update.js +1 -1
  153. package/lib/commands/menu/delete.js +1 -1
  154. package/lib/commands/menu/external-link-create.js +1 -1
  155. package/lib/commands/menu/external-link-update.js +1 -1
  156. package/lib/commands/menu/group-create.js +1 -1
  157. package/lib/commands/menu/group-update.js +1 -1
  158. package/lib/commands/menu/index.js +1 -1
  159. package/lib/commands/menu/list.js +1 -1
  160. package/lib/commands/menu/move.js +1 -1
  161. package/lib/commands/menu/regroup-start.js +1 -1
  162. package/lib/commands/menu/rename.js +1 -1
  163. package/lib/commands/menu/shared/compare-table.js +1 -1
  164. package/lib/commands/menu/shared/delete-plan.js +1 -1
  165. package/lib/commands/menu/shared/facts.js +1 -1
  166. package/lib/commands/menu/shared/index.js +1 -1
  167. package/lib/commands/menu/shared/inquirer.js +1 -1
  168. package/lib/commands/menu/shared/local-pages.js +1 -1
  169. package/lib/commands/menu/shared/logic.js +1 -1
  170. package/lib/commands/menu/shared/mutations.js +1 -1
  171. package/lib/commands/menu/shared/path.js +1 -1
  172. package/lib/commands/menu/shared/service.js +1 -1
  173. package/lib/commands/menu/shared/subapp-assets.js +1 -1
  174. package/lib/commands/menu/shared/sync-core.js +1 -1
  175. package/lib/commands/menu/shared/update-core.js +1 -1
  176. package/lib/commands/menu/shared/valid-url.js +1 -1
  177. package/lib/commands/menu/subapp-assets-status.js +1 -1
  178. package/lib/commands/menu/subapp-assets-update.js +1 -1
  179. package/lib/commands/menu/sync.js +1 -1
  180. package/lib/commands/menu/visibility-update.js +1 -1
  181. package/lib/commands/notification/config-create.js +1 -1
  182. package/lib/commands/notification/config-delete.js +1 -1
  183. package/lib/commands/notification/config-list.js +1 -1
  184. package/lib/commands/notification/config-update.js +1 -1
  185. package/lib/commands/notification/index.js +1 -1
  186. package/lib/commands/notification/shared.js +1 -1
  187. package/lib/commands/ocr/index.js +1 -1
  188. package/lib/commands/page/create.js +1 -1
  189. package/lib/commands/page/custom/detail.js +1 -1
  190. package/lib/commands/page/custom/list.js +1 -1
  191. package/lib/commands/page/custom/publish.js +1 -1
  192. package/lib/commands/page/custom/shared.js +1 -1
  193. package/lib/commands/page/custom/syntax.js +1 -1
  194. package/lib/commands/page/custom/update.js +1 -1
  195. package/lib/commands/page/data-list-status.js +1 -1
  196. package/lib/commands/page/generate-start.js +1 -1
  197. package/lib/commands/page/generate-status.js +1 -1
  198. package/lib/commands/page/index.js +1 -1
  199. package/lib/commands/page/pull.js +1 -1
  200. package/lib/commands/page/push.js +1 -1
  201. package/lib/commands/page/relation-audit.js +1 -1
  202. package/lib/commands/page/restore.js +1 -1
  203. package/lib/commands/page/shared.js +1 -1
  204. package/lib/commands/page/sync.js +1 -1
  205. package/lib/commands/project/api-architecture-upgrade.js +1 -1
  206. package/lib/commands/project/create/enhanced-guided-create.js +1 -1
  207. package/lib/commands/project/create/format-elapsed.js +1 -1
  208. package/lib/commands/project/create/main.js +1 -1
  209. package/lib/commands/project/create/materialize-project-template.js +1 -1
  210. package/lib/commands/project/create/project-name.js +1 -1
  211. package/lib/commands/project/create/project-template-archive.js +1 -1
  212. package/lib/commands/project/create/project-template-path.js +1 -1
  213. package/lib/commands/project/create/use-copy-project-template.js +1 -1
  214. package/lib/commands/project/create/use-format-code.js +1 -1
  215. package/lib/commands/project/create/use-install-dependencies.js +1 -1
  216. package/lib/commands/project/domain-routing-sync.js +1 -1
  217. package/lib/commands/project/index.js +1 -1
  218. package/lib/commands/project/upgrade.js +1 -1
  219. package/lib/commands/registry.js +1 -1
  220. package/lib/commands/role/delete.js +1 -1
  221. package/lib/commands/role/detail.js +1 -1
  222. package/lib/commands/role/index.js +1 -1
  223. package/lib/commands/role/list.js +1 -1
  224. package/lib/commands/role/shared.js +1 -1
  225. package/lib/commands/role/update.js +1 -1
  226. package/lib/commands/role/user-add.js +1 -1
  227. package/lib/commands/role/user-remove.js +1 -1
  228. package/lib/commands/role/user-resolve.js +1 -1
  229. package/lib/commands/rule/get.js +1 -1
  230. package/lib/commands/rule/index.js +1 -1
  231. package/lib/commands/rule/list.js +1 -1
  232. package/lib/commands/rule/set.js +1 -1
  233. package/lib/commands/rule/shared.js +1 -1
  234. package/lib/commands/run/index.js +1 -1
  235. package/lib/commands/schema.js +1 -1
  236. package/lib/commands/sql/create.js +1 -1
  237. package/lib/commands/sql/delete.js +1 -1
  238. package/lib/commands/sql/detail.js +1 -1
  239. package/lib/commands/sql/exec.js +1 -1
  240. package/lib/commands/sql/index.js +1 -1
  241. package/lib/commands/sql/list.js +1 -1
  242. package/lib/commands/sql/pull.js +1 -1
  243. package/lib/commands/sql/push.js +1 -1
  244. package/lib/commands/sql/shared.js +1 -1
  245. package/lib/commands/sql/status.js +1 -1
  246. package/lib/commands/sql/validate.js +1 -1
  247. package/lib/commands/task/index.js +1 -1
  248. package/lib/commands/task/status.js +1 -1
  249. package/lib/commands/tenant/index.js +1 -1
  250. package/lib/commands/tenant/members-list.js +1 -1
  251. package/lib/commands/tenant/shared.js +1 -1
  252. package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
  253. package/lib/commands/user-account/feishu-bind.js +1 -1
  254. package/lib/commands/user-account/index.js +1 -1
  255. package/lib/commands/workspace/add.js +1 -1
  256. package/lib/commands/workspace/index.js +1 -1
  257. package/lib/commands/workspace/remove.js +1 -1
  258. package/lib/config/domain-config.js +1 -1
  259. package/lib/config/project-domain-routing.js +1 -1
  260. package/lib/config/region-config.js +1 -1
  261. package/lib/config/schema.js +1 -1
  262. package/lib/constant/cdn.js +1 -1
  263. package/lib/constant/cli.js +1 -1
  264. package/lib/constant/defaults.js +1 -1
  265. package/lib/constant/domain.js +1 -1
  266. package/lib/constant/env.js +1 -1
  267. package/lib/constant/output.js +1 -1
  268. package/lib/constant/paths.js +1 -1
  269. package/lib/constant/region.js +1 -1
  270. package/lib/constant/risk.js +1 -1
  271. package/lib/constant/routing-profile.js +1 -1
  272. package/lib/context/app-resolver.js +1 -1
  273. package/lib/context/auth-resolver.js +1 -1
  274. package/lib/context/config-loader.js +1 -1
  275. package/lib/context.js +1 -1
  276. package/lib/core/alias-resolver.js +1 -1
  277. package/lib/core/api-client.js +1 -1
  278. package/lib/core/bff/config.js +1 -1
  279. package/lib/core/bff/file-system.js +1 -1
  280. package/lib/core/bff/hash.js +1 -1
  281. package/lib/core/bff/hook-directory.js +1 -1
  282. package/lib/core/bff/lock.js +1 -1
  283. package/lib/core/bff/utils.js +1 -1
  284. package/lib/core/cross-db-relation.js +1 -1
  285. package/lib/core/db-resolver.js +1 -1
  286. package/lib/core/flow-config.js +1 -1
  287. package/lib/core/instant-api-policy/config.js +1 -1
  288. package/lib/core/kb-search-client.js +1 -1
  289. package/lib/core/page/file-system.js +1 -1
  290. package/lib/core/page/hash.js +1 -1
  291. package/lib/core/page/lock.js +1 -1
  292. package/lib/core/page/lr-smart-jsx.js +1 -1
  293. package/lib/core/sql-index-auditor.js +1 -1
  294. package/lib/core/sql-sync/config.js +1 -1
  295. package/lib/core/sql-sync/file-system.js +1 -1
  296. package/lib/core/sql-sync/hash.js +1 -1
  297. package/lib/core/sql-sync/lock.js +1 -1
  298. package/lib/core/sql-sync/utils.js +1 -1
  299. package/lib/core/sql-validator.js +1 -1
  300. package/lib/errors.js +1 -1
  301. package/lib/framework/build-all-flags.js +1 -1
  302. package/lib/framework/error-output.js +1 -1
  303. package/lib/framework/explicit-yes.js +1 -1
  304. package/lib/framework/flags.js +1 -1
  305. package/lib/framework/help.js +1 -1
  306. package/lib/framework/index.js +1 -1
  307. package/lib/framework/output.js +1 -1
  308. package/lib/framework/response.js +1 -1
  309. package/lib/framework/runner-alias.js +1 -1
  310. package/lib/framework/runner.js +1 -1
  311. package/lib/framework/schema-export.js +1 -1
  312. package/lib/framework/supported-flags.js +1 -1
  313. package/lib/framework/types.js +1 -1
  314. package/lib/generated/build-info.d.ts +4 -4
  315. package/lib/generated/build-info.js +1 -1
  316. package/lib/generated/official-routing.js +1 -1
  317. package/lib/generated/routing-contract.js +1 -1
  318. package/lib/help.js +1 -1
  319. package/lib/postinstall.js +1 -1
  320. package/lib/runtime/confirmation.js +1 -1
  321. package/lib/runtime/event.js +1 -1
  322. package/lib/runtime/index.js +1 -1
  323. package/lib/runtime/queue.js +1 -1
  324. package/lib/runtime/resolve.js +1 -1
  325. package/lib/skills/builtin-skill.js +1 -1
  326. package/lib/skills/main.js +1 -1
  327. package/lib/skills/npx-skills-add.js +1 -1
  328. package/lib/skills/skill-presence.js +1 -1
  329. package/lib/telemetry/cli-command-trace.js +1 -1
  330. package/lib/telemetry/cli-help-trace.js +1 -1
  331. package/lib/telemetry/ensure-cli-otel-config.js +1 -1
  332. package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
  333. package/lib/telemetry/send-cli-trace-log.js +1 -1
  334. package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
  335. package/lib/utils/ai_config.js +1 -1
  336. package/lib/utils/apply-jq-filter.js +1 -1
  337. package/lib/utils/cdn-config.js +1 -1
  338. package/lib/utils/check-sdk-version.js +1 -1
  339. package/lib/utils/cli-version-check.js +1 -1
  340. package/lib/utils/cli-version-policy.js +1 -1
  341. package/lib/utils/config.js +1 -1
  342. package/lib/utils/entity-with-id.js +1 -1
  343. package/lib/utils/file-utils.js +1 -1
  344. package/lib/utils/guides-cdn.js +1 -1
  345. package/lib/utils/http-client.js +1 -1
  346. package/lib/utils/is-non-interactive.js +1 -1
  347. package/lib/utils/logger.js +1 -1
  348. package/lib/utils/params.js +1 -1
  349. package/lib/utils/platform.js +1 -1
  350. package/lib/utils/sleep.js +1 -1
  351. package/lib/utils/template-replacer.js +1 -1
  352. package/lib/utils/update-notice.js +1 -1
  353. package/lib/utils/version.js +1 -1
  354. package/lib/utils/with-active-cookie.js +1 -1
  355. package/lib/utils/write-cli-side-channel.js +1 -1
  356. package/package.json +2 -1
  357. package/skills/rabetbase/SKILL.md +1 -1
  358. package/skills/rabetbase-page-generation/SKILL.md +39 -0
  359. package/skills/rabetbase-page-generation/references/component-baseline.md +18 -0
  360. package/skills/rabetbase-page-generation/references/generation.md +126 -0
  361. package/skills/rabetbase-page-generation/templates/onepage/build.mjs +48 -0
  362. package/skills/rabetbase-page-generation/templates/onepage/create/README.md +20 -0
  363. package/skills/rabetbase-page-generation/templates/onepage/create/index.jsx +4 -0
  364. package/skills/rabetbase-page-generation/templates/onepage/create/preview.png +0 -0
  365. package/skills/rabetbase-page-generation/templates/onepage/detail/README.md +20 -0
  366. package/skills/rabetbase-page-generation/templates/onepage/detail/index.jsx +194 -0
  367. package/skills/rabetbase-page-generation/templates/onepage/detail/preview.png +0 -0
  368. package/skills/rabetbase-page-generation/templates/onepage/list/README.md +20 -0
  369. package/skills/rabetbase-page-generation/templates/onepage/list/index.jsx +721 -0
  370. package/skills/rabetbase-page-generation/templates/onepage/list/preview.png +0 -0
  371. package/skills/rabetbase-page-generation/templates/onepage/shared/editor.jsx +395 -0
  372. package/skills/rabetbase-page-generation/templates/onepage/shared/model.js +141 -0
  373. package/skills/rabetbase-page-generation/templates/onepage/shared/page.css +377 -0
  374. package/skills/rabetbase-page-generation/templates/onepage/shared/record-layout.jsx +90 -0
  375. package/skills/rabetbase-page-generation/templates/onepage/shared/responsive.jsx +70 -0
  376. package/skills/rabetbase-page-generation/templates/onepage/update/README.md +21 -0
  377. package/skills/rabetbase-page-generation/templates/onepage/update/index.jsx +4 -0
  378. package/skills/rabetbase-page-generation/templates/onepage/update/preview.png +0 -0
  379. package/skills/rabetbase.manifest.json +3 -3
@@ -0,0 +1,395 @@
1
+ import { useEffect, useRef, useState } from "react";
2
+ import {
3
+ Alert,
4
+ App,
5
+ Button,
6
+ ConfigProvider,
7
+ Form,
8
+ Input,
9
+ InputNumber,
10
+ Radio,
11
+ Space,
12
+ Spin,
13
+ theme,
14
+ } from "antd";
15
+ import dayjs from "dayjs";
16
+ import {
17
+ useAppContext,
18
+ useAppTheme,
19
+ useLocation,
20
+ useNavigate,
21
+ useSdkClient,
22
+ } from "@/context/app-context";
23
+ import {
24
+ DATASET_CODE,
25
+ LIST_PATH,
26
+ childPaths,
27
+ statusOptions,
28
+ typeOptions,
29
+ levelOptions,
30
+ } from "./model";
31
+ import { RecordGroups, RecordItem, recordTheme } from "./record-layout";
32
+ import { ResponsiveDateTime } from "./responsive";
33
+ import "./page.css";
34
+
35
+ function CustomerEditor({ mode }) {
36
+ const hostTheme = useAppTheme();
37
+ const client = useSdkClient(),
38
+ navigate = useNavigate(),
39
+ location = useLocation();
40
+ const { onePageInfo } = useAppContext();
41
+ const { message, modal } = App.useApp();
42
+ const continueAfterSave = useRef(false);
43
+ const focusNextRecord = useRef(false);
44
+ const customerNameInput = useRef(null);
45
+ const [dirty, setDirty] = useState(false);
46
+ const [form] = Form.useForm();
47
+ const updating = mode === "update";
48
+ const rawId =
49
+ onePageInfo?.innerSearchParams?.id ??
50
+ new URLSearchParams(location.search).get("id");
51
+ const id = rawId == null ? "" : String(rawId).trim();
52
+ const [loading, setLoading] = useState(updating),
53
+ [error, setError] = useState("");
54
+ const [saving, setSaving] = useState(false),
55
+ [revision, setRevision] = useState(0);
56
+ const original = useRef(null),
57
+ submitting = useRef(false);
58
+ const model = client.models[`dataset_${DATASET_CODE}`];
59
+ const params =
60
+ onePageInfo?.innerSearchParams ??
61
+ Object.fromEntries(new URLSearchParams(location.search));
62
+ const returnDetail = updating && params.returnDetail === "1";
63
+ const goBack = () =>
64
+ returnDetail
65
+ ? navigate(
66
+ `${childPaths.detail}?${new URLSearchParams({ id, ids: String(params.ids || "") })}`,
67
+ { replace: true },
68
+ )
69
+ : navigate(onePageInfo ? "../" : LIST_PATH);
70
+ const saveLabel = returnDetail ? "保存并返回详情" : "保存并返回";
71
+ function backToDetail() {
72
+ if (!dirty) return goBack();
73
+ modal.confirm({
74
+ title: "放弃未保存的修改?",
75
+ content: "返回后将显示上次保存的客户信息。",
76
+ okText: "放弃修改",
77
+ cancelText: "继续编辑",
78
+ onOk: goBack,
79
+ });
80
+ }
81
+
82
+ useEffect(() => {
83
+ let active = true;
84
+ original.current = null;
85
+ setError("");
86
+ form.resetFields();
87
+ if (!updating) {
88
+ setLoading(false);
89
+ return;
90
+ }
91
+ setLoading(true);
92
+ (async () => {
93
+ try {
94
+ if (!/^\d+$/.test(id))
95
+ throw Error("缺少或无效的客户主键,请从列表重新打开更新页");
96
+ const record = await model.getOne(id);
97
+ if (!record) throw Error("客户不存在或已被删除");
98
+ if (active) {
99
+ original.current = {
100
+ ...record,
101
+ onboarding_date: record.onboarding_date
102
+ ? dayjs(record.onboarding_date)
103
+ : null,
104
+ };
105
+ form.setFieldsValue(original.current);
106
+ }
107
+ } catch (cause) {
108
+ if (active) setError(cause.message || "加载失败,请重试");
109
+ } finally {
110
+ if (active) setLoading(false);
111
+ }
112
+ })();
113
+ return () => {
114
+ active = false;
115
+ };
116
+ }, [client, id, updating, revision, form]);
117
+
118
+ useEffect(() => {
119
+ if (!saving && focusNextRecord.current) {
120
+ focusNextRecord.current = false;
121
+ const frame = requestAnimationFrame(() =>
122
+ customerNameInput.current?.focus(),
123
+ );
124
+ return () => cancelAnimationFrame(frame);
125
+ }
126
+ }, [saving, form]);
127
+ const formName = `customer-${mode}`;
128
+ function submit(stay = false) {
129
+ if (submitting.current || saving || loading || error) return;
130
+ continueAfterSave.current = stay;
131
+ form.submit();
132
+ }
133
+ async function save(values) {
134
+ if (submitting.current || (updating && !original.current)) return;
135
+ submitting.current = true;
136
+ const stayOnCreate = !updating && continueAfterSave.current;
137
+ setSaving(true);
138
+ try {
139
+ const payload = {};
140
+ for (const key of [
141
+ "customer_name",
142
+ "status",
143
+ "customer_type",
144
+ "customer_level",
145
+ "contact_name",
146
+ "phone",
147
+ "email",
148
+ "region",
149
+ "annual_revenue",
150
+ "notes",
151
+ ])
152
+ payload[key] = values[key] ?? null;
153
+ payload.customer_name = values.customer_name.trim();
154
+ payload.onboarding_date = values.onboarding_date
155
+ ? values.onboarding_date.format("YYYY-MM-DD HH:mm:ss")
156
+ : null;
157
+ if (updating) await model.update(id, payload);
158
+ else await model.create(payload);
159
+ window.dispatchEvent(
160
+ new CustomEvent("lovrabet:page-generation:changed", {
161
+ detail: LIST_PATH,
162
+ }),
163
+ );
164
+ message.success("保存成功");
165
+ setDirty(false);
166
+ if (stayOnCreate) {
167
+ focusNextRecord.current = true;
168
+ form.resetFields();
169
+ } else goBack();
170
+ } catch (cause) {
171
+ message.error(cause.message || "保存失败,请重试");
172
+ } finally {
173
+ continueAfterSave.current = false;
174
+ submitting.current = false;
175
+ setSaving(false);
176
+ }
177
+ }
178
+
179
+ const controls = [
180
+ [
181
+ "customer_name",
182
+ "客户名称",
183
+ <Input allowClear />,
184
+ [{ required: true, whitespace: true, message: "请输入客户名称" }],
185
+ ],
186
+ ["status", "状态", <Radio.Group options={statusOptions} />],
187
+ ["customer_type", "客户类型", <Radio.Group options={typeOptions} />],
188
+ ["customer_level", "客户等级", <Radio.Group options={levelOptions} />],
189
+ ["contact_name", "联系人", <Input allowClear />],
190
+ ["phone", "电话", <Input allowClear />],
191
+ [
192
+ "email",
193
+ "邮箱",
194
+ <Input allowClear />,
195
+ [{ type: "email", message: "请输入有效邮箱" }],
196
+ ],
197
+ ["region", "区域", <Input allowClear />],
198
+ [
199
+ "annual_revenue",
200
+ "年营收",
201
+ <InputNumber precision={2} style={{ width: "100%" }} />,
202
+ ],
203
+ [
204
+ "onboarding_date",
205
+ "入驻日期",
206
+ <ResponsiveDateTime
207
+ placeholder="请选择入驻日期"
208
+ style={{ width: "100%" }}
209
+ />,
210
+ ],
211
+ ];
212
+ return (
213
+ <main
214
+ className="customer-record customer-editor"
215
+ onKeyDown={(event) => {
216
+ if (
217
+ (event.ctrlKey || event.metaKey) &&
218
+ event.key === "Enter" &&
219
+ !event.nativeEvent.isComposing
220
+ ) {
221
+ event.preventDefault();
222
+ if (!saving && !loading && !error) submit();
223
+ }
224
+ }}
225
+ >
226
+ {!onePageInfo && !returnDetail && (
227
+ <Button className="record-back" disabled={saving} onClick={goBack}>
228
+ 返回列表
229
+ </Button>
230
+ )}
231
+ <header className="record-heading">
232
+ <div className="record-heading-title">
233
+ <h1>{updating ? "编辑客户" : "新增客户"}</h1>
234
+ <span className="record-save-status" role="status">
235
+ {saving
236
+ ? "正在保存…"
237
+ : dirty
238
+ ? "有未保存的修改"
239
+ : updating
240
+ ? `主键 ${id}`
241
+ : "填写客户信息"}
242
+ </span>
243
+ </div>
244
+ <Space wrap>
245
+ {returnDetail && (
246
+ <Button disabled={saving} onClick={backToDetail}>
247
+ 返回详情
248
+ </Button>
249
+ )}
250
+ <Button
251
+ type="primary"
252
+ loading={saving}
253
+ disabled={loading || Boolean(error)}
254
+ onClick={() => submit()}
255
+ title="Ctrl / ⌘ + Enter 保存"
256
+ >
257
+ {saveLabel}
258
+ </Button>
259
+ </Space>
260
+ </header>
261
+ {loading ? (
262
+ <Spin />
263
+ ) : error ? (
264
+ <Alert
265
+ type="error"
266
+ showIcon
267
+ message="加载失败"
268
+ description={error}
269
+ action={
270
+ <Button onClick={() => setRevision((v) => v + 1)}>重试</Button>
271
+ }
272
+ />
273
+ ) : (
274
+ <Form
275
+ name={formName}
276
+ form={form}
277
+ layout="vertical"
278
+ onFinish={save}
279
+ onValuesChange={() => setDirty(true)}
280
+ scrollToFirstError={{
281
+ behavior: "smooth",
282
+ block: "center",
283
+ focus: true,
284
+ }}
285
+ onFinishFailed={() => {
286
+ continueAfterSave.current = false;
287
+ }}
288
+ disabled={saving}
289
+ >
290
+ <RecordGroups includeId={updating}>
291
+ {(field) => {
292
+ if (field.key === "id")
293
+ return (
294
+ <RecordItem key={field.key} field={field}>
295
+ <InputNumber
296
+ stringMode
297
+ value={id}
298
+ disabled
299
+ style={{ width: "100%" }}
300
+ />
301
+ </RecordItem>
302
+ );
303
+ if (field.key === "notes")
304
+ return (
305
+ <RecordItem key={field.key} field={field} name="notes">
306
+ <Input.TextArea
307
+ rows={2}
308
+ allowClear
309
+ placeholder="请输入备注"
310
+ />
311
+ </RecordItem>
312
+ );
313
+ const [, , control, rules] = controls.find(
314
+ ([name]) => name === field.key,
315
+ );
316
+ return (
317
+ <RecordItem
318
+ key={field.key}
319
+ field={field}
320
+ name={field.key}
321
+ rules={rules}
322
+ >
323
+ {field.type === "TEXT" ? (
324
+ <Input
325
+ ref={
326
+ field.key === "customer_name"
327
+ ? customerNameInput
328
+ : undefined
329
+ }
330
+ allowClear
331
+ type={
332
+ field.key === "phone"
333
+ ? "tel"
334
+ : field.key === "email"
335
+ ? "email"
336
+ : "text"
337
+ }
338
+ placeholder={`请输入${field.label}`}
339
+ />
340
+ ) : (
341
+ control
342
+ )}
343
+ </RecordItem>
344
+ );
345
+ }}
346
+ </RecordGroups>
347
+ <footer
348
+ className="record-footer"
349
+ style={{
350
+ background: hostTheme?.mode === "dark" ? "#1f1f1f" : "#f5f5f5",
351
+ }}
352
+ >
353
+ <Space>
354
+ <Button
355
+ onClick={() => {
356
+ setDirty(false);
357
+ form.resetFields();
358
+ if (original.current) form.setFieldsValue(original.current);
359
+ }}
360
+ >
361
+ 重置
362
+ </Button>
363
+ {!updating && (
364
+ <Button loading={saving} onClick={() => submit(true)}>
365
+ 保存并继续新增
366
+ </Button>
367
+ )}
368
+ <Button type="primary" loading={saving} onClick={() => submit()}>
369
+ {saveLabel}
370
+ </Button>
371
+ </Space>
372
+ </footer>
373
+ </Form>
374
+ )}
375
+ </main>
376
+ );
377
+ }
378
+
379
+ export default function EditorPage({ mode }) {
380
+ const hostTheme = useAppTheme();
381
+ return (
382
+ <ConfigProvider
383
+ theme={recordTheme(
384
+ hostTheme,
385
+ hostTheme?.mode === "dark"
386
+ ? theme.darkAlgorithm
387
+ : theme.defaultAlgorithm,
388
+ )}
389
+ >
390
+ <App>
391
+ <CustomerEditor mode={mode} />
392
+ </App>
393
+ </ConfigProvider>
394
+ );
395
+ }
@@ -0,0 +1,141 @@
1
+ // 生成时按 Dataset 元信息改写字段、枚举、排序、筛选和页面路径;这些客户字段仅表示模板写法。
2
+ import dayjs from "dayjs";
3
+ export const APP_CODE = "__APP_CODE__";
4
+ export const DATASET_CODE = "__DATASET_CODE__";
5
+ export const DEFAULT_ORDER = [{ customer_name: "desc" }, { id: "desc" }];
6
+ export const LIST_PATH = "__LIST_PATH__";
7
+ export const childPaths = {
8
+ create: "__CREATE_PATH__",
9
+ update: "__UPDATE_PATH__",
10
+ detail: "__DETAIL_PATH__",
11
+ };
12
+ export const statusOptions = [
13
+ { label: "活跃", value: "active" },
14
+ { label: "非活跃", value: "inactive" },
15
+ ];
16
+ export const typeOptions = [
17
+ { label: "企业", value: "enterprise" },
18
+ { label: "个人", value: "individual" },
19
+ ];
20
+ export const levelOptions = ["a", "b", "c"].map((value) => ({
21
+ label: value.toUpperCase(),
22
+ value,
23
+ }));
24
+ export const fields = [
25
+ { key: "id", label: "主键", type: "NUMBER", width: 56, align: "right" },
26
+ { key: "customer_name", label: "客户名称", type: "TEXT", width: 212 },
27
+ {
28
+ key: "status",
29
+ label: "状态",
30
+ type: "SELECT",
31
+ width: 70,
32
+ options: statusOptions,
33
+ tag: true,
34
+ },
35
+ {
36
+ key: "customer_type",
37
+ label: "客户类型",
38
+ type: "SELECT",
39
+ width: 64,
40
+ options: typeOptions,
41
+ },
42
+ {
43
+ key: "customer_level",
44
+ label: "客户等级",
45
+ type: "SELECT",
46
+ width: 64,
47
+ options: levelOptions,
48
+ tag: true,
49
+ },
50
+ { key: "contact_name", label: "联系人", type: "TEXT", width: 104 },
51
+ { key: "phone", label: "电话", type: "TEXT", width: 64 },
52
+ { key: "email", label: "邮箱", type: "TEXT", width: 188 },
53
+ { key: "region", label: "区域", type: "TEXT", width: 60 },
54
+ {
55
+ key: "annual_revenue",
56
+ label: "年营收",
57
+ type: "NUMBER",
58
+ width: 104,
59
+ align: "right",
60
+ precision: 2,
61
+ },
62
+ { key: "onboarding_date", label: "入驻日期", type: "DATETIME", width: 128 },
63
+ ];
64
+ export function traditionalWhere(values) {
65
+ const where = {};
66
+ for (const key of ["customer_name", "region", "contact_name"]) {
67
+ const value = values[key]?.trim();
68
+ if (value) where[key] = { $contain: value };
69
+ }
70
+ for (const key of ["status", "customer_type", "customer_level"])
71
+ if (values[key] !== undefined) where[key] = { $eq: values[key] };
72
+ if (values.onboarding_date?.[0] && values.onboarding_date?.[1])
73
+ where.onboarding_date = {
74
+ $gte: values.onboarding_date[0]
75
+ .startOf("day")
76
+ .format("YYYY-MM-DD HH:mm:ss"),
77
+ $lte: values.onboarding_date[1]
78
+ .endOf("day")
79
+ .format("YYYY-MM-DD HH:mm:ss"),
80
+ };
81
+ return where;
82
+ }
83
+ // Uses the host SDK's public runtime address. No credentials or environment fallback in page files.
84
+ export async function smartWhere(client, query, { signal }) {
85
+ const properties = fields.map(
86
+ ({ key: code, label: name, type, options }) => ({
87
+ code,
88
+ name,
89
+ type,
90
+ options,
91
+ }),
92
+ );
93
+ const response = await fetch(new URL("/api/search", client.getBaseUrl()), {
94
+ method: "POST",
95
+ credentials: "include",
96
+ signal,
97
+ headers: { "Content-Type": "application/json" },
98
+ body: JSON.stringify({
99
+ id: "TEXT_TO_FILTER_PARAM",
100
+ appCode: APP_CODE,
101
+ query: `**当前时间的 ISO 字符串**\n${new Date().toISOString()}\n**用户的查询需求(自然语言)**\n${query}\n**可用于 filter 的详细字段说明(含字段名和类型)**\n${JSON.stringify(properties)}`,
102
+ }),
103
+ });
104
+ if (!response.ok) throw Error(`智能搜索失败(${response.status}),请重试`);
105
+ const envelope = await response.json();
106
+ if (envelope.success === false)
107
+ throw Error(envelope.errorMsg || "智能搜索失败,请重试");
108
+ const result = JSON.parse((envelope.data ?? envelope).content);
109
+ if (
110
+ !result ||
111
+ typeof result !== "object" ||
112
+ Array.isArray(result) ||
113
+ !result.where ||
114
+ typeof result.where !== "object" ||
115
+ Array.isArray(result.where)
116
+ )
117
+ throw Error("智能搜索未返回有效筛选条件,请换一种描述");
118
+ return result.where;
119
+ }
120
+
121
+ export function formatField(value, field) {
122
+ if (value === undefined || value === null || value === "") return "--";
123
+ if (field.options)
124
+ return (
125
+ field.options.find((option) => option.value === value)?.label ??
126
+ String(value)
127
+ );
128
+ if (field.type === "NUMBER")
129
+ return Number.isFinite(Number(value))
130
+ ? Number(value).toLocaleString("en-US", {
131
+ useGrouping: false,
132
+ minimumFractionDigits: field.precision ?? 0,
133
+ maximumFractionDigits: field.precision ?? 0,
134
+ })
135
+ : String(value);
136
+ if (field.type === "DATETIME")
137
+ return dayjs(value).isValid()
138
+ ? dayjs(value).format("YYYY-MM-DD HH:mm")
139
+ : String(value);
140
+ return String(value);
141
+ }