@nocobase/portal-template-default 1.0.8 → 1.0.10

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 (262) hide show
  1. package/.env.example +5 -0
  2. package/.github/workflows/publish.yml +106 -0
  3. package/.gitignore +33 -0
  4. package/AGENTS.md +19 -0
  5. package/README.MD +61 -180
  6. package/package.json +3 -5
  7. package/scripts/build-html.mjs +12 -0
  8. package/src/App.css +2 -0
  9. package/src/App.tsx +35 -186
  10. package/src/app/development.tsx +154 -0
  11. package/src/app/extension.ts +5 -0
  12. package/src/app/extensions.tsx +18 -4
  13. package/src/app/routes.tsx +65 -0
  14. package/src/components/access-control/acl-bootstrap.tsx +11 -3
  15. package/src/components/access-control/acl-gate.tsx +7 -6
  16. package/src/components/access-control/can-access.tsx +17 -0
  17. package/src/components/access-control/navigate-to-accessible-resource.tsx +8 -3
  18. package/src/components/app-shell/sidebar.tsx +21 -5
  19. package/src/components/auth/auto-redirect-provider.tsx +2 -1
  20. package/src/extensions/nocobase-acl/README.md +74 -0
  21. package/{registry → src/extensions}/nocobase-acl/components/acl-boundary.tsx +22 -25
  22. package/{registry → src/extensions}/nocobase-acl/components/role-switcher.tsx +26 -23
  23. package/src/extensions/nocobase-acl/demo/acl-preview-provider.tsx +81 -0
  24. package/{registry → src/extensions}/nocobase-acl/demo/boundary-api.tsx +58 -0
  25. package/{registry → src/extensions}/nocobase-acl/demo/index.tsx +243 -105
  26. package/{registry → src/extensions}/nocobase-acl/demo/prompt-generator.tsx +3 -1
  27. package/src/extensions/nocobase-acl/extension.tsx +73 -0
  28. package/{registry → src/extensions}/nocobase-ai/README.md +21 -5
  29. package/{registry → src/extensions}/nocobase-ai/components/chat/chat-composer.tsx +3 -1
  30. package/{registry → src/extensions}/nocobase-ai/components/chat/chat-messages.tsx +38 -3
  31. package/{registry → src/extensions}/nocobase-ai/components/chat/tool-call-card.tsx +1 -9
  32. package/{registry → src/extensions}/nocobase-ai/components/index.ts +5 -0
  33. package/src/extensions/nocobase-ai/components/surfaces/chat-dialog.tsx +17 -0
  34. package/src/extensions/nocobase-ai/components/surfaces/chat-side-panel.tsx +35 -0
  35. package/src/extensions/nocobase-ai/components/surfaces/chat-surface.tsx +108 -0
  36. package/{registry → src/extensions}/nocobase-ai/components/triggers/ai-chat-floating-trigger.tsx +2 -2
  37. package/{registry → src/extensions}/nocobase-ai/demo/configuration-gate.tsx +4 -1
  38. package/{registry → src/extensions}/nocobase-ai/demo/container-showcase.tsx +2 -2
  39. package/{registry → src/extensions}/nocobase-ai/demo/floating.tsx +45 -15
  40. package/{registry → src/extensions}/nocobase-ai/demo/index.tsx +116 -74
  41. package/{registry → src/extensions}/nocobase-ai/demo/prompt-generator.tsx +3 -3
  42. package/{registry → src/extensions}/nocobase-ai/demo/tool-cards.tsx +2 -3
  43. package/src/extensions/nocobase-ai/extension.tsx +160 -0
  44. package/{registry → src/extensions}/nocobase-ai/global-ai-chat.tsx +12 -28
  45. package/{registry → src/extensions}/nocobase-ai/providers/ai-provider.tsx +14 -1
  46. package/{registry → src/extensions}/nocobase-ai/providers/chat-context.tsx +1 -0
  47. package/{registry → src/extensions}/nocobase-ai/providers/chat-provider.tsx +29 -8
  48. package/{registry → src/extensions}/nocobase-ai/providers/use-chat-attachments.ts +6 -1
  49. package/{registry → src/extensions}/nocobase-ai/providers/use-chat-work-context.ts +4 -1
  50. package/{registry → src/extensions}/nocobase-route-surfaces/README.md +2 -1
  51. package/{registry → src/extensions}/nocobase-route-surfaces/demo/index.tsx +33 -7
  52. package/{registry → src/extensions}/nocobase-route-surfaces/demo/scenarios.ts +20 -14
  53. package/{registry → src/extensions}/nocobase-route-surfaces/extension.tsx +55 -52
  54. package/src/{pages/users → extensions/nocobase-users-example}/create.tsx +4 -4
  55. package/src/{pages/users → extensions/nocobase-users-example}/edit.tsx +5 -9
  56. package/src/extensions/nocobase-users-example/extension.tsx +109 -0
  57. package/src/{pages/users → extensions/nocobase-users-example}/form-context.ts +11 -9
  58. package/src/extensions/nocobase-users-example/layout.tsx +16 -0
  59. package/src/{pages/users → extensions/nocobase-users-example}/list.tsx +1 -1
  60. package/src/extensions/nocobase-users-example/locales/en-US.ts +77 -0
  61. package/src/extensions/nocobase-users-example/locales/index.ts +8 -0
  62. package/src/extensions/nocobase-users-example/locales/zh-CN.ts +73 -0
  63. package/src/extensions/nocobase-users-example/optional-ai.ts +67 -0
  64. package/src/{pages/users → extensions/nocobase-users-example}/role-detail.tsx +4 -15
  65. package/src/{pages/users → extensions/nocobase-users-example}/routes.ts +1 -4
  66. package/src/extensions/nocobase-users-example/show.tsx +266 -0
  67. package/src/lib/nocobase/acl/context.ts +32 -0
  68. package/src/lib/nocobase/acl/evaluator.ts +186 -0
  69. package/src/lib/nocobase/acl/hooks.ts +40 -0
  70. package/src/lib/nocobase/acl/index.ts +4 -1
  71. package/src/lib/nocobase/acl/menu.ts +6 -6
  72. package/src/lib/nocobase/acl/record-permissions.ts +37 -7
  73. package/src/lib/nocobase/acl/store-provider.tsx +14 -0
  74. package/src/lib/nocobase/acl/store.ts +92 -86
  75. package/src/lib/nocobase/acl/types.ts +52 -32
  76. package/src/lib/nocobase/auth-session.ts +128 -0
  77. package/src/lib/nocobase/client.ts +48 -50
  78. package/src/locales/en-US.ts +0 -78
  79. package/src/locales/index.ts +2 -7
  80. package/src/locales/zh-CN.ts +0 -74
  81. package/src/providers/access-control.ts +43 -8
  82. package/src/providers/auth-callback.ts +1 -0
  83. package/src/providers/auth.ts +24 -26
  84. package/src/providers/constants.ts +0 -4
  85. package/src/providers/data.ts +14 -26
  86. package/src/providers/runtime-config.ts +40 -0
  87. package/src/vite-env.d.ts +9 -0
  88. package/tests/auth-session-regression.mjs +101 -0
  89. package/tsconfig.json +2 -1
  90. package/vite.config.ts +9 -1
  91. package/registry/nocobase-acl/README.md +0 -19
  92. package/registry/nocobase-acl/extension.tsx +0 -71
  93. package/registry/nocobase-acl/tests/acl-regression.mjs +0 -314
  94. package/registry/nocobase-ai/components/surfaces/chat-dialog.tsx +0 -31
  95. package/registry/nocobase-ai/components/surfaces/chat-side-panel.tsx +0 -74
  96. package/registry/nocobase-ai/extension.tsx +0 -158
  97. package/registry/nocobase-ai/tests/business-report-regression.mjs +0 -70
  98. package/registry/nocobase-ai/tests/form-filler-regression.mjs +0 -129
  99. package/registry/nocobase-ai/tests/frontend-tool-regression.mjs +0 -128
  100. package/registry/nocobase-ai/tests/page-context-regression.mjs +0 -48
  101. package/registry/nocobase-ai/tests/stream-regression.mjs +0 -207
  102. package/registry/nocobase-auth-cas/README.md +0 -6
  103. package/registry/nocobase-auth-cas/cas-sign-in-button.tsx +0 -41
  104. package/registry/nocobase-auth-cas/demo.tsx +0 -20
  105. package/registry/nocobase-auth-cas/extension.tsx +0 -46
  106. package/registry/nocobase-auth-cas/index.ts +0 -1
  107. package/registry/nocobase-auth-cas/use-cas-sign-in.ts +0 -29
  108. package/registry/nocobase-auth-dingtalk/README.md +0 -7
  109. package/registry/nocobase-auth-dingtalk/auto-login-provider.tsx +0 -154
  110. package/registry/nocobase-auth-dingtalk/demo.tsx +0 -23
  111. package/registry/nocobase-auth-dingtalk/dingtalk-sign-in-button.tsx +0 -45
  112. package/registry/nocobase-auth-dingtalk/extension.tsx +0 -55
  113. package/registry/nocobase-auth-dingtalk/index.ts +0 -4
  114. package/registry/nocobase-auth-dingtalk/use-dingtalk-sign-in.ts +0 -64
  115. package/registry/nocobase-auth-ldap/README.md +0 -6
  116. package/registry/nocobase-auth-ldap/demo.tsx +0 -21
  117. package/registry/nocobase-auth-ldap/extension.tsx +0 -46
  118. package/registry/nocobase-auth-ldap/index.ts +0 -1
  119. package/registry/nocobase-auth-ldap/ldap-sign-in-form.tsx +0 -69
  120. package/registry/nocobase-auth-ldap/use-ldap-sign-in.ts +0 -5
  121. package/registry/nocobase-auth-oidc/README.md +0 -11
  122. package/registry/nocobase-auth-oidc/auto-redirect-provider.tsx +0 -13
  123. package/registry/nocobase-auth-oidc/demo.tsx +0 -20
  124. package/registry/nocobase-auth-oidc/extension.tsx +0 -51
  125. package/registry/nocobase-auth-oidc/index.ts +0 -1
  126. package/registry/nocobase-auth-oidc/oidc-sign-in-button.tsx +0 -44
  127. package/registry/nocobase-auth-oidc/use-oidc-sign-in.ts +0 -58
  128. package/registry/nocobase-auth-saml/README.md +0 -6
  129. package/registry/nocobase-auth-saml/auto-redirect-provider.tsx +0 -13
  130. package/registry/nocobase-auth-saml/demo.tsx +0 -20
  131. package/registry/nocobase-auth-saml/extension.tsx +0 -51
  132. package/registry/nocobase-auth-saml/index.ts +0 -1
  133. package/registry/nocobase-auth-saml/saml-sign-in-button.tsx +0 -43
  134. package/registry/nocobase-auth-saml/use-saml-sign-in.ts +0 -51
  135. package/registry/nocobase-auth-sms/README.md +0 -7
  136. package/registry/nocobase-auth-sms/demo.tsx +0 -25
  137. package/registry/nocobase-auth-sms/extension.tsx +0 -46
  138. package/registry/nocobase-auth-sms/index.ts +0 -1
  139. package/registry/nocobase-auth-sms/sms-sign-in-form.tsx +0 -107
  140. package/registry/nocobase-auth-sms/use-sms-sign-in.ts +0 -88
  141. package/registry/nocobase-auth-wecom/README.md +0 -6
  142. package/registry/nocobase-auth-wecom/auto-login-provider.tsx +0 -21
  143. package/registry/nocobase-auth-wecom/demo.tsx +0 -23
  144. package/registry/nocobase-auth-wecom/extension.tsx +0 -49
  145. package/registry/nocobase-auth-wecom/index.ts +0 -1
  146. package/registry/nocobase-auth-wecom/use-wecom-sign-in.ts +0 -62
  147. package/registry/nocobase-auth-wecom/wecom-sign-in-button.tsx +0 -70
  148. package/registry/nocobase-i18n/README.md +0 -44
  149. package/registry/nocobase-i18n/components/index.ts +0 -1
  150. package/registry/nocobase-i18n/components/language-switcher.tsx +0 -138
  151. package/registry/nocobase-i18n/demo/index.tsx +0 -209
  152. package/registry/nocobase-i18n/demo/prompt-generator.tsx +0 -132
  153. package/registry/nocobase-i18n/extension.tsx +0 -45
  154. package/registry/nocobase-i18n/index.ts +0 -7
  155. package/registry/nocobase-i18n/locales/en-US.ts +0 -39
  156. package/registry/nocobase-i18n/locales/index.ts +0 -8
  157. package/registry/nocobase-i18n/locales/zh-CN.ts +0 -35
  158. package/registry/nocobase-i18n/provider.tsx +0 -44
  159. package/registry/nocobase-i18n/server-resources.ts +0 -166
  160. package/registry/nocobase-i18n/tests/i18n-regression.mjs +0 -51
  161. package/registry.config.json +0 -302
  162. package/scripts/registry.mjs +0 -164
  163. package/src/components/access-control/resource-access-guard.tsx +0 -21
  164. package/src/components/access-control/use-acl-runtime.ts +0 -28
  165. package/src/lib/nocobase/acl/action.ts +0 -147
  166. package/src/pages/users/layout.tsx +0 -15
  167. package/src/pages/users/show.tsx +0 -278
  168. /package/{registry → src/extensions}/nocobase-acl/components/index.ts +0 -0
  169. /package/{registry → src/extensions}/nocobase-acl/components/role-options.ts +0 -0
  170. /package/{registry → src/extensions}/nocobase-acl/demo/components.tsx +0 -0
  171. /package/{registry → src/extensions}/nocobase-acl/demo/lazy-route.tsx +0 -0
  172. /package/{registry → src/extensions}/nocobase-acl/demo/role-switcher-prompt-generator.tsx +0 -0
  173. /package/{registry → src/extensions}/nocobase-acl/demo/scenario-section.tsx +0 -0
  174. /package/{registry → src/extensions}/nocobase-acl/index.ts +0 -0
  175. /package/{registry → src/extensions}/nocobase-ai/adapters/react-hook-form.ts +0 -0
  176. /package/{registry → src/extensions}/nocobase-ai/assets/nocobase-ai-chat.svg +0 -0
  177. /package/{registry → src/extensions}/nocobase-ai/components/ai-root-provider.tsx +0 -0
  178. /package/{registry → src/extensions}/nocobase-ai/components/chat/ai-employee-avatar.tsx +0 -0
  179. /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-attachment.tsx +0 -0
  180. /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-compact.tsx +0 -0
  181. /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-empty-state.tsx +0 -0
  182. /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-header.tsx +0 -0
  183. /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-history-dialog.tsx +0 -0
  184. /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-message.tsx +0 -0
  185. /package/{registry → src/extensions}/nocobase-ai/components/chat/chat-window.tsx +0 -0
  186. /package/{registry → src/extensions}/nocobase-ai/components/chat/conversation-list.tsx +0 -0
  187. /package/{registry → src/extensions}/nocobase-ai/components/chat/markdown-message.tsx +0 -0
  188. /package/{registry → src/extensions}/nocobase-ai/components/chat/model-select-options.tsx +0 -0
  189. /package/{registry → src/extensions}/nocobase-ai/components/chat/reasoning-panel.tsx +0 -0
  190. /package/{registry → src/extensions}/nocobase-ai/components/chat/sub-agent-conversation.tsx +0 -0
  191. /package/{registry → src/extensions}/nocobase-ai/components/chat/user-prompt-editor.tsx +0 -0
  192. /package/{registry → src/extensions}/nocobase-ai/components/chat/work-context-chip.tsx +0 -0
  193. /package/{registry → src/extensions}/nocobase-ai/components/page-elements/ai-form.tsx +0 -0
  194. /package/{registry → src/extensions}/nocobase-ai/components/page-elements/page-element-provider.tsx +0 -0
  195. /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-inline.tsx +0 -0
  196. /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-page.tsx +0 -0
  197. /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-side-panel-layout.tsx +0 -0
  198. /package/{registry → src/extensions}/nocobase-ai/components/surfaces/chat-surface-actions.tsx +0 -0
  199. /package/{registry → src/extensions}/nocobase-ai/components/tools/builtin-tool-renderers.tsx +0 -0
  200. /package/{registry → src/extensions}/nocobase-ai/components/tools/business-report-dialog.tsx +0 -0
  201. /package/{registry → src/extensions}/nocobase-ai/components/tools/business-report-renderer.tsx +0 -0
  202. /package/{registry → src/extensions}/nocobase-ai/components/tools/business-report-utils.tsx +0 -0
  203. /package/{registry → src/extensions}/nocobase-ai/components/tools/chart-renderer.tsx +0 -0
  204. /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-preview.tsx +0 -0
  205. /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-advanced.ts +0 -0
  206. /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-common.ts +0 -0
  207. /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-components.ts +0 -0
  208. /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime-hierarchy.ts +0 -0
  209. /package/{registry → src/extensions}/nocobase-ai/components/tools/echarts-runtime.ts +0 -0
  210. /package/{registry → src/extensions}/nocobase-ai/components/tools/sub-agent-renderer.tsx +0 -0
  211. /package/{registry → src/extensions}/nocobase-ai/components/tools/suggestions-renderer.tsx +0 -0
  212. /package/{registry → src/extensions}/nocobase-ai/components/tools/tool-renderer-provider.tsx +0 -0
  213. /package/{registry → src/extensions}/nocobase-ai/components/tools/tool-renderer-utils.ts +0 -0
  214. /package/{registry → src/extensions}/nocobase-ai/components/tools/workflow-renderer.tsx +0 -0
  215. /package/{registry → src/extensions}/nocobase-ai/components/triggers/ai-employee-shortcut.tsx +0 -0
  216. /package/{registry → src/extensions}/nocobase-ai/demo/interaction-showcase.tsx +0 -0
  217. /package/{registry → src/extensions}/nocobase-ai/demo/page-context-prompt-generator.tsx +0 -0
  218. /package/{registry → src/extensions}/nocobase-ai/demo/page-context.tsx +0 -0
  219. /package/{registry → src/extensions}/nocobase-ai/demo/page-element-showcase.tsx +0 -0
  220. /package/{registry → src/extensions}/nocobase-ai/demo/prompt-card.tsx +0 -0
  221. /package/{registry → src/extensions}/nocobase-ai/demo/shortcut.tsx +0 -0
  222. /package/{registry → src/extensions}/nocobase-ai/index.ts +0 -0
  223. /package/{registry → src/extensions}/nocobase-ai/providers/avatars.ts +0 -0
  224. /package/{registry → src/extensions}/nocobase-ai/providers/chat-controller.ts +0 -0
  225. /package/{registry → src/extensions}/nocobase-ai/providers/chat-message-utils.ts +0 -0
  226. /package/{registry → src/extensions}/nocobase-ai/providers/chat-reducer.ts +0 -0
  227. /package/{registry → src/extensions}/nocobase-ai/providers/chat-task-utils.ts +0 -0
  228. /package/{registry → src/extensions}/nocobase-ai/providers/chat-transport.ts +0 -0
  229. /package/{registry → src/extensions}/nocobase-ai/providers/form-registry.tsx +0 -0
  230. /package/{registry → src/extensions}/nocobase-ai/providers/frontend-tool-registry.tsx +0 -0
  231. /package/{registry → src/extensions}/nocobase-ai/providers/index.ts +0 -0
  232. /package/{registry → src/extensions}/nocobase-ai/providers/model.ts +0 -0
  233. /package/{registry → src/extensions}/nocobase-ai/providers/page-context.tsx +0 -0
  234. /package/{registry → src/extensions}/nocobase-ai/providers/stream-coalescer.ts +0 -0
  235. /package/{registry → src/extensions}/nocobase-ai/providers/stream-event-utils.ts +0 -0
  236. /package/{registry → src/extensions}/nocobase-ai/providers/stream-parser.ts +0 -0
  237. /package/{registry → src/extensions}/nocobase-ai/providers/sub-agent-stream.ts +0 -0
  238. /package/{registry → src/extensions}/nocobase-ai/providers/types.ts +0 -0
  239. /package/{registry → src/extensions}/nocobase-ai/providers/ui-message-stream.ts +0 -0
  240. /package/{registry → src/extensions}/nocobase-ai/providers/use-automatic-tool-approval.ts +0 -0
  241. /package/{registry → src/extensions}/nocobase-ai/providers/use-chat-message-actions.ts +0 -0
  242. /package/{registry → src/extensions}/nocobase-ai/providers/use-chat-runtime.ts +0 -0
  243. /package/{registry → src/extensions}/nocobase-ai/providers/use-conversation-catalog.ts +0 -0
  244. /package/{registry → src/extensions}/nocobase-ai/providers/use-conversation-history.ts +0 -0
  245. /package/{registry → src/extensions}/nocobase-ai/services/index.ts +0 -0
  246. /package/{registry → src/extensions}/nocobase-ai/services/nocobase-ai-service.ts +0 -0
  247. /package/{registry → src/extensions}/nocobase-ai/services/types.ts +0 -0
  248. /package/{registry → src/extensions}/nocobase-route-surfaces/demo/lazy-route.tsx +0 -0
  249. /package/{registry → src/extensions}/nocobase-route-surfaces/demo/prompt-generator.tsx +0 -0
  250. /package/{registry → src/extensions}/nocobase-route-surfaces/index.ts +0 -0
  251. /package/{registry → src/extensions}/nocobase-route-surfaces/route-dialog.tsx +0 -0
  252. /package/{registry → src/extensions}/nocobase-route-surfaces/route-drawer.tsx +0 -0
  253. /package/{registry → src/extensions}/nocobase-route-surfaces/route-page.tsx +0 -0
  254. /package/{registry → src/extensions}/nocobase-route-surfaces/route-surface-context.ts +0 -0
  255. /package/{registry → src/extensions}/nocobase-route-surfaces/use-refine-unsaved-changes.tsx +0 -0
  256. /package/{registry → src/extensions}/nocobase-route-surfaces/use-route-surface-close.ts +0 -0
  257. /package/{registry → src/extensions}/nocobase-route-surfaces/use-route-surface-state.ts +0 -0
  258. /package/src/{pages/users → extensions/nocobase-users-example}/form-fields.tsx +0 -0
  259. /package/src/{pages/users → extensions/nocobase-users-example}/index.ts +0 -0
  260. /package/src/{pages/users → extensions/nocobase-users-example}/role-badges.tsx +0 -0
  261. /package/src/{pages/users → extensions/nocobase-users-example}/role-utils.ts +0 -0
  262. /package/src/{pages/users → extensions/nocobase-users-example}/types.ts +0 -0
package/.env.example CHANGED
@@ -6,5 +6,10 @@ NOCOBASE_AUTHENTICATOR=basic
6
6
  # Use / for root-local development, or /x/admin/ when building for storage/dist-client/x/admin.
7
7
  NOCOBASE_PORTAL_BASE=/x/admin/
8
8
 
9
+ # Keep these aligned with the main NocoBase frontend when customized.
10
+ # API_CLIENT_STORAGE_PREFIX=NOCOBASE_
11
+ # API_CLIENT_STORAGE_TYPE=localStorage
12
+ # API_CLIENT_SHARE_TOKEN=false
13
+
9
14
  # Optional for local development. Do not commit real access tokens.
10
15
  # NOCOBASE_API_TOKEN=
@@ -0,0 +1,106 @@
1
+ name: Publish npm package
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ inputs:
6
+ version:
7
+ description: Exact version (leave blank to increment patch)
8
+ required: false
9
+ type: string
10
+ tag:
11
+ description: npm distribution tag
12
+ required: true
13
+ default: latest
14
+ type: choice
15
+ options:
16
+ - latest
17
+ - next
18
+
19
+ permissions:
20
+ contents: write
21
+ id-token: write
22
+
23
+ concurrency:
24
+ group: publish-npm-package
25
+ cancel-in-progress: false
26
+
27
+ jobs:
28
+ publish:
29
+ runs-on: ubuntu-latest
30
+ steps:
31
+ - name: Checkout
32
+ uses: actions/checkout@v4
33
+ with:
34
+ fetch-depth: 0
35
+
36
+ - name: Set up pnpm
37
+ uses: pnpm/action-setup@v4
38
+ with:
39
+ run_install: false
40
+
41
+ - name: Set up Node.js
42
+ uses: actions/setup-node@v4
43
+ with:
44
+ node-version: 24
45
+ cache: pnpm
46
+ registry-url: https://registry.npmjs.org
47
+
48
+ - name: Update npm
49
+ run: npm install -g npm@latest
50
+
51
+ - name: Print tool versions
52
+ run: |
53
+ node --version
54
+ npm --version
55
+ pnpm --version
56
+
57
+ - name: Install dependencies
58
+ run: pnpm install --frozen-lockfile
59
+
60
+ - name: Resolve release version
61
+ id: release
62
+ env:
63
+ REF_TYPE: ${{ github.ref_type }}
64
+ REQUESTED_VERSION: ${{ inputs.version }}
65
+ run: |
66
+ if [ "$REF_TYPE" != "branch" ]; then
67
+ echo "Run this workflow from a branch, not a tag."
68
+ exit 1
69
+ fi
70
+
71
+ if [ -n "$REQUESTED_VERSION" ]; then
72
+ npm version "$REQUESTED_VERSION" --no-git-tag-version
73
+ else
74
+ npm version patch --no-git-tag-version
75
+ fi
76
+
77
+ VERSION=$(node -p "require('./package.json').version")
78
+ if git rev-parse --verify --quiet "refs/tags/v${VERSION}"; then
79
+ echo "Git tag v${VERSION} already exists."
80
+ exit 1
81
+ fi
82
+ echo "version=${VERSION}" >> "$GITHUB_OUTPUT"
83
+
84
+ - name: Materialize default extensions
85
+ run: node scripts/registry.mjs materialize
86
+
87
+ - name: Inspect package
88
+ run: npm pack --dry-run
89
+
90
+ - name: Build
91
+ run: pnpm build
92
+
93
+ - name: Publish package
94
+ run: npm publish --access public --tag "${{ inputs.tag }}" --loglevel verbose
95
+
96
+ - name: Commit and tag release
97
+ env:
98
+ TARGET_BRANCH: ${{ github.ref_name }}
99
+ VERSION: ${{ steps.release.outputs.version }}
100
+ run: |
101
+ git config user.name "github-actions[bot]"
102
+ git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
103
+ git add package.json
104
+ git commit -m "chore(release): v${VERSION}"
105
+ git tag -a "v${VERSION}" -m "v${VERSION}"
106
+ git push --atomic origin "HEAD:refs/heads/${TARGET_BRANCH}" "refs/tags/v${VERSION}"
package/.gitignore ADDED
@@ -0,0 +1,33 @@
1
+ # Logs
2
+
3
+ logs
4
+ _.log
5
+ npm-debug.log_
6
+ yarn-debug.log*
7
+ yarn-error.log*
8
+ pnpm-debug.log*
9
+ lerna-debug.log*
10
+
11
+ node_modules
12
+ dist
13
+ dist-ssr
14
+ *.local
15
+ /.extension-state/
16
+ /registry.json
17
+ /public/r/
18
+
19
+ # Environment variables
20
+ .env
21
+ .env.local
22
+
23
+ # Editor directories and files
24
+
25
+ .vscode/_
26
+ !.vscode/extensions.json
27
+ .idea
28
+ .DS_Store
29
+ _.suo
30
+ _.ntvs_
31
+ _.njsproj
32
+ _.sln
33
+ \*.sw?
package/AGENTS.md ADDED
@@ -0,0 +1,19 @@
1
+ # Application Development Guidelines
2
+
3
+ This repository is a starter for building a NocoBase-powered application. Keep changes focused on the application being built and follow these guidelines before introducing new abstractions.
4
+
5
+ ## Reuse existing extensions
6
+
7
+ Before writing new code, inspect `registry` in the Registry source repository or `src/extensions` in a published template for similar pages, hooks, components, and integration patterns. Reuse an existing implementation directly when it already fits the requirement, and extend or compose it when only a small adaptation is needed.
8
+
9
+ ## Customize UI components through composition
10
+
11
+ Treat `src/components/ui` as the project's shadcn/ui foundation. When application-specific behavior or styling is needed, prefer wrapping, pre-composing, or re-exporting the base component from a feature-level component instead of editing the base component directly. This keeps the base components replaceable and makes future updates easier to review.
12
+
13
+ Components copied from shadcn/ui are owned and maintained by this project; upstream changes are not applied automatically. If a base component must be changed or updated, compare it with the upstream version first, then selectively merge bug fixes and improvements while preserving intentional local behavior. Do not blindly overwrite customized components.
14
+
15
+ ## Develop Portal Registry items
16
+
17
+ Canonical NocoBase Registry source lives under `registry/`. In this source repository, normal development and builds load it directly; do not copy it into `src/extensions` for preview. Imports from a Registry item to the host application must use the `@/` alias. Relative imports must stay within that Registry item's own root so the item remains portable after installation. Registry items target this Portal Template's React, shadcn Base UI, and pnpm toolchain. They must never import Ant Design or NocoBase's Ant Design-based client components.
18
+
19
+ Keep Registry items portable and focused on reusable API adapters, hooks, components, and small demos. Update `registry.config.json` whenever an item's files, dependencies, or installation target changes. Validate Registry changes with the normal application build and the relevant regression scripts.
package/README.MD CHANGED
@@ -1,220 +1,101 @@
1
- # nocobase-admin-starter
1
+ # NocoBase Portal Template
2
2
 
3
- ![2026-07-22-08-48-12](https://static-docs.nocobase.com/2026-07-22-08-48-12.png)
3
+ A React and shadcn/ui template for building standalone frontends backed by
4
+ NocoBase.
4
5
 
5
- ## NocoBase configuration
6
+ ![NocoBase Portal Template](https://static-docs.nocobase.com/2026-07-22-08-48-12.png)
6
7
 
7
- Copy `.env.example` to `.env.local` and set the NocoBase API URL. The default `basic` authenticator uses the NocoBase username or email and password login. For local development, a temporary access token can be supplied through `NOCOBASE_API_TOKEN`; do not commit it. The data provider sends it as `Authorization: Bearer <token>`.
8
-
9
- If you call a remote NocoBase instance from `http://localhost:*`, the browser may block `auth:signIn` because NocoBase requires the `X-Authenticator` request header and the remote server must explicitly allow it in CORS preflight responses. In local Vite development, prefer using the built-in dev proxy:
10
-
11
- ```env
12
- NOCOBASE_API_URL=https://develop.v2.test.nocobase.com/nocobase/api/__app/cms
13
- ```
14
-
15
- In development, the app auto-detects the proxy target from `NOCOBASE_API_URL` when that value is an absolute URL. The configured API URL can stay on the original sub-app path such as `/nocobase/api/__app/cms`.
16
-
17
- Application resource names must match NocoBase collection names. The included
18
- Users example targets the default `users` collection, so it works without a
19
- project-specific business collection.
20
-
21
- Application-owned React translations live in `src/locales`. The entry registers
22
- an `app` namespace for business pages and augments the default `starter`
23
- namespace for shared controls. Feature-specific Registry translations remain
24
- inside their own extension namespace and are not mixed into application locale
25
- files.
26
-
27
- ### Authentication UI
28
-
29
- The default login page calls `authenticators:publicList` and renders every
30
- enabled NocoBase authenticator that has a frontend adapter installed. Basic
31
- username/password authentication is built into the Starter. Optional methods
32
- are installed independently:
8
+ ## Quick start
33
9
 
34
10
  ```bash
35
- pnpm exec shadcn add @nocobase/auth-sms
36
- pnpm exec shadcn add @nocobase/auth-ldap
37
- pnpm exec shadcn add @nocobase/auth-oidc
38
- pnpm exec shadcn add @nocobase/auth-saml
39
- pnpm exec shadcn add @nocobase/auth-cas
40
- pnpm exec shadcn add @nocobase/auth-wecom
41
- pnpm exec shadcn add @nocobase/auth-dingtalk
11
+ pnpm install
12
+ cp .env.example .env.local
13
+ pnpm dev
42
14
  ```
43
15
 
44
- The Starter includes an Authentication Demo for the three customization
45
- boundaries below. Each optional authentication Registry adds its own component
46
- Demo under the same Authentication menu when installed.
16
+ The development server starts at `http://localhost:5173` by default.
47
17
 
48
- The application login page remains the customization boundary. Keep the
49
- default dynamic page with:
18
+ ## Configuration
50
19
 
51
- ```tsx
52
- import { DefaultSignInPage } from "@/components/auth/default-sign-in-page"
20
+ The minimum local configuration is:
53
21
 
54
- export const Login = () => <DefaultSignInPage />
22
+ ```env
23
+ NOCOBASE_API_URL=/api
24
+ NOCOBASE_PORTAL_BASE=/
55
25
  ```
56
26
 
57
- To replace only one authenticator UI, use `renderAuthenticator` and return the
58
- default element for everything else:
59
-
60
- ```tsx
61
- import { DefaultSignInPage } from "@/components/auth/default-sign-in-page"
62
- import { useOidcSignIn } from "@/extensions/nocobase-auth-oidc"
63
- import { Button } from "@/components/ui/button"
64
-
65
- function CompanyOidcButton({ authenticator }) {
66
- const oidc = useOidcSignIn(authenticator)
67
- return <Button onClick={oidc.signIn}>Company SSO</Button>
68
- }
69
-
70
- export const Login = () => (
71
- <DefaultSignInPage
72
- renderAuthenticator={({ authenticator, defaultElement }) =>
73
- authenticator.name === "company-oidc" ? (
74
- <CompanyOidcButton authenticator={authenticator} />
75
- ) : (
76
- defaultElement
77
- )
78
- }
79
- />
80
- )
81
- ```
27
+ - `NOCOBASE_API_URL` is the NocoBase REST API root and must include `/api`.
28
+ Same-origin deployments normally use `/api`. During local development, an
29
+ absolute URL is handled through the Vite proxy.
30
+ - `NOCOBASE_PORTAL_BASE` is the public path where the Portal is mounted. Use
31
+ `/` for root development or set the deployment path before building.
32
+ - `NOCOBASE_API_TOKEN` can provide a temporary development token. Never commit
33
+ real tokens.
82
34
 
83
- Replace `src/pages/login/index.tsx` completely when the application needs a
84
- fully custom login page. Token callback capture, current authenticator storage,
85
- request headers, and logout behavior remain provided by the Starter runtime and
86
- do not depend on `DefaultSignInPage`.
87
-
88
- ```tsx
89
- import { AuthLayout } from "@/components/auth/auth-layout"
90
- import { BasicSignInForm } from "@/components/auth"
91
-
92
- export const Login = () => (
93
- <AuthLayout title="Sign in" description="Continue to your workspace.">
94
- <BasicSignInForm
95
- authenticator={{
96
- name: "basic",
97
- authType: "Email/Password",
98
- }}
99
- />
100
- </AuthLayout>
101
- )
102
- ```
35
+ The Portal uses the same authentication storage convention as NocoBase. If the
36
+ server customizes it, keep `API_CLIENT_STORAGE_PREFIX`,
37
+ `API_CLIENT_STORAGE_TYPE`, and `API_CLIENT_SHARE_TOKEN` aligned with the server.
103
38
 
104
- ## Available Scripts
105
-
106
- ### Running the development server.
39
+ ## Development
107
40
 
108
41
  ```bash
42
+ # Start the Vite development server
109
43
  pnpm dev
110
- ```
111
44
 
112
- ### Building for production.
113
-
114
- ```bash
45
+ # Build the production assets
115
46
  pnpm build
116
- ```
117
-
118
- ### Extensions and the NocoBase Shadcn Registry
119
-
120
- The starter separates framework-owned extension support from installed Registry
121
- source:
122
47
 
123
- - `src/app/extension.ts` defines the generic extension contract.
124
- - `src/app/extensions.tsx` discovers `src/extensions/*/extension.tsx` and adds
125
- its providers, Refine resources, and routes to the app.
126
- - `registry/<name>` contains the canonical authoring source for a Registry
127
- package while it is developed in this repository.
128
- - `src/extensions/<name>` contains installed, application-owned source.
129
- Downstream applications can commit this directory like any other source code.
130
-
131
- `registry.config.json` is the only authoring manifest. In addition to standard
132
- Shadcn Registry item fields, each item has a local `source` mapping used to
133
- generate its standard `files` array. The same mapping lets the starter's
134
- `postinstall` hook copy a locally authored extension only when its target is
135
- missing. Existing installed source is never compared, updated, or overwritten.
136
- Optional entries can set `source.install` to `false`; they remain available to
137
- Registry builds and local previews but are not added by `postinstall`.
138
-
139
- You can run the same missing-only installation explicitly with:
140
-
141
- ```bash
142
- pnpm registry:install
143
- ```
144
-
145
- This repository authors optional NocoBase integration entries. Internationalization
146
- is delivered as one cohesive Registry entry:
147
-
148
- - `i18n` extends the Starter's built-in translation provider and shared System
149
- Settings bootstrap with selected server-generated namespaces such as
150
- `lm-collections`, user locale persistence, the language switcher, and the
151
- lazy-loaded showcase with its prompt generator.
152
-
153
- The AI integration is available through four incremental entries:
154
-
155
- - `ai-runtime` provides AI services, providers, transports, and
156
- controllers. Its NocoBase requests use the starter's shared
157
- `src/lib/nocobase/client.ts` client.
158
- - `ai-chat` adds the reusable chat components and depends on the
159
- runtime entry.
160
- - `ai-react-hook-form` adds the optional React Hook Form adapter for the fixed
161
- Form filler Tool.
162
- - `ai` adds the application extension integration and Demo pages and depends on the
163
- chat entry.
164
-
165
- To refresh the local preview from the canonical Registry source, run:
48
+ # Serve a production build
49
+ pnpm start
166
50
 
167
- ```bash
168
- pnpm registry:preview
51
+ # Build a standalone HTML artifact
52
+ pnpm build:html
169
53
  ```
170
54
 
171
- This is the only command that intentionally replaces the local preview at
172
- `src/extensions/nocobase-ai`. Normal `pnpm dev`, `pnpm install`, and
173
- `pnpm registry:install` do not overwrite an installed extension.
55
+ Application pages and resources live under `src`. The included Users page is a
56
+ working example based on the standard NocoBase `users` collection.
174
57
 
175
- Build the standard Shadcn Registry JSON files into `public/r` with:
58
+ Application translations live in `src/locales`. Shared UI components live in
59
+ `src/components/ui` and follow the shadcn Base UI conventions.
176
60
 
177
- ```bash
178
- pnpm registry:build
179
- ```
61
+ ## Extensions
180
62
 
181
- With the development server running, a compatible starter can also add the
182
- complete item through Shadcn:
63
+ Installed extensions live in `src/extensions` and are ordinary
64
+ application-owned source files. Their providers, resources, routes, login
65
+ adapters, and user-menu items are discovered automatically.
183
66
 
184
- ```bash
185
- pnpm dlx shadcn@latest add @nocobase/ai
186
- ```
67
+ Optional NocoBase integrations, including authentication methods and i18n, can
68
+ be installed from the `@nocobase` Registry configured in `components.json`.
69
+ After installation, the generated source can be customized and committed with
70
+ the application.
187
71
 
188
- Install the optional NocoBase i18n integration with:
72
+ In this Registry source repository, canonical extension source lives in
73
+ `registry` and is loaded directly by `pnpm dev` and `pnpm build`. The published
74
+ npm template contains the default extensions under `src/extensions` instead.
189
75
 
190
- ```bash
191
- pnpm dlx shadcn@latest add @nocobase/i18n
192
- ```
76
+ ## Authentication
193
77
 
194
- Shadcn does not keep a Registry item lock or merge local changes. Re-running
195
- `add` downloads the current item, skips identical files, and asks before
196
- replacing different files. Use `--diff` to inspect an update and `--overwrite`
197
- to accept the Registry version explicitly.
78
+ Basic username or email and password login is built in. The default login page
79
+ also renders enabled NocoBase authentication methods when their frontend
80
+ Registry adapters are installed.
198
81
 
199
- The Registry alias is configured in `components.json` and resolves to
200
- `http://localhost:5173/r/{name}.json` during local development. The same generic
201
- extension host and Registry source mapping can be reused for future Registry
202
- packages without adding package-specific logic to `App.tsx` or the installer.
82
+ Customize `src/pages/login/index.tsx` to replace the whole login page, or use
83
+ `DefaultSignInPage` to keep dynamic authentication while overriding individual
84
+ authenticator UI.
203
85
 
204
- ### Running the production server.
86
+ ## Tests
205
87
 
206
88
  ```bash
207
- pnpm start
89
+ pnpm test:auth
90
+ pnpm test:acl
91
+ pnpm test:i18n
208
92
  ```
209
93
 
210
- ## Learn More
211
-
212
- To learn more about **Refine**, please check out the [Documentation](https://refine.dev/docs)
94
+ ## Learn more
213
95
 
214
- - **REST Data Provider** [Docs](https://refine.dev/docs/core/providers/data-provider/#overview)
215
- - **shadcn/ui** [Docs](https://refine.dev/docs/guides-concepts/general-concepts/#headless-concept)
216
- - **React Router** [Docs](https://refine.dev/docs/core/providers/router-provider/)
217
- - **Custom Auth Provider** [Docs](https://refine.dev/docs/core/providers/auth-provider/)
96
+ - [NocoBase documentation](https://docs.nocobase.com/)
97
+ - [Refine documentation](https://refine.dev/docs/)
98
+ - [shadcn/ui documentation](https://ui.shadcn.com/)
218
99
 
219
100
  ## License
220
101
 
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@nocobase/portal-template-default",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
+ "packageManager": "pnpm@10.28.0",
4
5
  "type": "module",
5
6
  "devDependencies": {
6
7
  "@ai-sdk/react": "2.0.0",
@@ -77,13 +78,10 @@
77
78
  "url": "git+https://github.com/nocobase/portal-template-default.git"
78
79
  },
79
80
  "scripts": {
80
- "postinstall": "node ./scripts/registry.mjs install-missing",
81
81
  "dev": "vite",
82
82
  "build": "tsc && refine build",
83
83
  "build:html": "node ./scripts/build-html.mjs",
84
- "registry:install": "node ./scripts/registry.mjs install-missing",
85
- "registry:preview": "node ./scripts/registry.mjs preview",
86
- "registry:build": "node ./scripts/registry.mjs build && shadcn build ./registry.json -o ./public/r",
84
+ "test:auth": "node tests/auth-session-regression.mjs",
87
85
  "test:acl": "node registry/nocobase-acl/tests/acl-regression.mjs",
88
86
  "test:i18n": "node registry/nocobase-i18n/tests/i18n-regression.mjs",
89
87
  "start": "refine start",
@@ -65,6 +65,15 @@ const stripExistingRuntimeConfig = (html) => {
65
65
 
66
66
  const portalBase = normalizePortalBase(process.env.NOCOBASE_PORTAL_BASE);
67
67
  const apiUrl = String(process.env.NOCOBASE_API_URL || "/api").trim() || "/api";
68
+ const storagePrefix =
69
+ String(process.env.API_CLIENT_STORAGE_PREFIX || "NOCOBASE_").trim() ||
70
+ "NOCOBASE_";
71
+ const storageType =
72
+ String(process.env.API_CLIENT_STORAGE_TYPE || "localStorage").trim() ||
73
+ "localStorage";
74
+ const shareToken = /^true$/i.test(
75
+ String(process.env.API_CLIENT_SHARE_TOKEN || "false").trim()
76
+ );
68
77
 
69
78
  if (!fs.existsSync(rawIndexPath)) {
70
79
  throw new Error(
@@ -76,6 +85,9 @@ const runtimeConfig = `${startMarker}
76
85
  <script>
77
86
  window.NOCOBASE_PORTAL_BASE = ${JSON.stringify(portalBase)};
78
87
  window.NOCOBASE_API_URL = ${JSON.stringify(apiUrl)};
88
+ window.__nocobase_api_client_storage_prefix__ = ${JSON.stringify(storagePrefix)};
89
+ window.__nocobase_api_client_storage_type__ = ${JSON.stringify(storageType)};
90
+ window.__nocobase_api_client_share_token__ = ${JSON.stringify(shareToken)};
79
91
  </script>
80
92
  ${endMarker}
81
93
  `;
package/src/App.css CHANGED
@@ -1,6 +1,8 @@
1
1
  @import "tailwindcss";
2
2
  @import "tw-animate-css";
3
3
  @import "shadcn/tailwind.css";
4
+ @source "./extensions";
5
+ @source "../registry";
4
6
 
5
7
  @custom-variant dark (&:is(.dark *));
6
8