@lovrabet/rabetbase-cli 2.4.3 → 2.4.4-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.
- package/lib/api/api-doc.js +1 -1
- package/lib/api/fetch-model-list.js +1 -1
- package/lib/api/generate-api-file.js +1 -1
- package/lib/auth/auth-server-ui.js +1 -1
- package/lib/auth/auth-server.js +1 -1
- package/lib/auth/constant.js +1 -1
- package/lib/auth/get-cookie.js +1 -1
- package/lib/auth/get-session-user.js +1 -1
- package/lib/auth/is-session-valid.js +1 -1
- package/lib/auth/login-success-html.js +1 -1
- package/lib/auth/logout.js +1 -1
- package/lib/cli-flags.js +1 -1
- package/lib/cli.js +1 -1
- package/lib/commands/api/generate.js +1 -1
- package/lib/commands/api/index.js +1 -1
- package/lib/commands/api/list.js +1 -1
- package/lib/commands/api/pull.js +1 -1
- package/lib/commands/api/shared.js +1 -1
- package/lib/commands/app/index.js +1 -1
- package/lib/commands/app/list.js +1 -1
- package/lib/commands/app/members-list.js +1 -1
- package/lib/commands/app/remote-directory.js +1 -1
- package/lib/commands/app/shared.js +1 -1
- package/lib/commands/app-config/delete.js +1 -1
- package/lib/commands/app-config/get.js +1 -1
- package/lib/commands/app-config/index.js +1 -1
- package/lib/commands/app-config/list.js +1 -1
- package/lib/commands/app-config/set.js +1 -1
- package/lib/commands/app-config/shared.js +1 -1
- package/lib/commands/auth/index.js +1 -1
- package/lib/commands/bff/create.js +1 -1
- package/lib/commands/bff/delete.js +1 -1
- package/lib/commands/bff/detail.js +1 -1
- package/lib/commands/bff/index.js +1 -1
- package/lib/commands/bff/list.js +1 -1
- package/lib/commands/bff/pull.js +1 -1
- package/lib/commands/bff/push.js +1 -1
- package/lib/commands/bff/status.js +1 -1
- package/lib/commands/cli-skill/index.js +1 -1
- package/lib/commands/cli-update.js +1 -1
- package/lib/commands/codegen/index.js +1 -1
- package/lib/commands/codegen/sdk.js +1 -1
- package/lib/commands/codegen/sql.js +1 -1
- package/lib/commands/common/app-registry.js +1 -1
- package/lib/commands/common/app-selector.js +1 -1
- package/lib/commands/common/async-task.js +1 -1
- package/lib/commands/common/dry-run.js +1 -1
- package/lib/commands/common/flags.js +1 -1
- package/lib/commands/common/local-file.js +1 -1
- package/lib/commands/common/validate.js +1 -1
- package/lib/commands/config/get.js +1 -1
- package/lib/commands/config/index.js +1 -1
- package/lib/commands/config/list.js +1 -1
- package/lib/commands/config/set.js +1 -1
- package/lib/commands/config/shared.js +1 -1
- package/lib/commands/data/filter.js +1 -1
- package/lib/commands/data/getOne.js +1 -1
- package/lib/commands/data/index.js +1 -1
- package/lib/commands/data/shared.js +1 -1
- package/lib/commands/dataset/business-group-update.js +1 -1
- package/lib/commands/dataset/capability.js +1 -1
- package/lib/commands/dataset/delete.js +1 -1
- package/lib/commands/dataset/detail.js +1 -1
- package/lib/commands/dataset/extend-update.js +1 -1
- package/lib/commands/dataset/field-update.js +1 -1
- package/lib/commands/dataset/generate.js +1 -1
- package/lib/commands/dataset/index.js +1 -1
- package/lib/commands/dataset/list.js +1 -1
- package/lib/commands/dataset/operations.js +1 -1
- package/lib/commands/dataset/relation-audit.js +1 -1
- package/lib/commands/dataset/relation-create.js +1 -1
- package/lib/commands/dataset/relation-delete.js +1 -1
- package/lib/commands/dataset/relation-shared.js +1 -1
- package/lib/commands/dataset/relation-update.js +1 -1
- package/lib/commands/dataset/relations.js +1 -1
- package/lib/commands/dataset/rename.js +1 -1
- package/lib/commands/dataset/restore.js +1 -1
- package/lib/commands/db/analysis-batching.js +1 -1
- package/lib/commands/db/analyze-batch-plan.js +1 -1
- package/lib/commands/db/analyze-cancel.js +1 -1
- package/lib/commands/db/analyze-start.js +1 -1
- package/lib/commands/db/analyze-status.js +1 -1
- package/lib/commands/db/create.js +1 -1
- package/lib/commands/db/delete.js +1 -1
- package/lib/commands/db/detail.js +1 -1
- package/lib/commands/db/diff-refresh-start.d.ts +2 -0
- package/lib/commands/db/diff-refresh-start.js +1 -0
- package/lib/commands/db/diff-refresh-status.d.ts +2 -0
- package/lib/commands/db/diff-refresh-status.js +1 -0
- package/lib/commands/db/diff.js +1 -1
- package/lib/commands/db/index.js +1 -1
- package/lib/commands/db/list.js +1 -1
- package/lib/commands/db/shared.js +1 -1
- package/lib/commands/db/tables.js +1 -1
- package/lib/commands/db/test.js +1 -1
- package/lib/commands/db/update.js +1 -1
- package/lib/commands/doctor.js +1 -1
- package/lib/commands/file/index.js +1 -1
- package/lib/commands/init/index.js +1 -1
- package/lib/commands/issue/index.js +1 -1
- package/lib/commands/issue/nudge.js +1 -1
- package/lib/commands/issue/report.js +1 -1
- package/lib/commands/issue/shared.js +1 -1
- package/lib/commands/kb/create.js +1 -1
- package/lib/commands/kb/delete.js +1 -1
- package/lib/commands/kb/detail.js +1 -1
- package/lib/commands/kb/index.js +1 -1
- package/lib/commands/kb/list.js +1 -1
- package/lib/commands/kb/shared.js +1 -1
- package/lib/commands/kb/update.js +1 -1
- package/lib/commands/logs/index.js +1 -1
- package/lib/commands/menu/asset-update.js +1 -1
- package/lib/commands/menu/delete.js +1 -1
- package/lib/commands/menu/external-link-create.js +1 -1
- package/lib/commands/menu/external-link-update.js +1 -1
- package/lib/commands/menu/group-create.js +1 -1
- package/lib/commands/menu/group-update.js +1 -1
- package/lib/commands/menu/index.js +1 -1
- package/lib/commands/menu/list.js +1 -1
- package/lib/commands/menu/move.js +1 -1
- package/lib/commands/menu/regroup-start.js +1 -1
- package/lib/commands/menu/rename.js +1 -1
- package/lib/commands/menu/shared/compare-table.js +1 -1
- package/lib/commands/menu/shared/delete-plan.js +1 -1
- package/lib/commands/menu/shared/facts.js +1 -1
- package/lib/commands/menu/shared/index.js +1 -1
- package/lib/commands/menu/shared/inquirer.js +1 -1
- package/lib/commands/menu/shared/local-pages.js +1 -1
- package/lib/commands/menu/shared/logic.js +1 -1
- package/lib/commands/menu/shared/mutations.js +1 -1
- package/lib/commands/menu/shared/service.js +1 -1
- package/lib/commands/menu/shared/sync-core.js +1 -1
- package/lib/commands/menu/shared/update-core.js +1 -1
- package/lib/commands/menu/shared/valid-url.js +1 -1
- package/lib/commands/menu/sync.js +1 -1
- package/lib/commands/notification/config-create.d.ts +2 -0
- package/lib/commands/notification/config-create.js +1 -0
- package/lib/commands/notification/config-delete.d.ts +2 -0
- package/lib/commands/notification/config-delete.js +1 -0
- package/lib/commands/notification/config-list.js +1 -1
- package/lib/commands/notification/config-update.d.ts +2 -0
- package/lib/commands/notification/config-update.js +1 -0
- package/lib/commands/notification/index.js +1 -1
- package/lib/commands/notification/shared.d.ts +97 -0
- package/lib/commands/notification/shared.js +1 -0
- package/lib/commands/ocr/index.js +1 -1
- package/lib/commands/page/generate-start.js +1 -1
- package/lib/commands/page/generate-status.js +1 -1
- package/lib/commands/page/index.js +1 -1
- package/lib/commands/page/pull.js +1 -1
- package/lib/commands/page/push.js +1 -1
- package/lib/commands/page/react/create.js +1 -1
- package/lib/commands/page/react/detail.js +1 -1
- package/lib/commands/page/react/list.js +1 -1
- package/lib/commands/page/react/publish.js +1 -1
- package/lib/commands/page/react/shared.js +1 -1
- package/lib/commands/page/react/syntax.js +1 -1
- package/lib/commands/page/react/template.js +1 -1
- package/lib/commands/page/react/update.js +1 -1
- package/lib/commands/page/relation-audit.js +1 -1
- package/lib/commands/page/restore.js +1 -1
- package/lib/commands/page/shared.js +1 -1
- package/lib/commands/page/standard-page-status.js +1 -1
- package/lib/commands/page/sync.js +1 -1
- package/lib/commands/permit/index.js +1 -1
- package/lib/commands/permit/page-get.js +1 -1
- package/lib/commands/permit/page-set.js +1 -1
- package/lib/commands/permit/role-apis-set.js +1 -1
- package/lib/commands/permit/role-menus-set.js +1 -1
- package/lib/commands/permit/role-menus.js +1 -1
- package/lib/commands/permit/shared.js +1 -1
- package/lib/commands/project/create/enhanced-guided-create.js +1 -1
- package/lib/commands/project/create/format-elapsed.js +1 -1
- package/lib/commands/project/create/main.d.ts +1 -0
- package/lib/commands/project/create/main.js +1 -1
- package/lib/commands/project/create/materialize-project-template.d.ts +11 -0
- package/lib/commands/project/create/materialize-project-template.js +1 -0
- package/lib/commands/project/create/project-name.d.ts +2 -0
- package/lib/commands/project/create/project-name.js +1 -0
- package/lib/commands/project/create/project-template-archive.d.ts +6 -0
- package/lib/commands/project/create/project-template-archive.js +1 -0
- package/lib/commands/project/create/project-template-path.d.ts +1 -3
- package/lib/commands/project/create/project-template-path.js +1 -1
- package/lib/commands/project/create/use-copy-project-template.d.ts +2 -1
- package/lib/commands/project/create/use-copy-project-template.js +1 -1
- package/lib/commands/project/create/use-format-code.js +1 -1
- package/lib/commands/project/create/use-install-dependencies.js +1 -1
- package/lib/commands/project/index.js +1 -1
- package/lib/commands/project/upgrade.js +1 -1
- package/lib/commands/registry.js +1 -1
- package/lib/commands/role/create.js +1 -1
- package/lib/commands/role/delete.js +1 -1
- package/lib/commands/role/detail.js +1 -1
- package/lib/commands/role/index.js +1 -1
- package/lib/commands/role/list.js +1 -1
- package/lib/commands/role/shared.js +1 -1
- package/lib/commands/role/update.js +1 -1
- package/lib/commands/role/user-add.js +1 -1
- package/lib/commands/role/user-remove.js +1 -1
- package/lib/commands/role/user-resolve.js +1 -1
- package/lib/commands/run/index.js +1 -1
- package/lib/commands/schema.js +1 -1
- package/lib/commands/sql/create.js +1 -1
- package/lib/commands/sql/delete.js +1 -1
- package/lib/commands/sql/detail.js +1 -1
- package/lib/commands/sql/exec.js +1 -1
- package/lib/commands/sql/index.js +1 -1
- package/lib/commands/sql/list.js +1 -1
- package/lib/commands/sql/pull.js +1 -1
- package/lib/commands/sql/push.js +1 -1
- package/lib/commands/sql/shared.js +1 -1
- package/lib/commands/sql/status.js +1 -1
- package/lib/commands/sql/validate.js +1 -1
- package/lib/commands/task/index.js +1 -1
- package/lib/commands/task/status.js +1 -1
- package/lib/commands/tenant/index.js +1 -1
- package/lib/commands/tenant/members-list.js +1 -1
- package/lib/commands/tenant/shared.js +1 -1
- package/lib/commands/user-account/dingding-sandbox-bind.js +1 -1
- package/lib/commands/user-account/index.js +1 -1
- package/lib/commands/workspace/add.js +1 -1
- package/lib/commands/workspace/index.js +1 -1
- package/lib/commands/workspace/remove.js +1 -1
- package/lib/config/schema.js +1 -1
- package/lib/constant/cdn.d.ts +2 -0
- package/lib/constant/cdn.js +1 -1
- package/lib/constant/cli.js +1 -1
- package/lib/constant/defaults.js +1 -1
- package/lib/constant/domain.js +1 -1
- package/lib/constant/env.js +1 -1
- package/lib/constant/output.js +1 -1
- package/lib/constant/paths.js +1 -1
- package/lib/constant/risk.js +1 -1
- package/lib/context/app-resolver.js +1 -1
- package/lib/context/auth-resolver.js +1 -1
- package/lib/context/config-loader.js +1 -1
- package/lib/context.d.ts +1 -1
- package/lib/context.js +1 -1
- package/lib/core/alias-resolver.js +1 -1
- package/lib/core/api-client.d.ts +29 -2
- package/lib/core/api-client.js +1 -1
- package/lib/core/bff/config.js +1 -1
- package/lib/core/bff/file-system.js +1 -1
- package/lib/core/bff/hash.js +1 -1
- package/lib/core/bff/lock.js +1 -1
- package/lib/core/bff/utils.js +1 -1
- package/lib/core/db-resolver.js +1 -1
- package/lib/core/page/file-system.js +1 -1
- package/lib/core/page/hash.js +1 -1
- package/lib/core/page/lock.js +1 -1
- package/lib/core/sql-index-auditor.js +1 -1
- package/lib/core/sql-sync/config.js +1 -1
- package/lib/core/sql-sync/file-system.js +1 -1
- package/lib/core/sql-sync/hash.js +1 -1
- package/lib/core/sql-sync/lock.js +1 -1
- package/lib/core/sql-sync/utils.js +1 -1
- package/lib/core/sql-validator.js +1 -1
- package/lib/errors.js +1 -1
- package/lib/framework/build-all-flags.js +1 -1
- package/lib/framework/error-output.js +1 -1
- package/lib/framework/explicit-yes.js +1 -1
- package/lib/framework/flags.js +1 -1
- package/lib/framework/help.js +1 -1
- package/lib/framework/index.js +1 -1
- package/lib/framework/output.js +1 -1
- package/lib/framework/response.js +1 -1
- package/lib/framework/runner-alias.js +1 -1
- package/lib/framework/runner.js +1 -1
- package/lib/framework/schema-export.js +1 -1
- package/lib/framework/types.js +1 -1
- package/lib/generated/build-info.d.ts +4 -4
- package/lib/generated/build-info.js +1 -1
- package/lib/help.js +1 -1
- package/lib/postinstall.js +1 -1
- package/lib/runtime/confirmation.js +1 -1
- package/lib/runtime/event.js +1 -1
- package/lib/runtime/index.js +1 -1
- package/lib/runtime/queue.js +1 -1
- package/lib/runtime/resolve.js +1 -1
- package/lib/skills/builtin-skill.js +1 -1
- package/lib/skills/main.js +1 -1
- package/lib/skills/npx-skills-add.js +1 -1
- package/lib/skills/skill-presence.js +1 -1
- package/lib/telemetry/cli-command-trace.js +1 -1
- package/lib/telemetry/cli-help-trace.js +1 -1
- package/lib/telemetry/ensure-cli-otel-config.js +1 -1
- package/lib/telemetry/register-otel-exit-shutdown.js +1 -1
- package/lib/telemetry/send-cli-trace-log.js +1 -1
- package/lib/telemetry/send-platform-issue-collect-log.js +1 -1
- package/lib/utils/ai_config.js +1 -1
- package/lib/utils/apply-jq-filter.js +1 -1
- package/lib/utils/cdn-config.js +1 -1
- package/lib/utils/check-sdk-version.js +1 -1
- package/lib/utils/cli-version-check.js +1 -1
- package/lib/utils/cli-version-policy.d.ts +13 -0
- package/lib/utils/cli-version-policy.js +1 -1
- package/lib/utils/config.js +1 -1
- package/lib/utils/entity-with-id.js +1 -1
- package/lib/utils/file-utils.js +1 -1
- package/lib/utils/guides-cdn.js +1 -1
- package/lib/utils/http-client.js +1 -1
- package/lib/utils/is-non-interactive.js +1 -1
- package/lib/utils/logger.js +1 -1
- package/lib/utils/params.js +1 -1
- package/lib/utils/platform.js +1 -1
- package/lib/utils/rules-cdn.js +1 -1
- package/lib/utils/sleep.js +1 -1
- package/lib/utils/template-replacer.js +1 -1
- package/lib/utils/update-notice.js +1 -1
- package/lib/utils/version.js +1 -1
- package/lib/utils/with-active-cookie.js +1 -1
- package/lib/utils/write-cli-side-channel.js +1 -1
- package/package.json +9 -4
- package/skills/rabetbase/SKILL.md +33 -22
- package/skills/rabetbase/guides/backend-function.md +5 -3
- package/skills/rabetbase/guides/bff-creation-workflow.md +2 -2
- package/skills/rabetbase/guides/conflict-detection.md +2 -2
- package/skills/rabetbase/guides/database-connection-workflow.md +39 -5
- package/skills/rabetbase/guides/react-custom-page-workflow.md +16 -4
- package/skills/rabetbase/guides/sql-creation-workflow.md +4 -2
- package/skills/rabetbase/guides/sql-mybatis.md +2 -2
- package/skills/rabetbase/knowledge/page-schema/YtPage.md +3 -37
- package/skills/rabetbase/knowledge/react-page/generation-standards.md +14 -3
- package/skills/rabetbase/references/rabetbase-app-config.md +2 -2
- package/skills/rabetbase/references/rabetbase-bff-push.md +4 -5
- package/skills/rabetbase/references/rabetbase-bff-save.md +3 -3
- package/skills/rabetbase/references/rabetbase-config.md +2 -2
- package/skills/rabetbase/references/rabetbase-db-analyze.md +2 -2
- package/skills/rabetbase/references/rabetbase-db-detail.md +3 -0
- package/skills/rabetbase/references/rabetbase-db-diff-refresh.md +53 -0
- package/skills/rabetbase/references/rabetbase-db-diff.md +40 -21
- package/skills/rabetbase/references/rabetbase-db-list.md +1 -1
- package/skills/rabetbase/references/rabetbase-kb.md +5 -3
- package/skills/rabetbase/references/rabetbase-menu-asset-update.md +9 -10
- package/skills/rabetbase/references/rabetbase-menu-external-link-update.md +1 -3
- package/skills/rabetbase/references/rabetbase-menu-regroup-start.md +2 -3
- package/skills/rabetbase/references/rabetbase-notification-config-list.md +2 -2
- package/skills/rabetbase/references/rabetbase-notification-config-mutations.md +56 -0
- package/skills/rabetbase/references/rabetbase-page-react-detail.md +1 -1
- package/skills/rabetbase/references/rabetbase-page-react-list.md +1 -1
- package/skills/rabetbase/references/rabetbase-page-react-publish.md +2 -2
- package/skills/rabetbase/references/rabetbase-project-create.md +3 -0
- package/skills/rabetbase/references/rabetbase-run.md +1 -1
- package/skills/rabetbase/references/rabetbase-sql-create.md +1 -1
- package/skills/rabetbase/references/rabetbase-sql-push.md +3 -4
- package/skills/rabetbase/references/rabetbase-user-account.md +0 -1
- package/skills/rabetbase.manifest.json +5 -5
- package/templates/README.md +14 -2
- package/lib/commands/project/create/non-interactive.d.ts +0 -9
- package/lib/commands/project/create/non-interactive.js +0 -1
- package/lib/utils/copy-directory.d.ts +0 -1
- package/lib/utils/copy-directory.js +0 -1
- package/skills/rabetbase/knowledge/page-schema/LrSmartEcharts.md +0 -291
- package/skills/rabetbase/knowledge/page-schema/LrSmartStatistic.md +0 -223
- package/templates/projects/sub-app-react-demo/.prettierrc +0 -1
- package/templates/projects/sub-app-react-demo/CHANGELOG.md +0 -67
- package/templates/projects/sub-app-react-demo/README.md +0 -246
- package/templates/projects/sub-app-react-demo/docs/quick-start.md +0 -245
- package/templates/projects/sub-app-react-demo/index.html +0 -27
- package/templates/projects/sub-app-react-demo/package.json +0 -34
- package/templates/projects/sub-app-react-demo/public/logo.svg +0 -1
- package/templates/projects/sub-app-react-demo/public/vite.svg +0 -1
- package/templates/projects/sub-app-react-demo/src/api/api.ts +0 -26
- package/templates/projects/sub-app-react-demo/src/api/client.ts +0 -32
- package/templates/projects/sub-app-react-demo/src/components/demo-page-container/DemoPageContainer.module.css +0 -28
- package/templates/projects/sub-app-react-demo/src/components/demo-page-container/DemoPageContainer.tsx +0 -55
- package/templates/projects/sub-app-react-demo/src/layouts/MainLayout.tsx +0 -308
- package/templates/projects/sub-app-react-demo/src/main.tsx +0 -52
- package/templates/projects/sub-app-react-demo/src/pages/dashboard/index.tsx +0 -570
- package/templates/projects/sub-app-react-demo/src/pages/data-screen/index.tsx +0 -531
- package/templates/projects/sub-app-react-demo/src/pages/index.module.css +0 -500
- package/templates/projects/sub-app-react-demo/src/pages/index.tsx +0 -641
- package/templates/projects/sub-app-react-demo/src/pages/sdk-demo/index.tsx +0 -536
- package/templates/projects/sub-app-react-demo/src/pages/workbench/index.module.css +0 -295
- package/templates/projects/sub-app-react-demo/src/pages/workbench/index.tsx +0 -242
- package/templates/projects/sub-app-react-demo/src/router/index.tsx +0 -30
- package/templates/projects/sub-app-react-demo/src/style.css +0 -108
- package/templates/projects/sub-app-react-demo/src/utils/api.ts +0 -12
- package/templates/projects/sub-app-react-demo/src/vite-env.d.ts +0 -2
- package/templates/projects/sub-app-react-demo/tsconfig.json +0 -26
- package/templates/projects/sub-app-react-demo/vite.config.ts +0 -111
|
@@ -1,536 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect } from "react";
|
|
2
|
-
import {
|
|
3
|
-
Button,
|
|
4
|
-
Table,
|
|
5
|
-
Card,
|
|
6
|
-
Typography,
|
|
7
|
-
Space,
|
|
8
|
-
message,
|
|
9
|
-
Select,
|
|
10
|
-
Input,
|
|
11
|
-
Tag,
|
|
12
|
-
} from "antd";
|
|
13
|
-
import {
|
|
14
|
-
ApiOutlined,
|
|
15
|
-
CheckOutlined,
|
|
16
|
-
CopyOutlined,
|
|
17
|
-
DownOutlined,
|
|
18
|
-
UpOutlined,
|
|
19
|
-
} from "@ant-design/icons";
|
|
20
|
-
import { lovrabetClient } from "@/api/client";
|
|
21
|
-
import DemoPageContainer from "@/components/demo-page-container/DemoPageContainer";
|
|
22
|
-
|
|
23
|
-
const { Title, Paragraph, Text } = Typography;
|
|
24
|
-
|
|
25
|
-
interface CollapsibleCodeBlockProps {
|
|
26
|
-
title: string;
|
|
27
|
-
code: string;
|
|
28
|
-
accent?: boolean;
|
|
29
|
-
defaultExpanded?: boolean;
|
|
30
|
-
maxHeight?: number;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function CollapsibleCodeBlock({
|
|
34
|
-
title,
|
|
35
|
-
code,
|
|
36
|
-
accent = false,
|
|
37
|
-
defaultExpanded = false,
|
|
38
|
-
maxHeight,
|
|
39
|
-
}: CollapsibleCodeBlockProps) {
|
|
40
|
-
const [expanded, setExpanded] = useState(defaultExpanded);
|
|
41
|
-
const [copied, setCopied] = useState(false);
|
|
42
|
-
|
|
43
|
-
const handleCopy = async () => {
|
|
44
|
-
try {
|
|
45
|
-
if (navigator.clipboard?.writeText) {
|
|
46
|
-
await navigator.clipboard.writeText(code);
|
|
47
|
-
}
|
|
48
|
-
setCopied(true);
|
|
49
|
-
window.setTimeout(() => setCopied(false), 2000);
|
|
50
|
-
} catch (error) {
|
|
51
|
-
console.error("复制代码失败:", error);
|
|
52
|
-
message.error("复制代码失败");
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
return (
|
|
57
|
-
<div
|
|
58
|
-
style={{
|
|
59
|
-
border: `1px solid ${accent ? "#1890ff" : "#d9d9d9"}`,
|
|
60
|
-
borderRadius: 6,
|
|
61
|
-
overflow: "hidden",
|
|
62
|
-
background: "#fff",
|
|
63
|
-
}}
|
|
64
|
-
>
|
|
65
|
-
<div
|
|
66
|
-
style={{
|
|
67
|
-
display: "flex",
|
|
68
|
-
justifyContent: "space-between",
|
|
69
|
-
alignItems: "center",
|
|
70
|
-
gap: 12,
|
|
71
|
-
padding: "10px 12px",
|
|
72
|
-
background: accent ? "#f0f8ff" : "#fafafa",
|
|
73
|
-
borderBottom: expanded
|
|
74
|
-
? `1px solid ${accent ? "#1890ff" : "#d9d9d9"}`
|
|
75
|
-
: "none",
|
|
76
|
-
}}
|
|
77
|
-
>
|
|
78
|
-
<Text strong>{title}</Text>
|
|
79
|
-
<Space size={8}>
|
|
80
|
-
<Button
|
|
81
|
-
size="small"
|
|
82
|
-
icon={copied ? <CheckOutlined /> : <CopyOutlined />}
|
|
83
|
-
onClick={handleCopy}
|
|
84
|
-
>
|
|
85
|
-
{copied ? "已复制" : "复制"}
|
|
86
|
-
</Button>
|
|
87
|
-
<Button
|
|
88
|
-
size="small"
|
|
89
|
-
icon={expanded ? <UpOutlined /> : <DownOutlined />}
|
|
90
|
-
onClick={() => setExpanded((current) => !current)}
|
|
91
|
-
>
|
|
92
|
-
{expanded ? "收起" : "展开"}
|
|
93
|
-
</Button>
|
|
94
|
-
</Space>
|
|
95
|
-
</div>
|
|
96
|
-
{expanded && (
|
|
97
|
-
<pre
|
|
98
|
-
style={{
|
|
99
|
-
background: accent ? "#f0f8ff" : "#f5f5f5",
|
|
100
|
-
padding: "16px",
|
|
101
|
-
margin: 0,
|
|
102
|
-
fontSize: "13px",
|
|
103
|
-
maxHeight,
|
|
104
|
-
overflow: "auto",
|
|
105
|
-
}}
|
|
106
|
-
>
|
|
107
|
-
{code}
|
|
108
|
-
</pre>
|
|
109
|
-
)}
|
|
110
|
-
</div>
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export default function SdkDemo() {
|
|
115
|
-
const [loading, setLoading] = useState(false);
|
|
116
|
-
const [data, setData] = useState<any[]>([]);
|
|
117
|
-
const [columns, setColumns] = useState<any[]>([]);
|
|
118
|
-
const [modelList, setModelList] = useState<
|
|
119
|
-
Array<{
|
|
120
|
-
value: string;
|
|
121
|
-
label: string;
|
|
122
|
-
alias?: string;
|
|
123
|
-
name?: string;
|
|
124
|
-
datasetCode: string;
|
|
125
|
-
}>
|
|
126
|
-
>([]);
|
|
127
|
-
const [selectedModel, setSelectedModel] = useState<string>("");
|
|
128
|
-
const [selectOptions, setSelectOptions] = useState<any[]>([]);
|
|
129
|
-
const [codeField, setCodeField] = useState<string>("id");
|
|
130
|
-
const [labelField, setLabelField] = useState<string>("");
|
|
131
|
-
|
|
132
|
-
// 获取选中模型的信息(用于代码示例展示 alias)
|
|
133
|
-
const selectedModelInfo = modelList.find((m) => m.value === selectedModel);
|
|
134
|
-
|
|
135
|
-
const filterCodeExample = `// ========== 方式一:标准 dataset_code 模式(推荐 AI/LLM 使用)==========
|
|
136
|
-
const response = await lovrabetClient
|
|
137
|
-
.models['${selectedModel || "dataset_xxx"}'].filter({
|
|
138
|
-
currentPage: 1,
|
|
139
|
-
pageSize: 10
|
|
140
|
-
});
|
|
141
|
-
${
|
|
142
|
-
selectedModelInfo?.alias
|
|
143
|
-
? `
|
|
144
|
-
// ========== 方式二:人类友好的 alias 模式 ==========
|
|
145
|
-
const response = await lovrabetClient
|
|
146
|
-
.models.${selectedModelInfo.alias}.filter({
|
|
147
|
-
currentPage: 1,
|
|
148
|
-
pageSize: 10
|
|
149
|
-
});
|
|
150
|
-
`
|
|
151
|
-
: ""
|
|
152
|
-
}
|
|
153
|
-
// ========== 完整查询示例(所有参数均为可选)==========
|
|
154
|
-
const response = await lovrabetClient
|
|
155
|
-
.models['${selectedModel || "dataset_xxx"}'].filter({
|
|
156
|
-
// where: 条件查询(可选)
|
|
157
|
-
// where: {
|
|
158
|
-
// age: { $gte: 18 },
|
|
159
|
-
// status: { $eq: 'active' }
|
|
160
|
-
// },
|
|
161
|
-
|
|
162
|
-
// select: 字段选择(可选)
|
|
163
|
-
// select: ['id', 'name', 'age'],
|
|
164
|
-
|
|
165
|
-
// orderBy: 排序(可选)
|
|
166
|
-
// orderBy: [{ createTime: 'desc' }],
|
|
167
|
-
|
|
168
|
-
// 分页参数(必需)
|
|
169
|
-
currentPage: 1,
|
|
170
|
-
pageSize: 10
|
|
171
|
-
});
|
|
172
|
-
|
|
173
|
-
// 其他可用参数(仅示例,以实际字段为准):
|
|
174
|
-
// - where: 支持 $eq, $ne, $gte, $lte, $in, $contain, $startWith, $endWith 等操作符
|
|
175
|
-
// - where: 支持 $and, $or 逻辑组合
|
|
176
|
-
// - select: 数组形式,指定返回的字段
|
|
177
|
-
// - orderBy: 数组形式,支持多字段排序 [{ field1: 'desc' }, { field2: 'asc' }]`;
|
|
178
|
-
|
|
179
|
-
const selectOptionsCodeExample = `// ========== 方式一:标准 dataset_code 模式(推荐 AI/LLM 使用)==========
|
|
180
|
-
const options = await lovrabetClient
|
|
181
|
-
.models['${selectedModel || "dataset_xxx"}'].getSelectOptions({
|
|
182
|
-
code: "${codeField || "id"}",
|
|
183
|
-
label: "${labelField || "name"}"
|
|
184
|
-
});
|
|
185
|
-
${
|
|
186
|
-
selectedModelInfo?.alias
|
|
187
|
-
? `
|
|
188
|
-
// ========== 方式二:人类友好的 alias 模式 ==========
|
|
189
|
-
const options = await lovrabetClient
|
|
190
|
-
.models.${selectedModelInfo.alias}.getSelectOptions({
|
|
191
|
-
code: "${codeField || "id"}",
|
|
192
|
-
label: "${labelField || "name"}"
|
|
193
|
-
});
|
|
194
|
-
`
|
|
195
|
-
: ""
|
|
196
|
-
}
|
|
197
|
-
// 返回格式:[{ label: "显示文本", value: "选项值" }]`;
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* 加载可用的数据模型列表
|
|
201
|
-
*/
|
|
202
|
-
useEffect(() => {
|
|
203
|
-
try {
|
|
204
|
-
// 使用 getModelListDetails 获取人类友好的模型列表
|
|
205
|
-
const models = lovrabetClient.getModelListDetails();
|
|
206
|
-
setModelList(models);
|
|
207
|
-
// 默认选择第一个模型
|
|
208
|
-
if (models.length > 0) {
|
|
209
|
-
setSelectedModel(models[0].value);
|
|
210
|
-
}
|
|
211
|
-
} catch (error) {
|
|
212
|
-
console.error("获取模型列表失败:", error);
|
|
213
|
-
message.error("获取模型列表失败");
|
|
214
|
-
}
|
|
215
|
-
}, []);
|
|
216
|
-
|
|
217
|
-
/**
|
|
218
|
-
* 使用 filter 接口查询数据
|
|
219
|
-
*/
|
|
220
|
-
const loadData = async () => {
|
|
221
|
-
if (!selectedModel) {
|
|
222
|
-
message.warning("请先选择一个数据模型");
|
|
223
|
-
return;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
setLoading(true);
|
|
227
|
-
|
|
228
|
-
try {
|
|
229
|
-
// 使用 filter 接口进行查询
|
|
230
|
-
const response = await lovrabetClient.models[selectedModel].filter({
|
|
231
|
-
currentPage: 1,
|
|
232
|
-
pageSize: 10,
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
processResponse(response, "查询成功!");
|
|
236
|
-
} catch (error: any) {
|
|
237
|
-
handleError(error, "查询");
|
|
238
|
-
} finally {
|
|
239
|
-
setLoading(false);
|
|
240
|
-
}
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
/**
|
|
244
|
-
* 处理响应数据
|
|
245
|
-
*/
|
|
246
|
-
const processResponse = (response: any, successMessage: string) => {
|
|
247
|
-
try {
|
|
248
|
-
// filter 接口返回的数据结构
|
|
249
|
-
const tableData = response?.tableData || response?.data || [];
|
|
250
|
-
|
|
251
|
-
// 确保 tableData 是数组
|
|
252
|
-
if (!Array.isArray(tableData)) {
|
|
253
|
-
console.error("返回的数据不是数组格式:", tableData);
|
|
254
|
-
message.error("返回数据格式错误,请检查 API 响应");
|
|
255
|
-
return;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
setData(tableData);
|
|
259
|
-
|
|
260
|
-
// 优先使用 tableColumns 配置
|
|
261
|
-
if (response?.tableColumns && Array.isArray(response.tableColumns)) {
|
|
262
|
-
// 如果有 tableColumns,优先使用它
|
|
263
|
-
const tableColumns = response.tableColumns.map((column: any) => ({
|
|
264
|
-
title:
|
|
265
|
-
column.title || column.dataIndex || column.key || String(column),
|
|
266
|
-
dataIndex: column.dataIndex || column.key || String(column),
|
|
267
|
-
key: column.dataIndex || column.key || String(column),
|
|
268
|
-
// 处理对象/数组类型的值,避免 React Error #31
|
|
269
|
-
render: (value: any) => {
|
|
270
|
-
if (value === null || value === undefined) {
|
|
271
|
-
return "-";
|
|
272
|
-
}
|
|
273
|
-
if (typeof value === "object") {
|
|
274
|
-
return JSON.stringify(value);
|
|
275
|
-
}
|
|
276
|
-
return String(value);
|
|
277
|
-
},
|
|
278
|
-
}));
|
|
279
|
-
setColumns(tableColumns);
|
|
280
|
-
} else if (tableData.length > 0) {
|
|
281
|
-
// 如果没有 tableColumns,从第一条数据中提取字段名作为列
|
|
282
|
-
const firstRow = tableData[0];
|
|
283
|
-
if (firstRow && typeof firstRow === "object") {
|
|
284
|
-
const tableColumns = Object.keys(firstRow).map((key) => ({
|
|
285
|
-
title: key,
|
|
286
|
-
dataIndex: key,
|
|
287
|
-
key: key,
|
|
288
|
-
// 处理对象/数组类型的值,避免 React Error #31
|
|
289
|
-
render: (value: any) => {
|
|
290
|
-
if (value === null || value === undefined) {
|
|
291
|
-
return "-";
|
|
292
|
-
}
|
|
293
|
-
if (typeof value === "object") {
|
|
294
|
-
return JSON.stringify(value);
|
|
295
|
-
}
|
|
296
|
-
return String(value);
|
|
297
|
-
},
|
|
298
|
-
}));
|
|
299
|
-
setColumns(tableColumns);
|
|
300
|
-
}
|
|
301
|
-
} else {
|
|
302
|
-
// 如果没有数据也没有列定义,清空列
|
|
303
|
-
setColumns([]);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
message.success(successMessage);
|
|
307
|
-
} catch (error: any) {
|
|
308
|
-
console.error("处理响应数据失败:", error);
|
|
309
|
-
message.error(`处理数据失败: ${error.message}`);
|
|
310
|
-
}
|
|
311
|
-
};
|
|
312
|
-
|
|
313
|
-
/**
|
|
314
|
-
* 获取下拉选项
|
|
315
|
-
*/
|
|
316
|
-
const loadSelectOptions = async () => {
|
|
317
|
-
if (!selectedModel) {
|
|
318
|
-
message.warning("请先选择一个数据模型");
|
|
319
|
-
return;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if (!codeField || !labelField) {
|
|
323
|
-
message.warning("请输入 code 和 label 字段名");
|
|
324
|
-
return;
|
|
325
|
-
}
|
|
326
|
-
|
|
327
|
-
setLoading(true);
|
|
328
|
-
setSelectOptions([]);
|
|
329
|
-
|
|
330
|
-
try {
|
|
331
|
-
const options = await lovrabetClient.models[
|
|
332
|
-
selectedModel
|
|
333
|
-
].getSelectOptions({
|
|
334
|
-
code: codeField,
|
|
335
|
-
label: labelField,
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
setSelectOptions(options);
|
|
339
|
-
message.success(`成功获取 ${options.length} 个下拉选项`);
|
|
340
|
-
console.log("下拉选项数据:", options);
|
|
341
|
-
} catch (error: any) {
|
|
342
|
-
console.error("获取下拉选项失败:", error);
|
|
343
|
-
message.error(`获取下拉选项失败: ${error.message}`);
|
|
344
|
-
} finally {
|
|
345
|
-
setLoading(false);
|
|
346
|
-
}
|
|
347
|
-
};
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* 处理错误
|
|
351
|
-
*/
|
|
352
|
-
const handleError = (error: any, action: string) => {
|
|
353
|
-
console.error(`${action}失败:`, error);
|
|
354
|
-
message.error(`${action}失败: ${error.message}`);
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
return (
|
|
358
|
-
<DemoPageContainer>
|
|
359
|
-
<div>
|
|
360
|
-
{/* 标题 */}
|
|
361
|
-
<Title level={2}>
|
|
362
|
-
<ApiOutlined /> Lovrabet SDK 简单演示
|
|
363
|
-
</Title>
|
|
364
|
-
|
|
365
|
-
<Paragraph style={{ color: "#666", marginBottom: 24 }}>
|
|
366
|
-
演示 Lovrabet SDK 的 <Text strong>filter</Text> 接口使用方法。filter
|
|
367
|
-
接口支持复杂条件查询、字段选择、多字段排序等功能。
|
|
368
|
-
<br />
|
|
369
|
-
<strong>注意:</strong>代码示例中的 "Requirements"
|
|
370
|
-
是假设已经存在的数据模型名称,实际使用时请根据下拉框中的可用模型进行选择。
|
|
371
|
-
</Paragraph>
|
|
372
|
-
|
|
373
|
-
{/* 数据模型选择 */}
|
|
374
|
-
<Card title="选择数据模型" size="small" style={{ marginBottom: 16 }}>
|
|
375
|
-
<Space>
|
|
376
|
-
<Select
|
|
377
|
-
placeholder="选择要查询的数据模型"
|
|
378
|
-
style={{ width: 350 }}
|
|
379
|
-
value={selectedModel}
|
|
380
|
-
onChange={setSelectedModel}
|
|
381
|
-
showSearch
|
|
382
|
-
optionFilterProp="label"
|
|
383
|
-
options={modelList}
|
|
384
|
-
/>
|
|
385
|
-
<Button
|
|
386
|
-
type="primary"
|
|
387
|
-
loading={loading}
|
|
388
|
-
onClick={loadData}
|
|
389
|
-
icon={<ApiOutlined />}
|
|
390
|
-
disabled={!selectedModel}
|
|
391
|
-
>
|
|
392
|
-
查询数据
|
|
393
|
-
</Button>
|
|
394
|
-
</Space>
|
|
395
|
-
</Card>
|
|
396
|
-
|
|
397
|
-
{/* 数据表格 */}
|
|
398
|
-
{data.length > 0 && (
|
|
399
|
-
<Card title="数据结果" size="small" style={{ marginBottom: 16 }}>
|
|
400
|
-
<Table
|
|
401
|
-
columns={columns}
|
|
402
|
-
dataSource={data}
|
|
403
|
-
rowKey={(_, index) => index?.toString() || "0"}
|
|
404
|
-
pagination={false}
|
|
405
|
-
size="small"
|
|
406
|
-
scroll={{ x: true }}
|
|
407
|
-
/>
|
|
408
|
-
</Card>
|
|
409
|
-
)}
|
|
410
|
-
|
|
411
|
-
{/* 代码示例 */}
|
|
412
|
-
<Card title="代码示例" size="small" style={{ marginBottom: 16 }}>
|
|
413
|
-
<CollapsibleCodeBlock
|
|
414
|
-
title="filter 查询代码"
|
|
415
|
-
code={filterCodeExample}
|
|
416
|
-
accent
|
|
417
|
-
defaultExpanded
|
|
418
|
-
/>
|
|
419
|
-
</Card>
|
|
420
|
-
|
|
421
|
-
{/* 获取下拉选项 */}
|
|
422
|
-
<Card title="📋 获取下拉选项" size="small" style={{ marginBottom: 16 }}>
|
|
423
|
-
<Space direction="vertical" style={{ width: "100%" }}>
|
|
424
|
-
<div style={{ color: "#666" }}>
|
|
425
|
-
用于获取数据表的下拉选项数据,适用于 Select、Radio、Checkbox
|
|
426
|
-
等表单组件(仅 WebAPI 模式支持)
|
|
427
|
-
</div>
|
|
428
|
-
|
|
429
|
-
{/* 显示可用字段 */}
|
|
430
|
-
{columns.length > 0 && (
|
|
431
|
-
<div style={{ marginBottom: 8 }}>
|
|
432
|
-
<span style={{ color: "#666", marginRight: 8 }}>
|
|
433
|
-
可用字段(点击快速填入):
|
|
434
|
-
</span>
|
|
435
|
-
<Space wrap size={[4, 4]}>
|
|
436
|
-
{columns.map((column: any) => (
|
|
437
|
-
<Tag
|
|
438
|
-
key={column.dataIndex}
|
|
439
|
-
color="blue"
|
|
440
|
-
style={{ cursor: "pointer" }}
|
|
441
|
-
onClick={() => {
|
|
442
|
-
if (!codeField) {
|
|
443
|
-
setCodeField(column.dataIndex);
|
|
444
|
-
message.success(
|
|
445
|
-
`已填入 Code 字段: ${column.dataIndex}`,
|
|
446
|
-
);
|
|
447
|
-
} else if (!labelField) {
|
|
448
|
-
setLabelField(column.dataIndex);
|
|
449
|
-
message.success(
|
|
450
|
-
`已填入 Label 字段: ${column.dataIndex}`,
|
|
451
|
-
);
|
|
452
|
-
} else {
|
|
453
|
-
message.info(
|
|
454
|
-
"Code 和 Label 已填写,如需更换请先清空",
|
|
455
|
-
);
|
|
456
|
-
}
|
|
457
|
-
}}
|
|
458
|
-
>
|
|
459
|
-
{column.dataIndex}
|
|
460
|
-
</Tag>
|
|
461
|
-
))}
|
|
462
|
-
</Space>
|
|
463
|
-
</div>
|
|
464
|
-
)}
|
|
465
|
-
|
|
466
|
-
<Space wrap>
|
|
467
|
-
<span>Code 字段:</span>
|
|
468
|
-
<Input
|
|
469
|
-
placeholder="用作选项值的字段名"
|
|
470
|
-
value={codeField}
|
|
471
|
-
onChange={(e) => setCodeField(e.target.value)}
|
|
472
|
-
style={{ width: 200 }}
|
|
473
|
-
allowClear
|
|
474
|
-
/>
|
|
475
|
-
<span>Label 字段:</span>
|
|
476
|
-
<Input
|
|
477
|
-
placeholder="用作显示文本的字段名"
|
|
478
|
-
value={labelField}
|
|
479
|
-
onChange={(e) => setLabelField(e.target.value)}
|
|
480
|
-
style={{ width: 200 }}
|
|
481
|
-
allowClear
|
|
482
|
-
/>
|
|
483
|
-
<Button
|
|
484
|
-
type="primary"
|
|
485
|
-
loading={loading}
|
|
486
|
-
onClick={loadSelectOptions}
|
|
487
|
-
icon={<ApiOutlined />}
|
|
488
|
-
disabled={!selectedModel || !codeField || !labelField}
|
|
489
|
-
>
|
|
490
|
-
获取选项
|
|
491
|
-
</Button>
|
|
492
|
-
</Space>
|
|
493
|
-
|
|
494
|
-
<CollapsibleCodeBlock
|
|
495
|
-
title="getSelectOptions 代码"
|
|
496
|
-
code={selectOptionsCodeExample}
|
|
497
|
-
defaultExpanded
|
|
498
|
-
/>
|
|
499
|
-
</Space>
|
|
500
|
-
</Card>
|
|
501
|
-
|
|
502
|
-
{/* 下拉选项结果 */}
|
|
503
|
-
{selectOptions.length > 0 && (
|
|
504
|
-
<Card
|
|
505
|
-
title={`下拉选项结果(共 ${selectOptions.length} 个)`}
|
|
506
|
-
size="small"
|
|
507
|
-
>
|
|
508
|
-
<CollapsibleCodeBlock
|
|
509
|
-
title="下拉选项 JSON"
|
|
510
|
-
code={JSON.stringify(selectOptions, null, 2)}
|
|
511
|
-
defaultExpanded
|
|
512
|
-
maxHeight={400}
|
|
513
|
-
/>
|
|
514
|
-
</Card>
|
|
515
|
-
)}
|
|
516
|
-
|
|
517
|
-
{/* API 参考文档 */}
|
|
518
|
-
<Card size="small" style={{ marginTop: 24, background: "#f5f5f5" }}>
|
|
519
|
-
<Paragraph style={{ margin: 0, textAlign: "center" }}>
|
|
520
|
-
<Text type="secondary">
|
|
521
|
-
技术开发文档指引:{" "}
|
|
522
|
-
<a
|
|
523
|
-
href="https://qizhiyuntu.feishu.cn/wiki/CMfxw6l2li01EVkBTcBcshD3nSe"
|
|
524
|
-
target="_blank"
|
|
525
|
-
rel="noopener noreferrer"
|
|
526
|
-
style={{ color: "#1890ff" }}
|
|
527
|
-
>
|
|
528
|
-
https://qizhiyuntu.feishu.cn/wiki/CMfxw6l2li01EVkBTcBcshD3nSe
|
|
529
|
-
</a>
|
|
530
|
-
</Text>
|
|
531
|
-
</Paragraph>
|
|
532
|
-
</Card>
|
|
533
|
-
</div>
|
|
534
|
-
</DemoPageContainer>
|
|
535
|
-
);
|
|
536
|
-
}
|