@h-ai/cli 0.1.0-alpha9 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +229 -0
- package/README.ja.md +229 -0
- package/README.md +175 -113
- package/dist/chunk-AKV2CQZV.js +1497 -0
- package/dist/chunk-AKV2CQZV.js.map +1 -0
- package/dist/chunk-EF7WOFWZ.js +7557 -0
- package/dist/chunk-EF7WOFWZ.js.map +1 -0
- package/dist/chunk-MUHRBJSW.js +29272 -0
- package/dist/chunk-MUHRBJSW.js.map +1 -0
- package/dist/chunk-ZSDEVXZ7.js +38 -0
- package/dist/{chunk-2H7UOFLK.js.map → chunk-ZSDEVXZ7.js.map} +1 -1
- package/dist/cli-config-templates-HHFHNXBN.js +5 -0
- package/dist/cli-config-templates-HHFHNXBN.js.map +1 -0
- package/dist/cli-skill-templates-PN4FLGBC.js +5 -0
- package/dist/cli-skill-templates-PN4FLGBC.js.map +1 -0
- package/dist/index.js +4444 -554
- package/dist/index.js.map +1 -1
- package/dist/metafile-esm.json +1 -0
- package/dist/src-TEBHR5I5.js +5 -0
- package/dist/src-TEBHR5I5.js.map +1 -0
- package/package.json +35 -15
- package/templates/README.md +56 -114
- package/templates/apps/admin/messages/en-US.json +7 -0
- package/templates/apps/admin/messages/ja-JP.json +40 -0
- package/templates/apps/admin/messages/zh-CN.json +7 -0
- package/templates/apps/admin/src/routes/+layout.svelte.hbs +65 -8
- package/templates/apps/admin/src/routes/+page.svelte.hbs +35 -14
- package/templates/apps/admin/src/routes/admin/+layout.svelte.hbs +54 -22
- package/templates/apps/admin/src/routes/admin/+page.svelte.hbs +33 -24
- package/templates/apps/admin/src/routes/admin/settings/+page.svelte.hbs +16 -13
- package/templates/apps/api/.dockerignore.hbs +25 -0
- package/templates/apps/api/.gitignore.hbs +22 -0
- package/templates/apps/api/.npmrc.hbs +1 -0
- package/templates/apps/api/apps/{{projectName}}-contract/README.md.hbs +39 -0
- package/templates/apps/api/apps/{{projectName}}-contract/package.json.hbs +41 -0
- package/templates/apps/api/apps/{{projectName}}-contract/src/app-contract.ts.hbs +27 -0
- package/templates/apps/api/apps/{{projectName}}-contract/src/app-schemas.ts.hbs +28 -0
- package/templates/apps/api/apps/{{projectName}}-contract/src/index.ts.hbs +5 -0
- package/templates/apps/api/apps/{{projectName}}-contract/src/{{projectName}}-contract.ts.hbs +16 -0
- package/templates/apps/api/apps/{{projectName}}-contract/tests/contract.test.ts.hbs +18 -0
- package/templates/apps/api/apps/{{projectName}}-contract/tsconfig.json.hbs +12 -0
- package/templates/apps/api/apps/{{projectName}}-contract/tsup.config.ts.hbs +11 -0
- package/templates/apps/api/apps/{{projectName}}-contract/vitest.config.ts.hbs +9 -0
- package/templates/apps/api/apps/{{projectName}}-serv/README.md.hbs +60 -0
- package/templates/apps/api/apps/{{projectName}}-serv/config/_core.yml.hbs +17 -0
- package/templates/apps/api/apps/{{projectName}}-serv/config/_serv.yml.hbs +54 -0
- package/templates/apps/api/apps/{{projectName}}-serv/data/.gitkeep.hbs +1 -0
- package/templates/apps/api/apps/{{projectName}}-serv/package.json.hbs +66 -0
- package/templates/apps/api/apps/{{projectName}}-serv/src/app.ts.hbs +119 -0
- package/templates/apps/api/apps/{{projectName}}-serv/src/build-metadata.ts.hbs +7 -0
- package/templates/apps/api/apps/{{projectName}}-serv/src/index.ts.hbs +41 -0
- package/templates/apps/api/apps/{{projectName}}-serv/src/lib/server/init.ts.hbs +165 -0
- package/templates/apps/api/apps/{{projectName}}-serv/src/server/procedures/app-procedures.ts.hbs +57 -0
- package/templates/apps/api/apps/{{projectName}}-serv/src/server/procedures/index.ts.hbs +41 -0
- package/templates/apps/api/apps/{{projectName}}-serv/tests/service.test.ts.hbs +176 -0
- package/templates/apps/api/apps/{{projectName}}-serv/tsconfig.json.hbs +16 -0
- package/templates/apps/api/apps/{{projectName}}-serv/tsup.config.ts.hbs +20 -0
- package/templates/apps/api/apps/{{projectName}}-serv/vitest.config.ts.hbs +12 -0
- package/templates/apps/api/e2e/api-serv.spec.ts.hbs +113 -0
- package/templates/apps/api/e2e/capture-evidence.ts.hbs +23 -0
- package/templates/apps/api/eslint.config.js.hbs +30 -0
- package/templates/apps/api/hai.json.hbs +4 -0
- package/templates/apps/api/images/serv.Dockerfile.hbs +37 -0
- package/templates/apps/api/package.json.hbs +53 -0
- package/templates/apps/api/playwright.config.ts.hbs +67 -0
- package/templates/apps/api/pnpm-workspace.yaml.hbs +40 -0
- package/templates/apps/api/tsconfig.base.json +14 -0
- package/templates/apps/fullstack/.dockerignore.hbs +25 -0
- package/templates/apps/fullstack/.gitignore.hbs +38 -0
- package/templates/apps/fullstack/.npmrc.hbs +1 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/.env.example.hbs +10 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/README.md.hbs +67 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/capacitor.config.ts.hbs +20 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/eslint.config.js.hbs +20 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/index.html.hbs +22 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/messages/en-US.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/messages/ja-JP.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/messages/zh-CN.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/package.json.hbs +86 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/project.inlang/settings.json.hbs +17 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/public/runtime-config.js.hbs +4 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/src/App.svelte.hbs +59 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/src/app.css.hbs +20 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/src/app.d.ts.hbs +8 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/src/build-metadata.ts.hbs +9 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/src/lib/capacitor.ts.hbs +19 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/src/main.ts.hbs +21 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/svelte.config.js.hbs +16 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/tsconfig.json.hbs +23 -0
- package/templates/apps/fullstack/apps/{{projectName}}-app/vite.config.ts.hbs +74 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/.env.example.hbs +6 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/README.md.hbs +64 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/eslint.config.js.hbs +20 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/index.html.hbs +20 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/messages/en-US.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/messages/ja-JP.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/messages/zh-CN.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/package.json.hbs +66 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/project.inlang/settings.json.hbs +17 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src/App.svelte.hbs +25 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src/app.css.hbs +18 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src/app.d.ts.hbs +8 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src/build-metadata.ts.hbs +9 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src/main.ts.hbs +20 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/Cargo.toml.hbs +33 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/build.rs.hbs +6 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/capabilities/default.json.hbs +16 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/icons/128x128.png +0 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/icons/128x128@2x.png +0 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/icons/32x32.png +0 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/icons/icon.icns +0 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/icons/icon.ico +0 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/src/lib.rs.hbs +91 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/src/main.rs.hbs +8 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/src-tauri/tauri.conf.json.hbs +46 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/svelte.config.js.hbs +14 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/tsconfig.json.hbs +22 -0
- package/templates/apps/fullstack/apps/{{projectName}}-desktop/vite.config.ts.hbs +89 -0
- package/templates/apps/fullstack/apps/{{projectName}}-miniapp/README.md.hbs +25 -0
- package/templates/apps/fullstack/apps/{{projectName}}-miniapp/messages/en-US.json.hbs +12 -0
- package/templates/apps/fullstack/apps/{{projectName}}-miniapp/messages/ja-JP.json.hbs +12 -0
- package/templates/apps/fullstack/apps/{{projectName}}-miniapp/messages/zh-CN.json.hbs +12 -0
- package/templates/apps/fullstack/apps/{{projectName}}-miniapp/project.inlang/settings.json.hbs +17 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/README.md.hbs +54 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/eslint.config.js.hbs +20 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/index.html.hbs +21 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/messages/en-US.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/messages/ja-JP.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/messages/zh-CN.json.hbs +7 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/package.json.hbs +53 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/project.inlang/settings.json.hbs +17 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/public/runtime-config.js.hbs +1 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/src/App.svelte.hbs +18 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/src/app.css.hbs +18 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/src/app.d.ts.hbs +8 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/src/build-metadata.ts.hbs +9 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/src/main.ts.hbs +14 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/svelte.config.js.hbs +16 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/tsconfig.json.hbs +23 -0
- package/templates/apps/fullstack/apps/{{projectName}}-web/vite.config.ts.hbs +76 -0
- package/templates/apps/fullstack/docs/security-configuration.md.hbs +349 -0
- package/templates/apps/fullstack/e2e/fullstack.spec.ts.hbs +988 -0
- package/templates/apps/fullstack/e2e/session-close.spec.ts.hbs +119 -0
- package/templates/apps/fullstack/eslint.config.js.hbs +41 -0
- package/templates/apps/fullstack/hai.json.hbs +11 -0
- package/templates/apps/fullstack/images/serv.Dockerfile.hbs +38 -0
- package/templates/apps/fullstack/images/web/19-runtime-config.envsh.hbs +5 -0
- package/templates/apps/fullstack/images/web/nginx.conf.hbs +24 -0
- package/templates/apps/fullstack/images/web/runtime-config.js.template.hbs +3 -0
- package/templates/apps/fullstack/images/web.Dockerfile.hbs +37 -0
- package/templates/apps/fullstack/package.json.hbs +61 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/README.md.hbs +40 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/package.json.hbs +30 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/src/admin-contract.ts.hbs +78 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/src/admin-schemas.ts.hbs +134 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/src/app-contract.ts.hbs +20 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/src/app-schemas.ts.hbs +35 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/src/index.ts.hbs +7 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/src/{{projectName}}-contract.ts.hbs +23 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/tests/contract.test.ts.hbs +31 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/tsconfig.json.hbs +9 -0
- package/templates/apps/fullstack/packages/{{projectName}}-contract/tsup.config.ts.hbs +9 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/README.md.hbs +84 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_ai.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_audit.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_cache.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_core.yml.hbs +22 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_db.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_feedback.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_iam.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_payment.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_reach.yml.hbs +60 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_scheduler.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_serv.yml.hbs +64 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_storage.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/config/_vecdb.yml.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/data/.gitkeep.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/package.json.hbs +62 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/app-server.ts.hbs +115 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/build-metadata.ts.hbs +7 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/index.ts.hbs +40 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/admin-service.ts.hbs +294 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/audit-jobs.ts.hbs +28 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/business-settings.ts.hbs +50 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/messages.ts.hbs +50 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/procedures/admin-procedures.ts.hbs +106 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/procedures/app-procedures.ts.hbs +49 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/procedures/index.ts.hbs +34 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/runtime.ts.hbs +159 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/src/server/security-roles.ts.hbs +73 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/tests/app-server.test.ts.hbs +505 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/tests/runtime.test.ts.hbs +72 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/tests/security.test.ts.hbs +183 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/tsconfig.json.hbs +10 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/tsup.config.ts.hbs +18 -0
- package/templates/apps/fullstack/packages/{{projectName}}-serv/vitest.config.ts.hbs +12 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/.gitignore.hbs +10 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/README.md.hbs +97 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/messages/en-US.json.hbs +164 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/messages/ja-JP.json.hbs +164 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/messages/zh-CN.json.hbs +164 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/package.json.hbs +55 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/project.inlang/settings.json.hbs +11 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/index.ts.hbs +7 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/api/api-client.ts.hbs +94 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/api/feedback-client.ts.hbs +36 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/api/sensitive-actions.svelte.ts.hbs +16 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/api/session-recovery.svelte.ts.hbs +4 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/components/AdminWorkspace.svelte.hbs +122 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/components/AppShell.svelte.hbs +90 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/components/FeedbackEntry.svelte.hbs +86 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/audit.svelte.hbs +94 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/configuration.svelte.hbs +25 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/feedback.svelte.hbs +157 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/roles.svelte.hbs +77 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/settings.svelte.hbs +44 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/users.svelte.hbs +216 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/security/role-label.ts.hbs +12 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/stores/guide-store.ts.hbs +55 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/stores/management-store.svelte.ts.hbs +614 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/stores/theme-store.svelte.ts.hbs +23 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/svelte.config.js.hbs +1 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/tests/api-client.test.ts.hbs +150 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/tests/management-store.test.ts.hbs +253 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/tsconfig.json.hbs +17 -0
- package/templates/apps/fullstack/packages/{{projectName}}-shared/vitest.config.ts.hbs +7 -0
- package/templates/apps/fullstack/playwright.config.ts.hbs +114 -0
- package/templates/apps/fullstack/playwright.session-close.config.ts.hbs +18 -0
- package/templates/apps/fullstack/pnpm-workspace.yaml.hbs +38 -0
- package/templates/apps/fullstack/tsconfig.base.json +14 -0
- package/templates/apps/h5/messages/en-US.json +3 -0
- package/templates/apps/h5/messages/ja-JP.json +40 -0
- package/templates/apps/h5/messages/zh-CN.json +3 -0
- package/templates/apps/h5/src/routes/+layout.svelte.hbs +85 -30
- package/templates/apps/h5/src/routes/+page.svelte.hbs +20 -8
- package/templates/apps/h5/src/routes/discover/+page.svelte.hbs +17 -6
- package/templates/apps/h5/src/routes/profile/+page.svelte.hbs +17 -6
- package/templates/apps/mobile-app/.env.hbs +3 -0
- package/templates/apps/{android-app → mobile-app}/capacitor.config.ts.hbs +2 -2
- package/templates/apps/mobile-app/index.html.hbs +14 -0
- package/templates/apps/mobile-app/messages/en-US.json +36 -0
- package/templates/apps/mobile-app/messages/ja-JP.json +36 -0
- package/templates/apps/mobile-app/messages/zh-CN.json +36 -0
- package/templates/apps/mobile-app/public/runtime-config.js +1 -0
- package/templates/apps/mobile-app/src/App.svelte.hbs +153 -0
- package/templates/apps/mobile-app/src/lib/api.ts.hbs +213 -0
- package/templates/apps/mobile-app/src/lib/app-config.ts.hbs +14 -0
- package/templates/apps/{android-app → mobile-app}/src/lib/capacitor.ts +6 -7
- package/templates/apps/mobile-app/src/lib/pages/home.svelte.hbs +58 -0
- package/templates/apps/mobile-app/src/lib/pages/profile.svelte.hbs +13 -0
- package/templates/apps/mobile-app/src/lib/pages/tasks.svelte.hbs +16 -0
- package/templates/apps/mobile-app/src/main.ts.hbs +11 -0
- package/templates/apps/website/messages/en-US.json +4 -2
- package/templates/apps/website/messages/ja-JP.json +34 -0
- package/templates/apps/website/messages/zh-CN.json +4 -2
- package/templates/apps/website/scripts/static-website.mjs.hbs +67 -0
- package/templates/apps/website/src/routes/+layout.svelte.hbs +77 -26
- package/templates/apps/website/src/routes/+layout.ts +3 -0
- package/templates/apps/website/src/routes/+page.svelte.hbs +31 -12
- package/templates/apps/website/src/routes/about/+page.svelte.hbs +11 -6
- package/templates/apps/website/src/routes/api/health/+server.ts +3 -0
- package/templates/apps/website/src/routes/contact/+page.svelte.hbs +44 -34
- package/templates/apps/website/src/routes/services/+page.svelte.hbs +27 -40
- package/templates/base/.dockerignore.hbs +27 -0
- package/templates/base/.gitignore.hbs +41 -0
- package/templates/base/.npmrc.hbs +1 -0
- package/templates/base/e2e/app.spec.ts.hbs +213 -0
- package/templates/base/e2e/helpers.ts +1 -1
- package/templates/base/eslint-rules.js +45 -0
- package/templates/base/eslint.config.js.hbs +34 -0
- package/templates/base/hai.json.hbs +4 -0
- package/templates/base/images/web/nginx.conf.hbs +24 -0
- package/templates/base/images/web.Dockerfile.hbs +72 -0
- package/templates/base/package.json.hbs +125 -49
- package/templates/base/playwright.config.ts +44 -6
- package/templates/base/pnpm-workspace.yaml.hbs +40 -0
- package/templates/base/src/app.css.hbs +40 -0
- package/templates/base/src/app.d.ts.hbs +14 -1
- package/templates/base/src/app.html.hbs +13 -0
- package/templates/base/src/hooks.server.ts.hbs +115 -43
- package/templates/base/src/lib/build-metadata.ts.hbs +7 -0
- package/templates/base/src/lib/server/init.ts.hbs +125 -152
- package/templates/base/src/lib/server/kit-config.ts.hbs +40 -0
- package/templates/base/src/routes/+layout.server.ts.hbs +35 -0
- package/templates/base/static/favicon.png +0 -0
- package/templates/base/svelte.config.js.hbs +84 -5
- package/templates/base/tests/scaffold.test.ts.hbs +102 -0
- package/templates/base/tsconfig.json.hbs +50 -0
- package/templates/base/vite.config.ts.hbs +117 -12
- package/templates/base/vitest.config.ts.hbs +19 -0
- package/templates/features/ai/routes/api/chat/+server.ts +6 -7
- package/templates/features/iam/routes-admin/(auth)/+layout.svelte.hbs +3 -17
- package/templates/features/iam/routes-admin/(auth)/auth/forgot-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-admin/(auth)/auth/login/+page.svelte.hbs +9 -96
- package/templates/features/iam/routes-admin/(auth)/auth/register/+page.svelte.hbs +9 -122
- package/templates/features/iam/routes-admin/(auth)/auth/reset-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-h5/auth/forgot-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-h5/auth/login/+page.svelte.hbs +9 -96
- package/templates/features/iam/routes-h5/auth/register/+page.svelte.hbs +9 -112
- package/templates/features/iam/routes-h5/auth/reset-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-shared/api/auth/captcha/+server.ts.hbs +4 -0
- package/templates/features/iam/routes-shared/api/auth/config/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/login/+server.ts +1 -29
- package/templates/features/iam/routes-shared/api/auth/login/ldap/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/login/otp/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/logout/+server.ts +13 -6
- package/templates/features/iam/routes-shared/api/auth/otp/send/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/password/renew/+server.ts +5 -0
- package/templates/features/iam/routes-shared/api/auth/password-reset/confirm/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/password-reset/request/+server.ts +4 -0
- package/templates/features/iam/routes-shared/api/auth/reauthenticate/+server.ts +5 -0
- package/templates/features/iam/routes-shared/api/auth/register/+server.ts +1 -23
- package/templates/features/iam/routes-shared/api/auth/session/close/+server.ts.hbs +4 -0
- package/templates/features/iam/routes-website/auth/forgot-password/+page.svelte.hbs +10 -0
- package/templates/features/iam/routes-website/auth/login/+page.svelte.hbs +11 -0
- package/templates/features/iam/routes-website/auth/register/+page.svelte.hbs +11 -0
- package/templates/features/iam/routes-website/auth/reset-password/+page.svelte.hbs +10 -0
- package/templates/features/payment/routes/api/v1/payment/create/+server.ts +25 -23
- package/templates/features/payment/routes/api/v1/payment/notify/[provider]/+server.ts +5 -2
- package/templates/features/storage/routes/api/upload/+server.ts +10 -8
- package/templates/i18n/project.inlang/settings.json +2 -2
- package/templates/shared/.gitattributes +11 -0
- package/templates/shared/build-metadata.ts +42 -0
- package/templates/shared/container-runtime-config.sh +30 -0
- package/templates/shared/e2e-env.ts +98 -0
- package/templates/shared/hash-router.svelte.ts +83 -0
- package/templates/shared/public-base-path.mjs +19 -0
- package/templates/shared/run-e2e.mjs +104 -0
- package/templates/shared/vite-runtime-config.ts +56 -0
- package/templates/skills/AGENTS.md +75 -16
- package/templates/skills/CLAUDE.md +0 -11
- package/templates/skills/bridges/admin/AGENTS.md +89 -0
- package/templates/skills/bridges/api/AGENTS.md +83 -0
- package/templates/skills/bridges/fullstack/AGENTS.md.hbs +102 -0
- package/templates/skills/bridges/h5/AGENTS.md +88 -0
- package/templates/skills/bridges/mobile-app/AGENTS.md +100 -0
- package/templates/skills/bridges/website/AGENTS.md +88 -0
- package/templates/skills/copilot-instructions.md +3 -59
- package/templates/skills/hai-ai/SKILL.md +44 -715
- package/templates/skills/hai-ai/guide.md +457 -0
- package/templates/skills/hai-ai/reference.md +292 -0
- package/templates/skills/hai-api-client/SKILL.md +26 -339
- package/templates/skills/hai-api-client/reference.md +180 -0
- package/templates/skills/hai-api-contract/SKILL.md +36 -0
- package/templates/skills/hai-api-contract/reference.md +280 -0
- package/templates/skills/hai-app-create/SKILL.md +38 -351
- package/templates/skills/hai-app-create/collaboration.md +52 -0
- package/templates/skills/hai-app-create/development.md +243 -0
- package/templates/skills/hai-app-create/reference.md +376 -0
- package/templates/skills/hai-app-review/SKILL.md +57 -126
- package/templates/skills/hai-app-review/differential.md +34 -0
- package/templates/skills/hai-app-tests/SKILL.md +34 -454
- package/templates/skills/hai-app-tests/reference.md +462 -0
- package/templates/skills/hai-app-tests/validation.md +42 -0
- package/templates/skills/hai-audit/SKILL.md +37 -122
- package/templates/skills/hai-audit/reference.md +184 -0
- package/templates/skills/hai-build/SKILL.md +62 -315
- package/templates/skills/hai-build/paths.md +30 -0
- package/templates/skills/hai-build/reference.md +353 -0
- package/templates/skills/hai-cache/SKILL.md +26 -175
- package/templates/skills/hai-cache/reference.md +229 -0
- package/templates/skills/hai-capacitor/SKILL.md +24 -364
- package/templates/skills/hai-capacitor/reference.md +358 -0
- package/templates/skills/hai-change-plan/SKILL.md +46 -0
- package/templates/skills/hai-ci/SKILL.md +114 -0
- package/templates/skills/hai-core/SKILL.md +31 -469
- package/templates/skills/hai-core/reference.md +557 -0
- package/templates/skills/hai-core/request-access.md +65 -0
- package/templates/skills/hai-crypto/SKILL.md +29 -180
- package/templates/skills/hai-crypto/reference.md +317 -0
- package/templates/skills/hai-datapipe/SKILL.md +24 -207
- package/templates/skills/hai-datapipe/reference.md +204 -0
- package/templates/skills/hai-deploy/SKILL.md +53 -178
- package/templates/skills/hai-deploy/credentials.md +19 -0
- package/templates/skills/hai-deploy/middleware.md +129 -0
- package/templates/skills/hai-feedback/SKILL.md +85 -0
- package/templates/skills/hai-framework-sync/SKILL.md +105 -0
- package/templates/skills/hai-framework-sync/sync.md +49 -0
- package/templates/skills/hai-iam/SKILL.md +53 -325
- package/templates/skills/hai-iam/reference.md +535 -0
- package/templates/skills/hai-kit/SKILL.md +33 -329
- package/templates/skills/hai-kit/reference.md +202 -0
- package/templates/skills/hai-payment/SKILL.md +28 -262
- package/templates/skills/hai-payment/reference.md +295 -0
- package/templates/skills/hai-pr-review/SKILL.md +41 -0
- package/templates/skills/hai-reach/SKILL.md +28 -300
- package/templates/skills/hai-reach/reference.md +363 -0
- package/templates/skills/hai-reldb/SKILL.md +28 -449
- package/templates/skills/hai-reldb/reference.md +500 -0
- package/templates/skills/hai-scheduler/SKILL.md +26 -174
- package/templates/skills/hai-scheduler/reference.md +216 -0
- package/templates/skills/hai-serv/SKILL.md +60 -0
- package/templates/skills/hai-serv/reference.md +792 -0
- package/templates/skills/hai-spec-implement/SKILL.md +50 -0
- package/templates/skills/hai-spec-implement/changes.md +67 -0
- package/templates/skills/hai-spec-implement/evaluation.md +18 -0
- package/templates/skills/hai-spec-implement/handoff.md +47 -0
- package/templates/skills/hai-spec-implement/templates.md +117 -0
- package/templates/skills/hai-spec-implement/workflow.md +56 -0
- package/templates/skills/hai-spec-review/SKILL.md +57 -0
- package/templates/skills/hai-spec-review/checklist.md +71 -0
- package/templates/skills/hai-storage/SKILL.md +31 -262
- package/templates/skills/hai-storage/reference.md +284 -0
- package/templates/skills/hai-ui/SKILL.md +62 -238
- package/templates/skills/hai-ui/guide.md +81 -0
- package/templates/skills/hai-ui/reference.md +705 -0
- package/templates/skills/hai-ui-design/SKILL.md +31 -0
- package/templates/skills/hai-ui-design/patterns.md +31 -0
- package/templates/skills/hai-ui-review/SKILL.md +32 -0
- package/templates/skills/hai-ui-review/checklist.md +29 -0
- package/templates/skills/hai-vecdb/SKILL.md +25 -267
- package/templates/skills/hai-vecdb/reference.md +325 -0
- package/templates/skills/opencode.json +0 -5
- package/dist/chunk-2H7UOFLK.js +0 -10
- package/dist/chunk-LANIDJC7.js +0 -659
- package/dist/chunk-LANIDJC7.js.map +0 -1
- package/dist/chunk-YV7WPUI6.js +0 -206
- package/dist/chunk-YV7WPUI6.js.map +0 -1
- package/dist/config-templates-S5RI2MC6.js +0 -5
- package/dist/config-templates-S5RI2MC6.js.map +0 -1
- package/dist/skill-templates-N5DU5FNX.js +0 -5
- package/dist/skill-templates-N5DU5FNX.js.map +0 -1
- package/dist/src-XJ6YXNAF.js +0 -15030
- package/dist/src-XJ6YXNAF.js.map +0 -1
- package/templates/apps/android-app/.env.hbs +0 -3
- package/templates/apps/android-app/messages/en-US.json +0 -24
- package/templates/apps/android-app/messages/zh-CN.json +0 -24
- package/templates/apps/android-app/src/lib/api.ts.hbs +0 -30
- package/templates/apps/android-app/src/routes/+layout.svelte.hbs +0 -42
- package/templates/apps/android-app/src/routes/+layout.ts +0 -7
- package/templates/apps/android-app/src/routes/+page.svelte.hbs +0 -27
- package/templates/apps/api/src/routes/+layout.svelte +0 -14
- package/templates/apps/api/src/routes/+page.svelte +0 -11
- package/templates/apps/api/src/routes/api/v1/health/+server.ts +0 -14
- package/templates/apps/api/src/routes/api/v1/items/+server.ts +0 -37
- package/templates/apps/api/src/routes/api/v1/items/[id]/+server.ts +0 -30
- package/templates/base/src/app.css +0 -2
- package/templates/base/tsconfig.json +0 -8
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
<script lang='ts'>
|
|
2
|
+
{{#if features.feedback}}
|
|
3
|
+
import { errorMessage, useToastFeedback } from '@h-ai/ui/toast'
|
|
4
|
+
{{else}}
|
|
5
|
+
import { useToastFeedback } from '@h-ai/ui/toast'
|
|
6
|
+
{{/if}}
|
|
7
|
+
import type { Component } from 'svelte'
|
|
8
|
+
import type { ManagementApiOptions } from '../api/api-client.js'
|
|
9
|
+
import { Skeleton, ToastContainer } from '@h-ai/ui/components/compounds/index'
|
|
10
|
+
import { Button } from '@h-ai/ui/components/primitives/index'
|
|
11
|
+
import { AuthPanel } from '@h-ai/ui/components/scenes/iam/index'
|
|
12
|
+
import { GuideHost } from '@h-ai/ui/guide'
|
|
13
|
+
import { onMount, untrack } from 'svelte'
|
|
14
|
+
import { managementAuthActions } from '../api/api-client.js'
|
|
15
|
+
import { HashRouter } from '../navigation/hash-router.svelte.js'
|
|
16
|
+
import * as m from '../paraglide/messages.js'
|
|
17
|
+
import { createManagementGuide } from '../stores/guide-store.js'
|
|
18
|
+
import { ManagementStore } from '../stores/management-store.svelte.js'
|
|
19
|
+
import AppShell from './AppShell.svelte'
|
|
20
|
+
{{#if features.feedback}}
|
|
21
|
+
import { browserFeedback, feedbackReview, initializeBrowserFeedback } from '../api/feedback-client.js'
|
|
22
|
+
{{/if}}
|
|
23
|
+
|
|
24
|
+
interface Props {
|
|
25
|
+
platform: 'web' | 'app' | 'desktop'
|
|
26
|
+
{{#if features.feedback}}
|
|
27
|
+
buildMetadata: { appVersion: string, buildId: string, commit: string }
|
|
28
|
+
{{/if}}
|
|
29
|
+
apiOptions?: ManagementApiOptions
|
|
30
|
+
onLocaleChange?: (locale: string) => void
|
|
31
|
+
}
|
|
32
|
+
const { platform, apiOptions = {}, onLocaleChange{{#if features.feedback}}, buildMetadata{{/if}} }: Props = $props()
|
|
33
|
+
const pages = import.meta.glob<{ default: Component<{ store: ManagementStore }> }>('../pages/**/*.svelte')
|
|
34
|
+
const router = new HashRouter(Object.keys(pages), '/users')
|
|
35
|
+
const store = new ManagementStore(router)
|
|
36
|
+
// 宿主平台在组件生命周期中固定,引导控制器只创建一次。
|
|
37
|
+
const guide = untrack(() => createManagementGuide(store, platform))
|
|
38
|
+
let resetToken = $state('')
|
|
39
|
+
const authConfig = $derived(store.authConfig && {
|
|
40
|
+
...store.authConfig,
|
|
41
|
+
ui: { ...store.authConfig.ui, brandTitle: store.authConfig.ui.brandTitle || store.info?.name },
|
|
42
|
+
})
|
|
43
|
+
async function authenticated() {
|
|
44
|
+
await store.authenticated()
|
|
45
|
+
if (resetToken) {
|
|
46
|
+
const url = new URL(location.href)
|
|
47
|
+
url.searchParams.delete('token')
|
|
48
|
+
history.replaceState(history.state, '', url)
|
|
49
|
+
}
|
|
50
|
+
resetToken = ''
|
|
51
|
+
}
|
|
52
|
+
const pageComponent = $derived(pages[router.file]())
|
|
53
|
+
onMount(() => {
|
|
54
|
+
const stopRouting = router.start(() => {
|
|
55
|
+
if (store.user)
|
|
56
|
+
void store.navigate(router.path.slice(1))
|
|
57
|
+
})
|
|
58
|
+
resetToken = new URL(location.href).searchParams.get('token') ?? ''
|
|
59
|
+
void store.initialize(apiOptions, onLocaleChange)
|
|
60
|
+
return () => {
|
|
61
|
+
stopRouting()
|
|
62
|
+
void store.close()
|
|
63
|
+
}
|
|
64
|
+
})
|
|
65
|
+
{{#if features.feedback}}
|
|
66
|
+
const feedbackUserId = $derived(store.user?.id)
|
|
67
|
+
$effect(() => {
|
|
68
|
+
const userId = feedbackUserId
|
|
69
|
+
if (userId) {
|
|
70
|
+
void initializeBrowserFeedback(buildMetadata).catch((cause) => {
|
|
71
|
+
store.error = errorMessage(cause, m.operation_failed())
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
feedbackReview.close()
|
|
76
|
+
void browserFeedback.close({ discard: true })
|
|
77
|
+
}
|
|
78
|
+
return () => {
|
|
79
|
+
feedbackReview.close()
|
|
80
|
+
void browserFeedback.close({ discard: true })
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
{{/if}}
|
|
84
|
+
$effect(() => {
|
|
85
|
+
if (store.info)
|
|
86
|
+
document.title = store.info.name
|
|
87
|
+
})
|
|
88
|
+
useToastFeedback(() => store.error)
|
|
89
|
+
</script>
|
|
90
|
+
|
|
91
|
+
{#key store.locale}
|
|
92
|
+
{#if store.initializing}
|
|
93
|
+
<div role='status' aria-live='polite' class='grid min-h-dvh place-items-center bg-base-200/50'><div class='w-72 space-y-4'><Skeleton variant='title' /><Skeleton count={3} /><p class='text-center text-sm text-base-content/50'>{m.home_loading()}</p></div></div>
|
|
94
|
+
{:else if !store.user || resetToken}
|
|
95
|
+
<header class='border-b border-base-content/8 bg-base-100 px-6 py-3 text-sm font-medium'>{store.info?.name}</header>
|
|
96
|
+
<main data-testid='login-page'>
|
|
97
|
+
{#if !store.info || !store.authConfig}
|
|
98
|
+
<section class='mx-auto mt-20 max-w-md space-y-4 p-6'>
|
|
99
|
+
<p class='text-sm text-base-content/60'>{m.home_error()}</p>
|
|
100
|
+
<Button variant='primary' onclick={() => void store.initialize(apiOptions, onLocaleChange)}>{m.home_refresh()}</Button>
|
|
101
|
+
</section>
|
|
102
|
+
{:else}
|
|
103
|
+
<div data-testid='login-form'>
|
|
104
|
+
<AuthPanel config={authConfig} actions={managementAuthActions} {resetToken} initialMode={resetToken ? 'reset' : 'login'} error={store.authConfig ? '' : store.error} onretry={() => void store.initialize(apiOptions, onLocaleChange)} onauthenticated={authenticated} />
|
|
105
|
+
</div>
|
|
106
|
+
<footer class='border-t border-base-content/8 p-3 text-center text-xs text-base-content/50'><span data-testid='app-name'>{store.info.name}</span> · <span data-testid='app-version'>v{store.info.version}</span> · <span data-testid='app-environment'>{store.info.env}</span></footer>
|
|
107
|
+
{/if}
|
|
108
|
+
</main>
|
|
109
|
+
{:else}
|
|
110
|
+
<AppShell {platform} {store} onhelp={() => guide.openHelp()}>
|
|
111
|
+
<div class='flex min-h-0 flex-1 flex-col gap-3'>
|
|
112
|
+
{#await pageComponent}
|
|
113
|
+
<div role='status' aria-label={m.home_loading()} class='space-y-4'><Skeleton variant='title' /><Skeleton count={3} /></div>
|
|
114
|
+
{:then { default: Page }}
|
|
115
|
+
<Page {store} />
|
|
116
|
+
{/await}
|
|
117
|
+
</div>
|
|
118
|
+
</AppShell>
|
|
119
|
+
<GuideHost {guide} locale={store.locale} scope={store.user.id} autoStart='overview' />
|
|
120
|
+
{/if}
|
|
121
|
+
{/key}
|
|
122
|
+
<ToastContainer />
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import type { ManagementPage, ManagementStore } from '../stores/management-store.svelte.js'
|
|
4
|
+
import { WorkspaceLayout } from '@h-ai/ui/components/scenes/app/index'
|
|
5
|
+
import { ReauthenticationDialog, SessionRecoveryDialog } from '@h-ai/ui/components/scenes/iam/index'
|
|
6
|
+
import { sessionRecovery } from '../api/session-recovery.svelte.js'
|
|
7
|
+
import { sensitiveActions } from '../api/sensitive-actions.svelte.js'
|
|
8
|
+
import { managementAuthActions } from '../api/api-client.js'
|
|
9
|
+
import { Avatar, Badge, BareButton, Button } from '@h-ai/ui/components/primitives/index'
|
|
10
|
+
import * as m from '../paraglide/messages.js'
|
|
11
|
+
{{#if features.feedback}}
|
|
12
|
+
import FeedbackEntry from './FeedbackEntry.svelte'
|
|
13
|
+
{{/if}}
|
|
14
|
+
|
|
15
|
+
interface Props {
|
|
16
|
+
platform: 'web' | 'app' | 'desktop' | 'miniapp'
|
|
17
|
+
store: ManagementStore
|
|
18
|
+
children: Snippet
|
|
19
|
+
onhelp: () => void
|
|
20
|
+
}
|
|
21
|
+
const { platform, store, children, onhelp }: Props = $props()
|
|
22
|
+
$effect(() => {
|
|
23
|
+
sessionRecovery.configure(store.authConfig, store.user ?? undefined)
|
|
24
|
+
return () => sessionRecovery.cancel()
|
|
25
|
+
})
|
|
26
|
+
$effect(() => managementAuthActions.bindPageExit({ enabled: Boolean(store.user) && store.authConfig?.session.endOnPageHide }))
|
|
27
|
+
$effect(() => {
|
|
28
|
+
sensitiveActions.configure(store.authConfig?.reauthentication ?? { enabled: false, operations: [] })
|
|
29
|
+
return () => sensitiveActions.cancel()
|
|
30
|
+
})
|
|
31
|
+
let menuOpen = $state(false)
|
|
32
|
+
const items = $derived([
|
|
33
|
+
{ id: 'users', label: m.nav_users(), icon: 'icon-[tabler--users]' },
|
|
34
|
+
{ id: 'roles', label: m.nav_roles(), icon: 'icon-[tabler--shield-lock]' },
|
|
35
|
+
{ id: 'configuration', label: m.business_settings_title(), icon: 'icon-[tabler--adjustments]' },
|
|
36
|
+
{ id: 'audit', label: m.nav_audit(), icon: 'icon-[tabler--file-text]' },
|
|
37
|
+
{{#if features.feedback}}
|
|
38
|
+
{ id: 'feedback', label: m.nav_feedback(), icon: 'icon-[tabler--message-report]' },
|
|
39
|
+
{{/if}}
|
|
40
|
+
{ id: 'settings', label: m.settings_title(), icon: 'icon-[tabler--settings]' },
|
|
41
|
+
].filter(item => store.canOpenPage(item.id)))
|
|
42
|
+
const title = $derived(items.find(item => item.id === store.page)?.label ?? store.info?.name ?? '')
|
|
43
|
+
|
|
44
|
+
function navigate(page: ManagementPage) {
|
|
45
|
+
menuOpen = false
|
|
46
|
+
void store.navigate(page)
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<SessionRecoveryDialog recovery={sessionRecovery} actions={managementAuthActions} />
|
|
51
|
+
<ReauthenticationDialog open={sensitiveActions.open} loading={sensitiveActions.loading} error={sensitiveActions.error} onsubmit={password => sensitiveActions.submit(password)} onclose={() => sensitiveActions.cancel()} />
|
|
52
|
+
|
|
53
|
+
<div class="flex h-dvh overflow-hidden bg-base-200/50 text-base-content" class:hai-safe-area={platform === 'app'}>
|
|
54
|
+
{#if menuOpen}
|
|
55
|
+
<BareButton class="fixed inset-0 z-30 bg-black/30 lg:hidden" ariaLabel={m.close_menu()} onclick={() => { menuOpen = false }} />
|
|
56
|
+
{/if}
|
|
57
|
+
<aside class="fixed inset-y-0 left-0 z-40 flex w-60 shrink-0 flex-col border-r border-base-content/8 bg-base-100 transition-transform duration-200 lg:sticky lg:top-0 lg:h-dvh lg:translate-x-0 {menuOpen ? 'translate-x-0' : '-translate-x-full'}">
|
|
58
|
+
<div class="flex h-12 items-center gap-3 border-b border-base-content/8 px-5">
|
|
59
|
+
<span class="grid size-8 shrink-0 place-items-center rounded-lg bg-primary text-primary-content"><span class="icon-[tabler--hexagon-letter-h] size-5"></span></span>
|
|
60
|
+
<span class="truncate text-sm font-semibold" data-testid="app-name">{store.info?.name}</span>
|
|
61
|
+
</div>
|
|
62
|
+
<nav class="flex-1 space-y-1 p-3" aria-label={m.navigation()}>
|
|
63
|
+
{#each items as item (item.id)}
|
|
64
|
+
<BareButton class="flex w-full items-center gap-3 rounded-lg px-3 py-2.5 text-left text-sm transition-colors {store.page === item.id ? 'bg-primary/10 font-medium text-primary' : 'text-base-content/60 hover:bg-base-content/4'}" onclick={() => navigate(item.id)} data-testid="nav-{item.id}">
|
|
65
|
+
<span class="{item.icon} size-4.5"></span>{item.label}
|
|
66
|
+
</BareButton>
|
|
67
|
+
{/each}
|
|
68
|
+
</nav>
|
|
69
|
+
<div class="border-t border-base-content/8 px-3 py-2 text-xs text-base-content/40"><span data-testid="app-version">v{store.info?.version}</span></div>
|
|
70
|
+
</aside>
|
|
71
|
+
<WorkspaceLayout {title} data-guide='admin-content'>
|
|
72
|
+
{#snippet leading()}<BareButton class="rounded-lg p-2 hover:bg-base-content/5 lg:hidden" ariaLabel={m.open_menu()} onclick={() => { menuOpen = !menuOpen }} data-testid="mobile-menu"><span class="icon-[tabler--menu-2] size-5"></span></BareButton>{/snippet}
|
|
73
|
+
{#snippet actions()}
|
|
74
|
+
<Button variant="ghost" size="sm" onclick={onhelp} data-guide="admin-help" data-testid="admin-help" ariaLabel={m.guide_help_title()}><span class="icon-[tabler--help-circle] size-4"></span><span class="hidden sm:inline">{m.guide_help_title()}</span></Button>
|
|
75
|
+
{{#if features.feedback}}
|
|
76
|
+
<FeedbackEntry />
|
|
77
|
+
{{/if}}
|
|
78
|
+
<Badge variant="ghost" size="sm" data-testid="app-environment">{store.info?.env}</Badge>
|
|
79
|
+
{#if store.user}
|
|
80
|
+
<BareButton class="flex items-center gap-2 rounded-lg px-1 py-1 hover:bg-base-content/5 sm:px-2" ariaLabel={m.settings_title()} onclick={() => navigate('settings')} data-guide="admin-profile">
|
|
81
|
+
<Avatar name={store.user.displayName || store.user.username} src={store.user.avatarUrl} size="sm" />
|
|
82
|
+
<span class="hidden max-w-36 truncate text-sm sm:block">{store.user.displayName || store.user.username}</span>
|
|
83
|
+
</BareButton>
|
|
84
|
+
{/if}
|
|
85
|
+
<Button variant="ghost" size="sm" loading={store.saving} onclick={() => void store.logout()} data-testid="logout">{m.logout()}</Button>
|
|
86
|
+
{/snippet}
|
|
87
|
+
{#if store.info?.notice}<p class='mb-2 rounded-lg bg-info/10 p-2 text-sm' data-testid='business-notice'>{store.info.notice}</p>{/if}{@render children()}
|
|
88
|
+
{#snippet footer()}{store.info?.name} · v{store.info?.version}{/snippet}
|
|
89
|
+
</WorkspaceLayout>
|
|
90
|
+
</div>
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
{{! @skipIfEmpty }}
|
|
2
|
+
{{#if features.feedback}}
|
|
3
|
+
<script lang='ts'>
|
|
4
|
+
import { errorMessage, useToastFeedback } from '@h-ai/ui/toast'
|
|
5
|
+
import type { FeedbackDraft } from '@h-ai/feedback/client'
|
|
6
|
+
import type { FeedbackAnnotation, FeedbackAttachmentView, FeedbackFormData } from '@h-ai/ui'
|
|
7
|
+
import { FeedbackModal } from '@h-ai/ui/components/scenes/app/index'
|
|
8
|
+
import { Button } from '@h-ai/ui/components/primitives/index'
|
|
9
|
+
import { onDestroy } from 'svelte'
|
|
10
|
+
import { browserFeedback } from '../api/feedback-client.js'
|
|
11
|
+
import * as m from '../paraglide/messages.js'
|
|
12
|
+
|
|
13
|
+
let open = $state(false)
|
|
14
|
+
$effect(() => {
|
|
15
|
+
if (!open)
|
|
16
|
+
browserFeedback.pause()
|
|
17
|
+
})
|
|
18
|
+
let preparing = $state(false)
|
|
19
|
+
let error = $state('')
|
|
20
|
+
let draft = $state.raw<FeedbackDraft>()
|
|
21
|
+
let attachments = $state<FeedbackAttachmentView[]>([])
|
|
22
|
+
function refreshAttachments() {
|
|
23
|
+
attachments = browserFeedback.getView().attachments
|
|
24
|
+
}
|
|
25
|
+
async function prepare() {
|
|
26
|
+
preparing = true
|
|
27
|
+
error = ''
|
|
28
|
+
try {
|
|
29
|
+
const result = await browserFeedback.prepare()
|
|
30
|
+
if (!result.success)
|
|
31
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
32
|
+
draft = result.data
|
|
33
|
+
refreshAttachments()
|
|
34
|
+
open = true
|
|
35
|
+
}
|
|
36
|
+
catch (cause) {
|
|
37
|
+
error = errorMessage(cause, m.operation_failed())
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
preparing = false
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function input(data: FeedbackFormData) {
|
|
44
|
+
return { description: data.description, category: data.type, contact: data.contact, files: data.files, removedAttachmentIds: data.removedAttachmentIds }
|
|
45
|
+
}
|
|
46
|
+
async function submit(data: FeedbackFormData) {
|
|
47
|
+
const result = await browserFeedback.submit(input(data))
|
|
48
|
+
if (!result.success)
|
|
49
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
50
|
+
return result.data
|
|
51
|
+
}
|
|
52
|
+
async function annotate(mark: FeedbackAnnotation) {
|
|
53
|
+
const result = await browserFeedback.annotate(mark.id, { mode: mark.mode, ...mark.rect, coordinateSpace: 'ratio' })
|
|
54
|
+
if (!result.success)
|
|
55
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
56
|
+
refreshAttachments()
|
|
57
|
+
}
|
|
58
|
+
async function capturePage(id?: string) {
|
|
59
|
+
const result = await browserFeedback.captureScreenshot(id)
|
|
60
|
+
if (!result.success)
|
|
61
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
62
|
+
draft = browserFeedback.getDraft()
|
|
63
|
+
refreshAttachments()
|
|
64
|
+
}
|
|
65
|
+
async function addFiles(files: File[], removedAttachmentIds: readonly string[] = []) {
|
|
66
|
+
const result = await browserFeedback.addFiles(files, removedAttachmentIds)
|
|
67
|
+
if (!result.success)
|
|
68
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
69
|
+
draft = browserFeedback.getDraft()
|
|
70
|
+
refreshAttachments()
|
|
71
|
+
}
|
|
72
|
+
async function exportLocal(data: FeedbackFormData) {
|
|
73
|
+
const result = await browserFeedback.saveDraft(input(data))
|
|
74
|
+
if (!result.success)
|
|
75
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
76
|
+
return result.data.status !== 'cancelled'
|
|
77
|
+
}
|
|
78
|
+
onDestroy(browserFeedback.releasePreviews)
|
|
79
|
+
useToastFeedback(() => error)
|
|
80
|
+
</script>
|
|
81
|
+
|
|
82
|
+
<Button variant='ghost' size='sm' loading={preparing} onclick={() => void prepare()} data-testid='feedback-open'>{m.nav_feedback()}</Button>
|
|
83
|
+
<FeedbackModal bind:open {attachments} budget={browserFeedback.budget} resetKey={draft?.submissionId} onsubmit={submit} oncapture={capturePage} onannotate={annotate} onexport={exportLocal} onfileschange={addFiles}
|
|
84
|
+
evidence={draft?.evidence ?? []}
|
|
85
|
+
evidenceSummary={draft?.missing.length ? [{ label: m.feedback_logs(), status: 'partial', detail: draft.missing.join(', ') }] : []} />
|
|
86
|
+
{{/if}}
|
package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/audit.svelte.hbs
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { AdminAuditLog } from '{{fullstack.contractPackageName}}'
|
|
3
|
+
import type { ManagementStore } from '../stores/management-store.svelte.js'
|
|
4
|
+
import { DataTable, FilterBar, FormField, FormLayout, Modal, PageHeader, Pagination } from '@h-ai/ui/components/compounds/index'
|
|
5
|
+
import { Badge, Button, Input, Select } from '@h-ai/ui/components/primitives/index'
|
|
6
|
+
import * as m from '../paraglide/messages.js'
|
|
7
|
+
|
|
8
|
+
interface Props { store: ManagementStore }
|
|
9
|
+
const { store }: Props = $props()
|
|
10
|
+
let selected = $state<AdminAuditLog | null>(null)
|
|
11
|
+
const columns = $derived([
|
|
12
|
+
{ key: 'createdAt', sortable: true, label: m.created_at() },
|
|
13
|
+
{ key: 'username', label: m.audit_actor() },
|
|
14
|
+
{ key: 'action', sortable: true, label: m.audit_action() },
|
|
15
|
+
{ key: 'category', sortable: true, label: m.audit_category() },
|
|
16
|
+
{ key: 'outcome', sortable: true, label: m.audit_outcome() },
|
|
17
|
+
{ key: 'severity', sortable: true, label: m.audit_severity() },
|
|
18
|
+
{ key: 'resource', sortable: true, label: m.audit_resource() },
|
|
19
|
+
{ key: 'ipAddress', label: m.audit_ip() },
|
|
20
|
+
])
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
<section class="flex min-h-0 flex-1 flex-col gap-3" data-testid="audit-page">
|
|
24
|
+
<PageHeader title={m.nav_audit()} description={m.audit_description()} class='mb-0 shrink-0'>
|
|
25
|
+
{#snippet actions()}{#if store.auditBackupEnabled && store.hasPermission('audit:backup')}<Button size='sm' variant='outline' loading={store.saving} onclick={() => void store.backupAudit()} data-testid='audit-backup'>{m.audit_backup_run()}</Button>{/if}{/snippet}
|
|
26
|
+
</PageHeader>
|
|
27
|
+
{#if store.auditBackupReceipt}<p class='break-all font-mono text-xs' data-testid='audit-backup-receipt'>{store.auditBackupReceipt.key} · {store.auditBackupReceipt.recordCount} · SHA-256: {store.auditBackupReceipt.sha256}</p>{/if}
|
|
28
|
+
<div class="flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-base-content/8 bg-base-100">
|
|
29
|
+
<form class='shrink-0 border-b border-base-content/8 p-3' onsubmit={(event) => {
|
|
30
|
+
event.preventDefault()
|
|
31
|
+
void store.queryAudit()
|
|
32
|
+
}}>
|
|
33
|
+
<FilterBar data-testid='audit-filters' activeCount={[store.auditAction, store.auditResource, store.auditStartDate, store.auditEndDate, store.auditCategory, store.auditOutcome, store.auditSeverity].filter(Boolean).length} onreset={() => {
|
|
34
|
+
store.auditAction = ''
|
|
35
|
+
store.auditResource = ''
|
|
36
|
+
store.auditStartDate = ''
|
|
37
|
+
store.auditEndDate = ''
|
|
38
|
+
store.auditCategory = ''
|
|
39
|
+
store.auditOutcome = ''
|
|
40
|
+
store.auditSeverity = ''
|
|
41
|
+
store.auditSortBy = 'createdAt'
|
|
42
|
+
store.auditSortDirection = 'desc'
|
|
43
|
+
void store.queryAudit()
|
|
44
|
+
}}>
|
|
45
|
+
{#snippet leading()}<div class='min-w-0 flex-1'><label class='sr-only' for='audit-action'>{m.audit_action()}</label><Input id='audit-action' size='sm' bind:value={store.auditAction} placeholder={m.audit_action_placeholder()} data-testid='audit-action' /></div>{/snippet}
|
|
46
|
+
{#snippet actions()}<Button type='submit' submitHint size='sm' variant='outline' disabled={store.loading}>{m.search()}</Button>{/snippet}
|
|
47
|
+
<FormLayout columns={2} class='w-full [--hai-form-gap:1rem_1.25rem]' data-testid='audit-advanced'>
|
|
48
|
+
<FormField label={m.audit_resource()}><Input size='sm' id="audit-resource" bind:value={store.auditResource} placeholder={m.audit_resource_placeholder()} data-testid="audit-resource" /></FormField>
|
|
49
|
+
<FormField label={m.audit_start()} for="audit-start"><input id="audit-start" type="date" class="input block h-9 min-w-0 w-full" bind:value={store.auditStartDate} /></FormField>
|
|
50
|
+
<FormField label={m.audit_end()} for="audit-end"><input id="audit-end" type="date" class="input block h-9 min-w-0 w-full" bind:value={store.auditEndDate} /></FormField>
|
|
51
|
+
<FormField label={m.audit_category()}><Select size='sm' bind:value={store.auditCategory} options={[{ value: '', label: m.audit_all() }, { value: 'system', label: m.audit_category_system() }, { value: 'business', label: m.audit_category_business() }]} data-testid='audit-category' /></FormField>
|
|
52
|
+
<FormField label={m.audit_outcome()}><Select size='sm' bind:value={store.auditOutcome} options={[{ value: '', label: m.audit_all() }, { value: 'success', label: m.audit_success() }, { value: 'failure', label: m.audit_failure() }, { value: 'denied', label: m.audit_denied() }]} data-testid='audit-outcome' /></FormField>
|
|
53
|
+
<FormField label={m.audit_severity()}><Select size='sm' bind:value={store.auditSeverity} options={[{ value: '', label: m.audit_all() }, { value: 'info', label: m.audit_info() }, { value: 'warning', label: m.audit_warning() }, { value: 'error', label: m.audit_error() }, { value: 'critical', label: m.audit_critical() }]} data-testid='audit-severity' /></FormField>
|
|
54
|
+
</FormLayout>
|
|
55
|
+
<div class='w-full space-y-2'>
|
|
56
|
+
<p class='text-xs text-base-content/60'>{m.audit_stats_hint()}</p>
|
|
57
|
+
<div class='flex flex-wrap gap-2'>{#each store.auditStats as stat (stat.action)}<Badge variant='ghost'>{stat.action}: {stat.count}</Badge>{/each}</div>
|
|
58
|
+
</div>
|
|
59
|
+
</FilterBar>
|
|
60
|
+
</form>
|
|
61
|
+
<div class="flex min-h-32 flex-1 flex-col overflow-auto">
|
|
62
|
+
<DataTable data={store.audit} {columns} keyField="id" loading={store.loading} striped={false} sortKey={store.auditSortBy} sortDir={store.auditSortDirection} onsort={(key, direction) => void store.sortAudit(key, direction)} class="min-h-0 flex-1 overflow-auto">
|
|
63
|
+
{#snippet cell(entry, key)}
|
|
64
|
+
{#if key === 'createdAt'}<span class="whitespace-nowrap text-xs">{store.formatDate(entry.createdAt)}</span>
|
|
65
|
+
{:else if key === 'username'}{entry.username || m.audit_system()}
|
|
66
|
+
{:else if key === 'action'}<span class="rounded-md bg-base-200 px-2 py-1 font-mono text-xs">{entry.action}</span>
|
|
67
|
+
{:else if key === 'category' || key === 'outcome' || key === 'severity'}{entry[key] ?? '—'}
|
|
68
|
+
{:else if key === 'resource'}<span class="text-sm">{entry.resource}</span>
|
|
69
|
+
{:else if key === 'ipAddress'}<span class="text-xs text-base-content/55">{entry.ipAddress || '—'}</span>{/if}
|
|
70
|
+
{/snippet}
|
|
71
|
+
{#snippet actions(entry)}<Button size="xs" variant="ghost" onclick={() => { selected = entry }}>{m.details()}</Button>{/snippet}
|
|
72
|
+
</DataTable>
|
|
73
|
+
</div>
|
|
74
|
+
<div class="mt-auto shrink-0 border-t border-base-content/8 px-3 py-2"><Pagination page={store.auditPage} total={store.auditTotal} pageSize={store.pageSize} onchange={page => void store.loadAudit(page)} /></div>
|
|
75
|
+
</div>
|
|
76
|
+
</section>
|
|
77
|
+
|
|
78
|
+
<Modal open={!!selected} title={m.audit_details()} onclose={() => { selected = null }}>
|
|
79
|
+
{#if selected}
|
|
80
|
+
<dl class="grid grid-cols-[auto_1fr] gap-x-5 gap-y-3 text-sm">
|
|
81
|
+
<dt>{m.audit_request_id()}</dt><dd class='break-all'>{selected.requestId ?? '—'}</dd>
|
|
82
|
+
<dt>{m.audit_trace_id()}</dt><dd class='break-all'>{selected.traceId ?? '—'}</dd>
|
|
83
|
+
<dt>{m.audit_scope()}</dt><dd class='break-all'>{selected.scopeId ?? '—'}</dd>
|
|
84
|
+
<dt>{m.audit_actor_snapshot()}</dt><dd class='break-all'>{selected.actorSnapshot ? JSON.stringify(selected.actorSnapshot) : '—'}</dd>
|
|
85
|
+
<dt class="text-base-content/50">{m.created_at()}</dt><dd>{store.formatDate(selected.createdAt)}</dd>
|
|
86
|
+
<dt class="text-base-content/50">{m.audit_actor()}</dt><dd class="break-all">{selected.username || m.audit_system()}</dd>
|
|
87
|
+
<dt class="text-base-content/50">{m.audit_action()}</dt><dd>{selected.action}</dd>
|
|
88
|
+
<dt class="text-base-content/50">{m.audit_resource()}</dt><dd>{selected.resource}</dd>
|
|
89
|
+
<dt class="text-base-content/50">{m.audit_resource_id()}</dt><dd class="break-all">{selected.resourceId || '—'}</dd>
|
|
90
|
+
<dt class="text-base-content/50">{m.audit_ip()}</dt><dd>{selected.ipAddress || '—'}</dd>
|
|
91
|
+
</dl>
|
|
92
|
+
<pre class="mt-5 max-h-72 overflow-auto whitespace-pre-wrap rounded-lg bg-base-200 p-4 text-xs">{selected.details || '—'}</pre>
|
|
93
|
+
{/if}
|
|
94
|
+
</Modal>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script lang='ts'>
|
|
2
|
+
import type { ManagementStore } from '../stores/management-store.svelte.js'
|
|
3
|
+
import { Card, FormField, PageHeader } from '@h-ai/ui/components/compounds/index'
|
|
4
|
+
import { Button, Textarea } from '@h-ai/ui/components/primitives/index'
|
|
5
|
+
import * as m from '../paraglide/messages.js'
|
|
6
|
+
|
|
7
|
+
interface Props { store: ManagementStore }
|
|
8
|
+
const { store }: Props = $props()
|
|
9
|
+
</script>
|
|
10
|
+
|
|
11
|
+
<section class='max-w-2xl space-y-3' data-testid='configuration-page'>
|
|
12
|
+
<PageHeader title={m.business_settings_title()} class='mb-0' />
|
|
13
|
+
<Card bordered shadow={false}>
|
|
14
|
+
<form class='space-y-4' onsubmit={(event) => {
|
|
15
|
+
event.preventDefault()
|
|
16
|
+
void store.saveConfiguration()
|
|
17
|
+
}}>
|
|
18
|
+
<FormField label={m.business_notice_label()} for='business-notice'>
|
|
19
|
+
<Textarea id='business-notice' bind:value={store.businessNotice} disabled={store.loading || store.saving} maxlength={200} rows={4} data-testid='business-notice-input' />
|
|
20
|
+
</FormField>
|
|
21
|
+
<p class='text-sm text-base-content/60'>{m.business_notice_hint()}</p>
|
|
22
|
+
<Button type='submit' loading={store.saving} disabled={store.loading}>{m.save()}</Button>
|
|
23
|
+
</form>
|
|
24
|
+
</Card>
|
|
25
|
+
</section>
|
package/templates/apps/fullstack/packages/{{projectName}}-shared/src/lib/pages/feedback.svelte.hbs
ADDED
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
{{! @skipIfEmpty }}
|
|
2
|
+
{{#if features.feedback}}
|
|
3
|
+
<script lang='ts'>
|
|
4
|
+
import type { FeedbackDetail as Detail, FeedbackEvidenceInput, FeedbackReport } from '@h-ai/api-contract/feedback'
|
|
5
|
+
import type { FeedbackEvidenceQuery, FeedbackListQuery, FeedbackReportView, FeedbackStatusChange } from '@h-ai/ui'
|
|
6
|
+
import type { ManagementStore } from '../stores/management-store.svelte.js'
|
|
7
|
+
import { PageHeader } from '@h-ai/ui/components/compounds/index'
|
|
8
|
+
import { FeedbackDetail, FeedbackList } from '@h-ai/ui/components/scenes/app/index'
|
|
9
|
+
import { errorMessage } from '@h-ai/ui/toast'
|
|
10
|
+
import { onMount } from 'svelte'
|
|
11
|
+
import { managementApi } from '../api/api-client.js'
|
|
12
|
+
import { downloadFeedback, feedbackDataBytes, feedbackReview } from '../api/feedback-client.js'
|
|
13
|
+
import * as m from '../paraglide/messages.js'
|
|
14
|
+
|
|
15
|
+
const { store }: { store: ManagementStore } = $props()
|
|
16
|
+
let page = $state({ items: [] as FeedbackReportView[], total: 0, page: 1, pageSize: 20 })
|
|
17
|
+
let query = $state<FeedbackListQuery>({ page: 1, pageSize: 20 })
|
|
18
|
+
let selected = $state<Detail>()
|
|
19
|
+
let evidence = $state({ items: [] as FeedbackEvidenceInput[], total: 0, page: 1, pageSize: 20 })
|
|
20
|
+
let loading = $state(false)
|
|
21
|
+
let error = $state('')
|
|
22
|
+
let requestVersion = 0
|
|
23
|
+
let detailVersion = 0
|
|
24
|
+
let imageUrls = $state<Record<string, string>>({})
|
|
25
|
+
const permissions = $derived({ read: store.hasPermission('feedback:read'), process: store.hasPermission('feedback:process'), reopen: store.hasPermission('feedback:reopen'), export: store.hasPermission('feedback:export'), retry: store.hasPermission('feedback:process') })
|
|
26
|
+
function view(report: FeedbackReport): FeedbackReportView {
|
|
27
|
+
return { ...report, description: report.description || report.summary || '', appVersion: report.appVersion || '' }
|
|
28
|
+
}
|
|
29
|
+
async function load(next: FeedbackListQuery = query) {
|
|
30
|
+
const version = ++requestVersion
|
|
31
|
+
query = next
|
|
32
|
+
loading = true
|
|
33
|
+
error = ''
|
|
34
|
+
try {
|
|
35
|
+
const result = await managementApi.feedback.reports.list(next)
|
|
36
|
+
if (!result.success)
|
|
37
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
38
|
+
if (version === requestVersion)
|
|
39
|
+
page = { ...result.data, items: result.data.items.map(view) }
|
|
40
|
+
}
|
|
41
|
+
catch (cause) {
|
|
42
|
+
if (version === requestVersion)
|
|
43
|
+
error = errorMessage(cause, m.operation_failed())
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
if (version === requestVersion)
|
|
47
|
+
loading = false
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async function loadEvidence(next: FeedbackEvidenceQuery = { page: 1, pageSize: 20 }) {
|
|
51
|
+
if (!selected)
|
|
52
|
+
return
|
|
53
|
+
const id = selected.report.id
|
|
54
|
+
const kind = next.kind as FeedbackEvidenceInput['kind'] | undefined
|
|
55
|
+
const result = await managementApi.feedback.reports.getEvidence({ ...next, kind, id })
|
|
56
|
+
if (!result.success)
|
|
57
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
58
|
+
if (selected?.report.id === id)
|
|
59
|
+
evidence = result.data
|
|
60
|
+
}
|
|
61
|
+
async function selectId(id: string) {
|
|
62
|
+
const version = ++detailVersion
|
|
63
|
+
const result = await managementApi.feedback.reports.get({ id })
|
|
64
|
+
if (version !== detailVersion)
|
|
65
|
+
return
|
|
66
|
+
if (!result.success)
|
|
67
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
68
|
+
selected = result.data
|
|
69
|
+
await loadEvidence()
|
|
70
|
+
}
|
|
71
|
+
async function loadReplay() {
|
|
72
|
+
const id = selected?.report.id
|
|
73
|
+
if (!id)
|
|
74
|
+
return []
|
|
75
|
+
const result = await feedbackReview.loadReplay(id)
|
|
76
|
+
if (!result.success)
|
|
77
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
78
|
+
return result.data
|
|
79
|
+
}
|
|
80
|
+
async function select(report: FeedbackReportView) {
|
|
81
|
+
await selectId(report.id)
|
|
82
|
+
}
|
|
83
|
+
function closeDetail() {
|
|
84
|
+
detailVersion++
|
|
85
|
+
selected = undefined
|
|
86
|
+
}
|
|
87
|
+
async function status(input: FeedbackStatusChange) {
|
|
88
|
+
const result = await managementApi.feedback.reports.setStatus(input)
|
|
89
|
+
if (!result.success)
|
|
90
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
91
|
+
if (selected?.report.id === input.id)
|
|
92
|
+
await select(view(result.data))
|
|
93
|
+
await load()
|
|
94
|
+
}
|
|
95
|
+
async function retry(report: FeedbackReportView) {
|
|
96
|
+
const retried = await feedbackReview.retryReport(report.id)
|
|
97
|
+
if (!retried.success)
|
|
98
|
+
throw new Error(retried.error.message, { cause: retried.error })
|
|
99
|
+
if (selected?.report.id === report.id)
|
|
100
|
+
await select(report)
|
|
101
|
+
await load()
|
|
102
|
+
}
|
|
103
|
+
async function exportBundle(report: FeedbackReportView) {
|
|
104
|
+
const result = await feedbackReview.exportReport(report.id)
|
|
105
|
+
if (!result.success)
|
|
106
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
107
|
+
}
|
|
108
|
+
async function attachment(id: string) {
|
|
109
|
+
if (!selected)
|
|
110
|
+
return
|
|
111
|
+
const result = await managementApi.feedback.attachments.get({ id: selected.report.id, attachmentId: id })
|
|
112
|
+
if (!result.success)
|
|
113
|
+
throw new Error(result.error.message, { cause: result.error })
|
|
114
|
+
if (result.data.contentType.startsWith('image/') || result.data.contentType.startsWith('video/')) {
|
|
115
|
+
if (imageUrls[id])
|
|
116
|
+
URL.revokeObjectURL(imageUrls[id])
|
|
117
|
+
imageUrls = { ...imageUrls, [id]: URL.createObjectURL(new Blob([new Uint8Array(feedbackDataBytes(result.data)).buffer], { type: result.data.contentType })) }
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
await downloadFeedback(feedbackDataBytes(result.data), result.data.name, result.data.contentType)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
onMount(() => {
|
|
124
|
+
let active = true
|
|
125
|
+
void load().then(async () => {
|
|
126
|
+
if (!active)
|
|
127
|
+
return
|
|
128
|
+
const id = new URL(location.href).searchParams.get('feedback')
|
|
129
|
+
if (id)
|
|
130
|
+
await selectId(id)
|
|
131
|
+
}).catch((cause) => {
|
|
132
|
+
if (active)
|
|
133
|
+
error = errorMessage(cause, m.operation_failed())
|
|
134
|
+
})
|
|
135
|
+
return () => {
|
|
136
|
+
active = false
|
|
137
|
+
requestVersion++
|
|
138
|
+
detailVersion++
|
|
139
|
+
for (const url of Object.values(imageUrls)) {
|
|
140
|
+
URL.revokeObjectURL(url)
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
</script>
|
|
145
|
+
|
|
146
|
+
<section data-testid='feedback-page' class='flex min-h-0 flex-1 flex-col gap-3'>
|
|
147
|
+
<PageHeader title={m.nav_feedback()} class='mb-0' />
|
|
148
|
+
{#if selected}
|
|
149
|
+
<FeedbackDetail report={view(selected.report)} webhook={selected.jobs.find(job => job.type === 'webhook')} {evidence} history={selected.history.map(item => ({ id: item.id, actorId: item.userId, fromStatus: item.from, toStatus: item.to, createdAt: item.timestamp, note: item.note }))} {permissions}
|
|
150
|
+
attachments={selected.attachments.map(item => ({ ...item, mimeType: item.contentType, url: imageUrls[item.id] }))}
|
|
151
|
+
onevidencequery={loadEvidence} onreplay={loadReplay} onstatus={status} onexport={exportBundle} onretry={retry}
|
|
152
|
+
onattachment={item => attachment(item.id)} onclose={closeDetail} />
|
|
153
|
+
{:else}
|
|
154
|
+
<FeedbackList data={page} bind:query {permissions} {loading} {error} onquerychange={load} onview={select} onstatus={status} onexport={exportBundle} onretry={retry} />
|
|
155
|
+
{/if}
|
|
156
|
+
</section>
|
|
157
|
+
{{/if}}
|