create-windy 0.1.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.
- package/README.md +114 -0
- package/assets/LICENSE-Apache-2.0.txt +201 -0
- package/dist/cli.js +1662 -0
- package/package.json +37 -0
- package/template/.dockerignore +11 -0
- package/template/.oxfmtrc.json +9 -0
- package/template/.oxlintrc.json +119 -0
- package/template/.windy-template.json +71 -0
- package/template/AGENTS.md +87 -0
- package/template/README.md +128 -0
- package/template/apps/server/Dockerfile +34 -0
- package/template/apps/server/package.json +30 -0
- package/template/apps/server/src/access-guards.ts +112 -0
- package/template/apps/server/src/admin/routes.test.ts +105 -0
- package/template/apps/server/src/admin/routes.ts +95 -0
- package/template/apps/server/src/agent/data-scope-routes.test.ts +143 -0
- package/template/apps/server/src/agent/routes.test.ts +244 -0
- package/template/apps/server/src/agent/routes.ts +257 -0
- package/template/apps/server/src/api-app.ts +32 -0
- package/template/apps/server/src/application-services.ts +154 -0
- package/template/apps/server/src/audit/contracts.ts +21 -0
- package/template/apps/server/src/audit/drizzle-log-store.ts +150 -0
- package/template/apps/server/src/audit/policy.ts +18 -0
- package/template/apps/server/src/audit/recovery-queue.test.ts +42 -0
- package/template/apps/server/src/audit/recovery-queue.ts +63 -0
- package/template/apps/server/src/audit/redaction.ts +55 -0
- package/template/apps/server/src/audit/reliable-writer.test.ts +200 -0
- package/template/apps/server/src/audit/reliable-writer.ts +201 -0
- package/template/apps/server/src/audit/search-summary.ts +32 -0
- package/template/apps/server/src/auth/actor-resolver.test.ts +138 -0
- package/template/apps/server/src/auth/actor-resolver.ts +109 -0
- package/template/apps/server/src/auth/authentication-provider.test.ts +180 -0
- package/template/apps/server/src/auth/authentication-provider.ts +117 -0
- package/template/apps/server/src/auth/authorization-snapshot.test.ts +117 -0
- package/template/apps/server/src/auth/authorization-snapshot.ts +98 -0
- package/template/apps/server/src/auth/bearer-token.ts +5 -0
- package/template/apps/server/src/auth/bootstrap-admin.ts +33 -0
- package/template/apps/server/src/auth/credential-restriction.ts +29 -0
- package/template/apps/server/src/auth/credential-routes.test.ts +190 -0
- package/template/apps/server/src/auth/credential-service.ts +165 -0
- package/template/apps/server/src/auth/development-bypass.ts +22 -0
- package/template/apps/server/src/auth/drizzle-repository.ts +315 -0
- package/template/apps/server/src/auth/drizzle-session-operations.ts +119 -0
- package/template/apps/server/src/auth/login-routes.ts +121 -0
- package/template/apps/server/src/auth/own-session-routes.test.ts +248 -0
- package/template/apps/server/src/auth/own-session-routes.ts +110 -0
- package/template/apps/server/src/auth/password.test.ts +30 -0
- package/template/apps/server/src/auth/password.ts +46 -0
- package/template/apps/server/src/auth/repository.test.ts +61 -0
- package/template/apps/server/src/auth/repository.ts +305 -0
- package/template/apps/server/src/auth/routes.test.ts +350 -0
- package/template/apps/server/src/auth/routes.ts +237 -0
- package/template/apps/server/src/auth/runtime.ts +20 -0
- package/template/apps/server/src/auth/service.ts +329 -0
- package/template/apps/server/src/auth/session-service.ts +123 -0
- package/template/apps/server/src/background/task-guard.test.ts +66 -0
- package/template/apps/server/src/background/task-guard.ts +49 -0
- package/template/apps/server/src/bulk-data/artifact-store.ts +82 -0
- package/template/apps/server/src/bulk-data/dictionary-handler.ts +122 -0
- package/template/apps/server/src/bulk-data/drizzle-repository.integration.test.ts +156 -0
- package/template/apps/server/src/bulk-data/drizzle-repository.ts +298 -0
- package/template/apps/server/src/bulk-data/helpers.ts +36 -0
- package/template/apps/server/src/bulk-data/input-validation.ts +99 -0
- package/template/apps/server/src/bulk-data/repository.ts +246 -0
- package/template/apps/server/src/bulk-data/resource-handler.ts +27 -0
- package/template/apps/server/src/bulk-data/routes.test.ts +169 -0
- package/template/apps/server/src/bulk-data/routes.ts +248 -0
- package/template/apps/server/src/bulk-data/scheduler-integration.test.ts +142 -0
- package/template/apps/server/src/bulk-data/service.test.ts +347 -0
- package/template/apps/server/src/bulk-data/service.ts +319 -0
- package/template/apps/server/src/bulk-data/types.ts +73 -0
- package/template/apps/server/src/configuration/bootstrap.ts +59 -0
- package/template/apps/server/src/configuration/definition.ts +89 -0
- package/template/apps/server/src/configuration/drizzle-repository.ts +166 -0
- package/template/apps/server/src/configuration/repository.ts +138 -0
- package/template/apps/server/src/configuration/routes.test.ts +178 -0
- package/template/apps/server/src/configuration/routes.ts +260 -0
- package/template/apps/server/src/configuration/service.test.ts +128 -0
- package/template/apps/server/src/configuration/service.ts +187 -0
- package/template/apps/server/src/data-access/context.ts +162 -0
- package/template/apps/server/src/data-access/department-tree.ts +27 -0
- package/template/apps/server/src/data-access/drizzle-predicate.test.ts +86 -0
- package/template/apps/server/src/data-access/drizzle-predicate.ts +50 -0
- package/template/apps/server/src/data-access/errors.ts +5 -0
- package/template/apps/server/src/data-access/platform-actor.ts +25 -0
- package/template/apps/server/src/data-access/query-specification.test.ts +82 -0
- package/template/apps/server/src/data-access/query-specification.ts +77 -0
- package/template/apps/server/src/data-access/scoped-repository.integration.test.ts +203 -0
- package/template/apps/server/src/data-access/scoped-repository.ts +268 -0
- package/template/apps/server/src/data-access/scoped-resource.test.ts +158 -0
- package/template/apps/server/src/data-access/scoped-resource.ts +141 -0
- package/template/apps/server/src/data-governance/export/approval-port.ts +84 -0
- package/template/apps/server/src/data-governance/export/authorization-port.test.ts +103 -0
- package/template/apps/server/src/data-governance/export/authorization-port.ts +69 -0
- package/template/apps/server/src/data-governance/export/drizzle-repository.integration.test.ts +88 -0
- package/template/apps/server/src/data-governance/export/drizzle-repository.ts +97 -0
- package/template/apps/server/src/data-governance/export/job-runtime.test.ts +339 -0
- package/template/apps/server/src/data-governance/export/job-runtime.ts +242 -0
- package/template/apps/server/src/data-governance/export/ndjson-stream.ts +62 -0
- package/template/apps/server/src/data-governance/export/postgres-api-actors.ts +140 -0
- package/template/apps/server/src/data-governance/export/postgres-api-assertions.ts +76 -0
- package/template/apps/server/src/data-governance/export/postgres-api-fixture.ts +265 -0
- package/template/apps/server/src/data-governance/export/postgres-api.integration.test.ts +298 -0
- package/template/apps/server/src/data-governance/export/postgres-recovery.integration.test.ts +344 -0
- package/template/apps/server/src/data-governance/export/repository.test.ts +55 -0
- package/template/apps/server/src/data-governance/export/repository.ts +83 -0
- package/template/apps/server/src/data-governance/export/request-fingerprint.test.ts +51 -0
- package/template/apps/server/src/data-governance/export/request-fingerprint.ts +45 -0
- package/template/apps/server/src/data-governance/export/routes-integrity.test.ts +90 -0
- package/template/apps/server/src/data-governance/export/routes-test-fixture.ts +239 -0
- package/template/apps/server/src/data-governance/export/routes.test.ts +182 -0
- package/template/apps/server/src/data-governance/export/routes.ts +215 -0
- package/template/apps/server/src/data-governance/export/scope-snapshot.test.ts +45 -0
- package/template/apps/server/src/data-governance/export/scope-snapshot.ts +27 -0
- package/template/apps/server/src/data-governance/export/service.ts +337 -0
- package/template/apps/server/src/data-governance/export/source.ts +69 -0
- package/template/apps/server/src/data-governance/export/types.ts +55 -0
- package/template/apps/server/src/data-governance/plaintext-access.test.ts +70 -0
- package/template/apps/server/src/data-governance/plaintext-access.ts +88 -0
- package/template/apps/server/src/data-governance/plaintext-postgres.integration.test.ts +223 -0
- package/template/apps/server/src/data-governance/user-plaintext-routes.test.ts +287 -0
- package/template/apps/server/src/data-governance/user-plaintext-routes.ts +181 -0
- package/template/apps/server/src/data-governance/user-projection.ts +54 -0
- package/template/apps/server/src/data-governance/user-sensitive-read-service.ts +54 -0
- package/template/apps/server/src/example-modules.ts +62 -0
- package/template/apps/server/src/example-permissions.ts +5 -0
- package/template/apps/server/src/feature/manifest-feature-repository.test.ts +187 -0
- package/template/apps/server/src/feature/manifest-feature-repository.ts +200 -0
- package/template/apps/server/src/feature/routes.authorization.test.ts +199 -0
- package/template/apps/server/src/feature/routes.ts +193 -0
- package/template/apps/server/src/foundation-access.test.ts +50 -0
- package/template/apps/server/src/foundation-access.ts +34 -0
- package/template/apps/server/src/foundation-route.ts +55 -0
- package/template/apps/server/src/foundation.ts +85 -0
- package/template/apps/server/src/guards.test.ts +74 -0
- package/template/apps/server/src/guards.ts +214 -0
- package/template/apps/server/src/http-app.test.ts +77 -0
- package/template/apps/server/src/http-app.ts +51 -0
- package/template/apps/server/src/index.ts +374 -0
- package/template/apps/server/src/jobs/artifact-service.test.ts +78 -0
- package/template/apps/server/src/jobs/artifact-service.ts +94 -0
- package/template/apps/server/src/jobs/drizzle-artifact.ts +63 -0
- package/template/apps/server/src/jobs/drizzle-claim.ts +111 -0
- package/template/apps/server/src/jobs/drizzle-execution-repository.ts +299 -0
- package/template/apps/server/src/jobs/drizzle-execution.integration.test.ts +232 -0
- package/template/apps/server/src/jobs/drizzle-lease.ts +21 -0
- package/template/apps/server/src/jobs/drizzle-mappers.ts +121 -0
- package/template/apps/server/src/jobs/drizzle-recovery-repository.ts +214 -0
- package/template/apps/server/src/jobs/drizzle-repository.integration.test.ts +135 -0
- package/template/apps/server/src/jobs/drizzle-repository.ts +268 -0
- package/template/apps/server/src/jobs/execution-repository.ts +72 -0
- package/template/apps/server/src/jobs/execution.test.ts +303 -0
- package/template/apps/server/src/jobs/handler-registry.ts +81 -0
- package/template/apps/server/src/jobs/in-memory-claim.ts +96 -0
- package/template/apps/server/src/jobs/in-memory-execution.ts +336 -0
- package/template/apps/server/src/jobs/in-memory-lease.ts +66 -0
- package/template/apps/server/src/jobs/legacy-adapter.integration.test.ts +177 -0
- package/template/apps/server/src/jobs/legacy-adapter.test.ts +199 -0
- package/template/apps/server/src/jobs/legacy-adapter.ts +109 -0
- package/template/apps/server/src/jobs/legacy-service-runtime.ts +95 -0
- package/template/apps/server/src/jobs/repository.ts +141 -0
- package/template/apps/server/src/jobs/service.test.ts +64 -0
- package/template/apps/server/src/jobs/service.ts +44 -0
- package/template/apps/server/src/jobs/types.ts +180 -0
- package/template/apps/server/src/jobs/worker.ts +258 -0
- package/template/apps/server/src/license/legacy-license-resolver.ts +23 -0
- package/template/apps/server/src/license/license-resolver.test.ts +55 -0
- package/template/apps/server/src/license/license-resolver.ts +122 -0
- package/template/apps/server/src/license/reminder.test.ts +61 -0
- package/template/apps/server/src/license/reminder.ts +33 -0
- package/template/apps/server/src/license/restriction.test.ts +54 -0
- package/template/apps/server/src/license/restriction.ts +80 -0
- package/template/apps/server/src/license/routes-offline-code.test.ts +173 -0
- package/template/apps/server/src/license/routes.ts +99 -0
- package/template/apps/server/src/license/runtime-audit-reliability.test.ts +96 -0
- package/template/apps/server/src/license/runtime-reminder.test.ts +147 -0
- package/template/apps/server/src/license/runtime-service-test-http.ts +28 -0
- package/template/apps/server/src/license/runtime-service.test.ts +334 -0
- package/template/apps/server/src/license/runtime-service.ts +308 -0
- package/template/apps/server/src/module-composition.test.ts +70 -0
- package/template/apps/server/src/module-composition.ts +28 -0
- package/template/apps/server/src/notification/drizzle-repository.ts +233 -0
- package/template/apps/server/src/notification/repository.ts +160 -0
- package/template/apps/server/src/notification/routes.test.ts +151 -0
- package/template/apps/server/src/notification/routes.ts +185 -0
- package/template/apps/server/src/observability/bootstrap.ts +56 -0
- package/template/apps/server/src/observability/http-observability.test.ts +53 -0
- package/template/apps/server/src/observability/http-observability.ts +54 -0
- package/template/apps/server/src/observability/metrics.test.ts +36 -0
- package/template/apps/server/src/observability/metrics.ts +105 -0
- package/template/apps/server/src/observability/readiness.test.ts +36 -0
- package/template/apps/server/src/observability/readiness.ts +43 -0
- package/template/apps/server/src/observability/routes.test.ts +61 -0
- package/template/apps/server/src/observability/routes.ts +44 -0
- package/template/apps/server/src/pagination.ts +31 -0
- package/template/apps/server/src/persistence.integration.test.ts +54 -0
- package/template/apps/server/src/persistence.ts +118 -0
- package/template/apps/server/src/profile/routes.test.ts +190 -0
- package/template/apps/server/src/profile/routes.ts +173 -0
- package/template/apps/server/src/request-restriction.ts +29 -0
- package/template/apps/server/src/route-guards.test.ts +148 -0
- package/template/apps/server/src/route-guards.ts +63 -0
- package/template/apps/server/src/runtime-audit-list.test.ts +98 -0
- package/template/apps/server/src/runtime-config.ts +11 -0
- package/template/apps/server/src/runtime-development.ts +68 -0
- package/template/apps/server/src/runtime-license.ts +50 -0
- package/template/apps/server/src/runtime.test.ts +264 -0
- package/template/apps/server/src/runtime.ts +324 -0
- package/template/apps/server/src/scheduler/audit.ts +38 -0
- package/template/apps/server/src/scheduler/definitions.test.ts +35 -0
- package/template/apps/server/src/scheduler/definitions.ts +79 -0
- package/template/apps/server/src/scheduler/drizzle-durable-links.ts +52 -0
- package/template/apps/server/src/scheduler/drizzle-mappers.ts +36 -0
- package/template/apps/server/src/scheduler/drizzle-repository.integration.test.ts +174 -0
- package/template/apps/server/src/scheduler/drizzle-repository.ts +348 -0
- package/template/apps/server/src/scheduler/execution-context.ts +24 -0
- package/template/apps/server/src/scheduler/execution-recorder.ts +101 -0
- package/template/apps/server/src/scheduler/feature-preflight.ts +40 -0
- package/template/apps/server/src/scheduler/history.ts +22 -0
- package/template/apps/server/src/scheduler/overview.test.ts +89 -0
- package/template/apps/server/src/scheduler/overview.ts +125 -0
- package/template/apps/server/src/scheduler/recovery-conflict.ts +19 -0
- package/template/apps/server/src/scheduler/recovery-service.test.ts +238 -0
- package/template/apps/server/src/scheduler/recovery-service.ts +152 -0
- package/template/apps/server/src/scheduler/repository.ts +274 -0
- package/template/apps/server/src/scheduler/routes.test.ts +347 -0
- package/template/apps/server/src/scheduler/routes.ts +222 -0
- package/template/apps/server/src/scheduler/sensitive-text.ts +20 -0
- package/template/apps/server/src/scheduler/service-idle.test.ts +73 -0
- package/template/apps/server/src/scheduler/service.test.ts +330 -0
- package/template/apps/server/src/scheduler/service.ts +339 -0
- package/template/apps/server/src/scheduler/types.ts +103 -0
- package/template/apps/server/src/scheduler/worker.ts +38 -0
- package/template/apps/server/src/search/config.test.ts +43 -0
- package/template/apps/server/src/search/config.ts +62 -0
- package/template/apps/server/src/search/contracts.ts +127 -0
- package/template/apps/server/src/search/cursor.ts +39 -0
- package/template/apps/server/src/search/errors.ts +11 -0
- package/template/apps/server/src/search/host.ts +36 -0
- package/template/apps/server/src/search/masking.ts +6 -0
- package/template/apps/server/src/search/provider-execution.ts +195 -0
- package/template/apps/server/src/search/rate-limiter.ts +23 -0
- package/template/apps/server/src/search/registry.ts +105 -0
- package/template/apps/server/src/search/routes.test.ts +156 -0
- package/template/apps/server/src/search/routes.ts +95 -0
- package/template/apps/server/src/search/service.test.ts +314 -0
- package/template/apps/server/src/search/service.ts +257 -0
- package/template/apps/server/src/search/test-support.ts +122 -0
- package/template/apps/server/src/session/routes.test.ts +111 -0
- package/template/apps/server/src/session/routes.ts +56 -0
- package/template/apps/server/src/settings/drizzle-repository.ts +66 -0
- package/template/apps/server/src/settings/repository.ts +29 -0
- package/template/apps/server/src/settings/routes.test.ts +250 -0
- package/template/apps/server/src/settings/routes.ts +175 -0
- package/template/apps/server/src/settings/runtime.ts +13 -0
- package/template/apps/server/src/storage/blob-reference-registry.test.ts +25 -0
- package/template/apps/server/src/storage/blob-reference-registry.ts +15 -0
- package/template/apps/server/src/storage/drizzle-upload-repository.integration.test.ts +136 -0
- package/template/apps/server/src/storage/drizzle-upload-repository.ts +248 -0
- package/template/apps/server/src/storage/route-support.ts +84 -0
- package/template/apps/server/src/storage/routes.test.ts +288 -0
- package/template/apps/server/src/storage/routes.ts +297 -0
- package/template/apps/server/src/storage/runtime.ts +86 -0
- package/template/apps/server/src/system/audit-query.ts +17 -0
- package/template/apps/server/src/system/audit-routes.test.ts +139 -0
- package/template/apps/server/src/system/audit-routes.ts +113 -0
- package/template/apps/server/src/system/built-in-roles.ts +116 -0
- package/template/apps/server/src/system/department-routes.test.ts +80 -0
- package/template/apps/server/src/system/department-routes.ts +90 -0
- package/template/apps/server/src/system/drizzle-mapping.ts +53 -0
- package/template/apps/server/src/system/drizzle-repository.ts +298 -0
- package/template/apps/server/src/system/drizzle-scoped-repository.ts +235 -0
- package/template/apps/server/src/system/drizzle-system.ts +361 -0
- package/template/apps/server/src/system/entities.ts +78 -0
- package/template/apps/server/src/system/feature-routes.test.ts +55 -0
- package/template/apps/server/src/system/identity-route-config.ts +73 -0
- package/template/apps/server/src/system/interface-catalog.test.ts +103 -0
- package/template/apps/server/src/system/interface-catalog.ts +82 -0
- package/template/apps/server/src/system/menu-registry.test.ts +125 -0
- package/template/apps/server/src/system/menu-registry.ts +259 -0
- package/template/apps/server/src/system/menu-routes.test.ts +68 -0
- package/template/apps/server/src/system/menu-routes.ts +200 -0
- package/template/apps/server/src/system/mutation-runner.ts +33 -0
- package/template/apps/server/src/system/operation-monitoring.test.ts +78 -0
- package/template/apps/server/src/system/operation-monitoring.ts +233 -0
- package/template/apps/server/src/system/operations.test.ts +269 -0
- package/template/apps/server/src/system/operations.ts +155 -0
- package/template/apps/server/src/system/postgres-monitoring.ts +31 -0
- package/template/apps/server/src/system/redis-health.test.ts +116 -0
- package/template/apps/server/src/system/redis-health.ts +230 -0
- package/template/apps/server/src/system/repository.ts +234 -0
- package/template/apps/server/src/system/resource-access-response.ts +47 -0
- package/template/apps/server/src/system/resource-export-route.ts +64 -0
- package/template/apps/server/src/system/resource-route-support.ts +50 -0
- package/template/apps/server/src/system/response-projection.ts +24 -0
- package/template/apps/server/src/system/route-helpers.ts +104 -0
- package/template/apps/server/src/system/route-test-app.ts +27 -0
- package/template/apps/server/src/system/route-types.ts +52 -0
- package/template/apps/server/src/system/routes-validation.test.ts +61 -0
- package/template/apps/server/src/system/routes.test.ts +311 -0
- package/template/apps/server/src/system/routes.ts +354 -0
- package/template/apps/server/src/system/seed.test.ts +129 -0
- package/template/apps/server/src/system/seed.ts +237 -0
- package/template/apps/server/src/system/user-account-policy.test.ts +158 -0
- package/template/apps/server/src/system/user-account-policy.ts +103 -0
- package/template/apps/server/src/system/user-data-scope.ts +10 -0
- package/template/apps/server/src/system/user-department-validation.ts +17 -0
- package/template/apps/server/src/system/user-projection.test.ts +40 -0
- package/template/apps/server/src/system/user-projection.ts +35 -0
- package/template/apps/server/src/work-order/data-scope.integration.test.ts +171 -0
- package/template/apps/server/src/work-order/drizzle-repository.integration.test.ts +78 -0
- package/template/apps/server/src/work-order/drizzle-repository.ts +67 -0
- package/template/apps/server/src/work-order/foundation-modules.test.ts +85 -0
- package/template/apps/server/src/work-order/repository.ts +46 -0
- package/template/apps/server/src/work-order/routes.test.ts +209 -0
- package/template/apps/server/src/work-order/routes.ts +159 -0
- package/template/apps/server/src/work-order/search-api.test.ts +121 -0
- package/template/apps/server/src/work-order/search-provider.test.ts +201 -0
- package/template/apps/server/src/work-order/search-provider.ts +59 -0
- package/template/apps/server/src/work-order/service.ts +82 -0
- package/template/apps/server/src/work-order/task.test.ts +79 -0
- package/template/apps/server/src/work-order/task.ts +30 -0
- package/template/apps/server/src/workflow/assignee-directory.ts +23 -0
- package/template/apps/server/src/workflow/drizzle-repository.integration.test.ts +213 -0
- package/template/apps/server/src/workflow/drizzle-repository.ts +299 -0
- package/template/apps/server/src/workflow/effects.test.ts +64 -0
- package/template/apps/server/src/workflow/effects.ts +112 -0
- package/template/apps/server/src/workflow/repository.ts +160 -0
- package/template/apps/server/src/workflow/routes.test.ts +256 -0
- package/template/apps/server/src/workflow/routes.ts +249 -0
- package/template/apps/server/src/workflow/service.ts +196 -0
- package/template/apps/server/src/workflow/timeout-runtime.test.ts +96 -0
- package/template/apps/server/src/workflow/timeout-runtime.ts +66 -0
- package/template/apps/server/tsconfig.json +17 -0
- package/template/apps/web/Dockerfile +41 -0
- package/template/apps/web/components.json +24 -0
- package/template/apps/web/dev/dev-identity.ts +58 -0
- package/template/apps/web/dev/dev-port.test.ts +53 -0
- package/template/apps/web/dev/dev-port.ts +68 -0
- package/template/apps/web/dev/start.ts +37 -0
- package/template/apps/web/index.html +14 -0
- package/template/apps/web/package.json +44 -0
- package/template/apps/web/runtime-server.test.ts +86 -0
- package/template/apps/web/runtime-server.ts +143 -0
- package/template/apps/web/server.ts +21 -0
- package/template/apps/web/src/App.vue +22 -0
- package/template/apps/web/src/app/home/HomePage.vue +75 -0
- package/template/apps/web/src/app/home/HomeWelcome.vue +85 -0
- package/template/apps/web/src/app/home/HomeWelcome.webtest.ts +32 -0
- package/template/apps/web/src/app/layouts/AppLayout.vue +10 -0
- package/template/apps/web/src/components/auth/DevelopmentAuthWarning.vue +15 -0
- package/template/apps/web/src/components/auth/LoginForm.vue +80 -0
- package/template/apps/web/src/components/auth/LoginForm.webtest.ts +33 -0
- package/template/apps/web/src/components/auth/PasswordChangeForm.vue +90 -0
- package/template/apps/web/src/components/auth/UserSessionMenu.vue +60 -0
- package/template/apps/web/src/components/auth/UserSessionMenu.webtest.ts +45 -0
- package/template/apps/web/src/components/common/ConfirmDialog.vue +75 -0
- package/template/apps/web/src/components/common/DataPagination.vue +79 -0
- package/template/apps/web/src/components/common/DataPagination.webtest.ts +28 -0
- package/template/apps/web/src/components/common/EmptyState.vue +43 -0
- package/template/apps/web/src/components/common/FormDialog.vue +86 -0
- package/template/apps/web/src/components/common/ModalBody.vue +19 -0
- package/template/apps/web/src/components/common/ModalLayout.webtest.ts +54 -0
- package/template/apps/web/src/components/common/PageError.vue +46 -0
- package/template/apps/web/src/components/common/PageLoading.vue +41 -0
- package/template/apps/web/src/components/common/StatusSummary.vue +37 -0
- package/template/apps/web/src/components/common/UnsavedChangesDialog.vue +60 -0
- package/template/apps/web/src/components/common/UnsavedChangesDialog.webtest.ts +60 -0
- package/template/apps/web/src/components/license/LicenseActivationCodeForm.vue +80 -0
- package/template/apps/web/src/components/license/LicenseExpiryBanner.vue +54 -0
- package/template/apps/web/src/components/license/LicenseFlow.webtest.ts +170 -0
- package/template/apps/web/src/components/license/LicenseStatusCard.vue +95 -0
- package/template/apps/web/src/components/license/LicenseUploadForm.vue +79 -0
- package/template/apps/web/src/components/license/license-display.ts +12 -0
- package/template/apps/web/src/components/ui/alert/Alert.vue +21 -0
- package/template/apps/web/src/components/ui/alert/AlertAction.vue +17 -0
- package/template/apps/web/src/components/ui/alert/AlertDescription.vue +22 -0
- package/template/apps/web/src/components/ui/alert/AlertTitle.vue +22 -0
- package/template/apps/web/src/components/ui/alert/index.ts +25 -0
- package/template/apps/web/src/components/ui/badge/Badge.vue +29 -0
- package/template/apps/web/src/components/ui/badge/index.ts +28 -0
- package/template/apps/web/src/components/ui/breadcrumb/Breadcrumb.vue +18 -0
- package/template/apps/web/src/components/ui/breadcrumb/BreadcrumbEllipsis.vue +26 -0
- package/template/apps/web/src/components/ui/breadcrumb/BreadcrumbItem.vue +17 -0
- package/template/apps/web/src/components/ui/breadcrumb/BreadcrumbLink.vue +24 -0
- package/template/apps/web/src/components/ui/breadcrumb/BreadcrumbList.vue +22 -0
- package/template/apps/web/src/components/ui/breadcrumb/BreadcrumbPage.vue +20 -0
- package/template/apps/web/src/components/ui/breadcrumb/BreadcrumbSeparator.vue +23 -0
- package/template/apps/web/src/components/ui/breadcrumb/index.ts +7 -0
- package/template/apps/web/src/components/ui/button/Button.vue +31 -0
- package/template/apps/web/src/components/ui/button/index.ts +42 -0
- package/template/apps/web/src/components/ui/card/Card.vue +29 -0
- package/template/apps/web/src/components/ui/card/CardAction.vue +22 -0
- package/template/apps/web/src/components/ui/card/CardContent.vue +17 -0
- package/template/apps/web/src/components/ui/card/CardDescription.vue +17 -0
- package/template/apps/web/src/components/ui/card/CardFooter.vue +22 -0
- package/template/apps/web/src/components/ui/card/CardHeader.vue +22 -0
- package/template/apps/web/src/components/ui/card/CardTitle.vue +22 -0
- package/template/apps/web/src/components/ui/card/index.ts +7 -0
- package/template/apps/web/src/components/ui/checkbox/Checkbox.vue +41 -0
- package/template/apps/web/src/components/ui/checkbox/index.ts +1 -0
- package/template/apps/web/src/components/ui/dialog/Dialog.vue +15 -0
- package/template/apps/web/src/components/ui/dialog/DialogClose.vue +12 -0
- package/template/apps/web/src/components/ui/dialog/DialogContent.vue +62 -0
- package/template/apps/web/src/components/ui/dialog/DialogDescription.vue +30 -0
- package/template/apps/web/src/components/ui/dialog/DialogFooter.vue +33 -0
- package/template/apps/web/src/components/ui/dialog/DialogHeader.vue +17 -0
- package/template/apps/web/src/components/ui/dialog/DialogOverlay.vue +28 -0
- package/template/apps/web/src/components/ui/dialog/DialogScrollContent.vue +67 -0
- package/template/apps/web/src/components/ui/dialog/DialogTitle.vue +27 -0
- package/template/apps/web/src/components/ui/dialog/DialogTrigger.vue +12 -0
- package/template/apps/web/src/components/ui/dialog/index.ts +10 -0
- package/template/apps/web/src/components/ui/dropdown-menu/DropdownMenu.vue +19 -0
- package/template/apps/web/src/components/ui/dropdown-menu/DropdownMenuCheckboxItem.vue +50 -0
- package/template/apps/web/src/components/ui/dropdown-menu/DropdownMenuContent.vue +48 -0
- package/template/apps/web/src/components/ui/dropdown-menu/DropdownMenuGroup.vue +12 -0
- package/template/apps/web/src/components/ui/dropdown-menu/DropdownMenuItem.vue +41 -0
- package/template/apps/web/src/components/ui/dropdown-menu/DropdownMenuLabel.vue +30 -0
- package/template/apps/web/src/components/ui/dropdown-menu/DropdownMenuRadioGroup.vue +21 -0
- package/template/apps/web/src/components/ui/dropdown-menu/DropdownMenuRadioItem.vue +51 -0
- package/template/apps/web/src/components/ui/dropdown-menu/DropdownMenuSeparator.vue +23 -0
- package/template/apps/web/src/components/ui/dropdown-menu/DropdownMenuShortcut.vue +22 -0
- package/template/apps/web/src/components/ui/dropdown-menu/DropdownMenuSub.vue +19 -0
- package/template/apps/web/src/components/ui/dropdown-menu/DropdownMenuSubContent.vue +34 -0
- package/template/apps/web/src/components/ui/dropdown-menu/DropdownMenuSubTrigger.vue +36 -0
- package/template/apps/web/src/components/ui/dropdown-menu/DropdownMenuTrigger.vue +17 -0
- package/template/apps/web/src/components/ui/dropdown-menu/index.ts +16 -0
- package/template/apps/web/src/components/ui/input/Input.vue +33 -0
- package/template/apps/web/src/components/ui/input/index.ts +1 -0
- package/template/apps/web/src/components/ui/select/Select.vue +15 -0
- package/template/apps/web/src/components/ui/select/SelectContent.vue +61 -0
- package/template/apps/web/src/components/ui/select/SelectGroup.vue +23 -0
- package/template/apps/web/src/components/ui/select/SelectItem.vue +49 -0
- package/template/apps/web/src/components/ui/select/SelectItemText.vue +12 -0
- package/template/apps/web/src/components/ui/select/SelectLabel.vue +19 -0
- package/template/apps/web/src/components/ui/select/SelectScrollDownButton.vue +34 -0
- package/template/apps/web/src/components/ui/select/SelectScrollUpButton.vue +34 -0
- package/template/apps/web/src/components/ui/select/SelectSeparator.vue +21 -0
- package/template/apps/web/src/components/ui/select/SelectTrigger.vue +43 -0
- package/template/apps/web/src/components/ui/select/SelectValue.vue +12 -0
- package/template/apps/web/src/components/ui/select/index.ts +11 -0
- package/template/apps/web/src/components/ui/separator/Separator.vue +30 -0
- package/template/apps/web/src/components/ui/separator/index.ts +1 -0
- package/template/apps/web/src/components/ui/sheet/Sheet.vue +15 -0
- package/template/apps/web/src/components/ui/sheet/SheetClose.vue +12 -0
- package/template/apps/web/src/components/ui/sheet/SheetContent.vue +62 -0
- package/template/apps/web/src/components/ui/sheet/SheetDescription.vue +23 -0
- package/template/apps/web/src/components/ui/sheet/SheetFooter.vue +15 -0
- package/template/apps/web/src/components/ui/sheet/SheetHeader.vue +15 -0
- package/template/apps/web/src/components/ui/sheet/SheetOverlay.vue +28 -0
- package/template/apps/web/src/components/ui/sheet/SheetTitle.vue +25 -0
- package/template/apps/web/src/components/ui/sheet/SheetTrigger.vue +12 -0
- package/template/apps/web/src/components/ui/sheet/index.ts +8 -0
- package/template/apps/web/src/components/ui/sidebar/Sidebar.vue +114 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarContent.vue +23 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarFooter.vue +18 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarGroup.vue +18 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarGroupAction.vue +29 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarGroupContent.vue +18 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarGroupLabel.vue +29 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarHeader.vue +18 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarInput.vue +19 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarInset.vue +22 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarMenu.vue +18 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarMenuAction.vue +37 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarMenuBadge.vue +23 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarMenuButton.vue +60 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarMenuButtonChild.vue +36 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarMenuItem.vue +18 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarMenuSkeleton.vue +35 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarMenuSub.vue +23 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarMenuSubButton.vue +39 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarMenuSubItem.vue +18 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarProvider.vue +128 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarRail.vue +94 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarSeparator.vue +19 -0
- package/template/apps/web/src/components/ui/sidebar/SidebarTrigger.vue +28 -0
- package/template/apps/web/src/components/ui/sidebar/index.ts +62 -0
- package/template/apps/web/src/components/ui/sidebar/sidebar-width.ts +29 -0
- package/template/apps/web/src/components/ui/sidebar/sidebar-width.webtest.ts +28 -0
- package/template/apps/web/src/components/ui/sidebar/utils.ts +26 -0
- package/template/apps/web/src/components/ui/skeleton/Skeleton.vue +17 -0
- package/template/apps/web/src/components/ui/skeleton/index.ts +1 -0
- package/template/apps/web/src/components/ui/sonner/Sonner.vue +70 -0
- package/template/apps/web/src/components/ui/sonner/index.ts +1 -0
- package/template/apps/web/src/components/ui/switch/Switch.vue +47 -0
- package/template/apps/web/src/components/ui/switch/Switch.webtest.ts +23 -0
- package/template/apps/web/src/components/ui/switch/index.ts +1 -0
- package/template/apps/web/src/components/ui/table/Table.vue +19 -0
- package/template/apps/web/src/components/ui/table/TableBody.vue +17 -0
- package/template/apps/web/src/components/ui/table/TableCaption.vue +17 -0
- package/template/apps/web/src/components/ui/table/TableCell.vue +22 -0
- package/template/apps/web/src/components/ui/table/TableEmpty.vue +37 -0
- package/template/apps/web/src/components/ui/table/TableFooter.vue +19 -0
- package/template/apps/web/src/components/ui/table/TableHead.vue +22 -0
- package/template/apps/web/src/components/ui/table/TableHeader.vue +14 -0
- package/template/apps/web/src/components/ui/table/TableRow.vue +22 -0
- package/template/apps/web/src/components/ui/table/index.ts +9 -0
- package/template/apps/web/src/components/ui/table/utils.ts +10 -0
- package/template/apps/web/src/components/ui/tabs/Tabs.vue +27 -0
- package/template/apps/web/src/components/ui/tabs/TabsContent.vue +23 -0
- package/template/apps/web/src/components/ui/tabs/TabsList.vue +34 -0
- package/template/apps/web/src/components/ui/tabs/TabsTrigger.vue +33 -0
- package/template/apps/web/src/components/ui/tabs/index.ts +24 -0
- package/template/apps/web/src/components/ui/tooltip/Tooltip.vue +15 -0
- package/template/apps/web/src/components/ui/tooltip/TooltipContent.vue +49 -0
- package/template/apps/web/src/components/ui/tooltip/TooltipProvider.vue +14 -0
- package/template/apps/web/src/components/ui/tooltip/TooltipTrigger.vue +12 -0
- package/template/apps/web/src/components/ui/tooltip/index.ts +4 -0
- package/template/apps/web/src/composables/useAccessSnapshot.ts +55 -0
- package/template/apps/web/src/composables/useAccessSnapshot.webtest.ts +39 -0
- package/template/apps/web/src/composables/useAppToast.ts +30 -0
- package/template/apps/web/src/composables/useAuthSession.ts +127 -0
- package/template/apps/web/src/composables/useAuthSession.webtest.ts +48 -0
- package/template/apps/web/src/composables/useLicenseReminderRefresh.ts +27 -0
- package/template/apps/web/src/composables/useLicenseReminderRefresh.webtest.ts +30 -0
- package/template/apps/web/src/composables/useLicenseRuntime.ts +90 -0
- package/template/apps/web/src/composables/useLoginFlow.ts +39 -0
- package/template/apps/web/src/composables/useModuleConfigurations.ts +116 -0
- package/template/apps/web/src/composables/usePasswordChange.ts +31 -0
- package/template/apps/web/src/composables/usePlatformSettings.ts +90 -0
- package/template/apps/web/src/composables/useSessionContext.ts +56 -0
- package/template/apps/web/src/composables/useTheme.ts +123 -0
- package/template/apps/web/src/composables/useUnsavedChangesConfirmation.ts +55 -0
- package/template/apps/web/src/composables/useWatermarkSettings.ts +56 -0
- package/template/apps/web/src/composables/watermark-settings.ts +45 -0
- package/template/apps/web/src/composables/watermark-settings.webtest.ts +38 -0
- package/template/apps/web/src/env.d.ts +17 -0
- package/template/apps/web/src/layout/AppHeader.vue +107 -0
- package/template/apps/web/src/layout/AppShell.vue +55 -0
- package/template/apps/web/src/layout/AppShell.webtest.ts +75 -0
- package/template/apps/web/src/layout/AppSidebar.vue +262 -0
- package/template/apps/web/src/layout/AppSidebar.webtest.ts +167 -0
- package/template/apps/web/src/layout/GlobalWatermark.vue +38 -0
- package/template/apps/web/src/layout/NavigationSearchDialog.vue +166 -0
- package/template/apps/web/src/layout/NavigationSearchDialog.webtest.ts +84 -0
- package/template/apps/web/src/layout/NotificationMenu.vue +174 -0
- package/template/apps/web/src/layout/NotificationMenu.webtest.ts +102 -0
- package/template/apps/web/src/layout/ThemeToggle.vue +44 -0
- package/template/apps/web/src/layout/navigation.ts +103 -0
- package/template/apps/web/src/layout/navigation.webtest.ts +99 -0
- package/template/apps/web/src/lib/date-time.ts +21 -0
- package/template/apps/web/src/lib/date-time.webtest.ts +14 -0
- package/template/apps/web/src/lib/utils.ts +7 -0
- package/template/apps/web/src/main.ts +11 -0
- package/template/apps/web/src/pages/AccessDeniedPage.vue +61 -0
- package/template/apps/web/src/pages/auth/ChangePasswordPage.vue +46 -0
- package/template/apps/web/src/pages/auth/LoginPage.vue +63 -0
- package/template/apps/web/src/pages/configuration/ModuleConfigurationPage.vue +15 -0
- package/template/apps/web/src/pages/configuration/components/ModuleConfigRollbackDialog.vue +51 -0
- package/template/apps/web/src/pages/configuration/components/ModuleConfigVersionList.vue +116 -0
- package/template/apps/web/src/pages/configuration/components/ModuleConfigurationEditor.vue +126 -0
- package/template/apps/web/src/pages/configuration/components/ModuleConfigurationEditor.webtest.ts +73 -0
- package/template/apps/web/src/pages/configuration/components/ModuleConfigurationWorkbench.vue +236 -0
- package/template/apps/web/src/pages/dashboard/DashboardPage.vue +39 -0
- package/template/apps/web/src/pages/dashboard/DashboardPage.webtest.ts +37 -0
- package/template/apps/web/src/pages/dashboard/components/DashboardAttention.vue +36 -0
- package/template/apps/web/src/pages/dashboard/components/DashboardMetricCards.vue +28 -0
- package/template/apps/web/src/pages/dashboard/dashboard-presenter.ts +115 -0
- package/template/apps/web/src/pages/dashboard/dashboard-presenter.webtest.ts +92 -0
- package/template/apps/web/src/pages/license/LicensePage.vue +65 -0
- package/template/apps/web/src/pages/profile/PersonalSettingsPage.vue +177 -0
- package/template/apps/web/src/pages/profile/PersonalSettingsPage.webtest.ts +78 -0
- package/template/apps/web/src/pages/settings/BrandingSettingsSection.vue +198 -0
- package/template/apps/web/src/pages/settings/GlobalSettingsPage.vue +195 -0
- package/template/apps/web/src/pages/settings/GlobalSettingsPage.webtest.ts +314 -0
- package/template/apps/web/src/pages/settings/WatermarkSettingsSection.vue +115 -0
- package/template/apps/web/src/pages/settings/logo-file.ts +23 -0
- package/template/apps/web/src/pages/settings/logo-file.webtest.ts +14 -0
- package/template/apps/web/src/pages/system/SystemNotificationsPage.vue +262 -0
- package/template/apps/web/src/pages/system/SystemNotificationsPage.webtest.ts +88 -0
- package/template/apps/web/src/pages/system/SystemOperationsPage.vue +151 -0
- package/template/apps/web/src/pages/system/SystemOperationsPage.webtest.ts +146 -0
- package/template/apps/web/src/pages/system/SystemResourceRoutePage.vue +80 -0
- package/template/apps/web/src/pages/system/SystemResourceRoutePage.webtest.ts +100 -0
- package/template/apps/web/src/pages/system/components/AuditActionCell.vue +87 -0
- package/template/apps/web/src/pages/system/components/AuditActionCell.webtest.ts +66 -0
- package/template/apps/web/src/pages/system/components/AuditLogFilters.vue +119 -0
- package/template/apps/web/src/pages/system/components/AuditLogFilters.webtest.ts +59 -0
- package/template/apps/web/src/pages/system/components/DiskUsageChart.vue +62 -0
- package/template/apps/web/src/pages/system/components/FeatureLicensePolicyDialog.vue +136 -0
- package/template/apps/web/src/pages/system/components/FeatureLicensePolicyDialog.webtest.ts +67 -0
- package/template/apps/web/src/pages/system/components/NotificationPublishForm.vue +57 -0
- package/template/apps/web/src/pages/system/components/OperationCacheMonitor.vue +73 -0
- package/template/apps/web/src/pages/system/components/OperationOnlineUsers.vue +60 -0
- package/template/apps/web/src/pages/system/components/OperationOnlineUsers.webtest.ts +35 -0
- package/template/apps/web/src/pages/system/components/OperationServiceMonitor.vue +118 -0
- package/template/apps/web/src/pages/system/components/OperationServiceMonitor.webtest.ts +64 -0
- package/template/apps/web/src/pages/system/components/SchedulerOperationsPanel.vue +297 -0
- package/template/apps/web/src/pages/system/components/SchedulerOperationsPanel.webtest.ts +145 -0
- package/template/apps/web/src/pages/system/components/SchedulerRunTable.vue +127 -0
- package/template/apps/web/src/pages/system/components/SchedulerRunTable.webtest.ts +75 -0
- package/template/apps/web/src/pages/system/components/SchedulerStaleRecoveryForm.vue +125 -0
- package/template/apps/web/src/pages/system/components/SchedulerStaleRecoveryForm.webtest.ts +84 -0
- package/template/apps/web/src/pages/system/components/SystemResourceFilters.vue +64 -0
- package/template/apps/web/src/pages/system/components/SystemResourceForm.vue +102 -0
- package/template/apps/web/src/pages/system/components/SystemResourcePage.vue +360 -0
- package/template/apps/web/src/pages/system/components/SystemResourcePage.webtest.ts +263 -0
- package/template/apps/web/src/pages/system/components/SystemResourceTable.vue +242 -0
- package/template/apps/web/src/pages/system/components/SystemResourceTable.webtest.ts +196 -0
- package/template/apps/web/src/pages/system/components/dictionary-bulk/DictionaryBulkActions.vue +142 -0
- package/template/apps/web/src/pages/system/components/dictionary-bulk/DictionaryBulkJobDetail.vue +109 -0
- package/template/apps/web/src/pages/system/components/dictionary-bulk/DictionaryBulkJobList.vue +127 -0
- package/template/apps/web/src/pages/system/components/dictionary-bulk/DictionaryBulkPanel.vue +72 -0
- package/template/apps/web/src/pages/system/components/dictionary-bulk/DictionaryBulkPanel.webtest.ts +255 -0
- package/template/apps/web/src/pages/system/components/feature-license-policy.ts +12 -0
- package/template/apps/web/src/pages/system/components/menu-management/MenuManagementPage.vue +131 -0
- package/template/apps/web/src/pages/system/components/menu-management/MenuManagementPage.webtest.ts +228 -0
- package/template/apps/web/src/pages/system/components/menu-management/MenuStructureTable.vue +230 -0
- package/template/apps/web/src/pages/system/components/menu-management/menu-model.ts +161 -0
- package/template/apps/web/src/pages/system/components/menu-management/menu-model.webtest.ts +133 -0
- package/template/apps/web/src/pages/system/components/menu-management/useMenuManagement.ts +117 -0
- package/template/apps/web/src/pages/system/components/role-policy/RolePermissionTree.vue +144 -0
- package/template/apps/web/src/pages/system/components/role-policy/RolePermissionTree.webtest.ts +55 -0
- package/template/apps/web/src/pages/system/components/role-policy/RolePolicyForm.vue +134 -0
- package/template/apps/web/src/pages/system/components/role-policy/permission-tree.ts +58 -0
- package/template/apps/web/src/pages/system/components/role-policy/permission-tree.webtest.ts +80 -0
- package/template/apps/web/src/pages/system/components/user-account/UserAccountForm.vue +307 -0
- package/template/apps/web/src/pages/system/components/user-account/UserRoleSelector.vue +111 -0
- package/template/apps/web/src/pages/system/components/user-account/UserRoleSelector.webtest.ts +45 -0
- package/template/apps/web/src/pages/system/components/user-account/save-user-account.ts +47 -0
- package/template/apps/web/src/pages/system/composables/useDictionaryBulkJobs.ts +152 -0
- package/template/apps/web/src/pages/system/composables/useFeatureLicenseEditor.ts +38 -0
- package/template/apps/web/src/pages/system/composables/useSchedulerOperations.ts +141 -0
- package/template/apps/web/src/pages/system/composables/useSchedulerOperations.webtest.ts +224 -0
- package/template/apps/web/src/pages/system/composables/useSystemResource.ts +269 -0
- package/template/apps/web/src/pages/system/composables/useSystemResource.webtest.ts +51 -0
- package/template/apps/web/src/pages/system/dictionary-bulk-presenter.ts +126 -0
- package/template/apps/web/src/pages/system/resource-config.ts +233 -0
- package/template/apps/web/src/router/auth-navigation.ts +76 -0
- package/template/apps/web/src/router/index.ts +246 -0
- package/template/apps/web/src/router/index.webtest.ts +396 -0
- package/template/apps/web/src/router/manifest-routes.ts +59 -0
- package/template/apps/web/src/services/access-api.ts +26 -0
- package/template/apps/web/src/services/auth-api.ts +72 -0
- package/template/apps/web/src/services/bulk-data-api.ts +105 -0
- package/template/apps/web/src/services/configuration-api.ts +43 -0
- package/template/apps/web/src/services/http.ts +145 -0
- package/template/apps/web/src/services/http.webtest.ts +73 -0
- package/template/apps/web/src/services/license-api.ts +53 -0
- package/template/apps/web/src/services/notification-api.ts +51 -0
- package/template/apps/web/src/services/operations-api.ts +128 -0
- package/template/apps/web/src/services/platform-settings-api.ts +21 -0
- package/template/apps/web/src/services/profile-api.ts +17 -0
- package/template/apps/web/src/services/session-context-api.ts +20 -0
- package/template/apps/web/src/services/system-api.ts +156 -0
- package/template/apps/web/src/style.css +142 -0
- package/template/apps/web/src/style.webtest.ts +18 -0
- package/template/apps/web/tsconfig.json +23 -0
- package/template/apps/web/vite.config.ts +26 -0
- package/template/apps/web/vitest.config.ts +14 -0
- package/template/bunfig.toml +2 -0
- package/template/docker-compose.yml +74 -0
- package/template/docs/adapters/ruoyi-vue-compatibility.md +93 -0
- package/template/docs/architecture/admin-surface-boundary.md +24 -0
- package/template/docs/architecture/data-scope-query-enforcement.md +26 -0
- package/template/docs/architecture/durable-jobs.md +101 -0
- package/template/docs/architecture/minimal-approval-workflow.md +60 -0
- package/template/docs/architecture/module-manifest-composition.md +47 -0
- package/template/docs/architecture/object-storage.md +65 -0
- package/template/docs/architecture/search-provider-protocol.md +59 -0
- package/template/docs/development/crud-generator.md +57 -0
- package/template/docs/license/license-offline-activation-code.md +67 -0
- package/template/docs/operations/observability.md +50 -0
- package/template/docs/platform/agent-tools.md +37 -0
- package/template/docs/platform/audit-reliability.md +95 -0
- package/template/docs/platform/bulk-data-jobs.md +156 -0
- package/template/docs/platform/data-access-control.md +62 -0
- package/template/docs/platform/module-configuration.md +98 -0
- package/template/docs/platform/navigation-registry.md +36 -0
- package/template/docs/platform/notifications.md +33 -0
- package/template/docs/platform/operations-overview.md +35 -0
- package/template/docs/platform/organization-membership.md +31 -0
- package/template/docs/platform/platform-authentication.md +127 -0
- package/template/docs/platform/platform-shell-settings.md +88 -0
- package/template/docs/platform/scheduled-task-executor.md +89 -0
- package/template/docs/platform/system-crud-api.md +100 -0
- package/template/docs/platform/web-system-crud.md +96 -0
- package/template/docs/product/built-in-roles.md +26 -0
- package/template/drizzle.config.ts +16 -0
- package/template/examples/inventory-item.crud.json +55 -0
- package/template/package.json +55 -0
- package/template/packages/config/index.test.ts +114 -0
- package/template/packages/config/index.ts +4 -0
- package/template/packages/config/package.json +13 -0
- package/template/packages/config/src/definition.ts +109 -0
- package/template/packages/config/src/environment-loader.ts +240 -0
- package/template/packages/config/src/platform.ts +185 -0
- package/template/packages/config/src/secrets.ts +69 -0
- package/template/packages/crud-generator/index.ts +3 -0
- package/template/packages/crud-generator/package.json +12 -0
- package/template/packages/crud-generator/src/cli.ts +31 -0
- package/template/packages/crud-generator/src/definition.ts +48 -0
- package/template/packages/crud-generator/src/generator.test.ts +180 -0
- package/template/packages/crud-generator/src/generator.ts +99 -0
- package/template/packages/crud-generator/src/template-helpers.ts +72 -0
- package/template/packages/crud-generator/src/templates/domain.ts +27 -0
- package/template/packages/crud-generator/src/templates/drizzle-repository.ts +126 -0
- package/template/packages/crud-generator/src/templates/dto.ts +19 -0
- package/template/packages/crud-generator/src/templates/index.ts +8 -0
- package/template/packages/crud-generator/src/templates/manifest.ts +69 -0
- package/template/packages/crud-generator/src/templates/project.ts +161 -0
- package/template/packages/crud-generator/src/templates/repository.ts +23 -0
- package/template/packages/crud-generator/src/templates/routes.ts +158 -0
- package/template/packages/crud-generator/src/templates/schema.ts +45 -0
- package/template/packages/crud-generator/src/templates/service.ts +32 -0
- package/template/packages/crud-generator/src/validation.ts +205 -0
- package/template/packages/crud-generator/tsconfig.json +15 -0
- package/template/packages/database/drizzle/0000_organic_madame_web.sql +136 -0
- package/template/packages/database/drizzle/0001_flawless_senator_kelly.sql +80 -0
- package/template/packages/database/drizzle/0002_woozy_squadron_supreme.sql +53 -0
- package/template/packages/database/drizzle/0003_far_carnage.sql +17 -0
- package/template/packages/database/drizzle/0004_flat_bastion.sql +2 -0
- package/template/packages/database/drizzle/0005_fixed_enchantress.sql +6 -0
- package/template/packages/database/drizzle/0006_groovy_overlord.sql +146 -0
- package/template/packages/database/drizzle/0007_chubby_may_parker.sql +9 -0
- package/template/packages/database/drizzle/0008_secret_toxin.sql +21 -0
- package/template/packages/database/drizzle/0009_ambiguous_adam_warlock.sql +46 -0
- package/template/packages/database/drizzle/0010_complex_orphan.sql +42 -0
- package/template/packages/database/drizzle/0011_lowly_maria_hill.sql +42 -0
- package/template/packages/database/drizzle/0012_serious_marvex.sql +11 -0
- package/template/packages/database/drizzle/0013_mysterious_miek.sql +48 -0
- package/template/packages/database/drizzle/0014_graceful_husk.sql +1 -0
- package/template/packages/database/drizzle/0015_illegal_jazinda.sql +29 -0
- package/template/packages/database/drizzle/0016_seed_platform_roles.sql +21 -0
- package/template/packages/database/drizzle/0017_silly_thunderbolt.sql +35 -0
- package/template/packages/database/drizzle/0018_cheerful_alex_power.sql +22 -0
- package/template/packages/database/drizzle/0019_omniscient_luckman.sql +3 -0
- package/template/packages/database/drizzle/0020_handy_vertigo.sql +18 -0
- package/template/packages/database/drizzle/0021_plain_paladin.sql +51 -0
- package/template/packages/database/drizzle/0022_icy_rhodey.sql +2 -0
- package/template/packages/database/drizzle/0023_fresh_thunderbolt_ross.sql +138 -0
- package/template/packages/database/drizzle/0024_misty_lizard.sql +13 -0
- package/template/packages/database/drizzle/0025_premium_songbird.sql +6 -0
- package/template/packages/database/drizzle/0026_aberrant_doctor_octopus.sql +42 -0
- package/template/packages/database/drizzle/0027_tiny_diamondback.sql +5 -0
- package/template/packages/database/drizzle/0028_condemned_ulik.sql +27 -0
- package/template/packages/database/drizzle/0029_clean_nightshade.sql +5 -0
- package/template/packages/database/drizzle/0030_governed_export_constraints.sql +84 -0
- package/template/packages/database/drizzle/meta/0000_snapshot.json +973 -0
- package/template/packages/database/drizzle/meta/0001_snapshot.json +1559 -0
- package/template/packages/database/drizzle/meta/0002_snapshot.json +1911 -0
- package/template/packages/database/drizzle/meta/0003_snapshot.json +2047 -0
- package/template/packages/database/drizzle/meta/0004_snapshot.json +2059 -0
- package/template/packages/database/drizzle/meta/0005_snapshot.json +2084 -0
- package/template/packages/database/drizzle/meta/0006_snapshot.json +3192 -0
- package/template/packages/database/drizzle/meta/0007_snapshot.json +3208 -0
- package/template/packages/database/drizzle/meta/0008_snapshot.json +3367 -0
- package/template/packages/database/drizzle/meta/0009_snapshot.json +3629 -0
- package/template/packages/database/drizzle/meta/0010_snapshot.json +3955 -0
- package/template/packages/database/drizzle/meta/0011_snapshot.json +4299 -0
- package/template/packages/database/drizzle/meta/0012_snapshot.json +4368 -0
- package/template/packages/database/drizzle/meta/0013_snapshot.json +4483 -0
- package/template/packages/database/drizzle/meta/0014_snapshot.json +4489 -0
- package/template/packages/database/drizzle/meta/0015_snapshot.json +4771 -0
- package/template/packages/database/drizzle/meta/0016_snapshot.json +4694 -0
- package/template/packages/database/drizzle/meta/0017_snapshot.json +4731 -0
- package/template/packages/database/drizzle/meta/0018_snapshot.json +4978 -0
- package/template/packages/database/drizzle/meta/0019_snapshot.json +4996 -0
- package/template/packages/database/drizzle/meta/0020_snapshot.json +5140 -0
- package/template/packages/database/drizzle/meta/0021_snapshot.json +5535 -0
- package/template/packages/database/drizzle/meta/0022_snapshot.json +5541 -0
- package/template/packages/database/drizzle/meta/0023_snapshot.json +6667 -0
- package/template/packages/database/drizzle/meta/0024_snapshot.json +6780 -0
- package/template/packages/database/drizzle/meta/0025_snapshot.json +6849 -0
- package/template/packages/database/drizzle/meta/0026_snapshot.json +7185 -0
- package/template/packages/database/drizzle/meta/0027_snapshot.json +7225 -0
- package/template/packages/database/drizzle/meta/0028_snapshot.json +7454 -0
- package/template/packages/database/drizzle/meta/0029_snapshot.json +7460 -0
- package/template/packages/database/drizzle/meta/0030_snapshot.json +7473 -0
- package/template/packages/database/drizzle/meta/_journal.json +223 -0
- package/template/packages/database/index.ts +5 -0
- package/template/packages/database/package.json +17 -0
- package/template/packages/database/src/dialects.test.ts +33 -0
- package/template/packages/database/src/dialects.ts +139 -0
- package/template/packages/database/src/runner.test.ts +96 -0
- package/template/packages/database/src/runner.ts +175 -0
- package/template/packages/database/src/schema/bulk-data.ts +87 -0
- package/template/packages/database/src/schema/common.ts +33 -0
- package/template/packages/database/src/schema/durable-jobs.ts +266 -0
- package/template/packages/database/src/schema/file-storage.ts +94 -0
- package/template/packages/database/src/schema/governance.ts +195 -0
- package/template/packages/database/src/schema/governed-exports.ts +90 -0
- package/template/packages/database/src/schema/identity.ts +169 -0
- package/template/packages/database/src/schema/index.ts +33 -0
- package/template/packages/database/src/schema/license-legacy.ts +93 -0
- package/template/packages/database/src/schema/license-v1.ts +246 -0
- package/template/packages/database/src/schema/migration-history.ts +30 -0
- package/template/packages/database/src/schema/notifications.ts +60 -0
- package/template/packages/database/src/schema/platform-settings.ts +55 -0
- package/template/packages/database/src/schema/scheduler.ts +89 -0
- package/template/packages/database/src/schema/work-orders.ts +23 -0
- package/template/packages/database/src/schema/workflow.ts +86 -0
- package/template/packages/database/src/schema-durable-links.test.ts +27 -0
- package/template/packages/database/src/schema-governed-exports.test.ts +49 -0
- package/template/packages/database/src/schema-workflow-notification.test.ts +63 -0
- package/template/packages/database/src/schema.test.ts +343 -0
- package/template/packages/database/src/sql-store.test.ts +92 -0
- package/template/packages/database/src/sql-store.ts +101 -0
- package/template/packages/database/src/store.ts +32 -0
- package/template/packages/database/tsconfig.json +17 -0
- package/template/packages/example-work-order/index.ts +3 -0
- package/template/packages/example-work-order/package.json +13 -0
- package/template/packages/example-work-order/src/contract.ts +50 -0
- package/template/packages/example-work-order/src/manifest.test.ts +54 -0
- package/template/packages/example-work-order/src/manifest.ts +120 -0
- package/template/packages/example-work-order/src/schema.ts +27 -0
- package/template/packages/license-sdk/index.ts +13 -0
- package/template/packages/license-sdk/package.json +18 -0
- package/template/packages/license-sdk/src/bounded-json-body.test.ts +65 -0
- package/template/packages/license-sdk/src/bounded-json-body.ts +135 -0
- package/template/packages/license-sdk/src/canonical-json.test.ts +28 -0
- package/template/packages/license-sdk/src/canonical-json.ts +104 -0
- package/template/packages/license-sdk/src/client.test.ts +82 -0
- package/template/packages/license-sdk/src/client.ts +86 -0
- package/template/packages/license-sdk/src/device.ts +46 -0
- package/template/packages/license-sdk/src/file-storage.test.ts +80 -0
- package/template/packages/license-sdk/src/file-storage.ts +77 -0
- package/template/packages/license-sdk/src/installation.test.ts +241 -0
- package/template/packages/license-sdk/src/installation.ts +150 -0
- package/template/packages/license-sdk/src/license-parser.ts +56 -0
- package/template/packages/license-sdk/src/offline-code-base32.ts +57 -0
- package/template/packages/license-sdk/src/offline-code-decompression.ts +55 -0
- package/template/packages/license-sdk/src/offline-code-limits.ts +10 -0
- package/template/packages/license-sdk/src/offline-code-wire.ts +72 -0
- package/template/packages/license-sdk/src/offline-code.test.ts +172 -0
- package/template/packages/license-sdk/src/offline-code.ts +319 -0
- package/template/packages/license-sdk/src/payload.test.ts +72 -0
- package/template/packages/license-sdk/src/payload.ts +201 -0
- package/template/packages/license-sdk/src/storage.ts +64 -0
- package/template/packages/license-sdk/src/test-fixtures.ts +59 -0
- package/template/packages/license-sdk/src/v1-test-vector.ts +49 -0
- package/template/packages/license-sdk/src/validation.test.ts +62 -0
- package/template/packages/license-sdk/src/validation.ts +143 -0
- package/template/packages/license-sdk/src/verification.test.ts +97 -0
- package/template/packages/license-sdk/src/verification.ts +199 -0
- package/template/packages/license-sdk/tsconfig.json +17 -0
- package/template/packages/modules/index.ts +8 -0
- package/template/packages/modules/package.json +13 -0
- package/template/packages/modules/src/composition.test.ts +267 -0
- package/template/packages/modules/src/composition.ts +342 -0
- package/template/packages/modules/src/installed-business-modules.ts +10 -0
- package/template/packages/modules/src/manifest.ts +97 -0
- package/template/packages/modules/src/menu-composition.test.ts +64 -0
- package/template/packages/modules/src/menu-composition.ts +54 -0
- package/template/packages/modules/src/registry.ts +53 -0
- package/template/packages/modules/src/system-admin-routes.ts +134 -0
- package/template/packages/modules/src/system-agent-tools.ts +28 -0
- package/template/packages/modules/src/system-api-binding.ts +37 -0
- package/template/packages/modules/src/system-api-data-governance.ts +21 -0
- package/template/packages/modules/src/system-api-permissions.ts +344 -0
- package/template/packages/modules/src/system-audit-actions.ts +70 -0
- package/template/packages/modules/src/system-data-governance.ts +30 -0
- package/template/packages/modules/src/system-features.ts +143 -0
- package/template/packages/modules/src/system-governed-export-bindings.ts +31 -0
- package/template/packages/modules/src/system-module-catalog.test.ts +145 -0
- package/template/packages/modules/src/system-module-catalog.ts +250 -0
- package/template/packages/modules/src/system-modules.test.ts +344 -0
- package/template/packages/modules/src/system-modules.ts +335 -0
- package/template/packages/modules/src/system-permissions.ts +142 -0
- package/template/packages/modules/user/module.ts +72 -0
- package/template/packages/shared/index.ts +16 -0
- package/template/packages/shared/package.json +9 -0
- package/template/packages/shared/src/audit.test.ts +17 -0
- package/template/packages/shared/src/audit.ts +237 -0
- package/template/packages/shared/src/correlation.test.ts +10 -0
- package/template/packages/shared/src/correlation.ts +11 -0
- package/template/packages/shared/src/data-governance.test.ts +44 -0
- package/template/packages/shared/src/data-governance.ts +89 -0
- package/template/packages/shared/src/database.ts +67 -0
- package/template/packages/shared/src/feature.test.ts +54 -0
- package/template/packages/shared/src/feature.ts +104 -0
- package/template/packages/shared/src/license-legacy.ts +153 -0
- package/template/packages/shared/src/license.test.ts +63 -0
- package/template/packages/shared/src/license.ts +267 -0
- package/template/packages/shared/src/module-configuration.ts +50 -0
- package/template/packages/shared/src/notification.ts +46 -0
- package/template/packages/shared/src/platform-settings.ts +5 -0
- package/template/packages/shared/src/primitives.ts +47 -0
- package/template/packages/shared/src/profile.ts +13 -0
- package/template/packages/shared/src/rbac.ts +117 -0
- package/template/packages/shared/src/ruoyi.ts +98 -0
- package/template/packages/shared/src/scheduler.ts +108 -0
- package/template/packages/shared/src/search-provider.ts +24 -0
- package/template/packages/shared/src/workflow.test.ts +225 -0
- package/template/packages/shared/src/workflow.ts +307 -0
- package/template/packages/storage/index.ts +11 -0
- package/template/packages/storage/package.json +12 -0
- package/template/packages/storage/src/blob-store.ts +64 -0
- package/template/packages/storage/src/content-hash.ts +24 -0
- package/template/packages/storage/src/file-service.test.ts +100 -0
- package/template/packages/storage/src/file-service.ts +59 -0
- package/template/packages/storage/src/in-memory-upload-repository.ts +154 -0
- package/template/packages/storage/src/local-file-blob-store.test.ts +175 -0
- package/template/packages/storage/src/local-file-blob-store.ts +344 -0
- package/template/packages/storage/src/local-file-maintenance.ts +133 -0
- package/template/packages/storage/src/memory-blob-store.test.ts +16 -0
- package/template/packages/storage/src/memory-blob-store.ts +100 -0
- package/template/packages/storage/src/upload-repository.ts +43 -0
- package/template/packages/storage/src/upload-service.test.ts +246 -0
- package/template/packages/storage/src/upload-service.ts +334 -0
- package/template/packages/storage/src/upload-streams.ts +123 -0
- package/template/packages/storage/src/upload-types.ts +110 -0
- package/template/packages/storage/tsconfig.json +16 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { entitlementKey, licenseVersionKey } from "@windy/shared";
|
|
3
|
+
import { createFoundationSnapshot } from "../foundation.js";
|
|
4
|
+
import { createServerRuntime } from "../runtime.js";
|
|
5
|
+
import { InMemorySchedulerRepository } from "./repository.js";
|
|
6
|
+
import { SchedulerService } from "./service.js";
|
|
7
|
+
import type { ScheduledTaskDefinition, SchedulerClock } from "./types.js";
|
|
8
|
+
|
|
9
|
+
class FakeClock implements SchedulerClock {
|
|
10
|
+
constructor(private current: Date) {}
|
|
11
|
+
|
|
12
|
+
now() {
|
|
13
|
+
return new Date(this.current);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
advance(seconds: number) {
|
|
17
|
+
this.current = new Date(this.current.getTime() + seconds * 1_000);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
describe("SchedulerService", () => {
|
|
22
|
+
test("重复 tick 不会并发执行同一任务", async () => {
|
|
23
|
+
const clock = new FakeClock(new Date("2026-07-10T00:00:00.000Z"));
|
|
24
|
+
let release: () => void = () => undefined;
|
|
25
|
+
const barrier = new Promise<void>((resolve) => (release = resolve));
|
|
26
|
+
let executions = 0;
|
|
27
|
+
const fixture = await createFixture(clock, async () => {
|
|
28
|
+
executions += 1;
|
|
29
|
+
await barrier;
|
|
30
|
+
return { execution: executions };
|
|
31
|
+
});
|
|
32
|
+
clock.advance(100);
|
|
33
|
+
|
|
34
|
+
const firstTick = fixture.scheduler.tick();
|
|
35
|
+
await until(() => executions === 1);
|
|
36
|
+
const duplicate = await fixture.scheduler.tick();
|
|
37
|
+
release();
|
|
38
|
+
const first = await firstTick;
|
|
39
|
+
|
|
40
|
+
expect(first.scheduled).toBe(1);
|
|
41
|
+
expect(duplicate.scheduled).toBe(0);
|
|
42
|
+
expect(executions).toBe(1);
|
|
43
|
+
expect(await fixture.scheduler.listRuns()).toEqual([
|
|
44
|
+
expect.objectContaining({ status: "succeeded", attempt: 1 }),
|
|
45
|
+
]);
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
test("失败按 fake clock 延迟重试并保留每次历史", async () => {
|
|
49
|
+
const clock = new FakeClock(new Date("2026-07-10T00:00:00.000Z"));
|
|
50
|
+
let executions = 0;
|
|
51
|
+
const fixture = await createFixture(clock, () => {
|
|
52
|
+
executions += 1;
|
|
53
|
+
if (executions < 3) throw new Error(`第 ${executions} 次失败`);
|
|
54
|
+
return { recovered: true };
|
|
55
|
+
});
|
|
56
|
+
clock.advance(100);
|
|
57
|
+
|
|
58
|
+
expect(await fixture.scheduler.tick()).toMatchObject({
|
|
59
|
+
scheduled: 1,
|
|
60
|
+
failed: 1,
|
|
61
|
+
});
|
|
62
|
+
expect((await fixture.scheduler.listRuns())[0]).toMatchObject({
|
|
63
|
+
status: "retry-pending",
|
|
64
|
+
attempt: 1,
|
|
65
|
+
error: "第 1 次失败",
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
clock.advance(9);
|
|
69
|
+
expect((await fixture.scheduler.tick()).retried).toBe(0);
|
|
70
|
+
clock.advance(1);
|
|
71
|
+
expect(await fixture.scheduler.tick()).toMatchObject({
|
|
72
|
+
retried: 1,
|
|
73
|
+
failed: 1,
|
|
74
|
+
});
|
|
75
|
+
clock.advance(10);
|
|
76
|
+
expect((await fixture.scheduler.tick()).retried).toBe(1);
|
|
77
|
+
|
|
78
|
+
expect(executions).toBe(3);
|
|
79
|
+
expect(
|
|
80
|
+
(await fixture.scheduler.listRuns()).map(({ status, attempt }) => ({
|
|
81
|
+
status,
|
|
82
|
+
attempt,
|
|
83
|
+
})),
|
|
84
|
+
).toEqual([
|
|
85
|
+
{ status: "succeeded", attempt: 3 },
|
|
86
|
+
{ status: "failed", attempt: 2 },
|
|
87
|
+
{ status: "failed", attempt: 1 },
|
|
88
|
+
]);
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
test("动态 Feature 停用后调度与手动触发都不执行,恢复无需重启", async () => {
|
|
92
|
+
const clock = new FakeClock(new Date("2026-07-10T00:00:00.000Z"));
|
|
93
|
+
let featureEnabled = false;
|
|
94
|
+
let executions = 0;
|
|
95
|
+
const fixture = await createFixture(
|
|
96
|
+
clock,
|
|
97
|
+
() => {
|
|
98
|
+
executions += 1;
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
featureResolver: {
|
|
102
|
+
resolve: (key) => ({
|
|
103
|
+
key,
|
|
104
|
+
enabled: featureEnabled,
|
|
105
|
+
visible: "visible",
|
|
106
|
+
}),
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
);
|
|
110
|
+
clock.advance(100);
|
|
111
|
+
|
|
112
|
+
expect(await fixture.scheduler.tick()).toMatchObject({
|
|
113
|
+
scheduled: 0,
|
|
114
|
+
blocked: 0,
|
|
115
|
+
});
|
|
116
|
+
expect(await fixture.scheduler.listRuns()).toHaveLength(0);
|
|
117
|
+
expect(fixture.runtime.auditSink.list()).toHaveLength(0);
|
|
118
|
+
const deniedContext = await fixture.context();
|
|
119
|
+
expect(
|
|
120
|
+
await fixture.scheduler.triggerManual("test.task", deniedContext),
|
|
121
|
+
).toMatchObject({
|
|
122
|
+
ok: false,
|
|
123
|
+
reason: "feature-disabled",
|
|
124
|
+
});
|
|
125
|
+
expect(executions).toBe(0);
|
|
126
|
+
|
|
127
|
+
featureEnabled = true;
|
|
128
|
+
const allowedContext = await fixture.context();
|
|
129
|
+
expect(
|
|
130
|
+
await fixture.scheduler.triggerManual("test.task", allowedContext),
|
|
131
|
+
).toMatchObject({
|
|
132
|
+
ok: true,
|
|
133
|
+
run: { status: "succeeded" },
|
|
134
|
+
});
|
|
135
|
+
expect(executions).toBe(1);
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
test("自动调度持续被同一策略拒绝时只记录一次审计,恢复后再次拒绝会重新记录", async () => {
|
|
139
|
+
const clock = new FakeClock(new Date("2026-07-10T00:00:00.000Z"));
|
|
140
|
+
let restricted = true;
|
|
141
|
+
const fixture = await createFixture(clock, () => undefined, {
|
|
142
|
+
licenseResolver: {
|
|
143
|
+
resolve: () => ({
|
|
144
|
+
versionKey: licenseVersionKey("standard"),
|
|
145
|
+
entitlements: [entitlementKey("capability.scheduler")],
|
|
146
|
+
status: restricted ? "expired" : "valid",
|
|
147
|
+
restricted,
|
|
148
|
+
}),
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
clock.advance(100);
|
|
153
|
+
expect(await fixture.scheduler.tick()).toMatchObject({ blocked: 1 });
|
|
154
|
+
expect(fixture.runtime.auditSink.list()).toEqual([
|
|
155
|
+
expect.objectContaining({ action: "task.execute", outcome: "denied" }),
|
|
156
|
+
]);
|
|
157
|
+
|
|
158
|
+
clock.advance(100);
|
|
159
|
+
expect(await fixture.scheduler.tick()).toMatchObject({ blocked: 1 });
|
|
160
|
+
expect(fixture.runtime.auditSink.list()).toHaveLength(1);
|
|
161
|
+
|
|
162
|
+
restricted = false;
|
|
163
|
+
clock.advance(100);
|
|
164
|
+
expect(await fixture.scheduler.tick()).toMatchObject({ scheduled: 1 });
|
|
165
|
+
|
|
166
|
+
restricted = true;
|
|
167
|
+
clock.advance(100);
|
|
168
|
+
expect(await fixture.scheduler.tick()).toMatchObject({ blocked: 1 });
|
|
169
|
+
expect(
|
|
170
|
+
fixture.runtime.auditSink
|
|
171
|
+
.list()
|
|
172
|
+
.filter(
|
|
173
|
+
({ action, outcome }) =>
|
|
174
|
+
action === "task.execute" && outcome === "denied",
|
|
175
|
+
),
|
|
176
|
+
).toHaveLength(2);
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
test("缺少 Entitlement 时手动触发在创建执行记录前被拒绝", async () => {
|
|
180
|
+
const clock = new FakeClock(new Date("2026-07-10T00:00:00.000Z"));
|
|
181
|
+
const fixture = await createFixture(clock, () => undefined, {}, false);
|
|
182
|
+
const result = await fixture.scheduler.triggerManual(
|
|
183
|
+
"test.task",
|
|
184
|
+
await fixture.context(),
|
|
185
|
+
);
|
|
186
|
+
|
|
187
|
+
expect(result).toMatchObject({
|
|
188
|
+
ok: false,
|
|
189
|
+
reason: "entitlement-not-granted",
|
|
190
|
+
});
|
|
191
|
+
expect(await fixture.scheduler.listRuns()).toHaveLength(0);
|
|
192
|
+
expect(fixture.runtime.auditSink.list()[0]?.action).toBe("security.denied");
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
test("License 限制模式先于 Entitlement、Feature 与 RBAC 阻断调度", async () => {
|
|
196
|
+
const clock = new FakeClock(new Date("2026-07-10T00:00:00.000Z"));
|
|
197
|
+
let featureReads = 0;
|
|
198
|
+
let executions = 0;
|
|
199
|
+
const fixture = await createFixture(
|
|
200
|
+
clock,
|
|
201
|
+
() => {
|
|
202
|
+
executions += 1;
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
licenseResolver: {
|
|
206
|
+
resolve: () => ({
|
|
207
|
+
entitlements: [entitlementKey("capability.scheduler")],
|
|
208
|
+
status: "expired",
|
|
209
|
+
restricted: true,
|
|
210
|
+
}),
|
|
211
|
+
},
|
|
212
|
+
featureResolver: {
|
|
213
|
+
resolve: (key) => {
|
|
214
|
+
featureReads += 1;
|
|
215
|
+
return { key, enabled: true, visible: "visible" };
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
expect(
|
|
222
|
+
await fixture.scheduler.triggerManual(
|
|
223
|
+
"test.task",
|
|
224
|
+
await fixture.context(),
|
|
225
|
+
),
|
|
226
|
+
).toMatchObject({ ok: false, reason: "license-restricted" });
|
|
227
|
+
expect(await fixture.scheduler.listRuns()).toHaveLength(0);
|
|
228
|
+
|
|
229
|
+
clock.advance(100);
|
|
230
|
+
expect(await fixture.scheduler.tick()).toMatchObject({
|
|
231
|
+
scheduled: 1,
|
|
232
|
+
blocked: 1,
|
|
233
|
+
});
|
|
234
|
+
expect(await fixture.scheduler.listRuns()).toEqual([
|
|
235
|
+
expect.objectContaining({
|
|
236
|
+
status: "blocked",
|
|
237
|
+
error: "license-restricted",
|
|
238
|
+
}),
|
|
239
|
+
]);
|
|
240
|
+
expect(featureReads).toBe(0);
|
|
241
|
+
expect(executions).toBe(0);
|
|
242
|
+
});
|
|
243
|
+
|
|
244
|
+
test("后台 License 解析异常会形成可重试失败而不是遗留 running", async () => {
|
|
245
|
+
const clock = new FakeClock(new Date("2026-07-10T00:00:00.000Z"));
|
|
246
|
+
const fixture = await createFixture(clock, () => undefined, {
|
|
247
|
+
licenseResolver: {
|
|
248
|
+
resolve() {
|
|
249
|
+
throw new Error("License 存储暂不可用");
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
});
|
|
253
|
+
clock.advance(100);
|
|
254
|
+
|
|
255
|
+
expect(await fixture.scheduler.tick()).toMatchObject({
|
|
256
|
+
scheduled: 1,
|
|
257
|
+
failed: 1,
|
|
258
|
+
});
|
|
259
|
+
expect(await fixture.scheduler.listRuns()).toEqual([
|
|
260
|
+
expect.objectContaining({
|
|
261
|
+
status: "retry-pending",
|
|
262
|
+
error: "License 存储暂不可用",
|
|
263
|
+
}),
|
|
264
|
+
]);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
async function createFixture(
|
|
270
|
+
clock: FakeClock,
|
|
271
|
+
handler: ScheduledTaskDefinition["handler"],
|
|
272
|
+
runtimeOptions: Parameters<typeof createServerRuntime>[1] = {},
|
|
273
|
+
licensed = true,
|
|
274
|
+
) {
|
|
275
|
+
const feature = createFoundationSnapshot().features.find(
|
|
276
|
+
({ key }) => key === "system.scheduler",
|
|
277
|
+
);
|
|
278
|
+
if (!feature) throw new Error("测试缺少 system.scheduler Feature");
|
|
279
|
+
const runtime = createServerRuntime(
|
|
280
|
+
{
|
|
281
|
+
WINDY_DEV_ADMIN_TOKEN: "token",
|
|
282
|
+
WINDY_LICENSE_ENTITLEMENTS: licensed ? "capability.scheduler" : undefined,
|
|
283
|
+
},
|
|
284
|
+
runtimeOptions,
|
|
285
|
+
);
|
|
286
|
+
const repository = new InMemorySchedulerRepository();
|
|
287
|
+
const scheduler = new SchedulerService(
|
|
288
|
+
repository,
|
|
289
|
+
[
|
|
290
|
+
{
|
|
291
|
+
key: "test.task",
|
|
292
|
+
label: "测试任务",
|
|
293
|
+
intervalSeconds: 100,
|
|
294
|
+
maxAttempts: 3,
|
|
295
|
+
retryDelaySeconds: 10,
|
|
296
|
+
permissionKey: "system.scheduler.manage",
|
|
297
|
+
feature: {
|
|
298
|
+
...feature,
|
|
299
|
+
requiredEntitlement: entitlementKey("capability.scheduler"),
|
|
300
|
+
},
|
|
301
|
+
handler,
|
|
302
|
+
},
|
|
303
|
+
],
|
|
304
|
+
runtime,
|
|
305
|
+
clock,
|
|
306
|
+
);
|
|
307
|
+
await scheduler.initialize();
|
|
308
|
+
return {
|
|
309
|
+
runtime,
|
|
310
|
+
repository,
|
|
311
|
+
scheduler,
|
|
312
|
+
context: () =>
|
|
313
|
+
runtime.createGuardContext(
|
|
314
|
+
new Request(
|
|
315
|
+
"http://localhost/api/system/scheduled-tasks/test.task/trigger",
|
|
316
|
+
{
|
|
317
|
+
headers: { authorization: "Bearer token" },
|
|
318
|
+
},
|
|
319
|
+
),
|
|
320
|
+
),
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
async function until(predicate: () => boolean) {
|
|
325
|
+
for (let attempt = 0; attempt < 100; attempt += 1) {
|
|
326
|
+
if (predicate()) return;
|
|
327
|
+
await Bun.sleep(1);
|
|
328
|
+
}
|
|
329
|
+
throw new Error("测试等待条件超时");
|
|
330
|
+
}
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
import { randomUUIDv7 } from "bun";
|
|
2
|
+
import type { SchedulerOperationsSnapshot } from "@windy/shared";
|
|
3
|
+
import { runGuardedBackgroundTask } from "../background/task-guard.js";
|
|
4
|
+
import type { RequestGuardContext } from "../guards.js";
|
|
5
|
+
import type { LegacyDurableAdapter } from "../jobs/legacy-adapter.js";
|
|
6
|
+
import type { createServerRuntime } from "../runtime.js";
|
|
7
|
+
import type { SchedulerRepository } from "./repository.js";
|
|
8
|
+
import { validateTaskDefinitions } from "./definitions.js";
|
|
9
|
+
import { SchedulerExecutionRecorder } from "./execution-recorder.js";
|
|
10
|
+
import {
|
|
11
|
+
schedulerActor,
|
|
12
|
+
schedulerPolicy,
|
|
13
|
+
type ManualTriggerResult,
|
|
14
|
+
} from "./execution-context.js";
|
|
15
|
+
import { isScheduledFeatureActive, isTaskDue } from "./feature-preflight.js";
|
|
16
|
+
import { listSchedulerRunHistory } from "./history.js";
|
|
17
|
+
import { buildSchedulerOperationsSnapshot } from "./overview.js";
|
|
18
|
+
import {
|
|
19
|
+
recoverStaleScheduledRun,
|
|
20
|
+
type StaleRecoveryServiceResult,
|
|
21
|
+
} from "./recovery-service.js";
|
|
22
|
+
import {
|
|
23
|
+
SCHEDULER_STALE_THRESHOLD_SECONDS,
|
|
24
|
+
systemClock,
|
|
25
|
+
type ScheduledTaskDefinition,
|
|
26
|
+
type ScheduledTaskRun,
|
|
27
|
+
type SchedulerClock,
|
|
28
|
+
type SchedulerTickResult,
|
|
29
|
+
type StoredScheduledTask,
|
|
30
|
+
} from "./types.js";
|
|
31
|
+
|
|
32
|
+
type ServerRuntime = ReturnType<typeof createServerRuntime>;
|
|
33
|
+
|
|
34
|
+
export class SchedulerService {
|
|
35
|
+
private readonly definitions = new Map<string, ScheduledTaskDefinition>();
|
|
36
|
+
private readonly recorder: SchedulerExecutionRecorder;
|
|
37
|
+
|
|
38
|
+
constructor(
|
|
39
|
+
private readonly repository: SchedulerRepository,
|
|
40
|
+
definitions: ScheduledTaskDefinition[],
|
|
41
|
+
private readonly runtime: ServerRuntime,
|
|
42
|
+
private readonly clock: SchedulerClock = systemClock,
|
|
43
|
+
private readonly durable?: LegacyDurableAdapter,
|
|
44
|
+
) {
|
|
45
|
+
this.recorder = new SchedulerExecutionRecorder(repository, runtime, clock);
|
|
46
|
+
validateTaskDefinitions(definitions);
|
|
47
|
+
definitions.forEach((definition) =>
|
|
48
|
+
this.definitions.set(definition.key, definition),
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async initialize() {
|
|
53
|
+
await this.repository.syncDefinitions(
|
|
54
|
+
[...this.definitions.values()],
|
|
55
|
+
this.clock.now(),
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
listTasks(): Promise<StoredScheduledTask[]> {
|
|
60
|
+
return this.repository.listTasks();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
listRuns(limit?: number): Promise<ScheduledTaskRun[]> {
|
|
64
|
+
return this.repository.listRuns(limit);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async listRunHistory(page: number, pageSize: number) {
|
|
68
|
+
return listSchedulerRunHistory(this.repository, page, pageSize);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
async operationsSnapshot(
|
|
72
|
+
staleThresholdSeconds = SCHEDULER_STALE_THRESHOLD_SECONDS,
|
|
73
|
+
runLimit = 50,
|
|
74
|
+
): Promise<SchedulerOperationsSnapshot> {
|
|
75
|
+
const [tasks, runs] = await Promise.all([
|
|
76
|
+
this.repository.listTasks(),
|
|
77
|
+
this.repository.listRuns(runLimit),
|
|
78
|
+
]);
|
|
79
|
+
return buildSchedulerOperationsSnapshot(
|
|
80
|
+
tasks,
|
|
81
|
+
runs,
|
|
82
|
+
new Set(this.definitions.keys()),
|
|
83
|
+
this.clock.now(),
|
|
84
|
+
staleThresholdSeconds,
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
async recoverStaleRun(
|
|
89
|
+
taskKey: string,
|
|
90
|
+
runId: string,
|
|
91
|
+
expectedStartedAt: string,
|
|
92
|
+
rawReason: string,
|
|
93
|
+
context: RequestGuardContext,
|
|
94
|
+
): Promise<StaleRecoveryServiceResult> {
|
|
95
|
+
return recoverStaleScheduledRun({
|
|
96
|
+
repository: this.repository,
|
|
97
|
+
runtime: this.runtime,
|
|
98
|
+
clock: this.clock,
|
|
99
|
+
definition: this.definitions.get(taskKey),
|
|
100
|
+
taskKey,
|
|
101
|
+
runId,
|
|
102
|
+
expectedStartedAt,
|
|
103
|
+
rawReason,
|
|
104
|
+
context,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async triggerManual(
|
|
109
|
+
taskKey: string,
|
|
110
|
+
context: RequestGuardContext,
|
|
111
|
+
): Promise<ManualTriggerResult> {
|
|
112
|
+
const definition = this.definitions.get(taskKey);
|
|
113
|
+
if (!definition) return { ok: false, reason: "not-found" };
|
|
114
|
+
let auditUnavailable = false;
|
|
115
|
+
const guarded = await runGuardedBackgroundTask(
|
|
116
|
+
this.runtime,
|
|
117
|
+
context,
|
|
118
|
+
schedulerPolicy(definition),
|
|
119
|
+
async () => {
|
|
120
|
+
const run = await this.repository.claimManual(
|
|
121
|
+
taskKey,
|
|
122
|
+
context.actor.id,
|
|
123
|
+
this.clock.now(),
|
|
124
|
+
);
|
|
125
|
+
if (!run) return undefined;
|
|
126
|
+
try {
|
|
127
|
+
await this.recorder.trigger(context, run);
|
|
128
|
+
} catch {
|
|
129
|
+
auditUnavailable = true;
|
|
130
|
+
await this.repository.complete(run.id, {
|
|
131
|
+
status: "blocked",
|
|
132
|
+
finishedAt: this.clock.now(),
|
|
133
|
+
error: "关键审计不可用,手动执行已阻断",
|
|
134
|
+
});
|
|
135
|
+
return undefined;
|
|
136
|
+
}
|
|
137
|
+
return this.execute(run, definition, context, false);
|
|
138
|
+
},
|
|
139
|
+
);
|
|
140
|
+
if (!guarded.ok) return { ok: false, reason: guarded.reason };
|
|
141
|
+
if (auditUnavailable) return { ok: false, reason: "audit-unavailable" };
|
|
142
|
+
const run = await guarded.value;
|
|
143
|
+
return run ? { ok: true, run } : { ok: false, reason: "busy" };
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
async tick(): Promise<SchedulerTickResult> {
|
|
147
|
+
const result: SchedulerTickResult = {
|
|
148
|
+
scheduled: 0,
|
|
149
|
+
retried: 0,
|
|
150
|
+
blocked: 0,
|
|
151
|
+
failed: 0,
|
|
152
|
+
};
|
|
153
|
+
await this.resumeDurableWork(result);
|
|
154
|
+
const now = this.clock.now();
|
|
155
|
+
for (const pending of await this.repository.listRetryable(now)) {
|
|
156
|
+
const definition = this.definitions.get(pending.taskKey);
|
|
157
|
+
if (
|
|
158
|
+
definition &&
|
|
159
|
+
!(await isScheduledFeatureActive(this.runtime, definition))
|
|
160
|
+
)
|
|
161
|
+
continue;
|
|
162
|
+
const run = await this.repository.claimRetry(pending.id, now);
|
|
163
|
+
if (!run) continue;
|
|
164
|
+
result.retried += 1;
|
|
165
|
+
this.recorder.count(await this.executeScheduled(run), result);
|
|
166
|
+
}
|
|
167
|
+
for (const task of await this.repository.listTasks()) {
|
|
168
|
+
if (!isTaskDue(task, now)) continue;
|
|
169
|
+
const definition = this.definitions.get(task.key);
|
|
170
|
+
if (
|
|
171
|
+
definition &&
|
|
172
|
+
!(await isScheduledFeatureActive(this.runtime, definition))
|
|
173
|
+
)
|
|
174
|
+
continue;
|
|
175
|
+
const run = await this.repository.claimScheduled(task.key, now);
|
|
176
|
+
if (!run) continue;
|
|
177
|
+
result.scheduled += 1;
|
|
178
|
+
this.recorder.count(await this.executeScheduled(run), result);
|
|
179
|
+
}
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async resumeDurable(runId: string, generation: number) {
|
|
184
|
+
const run = await this.repository.getRun(runId);
|
|
185
|
+
if (!run || run.status !== "running" || run.attempt !== generation) return;
|
|
186
|
+
const definition = this.definitions.get(run.taskKey);
|
|
187
|
+
if (!definition) {
|
|
188
|
+
await this.repository.complete(run.id, {
|
|
189
|
+
status: "failed",
|
|
190
|
+
finishedAt: this.clock.now(),
|
|
191
|
+
error: "任务定义已不存在",
|
|
192
|
+
});
|
|
193
|
+
return;
|
|
194
|
+
}
|
|
195
|
+
if (run.trigger !== "manual") {
|
|
196
|
+
await this.executeScheduled(run, false);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
await this.execute(
|
|
200
|
+
run,
|
|
201
|
+
definition,
|
|
202
|
+
manualResumeContext(run, definition),
|
|
203
|
+
false,
|
|
204
|
+
false,
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
private async executeScheduled(run: ScheduledTaskRun, useDurable = true) {
|
|
209
|
+
const definition = this.definitions.get(run.taskKey);
|
|
210
|
+
if (!definition) {
|
|
211
|
+
return this.repository.complete(run.id, {
|
|
212
|
+
status: "failed",
|
|
213
|
+
finishedAt: this.clock.now(),
|
|
214
|
+
error: "任务定义已不存在",
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
const actor = schedulerActor(definition.permissionKey);
|
|
218
|
+
const fallbackContext: RequestGuardContext = {
|
|
219
|
+
requestId: randomUUIDv7(),
|
|
220
|
+
actor,
|
|
221
|
+
startedAt: this.clock.now().toISOString(),
|
|
222
|
+
};
|
|
223
|
+
try {
|
|
224
|
+
const context = await this.runtime.createGuardContextForActor(
|
|
225
|
+
new Request(
|
|
226
|
+
`http://scheduler.local/tasks/${encodeURIComponent(run.taskKey)}`,
|
|
227
|
+
),
|
|
228
|
+
actor,
|
|
229
|
+
);
|
|
230
|
+
return this.execute(run, definition, context, true, useDurable);
|
|
231
|
+
} catch (error) {
|
|
232
|
+
return this.recorder.failure(run, definition, fallbackContext, error);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
private async execute(
|
|
237
|
+
run: ScheduledTaskRun,
|
|
238
|
+
definition: ScheduledTaskDefinition,
|
|
239
|
+
context: RequestGuardContext,
|
|
240
|
+
applyGuard: boolean,
|
|
241
|
+
useDurable = true,
|
|
242
|
+
) {
|
|
243
|
+
if (this.durable && useDurable) {
|
|
244
|
+
return this.dispatchDurable(run, definition);
|
|
245
|
+
}
|
|
246
|
+
if (applyGuard) {
|
|
247
|
+
let guarded;
|
|
248
|
+
try {
|
|
249
|
+
guarded = await runGuardedBackgroundTask(
|
|
250
|
+
this.runtime,
|
|
251
|
+
context,
|
|
252
|
+
schedulerPolicy(definition),
|
|
253
|
+
definition.handler,
|
|
254
|
+
{ recordDecision: false },
|
|
255
|
+
);
|
|
256
|
+
} catch (error) {
|
|
257
|
+
return this.recorder.failure(run, definition, context, error);
|
|
258
|
+
}
|
|
259
|
+
if (!guarded.ok) {
|
|
260
|
+
const blocked = await this.repository.complete(run.id, {
|
|
261
|
+
status: "blocked",
|
|
262
|
+
finishedAt: this.clock.now(),
|
|
263
|
+
error: guarded.reason,
|
|
264
|
+
});
|
|
265
|
+
this.recorder.denied(context, blocked, guarded.reason);
|
|
266
|
+
return blocked;
|
|
267
|
+
}
|
|
268
|
+
return this.recorder.success(run, definition, context, guarded.value);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
try {
|
|
272
|
+
return this.recorder.success(
|
|
273
|
+
run,
|
|
274
|
+
definition,
|
|
275
|
+
context,
|
|
276
|
+
await definition.handler(),
|
|
277
|
+
);
|
|
278
|
+
} catch (error) {
|
|
279
|
+
return this.recorder.failure(run, definition, context, error);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
private async dispatchDurable(
|
|
284
|
+
run: ScheduledTaskRun,
|
|
285
|
+
definition: ScheduledTaskDefinition,
|
|
286
|
+
) {
|
|
287
|
+
await this.durable!.dispatch({
|
|
288
|
+
legacyId: run.id,
|
|
289
|
+
generation: run.attempt,
|
|
290
|
+
requestedBy: run.requestedBy,
|
|
291
|
+
maxAttempts: definition.maxAttempts,
|
|
292
|
+
timeoutSeconds: Math.max(1, definition.intervalSeconds),
|
|
293
|
+
link: (durableJobId) =>
|
|
294
|
+
this.repository.linkDurableJob(run.id, run.attempt, durableJobId),
|
|
295
|
+
});
|
|
296
|
+
return (
|
|
297
|
+
(await this.repository.getRun(run.id)) || {
|
|
298
|
+
...run,
|
|
299
|
+
status: "succeeded" as const,
|
|
300
|
+
finishedAt: this.clock.now().toISOString(),
|
|
301
|
+
}
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
private async resumeDurableWork(result: SchedulerTickResult) {
|
|
306
|
+
if (!this.durable) return;
|
|
307
|
+
const resumed = await this.durable.runNext();
|
|
308
|
+
if (resumed.status !== "idle" && resumed.legacyId) {
|
|
309
|
+
const run = await this.repository.getRun(resumed.legacyId);
|
|
310
|
+
if (run) this.recorder.count(run, result);
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
313
|
+
const [orphan] = await this.repository.listUnlinkedRunning(1);
|
|
314
|
+
const definition = orphan && this.definitions.get(orphan.taskKey);
|
|
315
|
+
if (orphan && definition) {
|
|
316
|
+
this.recorder.count(
|
|
317
|
+
await this.dispatchDurable(orphan, definition),
|
|
318
|
+
result,
|
|
319
|
+
);
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function manualResumeContext(
|
|
325
|
+
run: ScheduledTaskRun,
|
|
326
|
+
definition: ScheduledTaskDefinition,
|
|
327
|
+
): RequestGuardContext {
|
|
328
|
+
return {
|
|
329
|
+
requestId: randomUUIDv7(),
|
|
330
|
+
actor: {
|
|
331
|
+
id: run.requestedBy,
|
|
332
|
+
type: "user",
|
|
333
|
+
name: run.requestedBy,
|
|
334
|
+
roleCodes: [],
|
|
335
|
+
permissionKeys: [definition.permissionKey],
|
|
336
|
+
},
|
|
337
|
+
startedAt: new Date().toISOString(),
|
|
338
|
+
};
|
|
339
|
+
}
|