@nocobase/portal-template-default 1.0.9 → 1.0.11
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/.env.example +5 -0
- package/.github/workflows/publish.yml +106 -0
- package/.gitignore +33 -0
- package/AGENTS.md +19 -0
- package/README.MD +61 -180
- package/dist/assets/{LineDraw-C0m1GONT.js → LineDraw-iG-ADes-.js} +1 -1
- package/dist/assets/{SymbolDraw-CCospe5G.js → SymbolDraw-DXoSw1tM.js} +1 -1
- package/dist/assets/VisualMapping-C_ee4Eht.js +1 -0
- package/dist/assets/auth-method-demo-DaOCuvsq.js +1 -0
- package/dist/assets/auto-login-provider-5Uxza9Ms.js +2 -0
- package/dist/assets/auto-login-provider-DyaPGK2D.js +1 -0
- package/dist/assets/auto-redirect-provider-CfwRvYOI.js +1 -0
- package/dist/assets/auto-redirect-provider-Cr3jmYts.js +1 -0
- package/dist/assets/auto-redirect-provider-QkJQRBbG.js +1 -0
- package/dist/assets/calendar-DjDRfD5t.js +1 -0
- package/dist/assets/card-DuQBOS6A.js +1 -0
- package/dist/assets/cas-sign-in-button-CyqG1QME.js +1 -0
- package/dist/assets/components-D-ptYjX_.js +20 -0
- package/dist/assets/configuration-gate-C08mkkiX.js +1 -0
- package/dist/assets/{createClipPathFromCoordSys-uEftn1Mq.js → createClipPathFromCoordSys-wj34-b1B.js} +1 -1
- package/dist/assets/createSeriesDataSimply-D0A6SAVQ.js +1 -0
- package/dist/assets/customGraphicKeyframeAnimation-DWrhrHL_.js +3 -0
- package/dist/assets/demo-BYWHeKUe.js +1 -0
- package/dist/assets/demo-CPWoNtx8.js +1 -0
- package/dist/assets/demo-CyvJk5zV.js +1 -0
- package/dist/assets/demo-D4OiKplc.js +1 -0
- package/dist/assets/demo-DBueJg0m.js +1 -0
- package/dist/assets/demo-DkIhyiRK.js +1 -0
- package/dist/assets/demo-tpTjO0sC.js +1 -0
- package/dist/assets/dingtalk-sign-in-button-DSWsSruv.js +1 -0
- package/dist/assets/echarts-preview-DxHNfq1C.js +1 -0
- package/dist/assets/{echarts-runtime-CEgJbv68.js → echarts-runtime-D8kXn6ME.js} +3 -3
- package/dist/assets/{echarts-runtime-advanced-Buhm2BHz.js → echarts-runtime-advanced-QY8v95qK.js} +1 -1
- package/dist/assets/{echarts-runtime-common-DLAdBAIa.js → echarts-runtime-common-D-yqAK-r.js} +1 -1
- package/dist/assets/{echarts-runtime-components-ypnyLkYx.js → echarts-runtime-components-P4-i8jPU.js} +1 -1
- package/dist/assets/{echarts-runtime-hierarchy-ClStquCF.js → echarts-runtime-hierarchy-ByQZ-DbP.js} +1 -1
- package/dist/assets/floating-BFVEyPEp.js +15 -0
- package/dist/assets/index-BgCbGDMc.js +43 -0
- package/dist/assets/index-Btk35Nx-.js +23 -0
- package/dist/assets/index-CwNxd66J.js +1 -0
- package/dist/assets/index-MB-jfQld.js +686 -0
- package/dist/assets/index-NH3aqqQz.css +1 -0
- package/dist/assets/index-gFtCXH3o.js +58 -0
- package/dist/assets/index-um5hdKdZ.js +23 -0
- package/dist/assets/{labelHelper-C137W5gU.js → labelHelper-DQqRy3a_.js} +1 -1
- package/dist/assets/ldap-sign-in-form--6Gt3yGq.js +1 -0
- package/dist/assets/oidc-sign-in-button-CQdRcR_p.js +1 -0
- package/dist/assets/{page-context-Cxx11gzg.js → page-context-CnQ4GYM7.js} +10 -10
- package/dist/assets/prompt-card-B2RS4nt2.js +1 -0
- package/dist/assets/prompt-output-DZHRM2ft.js +1 -0
- package/dist/assets/saml-sign-in-button-BHL5a0JV.js +1 -0
- package/dist/assets/{sectorHelper-Fqgz3uEk.js → sectorHelper-DN_Vv6OL.js} +1 -1
- package/dist/assets/shortcut-C5x5LQWU.js +47 -0
- package/dist/assets/sms-sign-in-form-DTX9GV2I.js +1 -0
- package/dist/assets/{static.browser-CfQQzERe.js → static.browser-jI1psK0d.js} +8 -8
- package/dist/assets/{switch-DrxImI8F.js → switch-CRL8PmRI.js} +1 -1
- package/dist/assets/{tool-cards-BGfsY8JF.js → tool-cards-DFttLAfo.js} +6 -7
- package/dist/assets/use-authenticator-sign-in-CRGjzXju.js +1 -0
- package/dist/assets/use-dingtalk-sign-in-8WYzJ2jf.js +1 -0
- package/dist/assets/use-wecom-sign-in-C9j8wfCD.js +1 -0
- package/dist/assets/wecom-sign-in-button-mIS1zGSU.js +1 -0
- package/dist/index.html +2 -2
- package/dist/index.raw.html +5 -2
- package/package.json +3 -5
- package/scripts/build-html.mjs +12 -0
- package/src/App.css +2 -0
- package/src/App.tsx +35 -186
- package/src/app/development.tsx +154 -0
- package/src/app/extension.ts +5 -0
- package/src/app/extensions.tsx +18 -4
- package/src/app/routes.tsx +65 -0
- package/src/components/access-control/acl-bootstrap.tsx +11 -3
- package/src/components/access-control/acl-gate.tsx +7 -6
- package/src/components/access-control/can-access.tsx +17 -0
- package/src/components/access-control/navigate-to-accessible-resource.tsx +8 -3
- package/src/components/app-shell/sidebar.tsx +21 -5
- package/src/components/auth/auto-redirect-provider.tsx +2 -1
- package/src/extensions/nocobase-acl/README.md +74 -0
- package/{registry → src/extensions}/nocobase-acl/components/acl-boundary.tsx +22 -25
- package/{registry → src/extensions}/nocobase-acl/components/role-switcher.tsx +26 -23
- package/src/extensions/nocobase-acl/demo/acl-preview-provider.tsx +81 -0
- package/{registry → src/extensions}/nocobase-acl/demo/boundary-api.tsx +58 -0
- package/{registry → src/extensions}/nocobase-acl/demo/index.tsx +243 -105
- package/{registry → src/extensions}/nocobase-acl/demo/prompt-generator.tsx +3 -1
- package/src/extensions/nocobase-acl/extension.tsx +73 -0
- package/{registry → src/extensions}/nocobase-ai/README.md +21 -5
- package/{registry → src/extensions}/nocobase-ai/components/chat/chat-composer.tsx +3 -1
- package/{registry → src/extensions}/nocobase-ai/components/chat/chat-messages.tsx +38 -3
- package/{registry → src/extensions}/nocobase-ai/components/chat/tool-call-card.tsx +1 -9
- package/{registry → src/extensions}/nocobase-ai/components/index.ts +5 -0
- package/src/extensions/nocobase-ai/components/surfaces/chat-dialog.tsx +17 -0
- package/src/extensions/nocobase-ai/components/surfaces/chat-side-panel.tsx +35 -0
- package/src/extensions/nocobase-ai/components/surfaces/chat-surface.tsx +108 -0
- package/{registry → src/extensions}/nocobase-ai/components/triggers/ai-chat-floating-trigger.tsx +2 -2
- package/{registry → src/extensions}/nocobase-ai/demo/configuration-gate.tsx +4 -1
- package/{registry → src/extensions}/nocobase-ai/demo/container-showcase.tsx +2 -2
- package/{registry → src/extensions}/nocobase-ai/demo/floating.tsx +45 -15
- package/{registry → src/extensions}/nocobase-ai/demo/index.tsx +116 -74
- package/{registry → src/extensions}/nocobase-ai/demo/prompt-generator.tsx +3 -3
- package/{registry → src/extensions}/nocobase-ai/demo/tool-cards.tsx +2 -3
- package/src/extensions/nocobase-ai/extension.tsx +160 -0
- package/{registry → src/extensions}/nocobase-ai/global-ai-chat.tsx +12 -28
- package/{registry → src/extensions}/nocobase-ai/providers/ai-provider.tsx +14 -1
- package/{registry → src/extensions}/nocobase-ai/providers/chat-context.tsx +1 -0
- package/{registry → src/extensions}/nocobase-ai/providers/chat-provider.tsx +29 -8
- package/{registry → src/extensions}/nocobase-ai/providers/use-chat-attachments.ts +6 -1
- package/{registry → src/extensions}/nocobase-ai/providers/use-chat-work-context.ts +4 -1
- package/{registry → src/extensions}/nocobase-route-surfaces/README.md +2 -1
- package/{registry → src/extensions}/nocobase-route-surfaces/demo/index.tsx +33 -7
- package/{registry → src/extensions}/nocobase-route-surfaces/demo/scenarios.ts +20 -14
- package/{registry → src/extensions}/nocobase-route-surfaces/extension.tsx +55 -52
- package/src/{pages/users → extensions/nocobase-users-example}/create.tsx +4 -4
- package/src/{pages/users → extensions/nocobase-users-example}/edit.tsx +5 -9
- package/src/extensions/nocobase-users-example/extension.tsx +109 -0
- package/src/{pages/users → extensions/nocobase-users-example}/form-context.ts +11 -9
- package/src/extensions/nocobase-users-example/layout.tsx +16 -0
- package/src/{pages/users → extensions/nocobase-users-example}/list.tsx +1 -1
- package/src/extensions/nocobase-users-example/locales/en-US.ts +77 -0
- package/src/extensions/nocobase-users-example/locales/index.ts +8 -0
- package/src/extensions/nocobase-users-example/locales/zh-CN.ts +73 -0
- package/src/extensions/nocobase-users-example/optional-ai.ts +67 -0
- package/src/{pages/users → extensions/nocobase-users-example}/role-detail.tsx +4 -15
- package/src/{pages/users → extensions/nocobase-users-example}/routes.ts +1 -4
- package/src/extensions/nocobase-users-example/show.tsx +266 -0
- package/src/lib/nocobase/acl/context.ts +32 -0
- package/src/lib/nocobase/acl/evaluator.ts +186 -0
- package/src/lib/nocobase/acl/hooks.ts +40 -0
- package/src/lib/nocobase/acl/index.ts +4 -1
- package/src/lib/nocobase/acl/menu.ts +6 -6
- package/src/lib/nocobase/acl/record-permissions.ts +37 -7
- package/src/lib/nocobase/acl/store-provider.tsx +14 -0
- package/src/lib/nocobase/acl/store.ts +92 -86
- package/src/lib/nocobase/acl/types.ts +52 -32
- package/src/lib/nocobase/auth-session.ts +128 -0
- package/src/lib/nocobase/client.ts +48 -50
- package/src/locales/en-US.ts +0 -78
- package/src/locales/index.ts +2 -7
- package/src/locales/zh-CN.ts +0 -74
- package/src/providers/access-control.ts +43 -8
- package/src/providers/auth-callback.ts +1 -0
- package/src/providers/auth.ts +24 -26
- package/src/providers/constants.ts +0 -4
- package/src/providers/data.ts +14 -26
- package/src/providers/runtime-config.ts +40 -0
- package/src/vite-env.d.ts +9 -0
- package/tests/auth-session-regression.mjs +101 -0
- package/tsconfig.json +2 -1
- package/vite.config.ts +9 -1
- package/dist/assets/VisualMapping-Cbv1v7Cd.js +0 -1
- package/dist/assets/ai-employee-shortcut-B253WWow.js +0 -1
- package/dist/assets/calendar-B3dXXyIv.js +0 -1
- package/dist/assets/chat-inline-xpQ9iq4p.js +0 -1
- package/dist/assets/chat-side-panel-layout-BVWsp5rr.js +0 -1
- package/dist/assets/components-ChhJaNRc.js +0 -20
- package/dist/assets/configuration-gate-Dwdq_lxf.js +0 -1
- package/dist/assets/createSeriesDataSimply-CI7l7Ufv.js +0 -1
- package/dist/assets/customGraphicKeyframeAnimation-DE3jSfMd.js +0 -3
- package/dist/assets/echarts-preview-C-cNUtJF.js +0 -1
- package/dist/assets/floating-BarTmn-b.js +0 -13
- package/dist/assets/index-BJIcYTdc.js +0 -53
- package/dist/assets/index-C6xNKxpg.js +0 -656
- package/dist/assets/index-D4JQi1TM.js +0 -54
- package/dist/assets/index-YA7-AUO8.css +0 -1
- package/dist/assets/index-g8zWVpP9.js +0 -23
- package/dist/assets/prompt-card-BsYMW_rq.js +0 -1
- package/dist/assets/shortcut-xtghDP63.js +0 -47
- package/registry/nocobase-acl/README.md +0 -19
- package/registry/nocobase-acl/extension.tsx +0 -71
- package/registry/nocobase-acl/tests/acl-regression.mjs +0 -314
- package/registry/nocobase-ai/components/surfaces/chat-dialog.tsx +0 -31
- package/registry/nocobase-ai/components/surfaces/chat-side-panel.tsx +0 -74
- package/registry/nocobase-ai/extension.tsx +0 -158
- package/registry/nocobase-ai/tests/business-report-regression.mjs +0 -70
- package/registry/nocobase-ai/tests/form-filler-regression.mjs +0 -129
- package/registry/nocobase-ai/tests/frontend-tool-regression.mjs +0 -128
- package/registry/nocobase-ai/tests/page-context-regression.mjs +0 -48
- package/registry/nocobase-ai/tests/stream-regression.mjs +0 -207
- package/registry/nocobase-auth-cas/README.md +0 -6
- package/registry/nocobase-auth-cas/cas-sign-in-button.tsx +0 -41
- package/registry/nocobase-auth-cas/demo.tsx +0 -20
- package/registry/nocobase-auth-cas/extension.tsx +0 -46
- package/registry/nocobase-auth-cas/index.ts +0 -1
- package/registry/nocobase-auth-cas/use-cas-sign-in.ts +0 -29
- package/registry/nocobase-auth-dingtalk/README.md +0 -7
- package/registry/nocobase-auth-dingtalk/auto-login-provider.tsx +0 -154
- package/registry/nocobase-auth-dingtalk/demo.tsx +0 -23
- package/registry/nocobase-auth-dingtalk/dingtalk-sign-in-button.tsx +0 -45
- package/registry/nocobase-auth-dingtalk/extension.tsx +0 -55
- package/registry/nocobase-auth-dingtalk/index.ts +0 -4
- package/registry/nocobase-auth-dingtalk/use-dingtalk-sign-in.ts +0 -64
- package/registry/nocobase-auth-ldap/README.md +0 -6
- package/registry/nocobase-auth-ldap/demo.tsx +0 -21
- package/registry/nocobase-auth-ldap/extension.tsx +0 -46
- package/registry/nocobase-auth-ldap/index.ts +0 -1
- package/registry/nocobase-auth-ldap/ldap-sign-in-form.tsx +0 -69
- package/registry/nocobase-auth-ldap/use-ldap-sign-in.ts +0 -5
- package/registry/nocobase-auth-oidc/README.md +0 -11
- package/registry/nocobase-auth-oidc/auto-redirect-provider.tsx +0 -13
- package/registry/nocobase-auth-oidc/demo.tsx +0 -20
- package/registry/nocobase-auth-oidc/extension.tsx +0 -51
- package/registry/nocobase-auth-oidc/index.ts +0 -1
- package/registry/nocobase-auth-oidc/oidc-sign-in-button.tsx +0 -44
- package/registry/nocobase-auth-oidc/use-oidc-sign-in.ts +0 -58
- package/registry/nocobase-auth-saml/README.md +0 -6
- package/registry/nocobase-auth-saml/auto-redirect-provider.tsx +0 -13
- package/registry/nocobase-auth-saml/demo.tsx +0 -20
- package/registry/nocobase-auth-saml/extension.tsx +0 -51
- package/registry/nocobase-auth-saml/index.ts +0 -1
- package/registry/nocobase-auth-saml/saml-sign-in-button.tsx +0 -43
- package/registry/nocobase-auth-saml/use-saml-sign-in.ts +0 -51
- package/registry/nocobase-auth-sms/README.md +0 -7
- package/registry/nocobase-auth-sms/demo.tsx +0 -25
- package/registry/nocobase-auth-sms/extension.tsx +0 -46
- package/registry/nocobase-auth-sms/index.ts +0 -1
- package/registry/nocobase-auth-sms/sms-sign-in-form.tsx +0 -107
- package/registry/nocobase-auth-sms/use-sms-sign-in.ts +0 -88
- package/registry/nocobase-auth-wecom/README.md +0 -6
- package/registry/nocobase-auth-wecom/auto-login-provider.tsx +0 -21
- package/registry/nocobase-auth-wecom/demo.tsx +0 -23
- package/registry/nocobase-auth-wecom/extension.tsx +0 -49
- package/registry/nocobase-auth-wecom/index.ts +0 -1
- package/registry/nocobase-auth-wecom/use-wecom-sign-in.ts +0 -62
- package/registry/nocobase-auth-wecom/wecom-sign-in-button.tsx +0 -70
- package/registry/nocobase-i18n/README.md +0 -44
- package/registry/nocobase-i18n/components/index.ts +0 -1
- package/registry/nocobase-i18n/components/language-switcher.tsx +0 -138
- package/registry/nocobase-i18n/demo/index.tsx +0 -209
- package/registry/nocobase-i18n/demo/prompt-generator.tsx +0 -132
- package/registry/nocobase-i18n/extension.tsx +0 -45
- package/registry/nocobase-i18n/index.ts +0 -7
- package/registry/nocobase-i18n/locales/en-US.ts +0 -39
- package/registry/nocobase-i18n/locales/index.ts +0 -8
- package/registry/nocobase-i18n/locales/zh-CN.ts +0 -35
- package/registry/nocobase-i18n/provider.tsx +0 -44
- package/registry/nocobase-i18n/server-resources.ts +0 -166
- package/registry/nocobase-i18n/tests/i18n-regression.mjs +0 -51
- package/registry.config.json +0 -302
- package/scripts/registry.mjs +0 -164
- package/src/components/access-control/resource-access-guard.tsx +0 -21
- package/src/components/access-control/use-acl-runtime.ts +0 -28
- package/src/lib/nocobase/acl/action.ts +0 -147
- package/src/pages/users/layout.tsx +0 -15
- package/src/pages/users/show.tsx +0 -278
- /package/{registry → src/extensions}/nocobase-acl/components/index.ts +0 -0
- /package/{registry → src/extensions}/nocobase-acl/components/role-options.ts +0 -0
- /package/{registry → src/extensions}/nocobase-acl/demo/components.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-acl/demo/lazy-route.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-acl/demo/role-switcher-prompt-generator.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-acl/demo/scenario-section.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-acl/index.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/adapters/react-hook-form.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/assets/nocobase-ai-chat.svg +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/ai-root-provider.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/ai-employee-avatar.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-attachment.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-compact.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-empty-state.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-header.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-history-dialog.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-message.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-window.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/conversation-list.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/markdown-message.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/model-select-options.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/reasoning-panel.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/sub-agent-conversation.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/user-prompt-editor.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/chat/work-context-chip.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/page-elements/ai-form.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/page-elements/page-element-provider.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-inline.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-page.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-side-panel-layout.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-surface-actions.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/builtin-tool-renderers.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/business-report-dialog.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/business-report-renderer.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/business-report-utils.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/chart-renderer.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-preview.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-advanced.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-common.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-components.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-hierarchy.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/sub-agent-renderer.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/suggestions-renderer.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/tool-renderer-provider.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/tool-renderer-utils.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/tools/workflow-renderer.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/components/triggers/ai-employee-shortcut.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/demo/interaction-showcase.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/demo/page-context-prompt-generator.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/demo/page-context.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/demo/page-element-showcase.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/demo/prompt-card.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/demo/shortcut.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/index.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/avatars.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/chat-controller.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/chat-message-utils.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/chat-reducer.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/chat-task-utils.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/chat-transport.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/form-registry.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/frontend-tool-registry.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/index.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/model.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/page-context.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/stream-coalescer.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/stream-event-utils.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/stream-parser.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/sub-agent-stream.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/types.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/ui-message-stream.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/use-automatic-tool-approval.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/use-chat-message-actions.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/use-chat-runtime.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/use-conversation-catalog.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/providers/use-conversation-history.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/services/index.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/services/nocobase-ai-service.ts +0 -0
- /package/{registry → src/extensions}/nocobase-ai/services/types.ts +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/demo/lazy-route.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/demo/prompt-generator.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/index.ts +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/route-dialog.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/route-drawer.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/route-page.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/route-surface-context.ts +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/use-refine-unsaved-changes.tsx +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/use-route-surface-close.ts +0 -0
- /package/{registry → src/extensions}/nocobase-route-surfaces/use-route-surface-state.ts +0 -0
- /package/src/{pages/users → extensions/nocobase-users-example}/form-fields.tsx +0 -0
- /package/src/{pages/users → extensions/nocobase-users-example}/index.ts +0 -0
- /package/src/{pages/users → extensions/nocobase-users-example}/role-badges.tsx +0 -0
- /package/src/{pages/users → extensions/nocobase-users-example}/role-utils.ts +0 -0
- /package/src/{pages/users → extensions/nocobase-users-example}/types.ts +0 -0
|
@@ -1,207 +0,0 @@
|
|
|
1
|
-
import assert from "node:assert/strict";
|
|
2
|
-
import { createServer } from "vite";
|
|
3
|
-
|
|
4
|
-
const wait = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
5
|
-
|
|
6
|
-
const encodeSSE = (events) => {
|
|
7
|
-
const encoder = new TextEncoder();
|
|
8
|
-
return new ReadableStream({
|
|
9
|
-
start(controller) {
|
|
10
|
-
controller.enqueue(
|
|
11
|
-
encoder.encode(
|
|
12
|
-
events.map((event) => `data: ${JSON.stringify(event)}\n\n`).join("")
|
|
13
|
-
)
|
|
14
|
-
);
|
|
15
|
-
controller.close();
|
|
16
|
-
},
|
|
17
|
-
});
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const collectStream = async (stream) => {
|
|
21
|
-
const result = [];
|
|
22
|
-
for await (const chunk of stream) result.push(chunk);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
const server = await createServer({
|
|
27
|
-
appType: "custom",
|
|
28
|
-
logLevel: "silent",
|
|
29
|
-
server: { middlewareMode: true },
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
try {
|
|
33
|
-
const { StreamCoalescer } = await server.ssrLoadModule(
|
|
34
|
-
"/registry/nocobase-ai/providers/stream-coalescer.ts"
|
|
35
|
-
);
|
|
36
|
-
const { NocoBaseChatTransport } = await server.ssrLoadModule(
|
|
37
|
-
"/registry/nocobase-ai/providers/chat-transport.ts"
|
|
38
|
-
);
|
|
39
|
-
const { SubAgentStreamAccumulator } = await server.ssrLoadModule(
|
|
40
|
-
"/registry/nocobase-ai/providers/sub-agent-stream.ts"
|
|
41
|
-
);
|
|
42
|
-
const { NocoBaseClient } = await server.ssrLoadModule(
|
|
43
|
-
"/src/lib/nocobase/client.ts"
|
|
44
|
-
);
|
|
45
|
-
|
|
46
|
-
{
|
|
47
|
-
const client = new NocoBaseClient("http://localhost:13001/api");
|
|
48
|
-
assert.equal(
|
|
49
|
-
client.resolveUrl("/files/main/main/aiFiles/5.png?preview=1"),
|
|
50
|
-
"http://localhost:13001/files/main/main/aiFiles/5.png?preview=1"
|
|
51
|
-
);
|
|
52
|
-
assert.equal(
|
|
53
|
-
client.resolveUrl("https://cdn.example.com/file.png"),
|
|
54
|
-
"https://cdn.example.com/file.png"
|
|
55
|
-
);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
{
|
|
59
|
-
const flushed = [];
|
|
60
|
-
const coalescer = new StreamCoalescer({
|
|
61
|
-
interval: 20,
|
|
62
|
-
maxSize: 100,
|
|
63
|
-
getSize: (value) => value.length,
|
|
64
|
-
merge: (current, incoming) => current + incoming,
|
|
65
|
-
onFlush: (key, value) => flushed.push([key, value]),
|
|
66
|
-
});
|
|
67
|
-
coalescer.push("message", "hello ");
|
|
68
|
-
coalescer.push("message", "world");
|
|
69
|
-
await wait(35);
|
|
70
|
-
assert.deepEqual(flushed, [["message", "hello world"]]);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
{
|
|
74
|
-
const seedMessage = {
|
|
75
|
-
id: "assistant-existing",
|
|
76
|
-
role: "assistant",
|
|
77
|
-
parts: [
|
|
78
|
-
{
|
|
79
|
-
type: "data-subAgent",
|
|
80
|
-
id: "sub-1",
|
|
81
|
-
data: {
|
|
82
|
-
sessionId: "sub-1",
|
|
83
|
-
username: "viz",
|
|
84
|
-
status: "pending",
|
|
85
|
-
messages: [
|
|
86
|
-
{
|
|
87
|
-
id: "sub-message",
|
|
88
|
-
role: "assistant",
|
|
89
|
-
parts: [{ type: "text", text: "saved ", state: "done" }],
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
},
|
|
93
|
-
},
|
|
94
|
-
],
|
|
95
|
-
};
|
|
96
|
-
const accumulator = new SubAgentStreamAccumulator(seedMessage);
|
|
97
|
-
const [chunk] = accumulator.process({
|
|
98
|
-
type: "content",
|
|
99
|
-
body: "tail",
|
|
100
|
-
from: "sub-agent",
|
|
101
|
-
sessionId: "sub-1",
|
|
102
|
-
username: "viz",
|
|
103
|
-
});
|
|
104
|
-
assert.equal(chunk.data.messages.length, 1);
|
|
105
|
-
assert.equal(chunk.data.messages[0].parts[0].text, "saved tail");
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
{
|
|
109
|
-
const toolCallId = "report-tool";
|
|
110
|
-
const events = [
|
|
111
|
-
...Array.from({ length: 100 }, (_, index) => ({
|
|
112
|
-
type: "tool_call_chunks",
|
|
113
|
-
from: "main-agent",
|
|
114
|
-
sessionId: "conversation-1",
|
|
115
|
-
body: [
|
|
116
|
-
index === 0
|
|
117
|
-
? {
|
|
118
|
-
id: toolCallId,
|
|
119
|
-
name: "businessReportGenerator",
|
|
120
|
-
args: "{",
|
|
121
|
-
}
|
|
122
|
-
: { id: toolCallId, args: "x" },
|
|
123
|
-
],
|
|
124
|
-
})),
|
|
125
|
-
{ type: "stream_end", from: "main-agent", sessionId: "conversation-1" },
|
|
126
|
-
];
|
|
127
|
-
const service = {
|
|
128
|
-
resumeConversationStream: async () => encodeSSE(events),
|
|
129
|
-
};
|
|
130
|
-
const transport = new NocoBaseChatTransport({
|
|
131
|
-
service,
|
|
132
|
-
getContext: () => ({
|
|
133
|
-
sessionId: "conversation-1",
|
|
134
|
-
employee: { username: "atlas", nickname: "Atlas" },
|
|
135
|
-
model: { value: "test", label: "Test" },
|
|
136
|
-
}),
|
|
137
|
-
});
|
|
138
|
-
transport.prepareConversationResume([
|
|
139
|
-
{ id: "assistant-existing", role: "assistant", parts: [] },
|
|
140
|
-
]);
|
|
141
|
-
const chunks = await collectStream(await transport.reconnectToStream());
|
|
142
|
-
const start = chunks.find((chunk) => chunk.type === "start");
|
|
143
|
-
const toolDeltas = chunks.filter(
|
|
144
|
-
(chunk) => chunk.type === "tool-input-delta"
|
|
145
|
-
);
|
|
146
|
-
assert.equal(start.messageId, undefined);
|
|
147
|
-
assert.ok(toolDeltas.length < 10, `received ${toolDeltas.length} deltas`);
|
|
148
|
-
assert.equal(
|
|
149
|
-
toolDeltas.reduce((size, chunk) => size + chunk.inputTextDelta.length, 0),
|
|
150
|
-
100
|
|
151
|
-
);
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
{
|
|
155
|
-
let request;
|
|
156
|
-
const service = {
|
|
157
|
-
sendMessagesStream: async (input) => {
|
|
158
|
-
request = input;
|
|
159
|
-
return encodeSSE([
|
|
160
|
-
{ type: "content", body: "ok", from: "main-agent" },
|
|
161
|
-
{ type: "stream_end", from: "main-agent" },
|
|
162
|
-
]);
|
|
163
|
-
},
|
|
164
|
-
};
|
|
165
|
-
const transport = new NocoBaseChatTransport({
|
|
166
|
-
service,
|
|
167
|
-
getContext: () => ({
|
|
168
|
-
sessionId: "conversation-context",
|
|
169
|
-
employee: { username: "mira", nickname: "Mira" },
|
|
170
|
-
model: { value: "test", label: "Test" },
|
|
171
|
-
}),
|
|
172
|
-
});
|
|
173
|
-
await collectStream(
|
|
174
|
-
await transport.sendMessages({
|
|
175
|
-
messages: [
|
|
176
|
-
{
|
|
177
|
-
id: "user-context",
|
|
178
|
-
role: "user",
|
|
179
|
-
metadata: {
|
|
180
|
-
workContext: [
|
|
181
|
-
{
|
|
182
|
-
type: "page-element",
|
|
183
|
-
id: "customer-form",
|
|
184
|
-
title: "Customer form",
|
|
185
|
-
content: { values: { name: "Northwind" } },
|
|
186
|
-
},
|
|
187
|
-
],
|
|
188
|
-
},
|
|
189
|
-
parts: [{ type: "text", text: "Review this form" }],
|
|
190
|
-
},
|
|
191
|
-
],
|
|
192
|
-
})
|
|
193
|
-
);
|
|
194
|
-
assert.deepEqual(request.messages[0].workContext, [
|
|
195
|
-
{
|
|
196
|
-
type: "page-element",
|
|
197
|
-
id: "customer-form",
|
|
198
|
-
title: "Customer form",
|
|
199
|
-
content: { values: { name: "Northwind" } },
|
|
200
|
-
},
|
|
201
|
-
]);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
console.log("AI stream regression tests passed");
|
|
205
|
-
} finally {
|
|
206
|
-
await server.close();
|
|
207
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { LogIn } from "lucide-react";
|
|
2
|
-
|
|
3
|
-
import type { AuthenticatorComponentProps } from "@/components/auth/types";
|
|
4
|
-
import {
|
|
5
|
-
Alert,
|
|
6
|
-
AlertDescription,
|
|
7
|
-
AlertTitle,
|
|
8
|
-
} from "@/components/ui/alert";
|
|
9
|
-
import { Button } from "@/components/ui/button";
|
|
10
|
-
import { resolveTranslatableText } from "@/lib/i18n";
|
|
11
|
-
|
|
12
|
-
import { useCasSignIn } from "./use-cas-sign-in";
|
|
13
|
-
|
|
14
|
-
export default function CasSignInButton({
|
|
15
|
-
authenticator,
|
|
16
|
-
onSignIn,
|
|
17
|
-
}: AuthenticatorComponentProps & { onSignIn?: () => void }) {
|
|
18
|
-
const { signIn, error } = useCasSignIn(authenticator);
|
|
19
|
-
|
|
20
|
-
return (
|
|
21
|
-
<div className="space-y-3">
|
|
22
|
-
{error && (
|
|
23
|
-
<Alert variant="destructive">
|
|
24
|
-
<AlertTitle>CAS sign-in failed</AlertTitle>
|
|
25
|
-
<AlertDescription>{error.message}</AlertDescription>
|
|
26
|
-
</Alert>
|
|
27
|
-
)}
|
|
28
|
-
<Button
|
|
29
|
-
type="button"
|
|
30
|
-
variant="outline"
|
|
31
|
-
className="w-full"
|
|
32
|
-
onClick={onSignIn ?? signIn}
|
|
33
|
-
>
|
|
34
|
-
<LogIn />
|
|
35
|
-
{resolveTranslatableText(
|
|
36
|
-
authenticator.title || authenticator.authTypeTitle || "CAS"
|
|
37
|
-
)}
|
|
38
|
-
</Button>
|
|
39
|
-
</div>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { AuthMethodDemo } from "@/components/auth/demo";
|
|
2
|
-
import CasSignInButton from "./cas-sign-in-button";
|
|
3
|
-
|
|
4
|
-
const authenticator = {
|
|
5
|
-
name: "company-cas",
|
|
6
|
-
authType: "CAS",
|
|
7
|
-
title: "Company CAS",
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export function CasAuthDemoPage() {
|
|
11
|
-
return (
|
|
12
|
-
<AuthMethodDemo
|
|
13
|
-
authType="CAS"
|
|
14
|
-
methodName="Central Authentication Service"
|
|
15
|
-
description="Redirect users to a CAS server and capture the returned NocoBase token without coupling the page UI to CAS."
|
|
16
|
-
>
|
|
17
|
-
<CasSignInButton authenticator={authenticator} onSignIn={() => {}} />
|
|
18
|
-
</AuthMethodDemo>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { lazy } from "react";
|
|
2
|
-
import { KeyRound } from "lucide-react";
|
|
3
|
-
import { Route } from "react-router";
|
|
4
|
-
|
|
5
|
-
import type { AppExtension } from "@/app/extension";
|
|
6
|
-
import { AuthDemoRoute } from "@/components/auth/demo";
|
|
7
|
-
|
|
8
|
-
const CasSignInButton = lazy(() => import("./cas-sign-in-button"));
|
|
9
|
-
const CasAuthDemoPage = lazy(() =>
|
|
10
|
-
import("./demo").then((module) => ({ default: module.CasAuthDemoPage }))
|
|
11
|
-
);
|
|
12
|
-
|
|
13
|
-
const casAuthExtension: AppExtension = {
|
|
14
|
-
id: "nocobase-auth-cas",
|
|
15
|
-
resources: [
|
|
16
|
-
{
|
|
17
|
-
name: "auth-cas-demo",
|
|
18
|
-
list: "/auth/cas",
|
|
19
|
-
meta: {
|
|
20
|
-
parent: "auth-components",
|
|
21
|
-
label: "CAS",
|
|
22
|
-
icon: <KeyRound />,
|
|
23
|
-
acl: { type: "authenticated" },
|
|
24
|
-
},
|
|
25
|
-
},
|
|
26
|
-
],
|
|
27
|
-
routes: (
|
|
28
|
-
<Route
|
|
29
|
-
path="/auth/cas"
|
|
30
|
-
element={
|
|
31
|
-
<AuthDemoRoute>
|
|
32
|
-
<CasAuthDemoPage />
|
|
33
|
-
</AuthDemoRoute>
|
|
34
|
-
}
|
|
35
|
-
/>
|
|
36
|
-
),
|
|
37
|
-
authAdapters: [
|
|
38
|
-
{
|
|
39
|
-
authType: "CAS",
|
|
40
|
-
placement: "button",
|
|
41
|
-
Component: CasSignInButton,
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
};
|
|
45
|
-
|
|
46
|
-
export default casAuthExtension;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useCasSignIn } from "./use-cas-sign-in";
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { useCallback, useMemo } from "react";
|
|
2
|
-
import { useSearchParams } from "react-router";
|
|
3
|
-
|
|
4
|
-
import type { Authenticator } from "@/components/auth/types";
|
|
5
|
-
import { nocobaseClient } from "@/lib/nocobase/client";
|
|
6
|
-
|
|
7
|
-
export function useCasSignIn(authenticator: Authenticator) {
|
|
8
|
-
const [searchParams] = useSearchParams();
|
|
9
|
-
const callbackError = useMemo(() => {
|
|
10
|
-
if (searchParams.get("authenticator") !== authenticator.name) {
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
13
|
-
const message = searchParams.get("error");
|
|
14
|
-
return message ? new Error(message) : undefined;
|
|
15
|
-
}, [authenticator.name, searchParams]);
|
|
16
|
-
|
|
17
|
-
const signIn = useCallback(() => {
|
|
18
|
-
const redirect =
|
|
19
|
-
searchParams.get("to") || searchParams.get("redirect") || "/";
|
|
20
|
-
const url = nocobaseClient.buildUrl("cas:login", {
|
|
21
|
-
authenticator: authenticator.name,
|
|
22
|
-
__appName: "main",
|
|
23
|
-
redirect,
|
|
24
|
-
});
|
|
25
|
-
window.location.replace(url.toString());
|
|
26
|
-
}, [authenticator.name, searchParams]);
|
|
27
|
-
|
|
28
|
-
return { signIn, error: callbackError };
|
|
29
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
# NocoBase DingTalk authentication
|
|
2
|
-
|
|
3
|
-
Adds DingTalk OAuth sign-in, callback errors, OAuth or micro-app automatic
|
|
4
|
-
login, and `useDingtalkSignIn` for custom UI. The DingTalk JSAPI is loaded only
|
|
5
|
-
inside a DingTalk browser during internal automatic login.
|
|
6
|
-
|
|
7
|
-
Installing the Registry also adds a DingTalk component Demo under Authentication.
|
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { useEffect, useRef, useState } from "react";
|
|
2
|
-
import { useLocation } from "react-router";
|
|
3
|
-
|
|
4
|
-
import { LoadingState } from "@/components/app-shell/loading-state";
|
|
5
|
-
import { clearAcl } from "@/lib/nocobase/acl";
|
|
6
|
-
import { nocobaseClient } from "@/lib/nocobase/client";
|
|
7
|
-
|
|
8
|
-
import { isDingtalkBrowser } from "./use-dingtalk-sign-in";
|
|
9
|
-
|
|
10
|
-
type CheckLoginResponse = {
|
|
11
|
-
success?: boolean;
|
|
12
|
-
autoLoginType?: "oauth" | "internal";
|
|
13
|
-
authUrl?: string;
|
|
14
|
-
authenticator?: string;
|
|
15
|
-
corpId?: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
type SignInResponse = {
|
|
19
|
-
token?: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const publicAuthPaths = new Set([
|
|
23
|
-
"/login",
|
|
24
|
-
"/signin",
|
|
25
|
-
"/register",
|
|
26
|
-
"/forgot-password",
|
|
27
|
-
]);
|
|
28
|
-
|
|
29
|
-
async function requestDingtalkAuthCode(corpId: string) {
|
|
30
|
-
const module = await import("dingtalk-jsapi");
|
|
31
|
-
const dd = ((module as { default?: unknown }).default ?? module) as any;
|
|
32
|
-
|
|
33
|
-
return new Promise<string>((resolve, reject) => {
|
|
34
|
-
const success = (result: { code?: string; authCode?: string }) => {
|
|
35
|
-
const code = result?.code ?? result?.authCode;
|
|
36
|
-
code
|
|
37
|
-
? resolve(String(code))
|
|
38
|
-
: reject(new Error("DingTalk did not return an authorization code."));
|
|
39
|
-
};
|
|
40
|
-
const fail = (error: { errorMessage?: string; message?: string }) =>
|
|
41
|
-
reject(
|
|
42
|
-
new Error(
|
|
43
|
-
error?.errorMessage ||
|
|
44
|
-
error?.message ||
|
|
45
|
-
"Unable to request a DingTalk authorization code."
|
|
46
|
-
)
|
|
47
|
-
);
|
|
48
|
-
const run = () => {
|
|
49
|
-
const requestAuthCode = dd?.runtime?.permission?.requestAuthCode;
|
|
50
|
-
if (typeof requestAuthCode === "function") {
|
|
51
|
-
const result = requestAuthCode({ corpId, success, fail });
|
|
52
|
-
if (result?.then) result.then(success).catch(fail);
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (typeof dd?.getAuthCode === "function") {
|
|
56
|
-
dd.getAuthCode({ corpId, success, fail });
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
fail({ message: "DingTalk auth-code API is unavailable." });
|
|
60
|
-
};
|
|
61
|
-
|
|
62
|
-
try {
|
|
63
|
-
typeof dd?.ready === "function" ? dd.ready(run) : run();
|
|
64
|
-
} catch (error) {
|
|
65
|
-
fail(error as Error);
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default function DingtalkAutoLoginProvider({
|
|
71
|
-
children,
|
|
72
|
-
}: React.PropsWithChildren) {
|
|
73
|
-
const { pathname, search } = useLocation();
|
|
74
|
-
const attemptedRef = useRef(false);
|
|
75
|
-
const insideDingtalk = isDingtalkBrowser();
|
|
76
|
-
const redirect = `${pathname}${search}`;
|
|
77
|
-
const shouldCheck =
|
|
78
|
-
insideDingtalk &&
|
|
79
|
-
!nocobaseClient.getToken() &&
|
|
80
|
-
!publicAuthPaths.has(pathname);
|
|
81
|
-
const [isChecking, setIsChecking] = useState(shouldCheck);
|
|
82
|
-
|
|
83
|
-
useEffect(() => {
|
|
84
|
-
if (!shouldCheck || attemptedRef.current) {
|
|
85
|
-
setIsChecking(false);
|
|
86
|
-
return;
|
|
87
|
-
}
|
|
88
|
-
attemptedRef.current = true;
|
|
89
|
-
setIsChecking(true);
|
|
90
|
-
const controller = new AbortController();
|
|
91
|
-
|
|
92
|
-
void (async () => {
|
|
93
|
-
try {
|
|
94
|
-
const result = await nocobaseClient.action<CheckLoginResponse>(
|
|
95
|
-
"dingtalk",
|
|
96
|
-
"checkLogin",
|
|
97
|
-
{
|
|
98
|
-
method: "GET",
|
|
99
|
-
query: { isDingTalkBrowser: true, redirect },
|
|
100
|
-
signal: controller.signal,
|
|
101
|
-
authenticator: null,
|
|
102
|
-
includeRole: false,
|
|
103
|
-
withAclMeta: false,
|
|
104
|
-
}
|
|
105
|
-
);
|
|
106
|
-
|
|
107
|
-
if (result?.success !== false) return;
|
|
108
|
-
if (result.autoLoginType === "oauth" && result.authUrl) {
|
|
109
|
-
window.location.replace(nocobaseClient.resolveUrl(result.authUrl));
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
if (
|
|
113
|
-
result.autoLoginType !== "internal" ||
|
|
114
|
-
!result.authenticator ||
|
|
115
|
-
!result.corpId
|
|
116
|
-
) {
|
|
117
|
-
return;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const authCode = await requestDingtalkAuthCode(result.corpId);
|
|
121
|
-
const signedIn = await nocobaseClient.action<SignInResponse>(
|
|
122
|
-
"auth",
|
|
123
|
-
"signIn",
|
|
124
|
-
{
|
|
125
|
-
method: "POST",
|
|
126
|
-
authenticator: result.authenticator,
|
|
127
|
-
body: { authCode, loginType: "internal" },
|
|
128
|
-
}
|
|
129
|
-
);
|
|
130
|
-
if (!signedIn.token) {
|
|
131
|
-
throw new Error("NocoBase did not return an access token.");
|
|
132
|
-
}
|
|
133
|
-
nocobaseClient.setAuthenticator(result.authenticator);
|
|
134
|
-
nocobaseClient.setToken(signedIn.token);
|
|
135
|
-
nocobaseClient.setRole(null);
|
|
136
|
-
clearAcl();
|
|
137
|
-
window.location.replace(redirect);
|
|
138
|
-
} catch (error) {
|
|
139
|
-
if (!(error instanceof DOMException && error.name === "AbortError")) {
|
|
140
|
-
console.warn("Unable to complete DingTalk automatic login", error);
|
|
141
|
-
}
|
|
142
|
-
} finally {
|
|
143
|
-
setIsChecking(false);
|
|
144
|
-
}
|
|
145
|
-
})();
|
|
146
|
-
|
|
147
|
-
return () => controller.abort();
|
|
148
|
-
}, [redirect, shouldCheck]);
|
|
149
|
-
|
|
150
|
-
if (isChecking) {
|
|
151
|
-
return <LoadingState className="min-h-svh" />;
|
|
152
|
-
}
|
|
153
|
-
return children;
|
|
154
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { AuthMethodDemo } from "@/components/auth/demo";
|
|
2
|
-
import DingtalkSignInButton from "./dingtalk-sign-in-button";
|
|
3
|
-
|
|
4
|
-
const authenticator = {
|
|
5
|
-
name: "company-dingtalk",
|
|
6
|
-
authType: "dingtalk",
|
|
7
|
-
title: "Sign in via DingTalk",
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export function DingtalkAuthDemoPage() {
|
|
11
|
-
return (
|
|
12
|
-
<AuthMethodDemo
|
|
13
|
-
authType="dingtalk"
|
|
14
|
-
methodName="DingTalk"
|
|
15
|
-
description="Provide DingTalk OAuth login and support internal micro-app automatic login through DingTalk JSAPI."
|
|
16
|
-
>
|
|
17
|
-
<DingtalkSignInButton
|
|
18
|
-
authenticator={authenticator}
|
|
19
|
-
onSignIn={() => {}}
|
|
20
|
-
/>
|
|
21
|
-
</AuthMethodDemo>
|
|
22
|
-
);
|
|
23
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import { MessageSquare } from "lucide-react";
|
|
2
|
-
|
|
3
|
-
import type { AuthenticatorComponentProps } from "@/components/auth/types";
|
|
4
|
-
import {
|
|
5
|
-
Alert,
|
|
6
|
-
AlertDescription,
|
|
7
|
-
AlertTitle,
|
|
8
|
-
} from "@/components/ui/alert";
|
|
9
|
-
import { Button } from "@/components/ui/button";
|
|
10
|
-
import { resolveTranslatableText } from "@/lib/i18n";
|
|
11
|
-
|
|
12
|
-
import { useDingtalkSignIn } from "./use-dingtalk-sign-in";
|
|
13
|
-
|
|
14
|
-
export default function DingtalkSignInButton({
|
|
15
|
-
authenticator,
|
|
16
|
-
onSignIn,
|
|
17
|
-
}: AuthenticatorComponentProps & { onSignIn?: () => void }) {
|
|
18
|
-
const { signIn, isPending, error } = useDingtalkSignIn(authenticator);
|
|
19
|
-
return (
|
|
20
|
-
<div className="space-y-3">
|
|
21
|
-
{error && (
|
|
22
|
-
<Alert variant="destructive">
|
|
23
|
-
<AlertTitle>DingTalk sign-in failed</AlertTitle>
|
|
24
|
-
<AlertDescription>{error.message}</AlertDescription>
|
|
25
|
-
</Alert>
|
|
26
|
-
)}
|
|
27
|
-
<Button
|
|
28
|
-
type="button"
|
|
29
|
-
variant="outline"
|
|
30
|
-
className="w-full"
|
|
31
|
-
disabled={!onSignIn && isPending}
|
|
32
|
-
onClick={onSignIn ?? signIn}
|
|
33
|
-
>
|
|
34
|
-
<MessageSquare />
|
|
35
|
-
{!onSignIn && isPending
|
|
36
|
-
? "Redirecting…"
|
|
37
|
-
: resolveTranslatableText(
|
|
38
|
-
authenticator.title ||
|
|
39
|
-
authenticator.authTypeTitle ||
|
|
40
|
-
"Sign in via DingTalk"
|
|
41
|
-
)}
|
|
42
|
-
</Button>
|
|
43
|
-
</div>
|
|
44
|
-
);
|
|
45
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { lazy } from "react";
|
|
2
|
-
import { MessageSquare } from "lucide-react";
|
|
3
|
-
import { Route } from "react-router";
|
|
4
|
-
|
|
5
|
-
import type { AppExtension } from "@/app/extension";
|
|
6
|
-
import { AuthDemoRoute } from "@/components/auth/demo";
|
|
7
|
-
|
|
8
|
-
const DingtalkSignInButton = lazy(
|
|
9
|
-
() => import("./dingtalk-sign-in-button")
|
|
10
|
-
);
|
|
11
|
-
const DingtalkAutoLoginProvider = lazy(
|
|
12
|
-
() => import("./auto-login-provider")
|
|
13
|
-
);
|
|
14
|
-
const DingtalkAuthDemoPage = lazy(() =>
|
|
15
|
-
import("./demo").then((module) => ({
|
|
16
|
-
default: module.DingtalkAuthDemoPage,
|
|
17
|
-
}))
|
|
18
|
-
);
|
|
19
|
-
|
|
20
|
-
const dingtalkAuthExtension: AppExtension = {
|
|
21
|
-
id: "nocobase-auth-dingtalk",
|
|
22
|
-
AuthRuntimeProvider: DingtalkAutoLoginProvider,
|
|
23
|
-
authRuntimePriority: 10,
|
|
24
|
-
resources: [
|
|
25
|
-
{
|
|
26
|
-
name: "auth-dingtalk-demo",
|
|
27
|
-
list: "/auth/dingtalk",
|
|
28
|
-
meta: {
|
|
29
|
-
parent: "auth-components",
|
|
30
|
-
label: "DingTalk",
|
|
31
|
-
icon: <MessageSquare />,
|
|
32
|
-
acl: { type: "authenticated" },
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
routes: (
|
|
37
|
-
<Route
|
|
38
|
-
path="/auth/dingtalk"
|
|
39
|
-
element={
|
|
40
|
-
<AuthDemoRoute>
|
|
41
|
-
<DingtalkAuthDemoPage />
|
|
42
|
-
</AuthDemoRoute>
|
|
43
|
-
}
|
|
44
|
-
/>
|
|
45
|
-
),
|
|
46
|
-
authAdapters: [
|
|
47
|
-
{
|
|
48
|
-
authType: "dingtalk",
|
|
49
|
-
placement: "button",
|
|
50
|
-
Component: DingtalkSignInButton,
|
|
51
|
-
},
|
|
52
|
-
],
|
|
53
|
-
};
|
|
54
|
-
|
|
55
|
-
export default dingtalkAuthExtension;
|