create-windy 0.2.33 → 0.3.0

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 (284) hide show
  1. package/dist/cli.js +173 -17
  2. package/package.json +1 -1
  3. package/template/.agents/skills/windy-business-module/SKILL.md +10 -1
  4. package/template/.windy-template.json +2 -2
  5. package/template/AGENTS.md +9 -0
  6. package/template/README.md +3 -1
  7. package/template/apps/agent-server/Dockerfile +1 -0
  8. package/template/apps/agent-server/README.md +28 -5
  9. package/template/apps/agent-server/adk_web_agents/__init__.py +1 -0
  10. package/template/apps/agent-server/adk_web_agents/safe_debug/__init__.py +3 -0
  11. package/template/apps/agent-server/adk_web_agents/safe_debug/agent.py +40 -0
  12. package/template/apps/agent-server/pyproject.toml +1 -1
  13. package/template/apps/agent-server/src/southwind_agent_server/adk_adapter.py +191 -16
  14. package/template/apps/agent-server/src/southwind_agent_server/adk_failure.py +13 -0
  15. package/template/apps/agent-server/src/southwind_agent_server/adk_model.py +225 -0
  16. package/template/apps/agent-server/src/southwind_agent_server/adk_tools.py +76 -0
  17. package/template/apps/agent-server/src/southwind_agent_server/app.py +63 -3
  18. package/template/apps/agent-server/src/southwind_agent_server/contracts.py +35 -0
  19. package/template/apps/agent-server/src/southwind_agent_server/engine.py +2 -0
  20. package/template/apps/agent-server/src/southwind_agent_server/openai_engine.py +31 -3
  21. package/template/apps/agent-server/src/southwind_agent_server/openai_provider.py +22 -9
  22. package/template/apps/agent-server/src/southwind_agent_server/provider_audit.py +144 -0
  23. package/template/apps/agent-server/src/southwind_agent_server/provider_governance.py +227 -0
  24. package/template/apps/agent-server/src/southwind_agent_server/service.py +1 -0
  25. package/template/apps/agent-server/tests/test_adk_adapter.py +305 -0
  26. package/template/apps/agent-server/tests/test_adk_web_agent.py +12 -0
  27. package/template/apps/agent-server/tests/test_api.py +16 -1
  28. package/template/apps/agent-server/tests/test_openai_provider.py +79 -0
  29. package/template/apps/agent-server/tests/test_provider_governance.py +215 -0
  30. package/template/apps/server/package.json +4 -1
  31. package/template/apps/server/src/agent/provider-input-governance.test.ts +82 -0
  32. package/template/apps/server/src/agent/provider-input-governance.ts +140 -0
  33. package/template/apps/server/src/agent/remote-runtime.test.ts +22 -0
  34. package/template/apps/server/src/agent/remote-runtime.ts +1 -0
  35. package/template/apps/server/src/agent/run-contracts.ts +2 -0
  36. package/template/apps/server/src/agent/run-facade.test.ts +52 -2
  37. package/template/apps/server/src/agent/run-facade.ts +38 -9
  38. package/template/apps/server/src/agent/tool-registry.ts +2 -6
  39. package/template/apps/server/src/application-services.ts +50 -0
  40. package/template/apps/server/src/audit/drizzle-log-store.ts +25 -0
  41. package/template/apps/server/src/audit/search-summary.ts +2 -6
  42. package/template/apps/server/src/auth/credential-restriction.ts +1 -0
  43. package/template/apps/server/src/auth/password.ts +30 -21
  44. package/template/apps/server/src/auth/routes.test.ts +44 -3
  45. package/template/apps/server/src/auth/routes.ts +6 -1
  46. package/template/apps/server/src/auth/runtime.ts +4 -1
  47. package/template/apps/server/src/auth/service.ts +25 -7
  48. package/template/apps/server/src/configuration/bootstrap.ts +20 -1
  49. package/template/apps/server/src/configuration/definition.test.ts +71 -0
  50. package/template/apps/server/src/configuration/definition.ts +242 -12
  51. package/template/apps/server/src/configuration/drizzle-repository.ts +36 -2
  52. package/template/apps/server/src/configuration/repository.ts +27 -2
  53. package/template/apps/server/src/configuration/routes.ts +4 -1
  54. package/template/apps/server/src/configuration/service.test.ts +100 -0
  55. package/template/apps/server/src/configuration/service.ts +50 -10
  56. package/template/apps/server/src/data-access/scoped-repository.integration.test.ts +3 -2
  57. package/template/apps/server/src/data-governance/export/service.ts +2 -6
  58. package/template/apps/server/src/example-modules.ts +4 -1
  59. package/template/apps/server/src/guards.ts +18 -5
  60. package/template/apps/server/src/http/request-source.test.ts +85 -0
  61. package/template/apps/server/src/http/request-source.ts +90 -0
  62. package/template/apps/server/src/index.ts +45 -45
  63. package/template/apps/server/src/license/routes.ts +2 -0
  64. package/template/apps/server/src/license/runtime-service.ts +10 -11
  65. package/template/apps/server/src/module-bootstrap.ts +2 -2
  66. package/template/apps/server/src/module-host/initialize-contracts.ts +6 -0
  67. package/template/apps/server/src/module-host/initialize.ts +30 -44
  68. package/template/apps/server/src/module-host/request-context.ts +29 -23
  69. package/template/apps/server/src/module-host/resource-file-policies.test.ts +197 -0
  70. package/template/apps/server/src/module-host/resource-file-policies.ts +108 -0
  71. package/template/apps/server/src/module-host/route-declaration.ts +45 -0
  72. package/template/apps/server/src/module-host/route-installer.ts +27 -3
  73. package/template/apps/server/src/module-host/storage-port.test.ts +170 -1
  74. package/template/apps/server/src/module-host/storage-port.ts +134 -1
  75. package/template/apps/server/src/module-host/storage-scope.ts +89 -0
  76. package/template/apps/server/src/module-host/tool-handlers.test.ts +305 -0
  77. package/template/apps/server/src/module-host/tool-handlers.ts +38 -4
  78. package/template/apps/server/src/module-host/user-directory-composition.test.ts +126 -0
  79. package/template/apps/server/src/module-host/user-directory-port.test.ts +238 -0
  80. package/template/apps/server/src/module-host/user-directory-port.ts +139 -0
  81. package/template/apps/server/src/module-host.ts +4 -0
  82. package/template/apps/server/src/notification/channel-adapter.ts +46 -0
  83. package/template/apps/server/src/notification/delivery-policy.test.ts +59 -0
  84. package/template/apps/server/src/notification/delivery-policy.ts +37 -0
  85. package/template/apps/server/src/notification/delivery-repository.ts +198 -0
  86. package/template/apps/server/src/notification/delivery-worker.test.ts +87 -0
  87. package/template/apps/server/src/notification/delivery-worker.ts +88 -0
  88. package/template/apps/server/src/notification/drizzle-management.ts +180 -0
  89. package/template/apps/server/src/notification/drizzle-query.ts +160 -0
  90. package/template/apps/server/src/notification/drizzle-repository.integration.test.ts +301 -0
  91. package/template/apps/server/src/notification/drizzle-repository.ts +156 -90
  92. package/template/apps/server/src/notification/extension-routes.test.ts +119 -0
  93. package/template/apps/server/src/notification/extension-routes.ts +111 -0
  94. package/template/apps/server/src/notification/memory-delivery-repository.ts +137 -0
  95. package/template/apps/server/src/notification/memory-support.ts +72 -0
  96. package/template/apps/server/src/notification/preference-repository.ts +95 -0
  97. package/template/apps/server/src/notification/recipient-directory.ts +104 -0
  98. package/template/apps/server/src/notification/repository.test.ts +171 -0
  99. package/template/apps/server/src/notification/repository.ts +179 -32
  100. package/template/apps/server/src/notification/revision-routes.test.ts +186 -0
  101. package/template/apps/server/src/notification/route-support.ts +225 -0
  102. package/template/apps/server/src/notification/routes.test.ts +182 -0
  103. package/template/apps/server/src/notification/routes.ts +225 -132
  104. package/template/apps/server/src/notification/service.test.ts +104 -0
  105. package/template/apps/server/src/notification/service.ts +140 -0
  106. package/template/apps/server/src/notification/smtp-adapter.test.ts +65 -0
  107. package/template/apps/server/src/notification/smtp-adapter.ts +68 -0
  108. package/template/apps/server/src/persistence.integration.test.ts +41 -2
  109. package/template/apps/server/src/route-guards.ts +1 -0
  110. package/template/apps/server/src/runtime-audit-list.test.ts +39 -0
  111. package/template/apps/server/src/runtime-development.ts +2 -0
  112. package/template/apps/server/src/runtime.test.ts +23 -9
  113. package/template/apps/server/src/runtime.ts +39 -2
  114. package/template/apps/server/src/scheduler/audit.ts +2 -11
  115. package/template/apps/server/src/scheduler/definitions.test.ts +6 -0
  116. package/template/apps/server/src/scheduler/definitions.ts +7 -0
  117. package/template/apps/server/src/scheduler/recovery-service.ts +2 -11
  118. package/template/apps/server/src/scheduler/routes.ts +2 -7
  119. package/template/apps/server/src/search/opensearch-client.test.ts +45 -0
  120. package/template/apps/server/src/search/opensearch-client.ts +145 -0
  121. package/template/apps/server/src/search/service.ts +2 -6
  122. package/template/apps/server/src/settings/routes.ts +15 -3
  123. package/template/apps/server/src/settings/runtime.ts +10 -1
  124. package/template/apps/server/src/storage/runtime.ts +13 -0
  125. package/template/apps/server/src/system/audit-query.ts +33 -4
  126. package/template/apps/server/src/system/audit-routes.test.ts +58 -4
  127. package/template/apps/server/src/system/audit-routes.ts +6 -5
  128. package/template/apps/server/src/system/built-in-roles.ts +1 -0
  129. package/template/apps/server/src/system/department-organization.ts +320 -0
  130. package/template/apps/server/src/system/department-routes.test.ts +207 -48
  131. package/template/apps/server/src/system/department-routes.ts +114 -33
  132. package/template/apps/server/src/system/drizzle-repository.ts +15 -7
  133. package/template/apps/server/src/system/drizzle-scoped-repository.ts +5 -3
  134. package/template/apps/server/src/system/drizzle-system.ts +37 -9
  135. package/template/apps/server/src/system/drizzle-transaction-context.ts +14 -0
  136. package/template/apps/server/src/system/identity-route-config.ts +7 -2
  137. package/template/apps/server/src/system/mutation-runner.ts +23 -0
  138. package/template/apps/server/src/system/organization-postgres.integration.test.ts +176 -0
  139. package/template/apps/server/src/system/resource-access-response.ts +12 -6
  140. package/template/apps/server/src/system/role-department-scope-policy.ts +55 -0
  141. package/template/apps/server/src/system/route-helpers.ts +2 -5
  142. package/template/apps/server/src/system/route-types.ts +12 -3
  143. package/template/apps/server/src/system/routes-validation.test.ts +26 -0
  144. package/template/apps/server/src/system/routes.test.ts +10 -2
  145. package/template/apps/server/src/system/routes.ts +70 -36
  146. package/template/apps/server/src/system/seed.ts +7 -0
  147. package/template/apps/server/src/work-order/data-scope.integration.test.ts +9 -2
  148. package/template/apps/server/src/work-order/opensearch-index.test.ts +97 -0
  149. package/template/apps/server/src/work-order/opensearch-index.ts +313 -0
  150. package/template/apps/server/src/work-order/search-provider.ts +60 -1
  151. package/template/apps/server/src/work-order/service.ts +42 -10
  152. package/template/apps/web/src/app/error-pages.ts +9 -0
  153. package/template/apps/web/src/components/auth/PasswordChangeForm.vue +16 -11
  154. package/template/apps/web/src/components/auth/PasswordChangeForm.webtest.ts +14 -0
  155. package/template/apps/web/src/components/common/FormDialog.vue +16 -2
  156. package/template/apps/web/src/components/common/ModalLayout.webtest.ts +20 -1
  157. package/template/apps/web/src/composables/useGlobalSearch.ts +68 -0
  158. package/template/apps/web/src/composables/usePlatformSettings.ts +8 -7
  159. package/template/apps/web/src/layout/GlobalSearchResults.vue +58 -0
  160. package/template/apps/web/src/layout/NavigationSearchDialog.vue +42 -6
  161. package/template/apps/web/src/layout/NavigationSearchDialog.webtest.ts +71 -0
  162. package/template/apps/web/src/layout/NotificationMenu.vue +73 -31
  163. package/template/apps/web/src/layout/NotificationMenu.webtest.ts +44 -1
  164. package/template/apps/web/src/layout/NotificationMenuItem.vue +61 -0
  165. package/template/apps/web/src/layout/NotificationPreferencesDialog.vue +181 -0
  166. package/template/apps/web/src/layout/NotificationPreferencesDialog.webtest.ts +80 -0
  167. package/template/apps/web/src/lib/date-time.ts +22 -10
  168. package/template/apps/web/src/lib/date-time.webtest.ts +9 -1
  169. package/template/apps/web/src/main.ts +14 -1
  170. package/template/apps/web/src/pages/auth/ChangePasswordPage.vue +16 -1
  171. package/template/apps/web/src/pages/configuration/components/ModuleConfigVersionList.vue +1 -0
  172. package/template/apps/web/src/pages/configuration/components/ModuleConfigurationEditor.vue +10 -0
  173. package/template/apps/web/src/pages/configuration/components/ModuleConfigurationWorkbench.vue +37 -6
  174. package/template/apps/web/src/pages/errors/PlatformErrorPage.vue +115 -0
  175. package/template/apps/web/src/pages/errors/PlatformErrorPage.webtest.ts +44 -0
  176. package/template/apps/web/src/pages/errors/error-page-extension.ts +26 -0
  177. package/template/apps/web/src/pages/system/SystemNotificationsPage.vue +136 -68
  178. package/template/apps/web/src/pages/system/SystemNotificationsPage.webtest.ts +224 -12
  179. package/template/apps/web/src/pages/system/audit-log-presenter.ts +86 -0
  180. package/template/apps/web/src/pages/system/audit-time-range.ts +28 -0
  181. package/template/apps/web/src/pages/system/components/AuditActionCell.vue +10 -69
  182. package/template/apps/web/src/pages/system/components/AuditActionCell.webtest.ts +20 -27
  183. package/template/apps/web/src/pages/system/components/AuditLogDetailDialog.vue +134 -0
  184. package/template/apps/web/src/pages/system/components/AuditLogDetailDialog.webtest.ts +76 -0
  185. package/template/apps/web/src/pages/system/components/AuditLogFilters.vue +116 -52
  186. package/template/apps/web/src/pages/system/components/AuditLogFilters.webtest.ts +52 -15
  187. package/template/apps/web/src/pages/system/components/NotificationHistoryDialog.vue +129 -0
  188. package/template/apps/web/src/pages/system/components/NotificationManagementCard.vue +91 -0
  189. package/template/apps/web/src/pages/system/components/NotificationPublishDialog.vue +121 -0
  190. package/template/apps/web/src/pages/system/components/NotificationPublishForm.vue +162 -1
  191. package/template/apps/web/src/pages/system/components/SystemResourceActions.vue +68 -0
  192. package/template/apps/web/src/pages/system/components/SystemResourceEditor.vue +74 -0
  193. package/template/apps/web/src/pages/system/components/SystemResourceFilters.vue +3 -4
  194. package/template/apps/web/src/pages/system/components/SystemResourcePage.vue +91 -98
  195. package/template/apps/web/src/pages/system/components/SystemResourcePage.webtest.ts +68 -0
  196. package/template/apps/web/src/pages/system/components/SystemResourceTable.vue +20 -1
  197. package/template/apps/web/src/pages/system/components/SystemResourceTable.webtest.ts +28 -7
  198. package/template/apps/web/src/pages/system/components/department/DepartmentOrganizationForm.vue +210 -0
  199. package/template/apps/web/src/pages/system/components/department/DepartmentTransitionDialog.vue +112 -0
  200. package/template/apps/web/src/pages/system/components/user-account/UserAccountForm.vue +17 -4
  201. package/template/apps/web/src/pages/system/composables/useDepartmentTransitions.ts +79 -0
  202. package/template/apps/web/src/pages/system/composables/useNotificationPermissions.ts +14 -0
  203. package/template/apps/web/src/pages/system/composables/useSystemResource.ts +2 -0
  204. package/template/apps/web/src/pages/system/composables/useSystemResource.webtest.ts +15 -2
  205. package/template/apps/web/src/pages/system/resource-config.ts +12 -4
  206. package/template/apps/web/src/router/error-navigation.ts +50 -0
  207. package/template/apps/web/src/router/error-navigation.webtest.ts +106 -0
  208. package/template/apps/web/src/router/index.ts +71 -0
  209. package/template/apps/web/src/router/index.webtest.ts +29 -0
  210. package/template/apps/web/src/router/manifest-routes.webtest.ts +4 -0
  211. package/template/apps/web/src/router/shared-scaffold-neutrality.webtest.ts +12 -0
  212. package/template/apps/web/src/services/auth-api.ts +5 -0
  213. package/template/apps/web/src/services/http.ts +43 -6
  214. package/template/apps/web/src/services/http.webtest.ts +70 -0
  215. package/template/apps/web/src/services/notification-api.ts +85 -2
  216. package/template/apps/web/src/services/notification-api.webtest.ts +110 -0
  217. package/template/apps/web/src/services/search-api.ts +39 -0
  218. package/template/apps/web/src/services/system-api.ts +18 -0
  219. package/template/apps/web/vitest.config.ts +1 -0
  220. package/template/docker-compose.yml +68 -0
  221. package/template/docs/architecture/ai-egress.md +49 -7
  222. package/template/docs/architecture/ai-runtime.md +34 -6
  223. package/template/docs/architecture/data-scope-query-enforcement.md +4 -0
  224. package/template/docs/architecture/object-storage.md +22 -2
  225. package/template/docs/architecture/search-provider-protocol.md +38 -2
  226. package/template/docs/development/custom-error-pages.md +78 -0
  227. package/template/docs/development/custom-login-page.md +3 -3
  228. package/template/docs/platform/agent-runtime.md +76 -7
  229. package/template/docs/platform/audit-reliability.md +46 -2
  230. package/template/docs/platform/business-user-directory.md +82 -0
  231. package/template/docs/platform/module-configuration.md +13 -4
  232. package/template/docs/platform/notifications.md +67 -11
  233. package/template/docs/platform/organization-membership.md +17 -3
  234. package/template/docs/platform/system-crud-api.md +16 -0
  235. package/template/docs/platform/web-system-crud.md +6 -2
  236. package/template/package.json +4 -0
  237. package/template/packages/config/index.test.ts +45 -0
  238. package/template/packages/config/package.json +1 -1
  239. package/template/packages/config/src/platform.ts +169 -48
  240. package/template/packages/database/drizzle/0035_material_nightshade.sql +10 -0
  241. package/template/packages/database/drizzle/0036_hesitant_speed.sql +35 -0
  242. package/template/packages/database/drizzle/0037_absent_nick_fury.sql +2 -0
  243. package/template/packages/database/drizzle/0038_uneven_wasp.sql +38 -0
  244. package/template/packages/database/drizzle/meta/0035_snapshot.json +7331 -0
  245. package/template/packages/database/drizzle/meta/0036_snapshot.json +7436 -0
  246. package/template/packages/database/drizzle/meta/0037_snapshot.json +7457 -0
  247. package/template/packages/database/drizzle/meta/0038_snapshot.json +7749 -0
  248. package/template/packages/database/drizzle/meta/_journal.json +28 -0
  249. package/template/packages/database/package.json +1 -1
  250. package/template/packages/database/src/schema/identity.ts +7 -0
  251. package/template/packages/database/src/schema/notifications.ts +135 -0
  252. package/template/packages/database/src/schema-notification-delivery.test.ts +54 -0
  253. package/template/packages/database/src/schema-workflow-notification.test.ts +40 -1
  254. package/template/packages/modules/package.json +1 -1
  255. package/template/packages/modules/src/ai-operation-composition.test.ts +68 -0
  256. package/template/packages/modules/src/ai-operation-composition.ts +115 -0
  257. package/template/packages/modules/src/manifest.ts +26 -0
  258. package/template/packages/modules/src/provider-data-policy-composition.test.ts +74 -0
  259. package/template/packages/modules/src/system-api-permissions.ts +54 -0
  260. package/template/packages/modules/src/system-audit-actions.ts +15 -0
  261. package/template/packages/modules/src/system-features.ts +6 -1
  262. package/template/packages/modules/src/system-module-catalog.test.ts +16 -0
  263. package/template/packages/modules/src/system-module-catalog.ts +28 -4
  264. package/template/packages/modules/src/system-modules.test.ts +13 -1
  265. package/template/packages/modules/src/system-modules.ts +12 -0
  266. package/template/packages/modules/src/system-permissions.ts +11 -5
  267. package/template/packages/server-sdk/index.ts +11 -0
  268. package/template/packages/server-sdk/package.json +3 -2
  269. package/template/packages/server-sdk/src/ai-operation-registration.ts +2 -1
  270. package/template/packages/server-sdk/src/module-host.ts +8 -0
  271. package/template/packages/server-sdk/src/request-context.ts +2 -0
  272. package/template/packages/server-sdk/src/storage-port.ts +66 -0
  273. package/template/packages/server-sdk/src/tool-registration.ts +6 -0
  274. package/template/packages/server-sdk/src/user-directory-port.ts +42 -0
  275. package/template/packages/shared/package.json +1 -1
  276. package/template/packages/shared/src/audit.ts +25 -0
  277. package/template/packages/shared/src/module-configuration.ts +5 -0
  278. package/template/packages/shared/src/notification.ts +92 -1
  279. package/template/packages/shared/src/password.ts +7 -2
  280. package/template/packages/shared/src/platform-settings.ts +2 -0
  281. package/template/packages/storage/package.json +1 -1
  282. package/template/packages/storage/src/upload-service.test.ts +16 -0
  283. package/template/packages/storage/src/upload-service.ts +5 -1
  284. package/template/scripts/notification-postgres-regression.ts +27 -0
@@ -0,0 +1,28 @@
1
+ export function localMinuteToIso(
2
+ value: string,
3
+ boundary: "start" | "end",
4
+ ): string | undefined {
5
+ const match =
6
+ /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2})$/.exec(value.trim());
7
+ if (!match) return undefined;
8
+ const [, year, month, day, hour, minute] = match;
9
+ const local = new Date(
10
+ Number(year),
11
+ Number(month) - 1,
12
+ Number(day),
13
+ Number(hour),
14
+ Number(minute),
15
+ boundary === "end" ? 59 : 0,
16
+ boundary === "end" ? 999 : 0,
17
+ );
18
+ if (
19
+ local.getFullYear() !== Number(year) ||
20
+ local.getMonth() !== Number(month) - 1 ||
21
+ local.getDate() !== Number(day) ||
22
+ local.getHours() !== Number(hour) ||
23
+ local.getMinutes() !== Number(minute)
24
+ ) {
25
+ return undefined;
26
+ }
27
+ return local.toISOString();
28
+ }
@@ -1,13 +1,9 @@
1
1
  <script setup lang="ts">
2
2
  import { computed } from "vue";
3
3
  import { AUDIT_ACTION_DEFINITIONS } from "@southwind-ai/shared";
4
- import {
5
- Tooltip,
6
- TooltipContent,
7
- TooltipTrigger,
8
- } from "@/components/ui/tooltip";
9
4
  import { useAccessSnapshot } from "@/composables/useAccessSnapshot";
10
5
  import type { SystemRecord } from "@/services/system-api";
6
+ import { auditOperationSummary } from "../audit-log-presenter";
11
7
 
12
8
  const props = defineProps<{
13
9
  item: SystemRecord;
@@ -22,71 +18,16 @@ const actionCatalog = computed(
22
18
  const definition = computed(() =>
23
19
  actionCatalog.value.find((item) => item.key === props.actionKey),
24
20
  );
25
- const target = computed(() => record(props.item.target));
26
- const metadata = computed(() => record(props.item.metadata));
27
- const details = computed(() => {
28
- const values: string[] = [];
29
- const message = text(props.item.message);
30
- if (message) values.push(`补充说明:${message}`);
31
- const targetLabel = text(target.value.label);
32
- const targetType = text(target.value.type);
33
- const targetId = text(target.value.id);
34
- if (targetLabel || targetType || targetId) {
35
- values.push(
36
- `操作对象:${targetLabel || targetType || "未标注"}${targetId ? `(${targetId})` : ""}`,
37
- );
38
- }
39
- const query = text(metadata.value.query);
40
- if (query) values.push(`搜索内容:${query}`);
41
- const matched = metadata.value.matched;
42
- if (typeof matched === "number") values.push(`匹配结果:${matched} 条`);
43
- const enabled = metadata.value.enabled;
44
- if (typeof enabled === "boolean") {
45
- values.push(`开关状态:${enabled ? "已启用" : "已停用"}`);
46
- }
47
- const visible = text(metadata.value.visible);
48
- if (visible) {
49
- values.push(`入口可见性:${visible === "hidden" ? "隐藏" : "显示"}`);
50
- }
51
- if (Object.hasOwn(metadata.value, "licenseVersionOverride")) {
52
- values.push(formatLicenseScope(metadata.value.licenseVersionOverride));
53
- }
54
- return values;
55
- });
56
-
57
- function record(value: unknown): Record<string, unknown> {
58
- return value && typeof value === "object" && !Array.isArray(value)
59
- ? (value as Record<string, unknown>)
60
- : {};
61
- }
62
-
63
- function text(value: unknown): string | undefined {
64
- return typeof value === "string" && value.trim() ? value.trim() : undefined;
65
- }
66
-
67
- function formatLicenseScope(value: unknown): string {
68
- if (value === null) return "License 范围:跟随模块默认设置";
69
- if (!Array.isArray(value) || value.length === 0) {
70
- return "License 范围:基础能力(不限制版本)";
71
- }
72
- return `License 范围:${value.map(String).join("、")}`;
73
- }
21
+ const summary = computed(() =>
22
+ auditOperationSummary(props.item, definition.value?.label),
23
+ );
74
24
  </script>
75
25
 
76
26
  <template>
77
- <Tooltip>
78
- <TooltipTrigger as-child>
79
- <button
80
- type="button"
81
- class="cursor-help text-left underline decoration-dotted underline-offset-4"
82
- >
83
- {{ definition?.label || key }}
84
- </button>
85
- </TooltipTrigger>
86
- <TooltipContent class="max-w-sm flex-col items-start gap-1 p-3">
87
- <p><span class="opacity-70">Key:</span>{{ key }}</p>
88
- <p>{{ definition?.description || "平台记录的自定义审计动作。" }}</p>
89
- <p v-for="detail in details" :key="detail">{{ detail }}</p>
90
- </TooltipContent>
91
- </Tooltip>
27
+ <div class="min-w-48 max-w-md space-y-1">
28
+ <p class="font-medium">{{ definition?.label || key }}</p>
29
+ <p class="line-clamp-2 break-words text-xs text-muted-foreground">
30
+ {{ summary }}
31
+ </p>
32
+ </div>
92
33
  </template>
@@ -3,7 +3,7 @@ import { mount } from "@vue/test-utils";
3
3
  import AuditActionCell from "./AuditActionCell.vue";
4
4
 
5
5
  describe("AuditActionCell", () => {
6
- test("显示中文动作名,并在组件库 Tooltip 中解释 key、对象和搜索内容", () => {
6
+ test("直接显示中文动作名和稳定的搜索操作摘要", () => {
7
7
  const wrapper = mount(AuditActionCell, {
8
8
  props: {
9
9
  actionKey: "data.search",
@@ -14,28 +14,13 @@ describe("AuditActionCell", () => {
14
14
  metadata: { query: "张三", matched: 2 },
15
15
  },
16
16
  },
17
- global: {
18
- stubs: {
19
- Tooltip: { template: "<div><slot /></div>" },
20
- TooltipTrigger: { template: "<div><slot /></div>" },
21
- TooltipContent: {
22
- template: '<div data-testid="tooltip-content"><slot /></div>',
23
- },
24
- },
25
- },
26
17
  });
27
18
 
28
- expect(wrapper.get("button").text()).toBe("数据搜索");
29
- expect(wrapper.get("button").attributes("title")).toBeUndefined();
30
- expect(wrapper.get('[data-testid="tooltip-content"]').text()).toContain(
31
- "Key:data.search",
32
- );
33
- expect(wrapper.text()).toContain("操作对象:users");
34
- expect(wrapper.text()).toContain("搜索内容:张三");
35
- expect(wrapper.text()).toContain("匹配结果:2 条");
19
+ expect(wrapper.text()).toContain("数据搜索");
20
+ expect(wrapper.text()).toContain("搜索 users:张三");
36
21
  });
37
22
 
38
- test("功能开关变更说明状态、可见性和 License 范围", () => {
23
+ test("功能开关变更给出启停与对象摘要", () => {
39
24
  const wrapper = mount(AuditActionCell, {
40
25
  props: {
41
26
  actionKey: "feature.update",
@@ -50,17 +35,25 @@ describe("AuditActionCell", () => {
50
35
  },
51
36
  },
52
37
  },
53
- global: {
54
- stubs: {
55
- Tooltip: { template: "<div><slot /></div>" },
56
- TooltipTrigger: { template: "<div><slot /></div>" },
57
- TooltipContent: { template: "<div><slot /></div>" },
38
+ });
39
+
40
+ expect(wrapper.text()).toContain("停用 features(system.audit)");
41
+ });
42
+
43
+ test("未知业务动作保留 key、对象和已记录上下文", () => {
44
+ const wrapper = mount(AuditActionCell, {
45
+ props: {
46
+ actionKey: "case.review.complete",
47
+ item: {
48
+ id: "audit_unknown",
49
+ action: "case.review.complete",
50
+ target: { type: "case", id: "case_1", label: "案件甲" },
51
+ message: "完成人工复核",
58
52
  },
59
53
  },
60
54
  });
61
55
 
62
- expect(wrapper.text()).toContain("开关状态:已停用");
63
- expect(wrapper.text()).toContain("入口可见性:隐藏");
64
- expect(wrapper.text()).toContain("License 范围:advanced");
56
+ expect(wrapper.text()).toContain("case.review.complete");
57
+ expect(wrapper.text()).toContain("完成人工复核;对象:案件甲");
65
58
  });
66
59
  });
@@ -0,0 +1,134 @@
1
+ <script setup lang="ts">
2
+ import { computed } from "vue";
3
+ import { AUDIT_ACTION_DEFINITIONS } from "@southwind-ai/shared";
4
+ import { Button } from "@/components/ui/button";
5
+ import {
6
+ Dialog,
7
+ DialogClose,
8
+ DialogContent,
9
+ DialogDescription,
10
+ DialogFooter,
11
+ DialogHeader,
12
+ DialogTitle,
13
+ } from "@/components/ui/dialog";
14
+ import { useAccessSnapshot } from "@/composables/useAccessSnapshot";
15
+ import { formatDateTime } from "@/lib/date-time";
16
+ import type { SystemRecord } from "@/services/system-api";
17
+ import {
18
+ auditActorLabel,
19
+ auditOperationSummary,
20
+ auditOutcomeLabel,
21
+ auditRecord,
22
+ auditTargetLabel,
23
+ auditText,
24
+ formatAuditMetadata,
25
+ } from "../audit-log-presenter";
26
+
27
+ const props = defineProps<{ item?: SystemRecord }>();
28
+ const open = defineModel<boolean>("open", { required: true });
29
+ const access = useAccessSnapshot();
30
+ const catalog = computed(
31
+ () => access.snapshot.value?.auditActionCatalog || AUDIT_ACTION_DEFINITIONS,
32
+ );
33
+ const definition = computed(() =>
34
+ catalog.value.find(({ key }) => key === props.item?.action),
35
+ );
36
+ const actor = computed(() => auditRecord(props.item?.actor));
37
+ const actionKey = computed(() => auditText(props.item?.action) || "unknown");
38
+ const actionLabel = computed(() => definition.value?.label || actionKey.value);
39
+ const summary = computed(() =>
40
+ props.item
41
+ ? auditOperationSummary(props.item, actionLabel.value)
42
+ : "未记录",
43
+ );
44
+
45
+ function value(value: unknown): string {
46
+ return auditText(value) || "未记录";
47
+ }
48
+ </script>
49
+
50
+ <template>
51
+ <Dialog v-model:open="open">
52
+ <DialogContent class="max-h-[85vh] max-w-3xl overflow-y-auto">
53
+ <DialogHeader>
54
+ <DialogTitle>审计日志详情</DialogTitle>
55
+ <DialogDescription>
56
+ 展示服务端已经脱敏并持久化的审计事实;未记录的信息不会推断补全。
57
+ </DialogDescription>
58
+ </DialogHeader>
59
+
60
+ <dl v-if="item" class="grid gap-x-6 gap-y-4 text-sm sm:grid-cols-2">
61
+ <div class="sm:col-span-2">
62
+ <dt class="text-muted-foreground">具体操作</dt>
63
+ <dd class="mt-1 break-words font-medium">{{ summary }}</dd>
64
+ </div>
65
+ <div>
66
+ <dt class="text-muted-foreground">动作</dt>
67
+ <dd class="mt-1 break-words">
68
+ {{ actionLabel }}({{ actionKey }})
69
+ </dd>
70
+ </div>
71
+ <div>
72
+ <dt class="text-muted-foreground">结果</dt>
73
+ <dd class="mt-1">{{ auditOutcomeLabel(item.outcome) }}</dd>
74
+ </div>
75
+ <div class="sm:col-span-2">
76
+ <dt class="text-muted-foreground">动作说明</dt>
77
+ <dd class="mt-1 break-words">
78
+ {{ definition?.description || "未记录该自定义动作的说明。" }}
79
+ </dd>
80
+ </div>
81
+ <div>
82
+ <dt class="text-muted-foreground">操作者</dt>
83
+ <dd class="mt-1 break-words">{{ auditActorLabel(item) }}</dd>
84
+ </div>
85
+ <div>
86
+ <dt class="text-muted-foreground">IP</dt>
87
+ <dd class="mt-1 break-all">{{ value(actor.ip) }}</dd>
88
+ </div>
89
+ <div>
90
+ <dt class="text-muted-foreground">时间</dt>
91
+ <dd class="mt-1">{{ formatDateTime(item.occurredAt) }}</dd>
92
+ </div>
93
+ <div>
94
+ <dt class="text-muted-foreground">操作对象</dt>
95
+ <dd class="mt-1 break-words">{{ auditTargetLabel(item) }}</dd>
96
+ </div>
97
+ <div>
98
+ <dt class="text-muted-foreground">模块</dt>
99
+ <dd class="mt-1 break-all">{{ value(item.module) }}</dd>
100
+ </div>
101
+ <div>
102
+ <dt class="text-muted-foreground">Request ID</dt>
103
+ <dd class="mt-1 break-all">{{ value(item.requestId) }}</dd>
104
+ </div>
105
+ <div class="sm:col-span-2">
106
+ <dt class="text-muted-foreground">Message</dt>
107
+ <dd class="mt-1 whitespace-pre-wrap break-words">
108
+ {{ value(item.message) }}
109
+ </dd>
110
+ </div>
111
+ <div class="sm:col-span-2">
112
+ <dt class="text-muted-foreground">User-Agent</dt>
113
+ <dd class="mt-1 whitespace-pre-wrap break-all">
114
+ {{ value(actor.userAgent) }}
115
+ </dd>
116
+ </div>
117
+ <div class="sm:col-span-2">
118
+ <dt class="text-muted-foreground">Metadata(已脱敏)</dt>
119
+ <dd class="mt-1">
120
+ <pre
121
+ class="max-h-64 overflow-auto whitespace-pre-wrap break-all rounded-md bg-muted p-3 font-mono text-xs"
122
+ >{{ formatAuditMetadata(item.metadata) }}</pre>
123
+ </dd>
124
+ </div>
125
+ </dl>
126
+
127
+ <DialogFooter>
128
+ <DialogClose as-child>
129
+ <Button variant="outline">关闭</Button>
130
+ </DialogClose>
131
+ </DialogFooter>
132
+ </DialogContent>
133
+ </Dialog>
134
+ </template>
@@ -0,0 +1,76 @@
1
+ import { flushPromises, mount } from "@vue/test-utils";
2
+ import { afterEach, describe, expect, test } from "vitest";
3
+ import AuditLogDetailDialog from "./AuditLogDetailDialog.vue";
4
+
5
+ afterEach(() => {
6
+ document.body.innerHTML = "";
7
+ });
8
+
9
+ describe("审计日志详情", () => {
10
+ test("以纯文本展示 IP、来源、对象、上下文和已脱敏 metadata", async () => {
11
+ const wrapper = mount(AuditLogDetailDialog, {
12
+ props: {
13
+ open: true,
14
+ item: {
15
+ id: "audit_1",
16
+ action: "feature.update",
17
+ outcome: "success",
18
+ actor: {
19
+ id: "user_1",
20
+ name: "管理员",
21
+ ip: "203.0.113.8",
22
+ userAgent: "Windy-Browser/1.0",
23
+ },
24
+ target: {
25
+ type: "features",
26
+ id: "system.audit",
27
+ label: "审计日志",
28
+ },
29
+ occurredAt: "2026-07-20T01:15:00.000Z",
30
+ message: "更新功能策略",
31
+ module: "system",
32
+ requestId: "request_1",
33
+ metadata: {
34
+ enabled: true,
35
+ token: "[REDACTED]",
36
+ note: "<script>unsafe()</script>",
37
+ },
38
+ },
39
+ },
40
+ attachTo: document.body,
41
+ });
42
+ await flushPromises();
43
+
44
+ expect(document.body.textContent).toContain("审计日志详情");
45
+ expect(document.body.textContent).toContain("管理员(user_1)");
46
+ expect(document.body.textContent).toContain("203.0.113.8");
47
+ expect(document.body.textContent).toContain("Windy-Browser/1.0");
48
+ expect(document.body.textContent).toContain("审计日志(features / system.audit)");
49
+ expect(document.body.textContent).toContain("[REDACTED]");
50
+ expect(document.body.querySelector("script")).toBeNull();
51
+ wrapper.unmount();
52
+ });
53
+
54
+ test("未知动作和缺失字段使用明确 fallback", async () => {
55
+ const wrapper = mount(AuditLogDetailDialog, {
56
+ props: {
57
+ open: true,
58
+ item: {
59
+ id: "audit_unknown",
60
+ action: "case.review.complete",
61
+ outcome: "success",
62
+ actor: { id: "service_1", name: "案件服务" },
63
+ occurredAt: "2026-07-20T01:15:00.000Z",
64
+ },
65
+ },
66
+ attachTo: document.body,
67
+ });
68
+ await flushPromises();
69
+
70
+ expect(document.body.textContent).toContain("case.review.complete");
71
+ expect(document.body.textContent).toContain("未记录操作对象");
72
+ expect(document.body.textContent).toContain("IP");
73
+ expect(document.body.textContent).toContain("未记录");
74
+ wrapper.unmount();
75
+ });
76
+ });
@@ -1,6 +1,10 @@
1
1
  <script setup lang="ts">
2
2
  import { computed, onMounted, shallowRef, watch } from "vue";
3
3
  import { AUDIT_ACTION_DEFINITIONS } from "@southwind-ai/shared";
4
+ import { SearchIcon, XIcon } from "@lucide/vue";
5
+ import { Button } from "@/components/ui/button";
6
+ import { Checkbox } from "@/components/ui/checkbox";
7
+ import { Input } from "@/components/ui/input";
4
8
  import {
5
9
  Select,
6
10
  SelectContent,
@@ -8,20 +12,28 @@ import {
8
12
  SelectTrigger,
9
13
  SelectValue,
10
14
  } from "@/components/ui/select";
11
- import { Checkbox } from "@/components/ui/checkbox";
12
15
  import { useAccessSnapshot } from "@/composables/useAccessSnapshot";
13
16
  import { listSystemResource, type SystemRecord } from "@/services/system-api";
17
+ import { localMinuteToIso } from "../audit-time-range";
18
+
19
+ export interface AuditLogFilterValue {
20
+ q?: string;
21
+ actorId?: string;
22
+ action?: string;
23
+ occurredAfter?: string;
24
+ occurredBefore?: string;
25
+ }
14
26
 
15
27
  const emit = defineEmits<{
16
- change: [
17
- filters: { actorId?: string; action?: string; occurredAfter?: string },
18
- ];
28
+ change: [filters: AuditLogFilterValue];
19
29
  "export-options": [options: { includeScheduler: boolean }];
20
30
  }>();
21
31
 
32
+ const keyword = shallowRef("");
22
33
  const actorId = shallowRef("all");
23
34
  const action = shallowRef("all");
24
- const timeRange = shallowRef("all");
35
+ const occurredAfterLocal = shallowRef("");
36
+ const occurredBeforeLocal = shallowRef("");
25
37
  const optionSource = shallowRef<SystemRecord[]>([]);
26
38
  const includeScheduler = shallowRef(false);
27
39
  const access = useAccessSnapshot();
@@ -53,66 +65,118 @@ onMounted(async () => {
53
65
  }
54
66
  });
55
67
 
56
- watch([actorId, action, timeRange], () => {
68
+ watch(includeScheduler, (value) => {
69
+ emit("export-options", { includeScheduler: value });
70
+ });
71
+
72
+ function applyFilters() {
57
73
  emit("change", {
74
+ q: keyword.value.trim() || undefined,
58
75
  actorId: actorId.value === "all" ? undefined : actorId.value,
59
76
  action: action.value === "all" ? undefined : action.value,
60
- occurredAfter: timeRangeStart(timeRange.value),
77
+ occurredAfter: localMinuteToIso(occurredAfterLocal.value, "start"),
78
+ occurredBefore: localMinuteToIso(occurredBeforeLocal.value, "end"),
61
79
  });
62
- });
80
+ }
63
81
 
64
- watch(includeScheduler, (value) => {
65
- emit("export-options", { includeScheduler: value });
66
- });
82
+ function resetFilters() {
83
+ keyword.value = "";
84
+ actorId.value = "all";
85
+ action.value = "all";
86
+ occurredAfterLocal.value = "";
87
+ occurredBeforeLocal.value = "";
88
+ applyFilters();
89
+ }
67
90
 
68
- function timeRangeStart(value: string) {
69
- const duration = {
70
- day: 24 * 60 * 60 * 1_000,
71
- week: 7 * 24 * 60 * 60 * 1_000,
72
- month: 30 * 24 * 60 * 60 * 1_000,
73
- }[value];
74
- return duration ? new Date(Date.now() - duration).toISOString() : undefined;
91
+ function clearKeyword() {
92
+ keyword.value = "";
93
+ applyFilters();
75
94
  }
76
95
  </script>
77
96
 
78
97
  <template>
79
- <div class="grid gap-3 md:grid-cols-3" data-testid="audit-filters">
80
- <Select v-model="actorId">
81
- <SelectTrigger aria-label="筛选操作者"><SelectValue /></SelectTrigger>
82
- <SelectContent>
83
- <SelectItem value="all">全部操作者</SelectItem>
84
- <SelectItem v-for="actor in actors" :key="actor.id" :value="actor.id">
85
- {{ actor.name }}({{ actor.id }})
86
- </SelectItem>
87
- </SelectContent>
88
- </Select>
89
-
90
- <Select v-model="action">
91
- <SelectTrigger aria-label="筛选动作"><SelectValue /></SelectTrigger>
92
- <SelectContent>
93
- <SelectItem value="all">全部动作</SelectItem>
94
- <SelectItem
95
- v-for="definition in actionCatalog"
96
- :key="definition.key"
97
- :value="definition.key"
98
+ <form
99
+ class="space-y-3"
100
+ data-testid="audit-filters"
101
+ @submit.prevent="applyFilters"
102
+ >
103
+ <div class="grid gap-3 lg:grid-cols-2 xl:grid-cols-4">
104
+ <div class="flex gap-2">
105
+ <Input
106
+ v-model="keyword"
107
+ aria-label="审计关键字"
108
+ placeholder="搜索动作、操作者、对象、IP 或上下文"
109
+ maxlength="120"
110
+ />
111
+ <Button
112
+ v-if="keyword"
113
+ type="button"
114
+ variant="outline"
115
+ aria-label="清空审计关键字"
116
+ @click="clearKeyword"
98
117
  >
99
- {{ definition.label }}({{ definition.key }})
100
- </SelectItem>
101
- </SelectContent>
102
- </Select>
118
+ 清空
119
+ </Button>
120
+ </div>
121
+ <Select v-model="actorId">
122
+ <SelectTrigger aria-label="筛选操作者"><SelectValue /></SelectTrigger>
123
+ <SelectContent>
124
+ <SelectItem value="all">全部操作者</SelectItem>
125
+ <SelectItem v-for="actor in actors" :key="actor.id" :value="actor.id">
126
+ {{ actor.name }}({{ actor.id }})
127
+ </SelectItem>
128
+ </SelectContent>
129
+ </Select>
130
+ <Select v-model="action">
131
+ <SelectTrigger aria-label="筛选动作"><SelectValue /></SelectTrigger>
132
+ <SelectContent>
133
+ <SelectItem value="all">全部动作</SelectItem>
134
+ <SelectItem
135
+ v-for="definition in actionCatalog"
136
+ :key="definition.key"
137
+ :value="definition.key"
138
+ >
139
+ {{ definition.label }}({{ definition.key }})
140
+ </SelectItem>
141
+ </SelectContent>
142
+ </Select>
143
+ <div class="flex gap-2">
144
+ <Button type="submit" class="flex-1">
145
+ <SearchIcon data-icon="inline-start" />
146
+ 查询
147
+ </Button>
148
+ <Button type="button" variant="outline" @click="resetFilters">
149
+ <XIcon data-icon="inline-start" />
150
+ 重置
151
+ </Button>
152
+ </div>
153
+ </div>
154
+
155
+ <div class="grid gap-3 md:grid-cols-2">
156
+ <label class="space-y-1 text-sm">
157
+ <span class="text-muted-foreground">开始时间(本地时间)</span>
158
+ <Input
159
+ v-model="occurredAfterLocal"
160
+ aria-label="审计开始时间"
161
+ type="datetime-local"
162
+ step="60"
163
+ />
164
+ </label>
165
+ <label class="space-y-1 text-sm">
166
+ <span class="text-muted-foreground">结束时间(本地时间)</span>
167
+ <Input
168
+ v-model="occurredBeforeLocal"
169
+ aria-label="审计结束时间"
170
+ type="datetime-local"
171
+ step="60"
172
+ />
173
+ </label>
174
+ </div>
175
+ </form>
103
176
 
104
- <Select v-model="timeRange">
105
- <SelectTrigger aria-label="筛选时间"><SelectValue /></SelectTrigger>
106
- <SelectContent>
107
- <SelectItem value="all">全部时间</SelectItem>
108
- <SelectItem value="day">最近 24 小时</SelectItem>
109
- <SelectItem value="week">最近 7 天</SelectItem>
110
- <SelectItem value="month">最近 30 天</SelectItem>
111
- </SelectContent>
112
- </Select>
113
- </div>
114
177
  <p class="text-xs text-muted-foreground">
115
- 操作者选项来自最近 100 条审计记录;动作名称和说明来自平台稳定动作目录。
178
+ 起点按所选分钟的 00.000 秒计算,终点包含所选分钟至 59.999
179
+ 秒;操作者选项来自最近 100 条审计记录。
116
180
  </p>
117
181
  <label class="flex w-fit items-center gap-2 text-sm">
118
182
  <Checkbox v-model="includeScheduler" aria-label="导出时包含定时器日志" />