create-windy 0.2.7 → 0.2.9
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 +6 -0
- package/dist/cli.js +181 -87
- package/package.json +1 -1
- package/template/.windy-template.json +2 -2
- package/template/apps/server/Dockerfile +2 -0
- package/template/apps/server/package.json +10 -8
- package/template/apps/server/src/access-guards.ts +1 -1
- package/template/apps/server/src/admin/routes.test.ts +10 -0
- package/template/apps/server/src/admin/routes.ts +4 -2
- package/template/apps/server/src/agent/routes.test.ts +1 -1
- package/template/apps/server/src/agent/routes.ts +2 -2
- package/template/apps/server/src/application-services.ts +3 -0
- package/template/apps/server/src/audit/drizzle-log-store.ts +2 -2
- package/template/apps/server/src/audit/policy.ts +1 -1
- package/template/apps/server/src/audit/recovery-queue.test.ts +1 -1
- package/template/apps/server/src/audit/recovery-queue.ts +1 -1
- package/template/apps/server/src/audit/redaction.ts +1 -1
- package/template/apps/server/src/audit/reliable-writer.test.ts +1 -1
- package/template/apps/server/src/audit/reliable-writer.ts +1 -1
- package/template/apps/server/src/audit/search-summary.ts +1 -1
- package/template/apps/server/src/auth/authentication-provider.test.ts +1 -1
- package/template/apps/server/src/auth/credential-service.ts +1 -1
- package/template/apps/server/src/auth/drizzle-repository.ts +2 -2
- package/template/apps/server/src/auth/drizzle-session-operations.ts +1 -1
- package/template/apps/server/src/auth/own-session-routes.test.ts +1 -1
- package/template/apps/server/src/auth/password.ts +2 -2
- package/template/apps/server/src/auth/repository.ts +1 -1
- package/template/apps/server/src/auth/routes.test.ts +1 -1
- package/template/apps/server/src/auth/service.ts +1 -1
- package/template/apps/server/src/bulk-data/artifact-store.ts +1 -1
- package/template/apps/server/src/bulk-data/dictionary-handler.ts +1 -1
- package/template/apps/server/src/bulk-data/drizzle-repository.ts +3 -3
- package/template/apps/server/src/bulk-data/repository.ts +1 -1
- package/template/apps/server/src/bulk-data/routes.test.ts +1 -1
- package/template/apps/server/src/bulk-data/routes.ts +1 -1
- package/template/apps/server/src/bulk-data/service.test.ts +1 -1
- package/template/apps/server/src/bulk-data/service.ts +1 -1
- package/template/apps/server/src/bulk-data/types.ts +1 -1
- package/template/apps/server/src/configuration/bootstrap.ts +2 -2
- package/template/apps/server/src/configuration/definition.ts +2 -2
- package/template/apps/server/src/configuration/drizzle-repository.ts +2 -2
- package/template/apps/server/src/configuration/repository.ts +1 -1
- package/template/apps/server/src/configuration/routes.ts +1 -1
- package/template/apps/server/src/configuration/service.ts +1 -1
- package/template/apps/server/src/data-access/context.ts +2 -2
- package/template/apps/server/src/data-access/query-specification.test.ts +1 -1
- package/template/apps/server/src/data-access/scoped-repository.integration.test.ts +1 -1
- package/template/apps/server/src/data-access/scoped-repository.ts +1 -1
- package/template/apps/server/src/data-access/scoped-resource.test.ts +1 -1
- package/template/apps/server/src/data-access/scoped-resource.ts +1 -1
- package/template/apps/server/src/data-governance/export/approval-port.ts +1 -1
- package/template/apps/server/src/data-governance/export/drizzle-repository.ts +1 -1
- package/template/apps/server/src/data-governance/export/job-runtime.test.ts +2 -2
- package/template/apps/server/src/data-governance/export/job-runtime.ts +2 -3
- package/template/apps/server/src/data-governance/export/postgres-api-fixture.ts +2 -2
- package/template/apps/server/src/data-governance/export/postgres-api.integration.test.ts +1 -1
- package/template/apps/server/src/data-governance/export/routes-test-fixture.ts +3 -3
- package/template/apps/server/src/data-governance/export/routes.ts +1 -1
- package/template/apps/server/src/data-governance/export/scope-snapshot.ts +1 -1
- package/template/apps/server/src/data-governance/export/service.ts +2 -2
- package/template/apps/server/src/data-governance/export/source.ts +1 -1
- package/template/apps/server/src/data-governance/export/types.ts +1 -1
- package/template/apps/server/src/data-governance/plaintext-access.test.ts +1 -1
- package/template/apps/server/src/data-governance/plaintext-access.ts +1 -1
- package/template/apps/server/src/data-governance/plaintext-postgres.integration.test.ts +1 -1
- package/template/apps/server/src/data-governance/user-plaintext-routes.ts +1 -1
- package/template/apps/server/src/data-governance/user-projection.ts +2 -2
- package/template/apps/server/src/example-modules.ts +25 -1
- package/template/apps/server/src/feature/manifest-feature-repository.test.ts +1 -1
- package/template/apps/server/src/feature/manifest-feature-repository.ts +1 -1
- package/template/apps/server/src/feature/routes.ts +3 -6
- package/template/apps/server/src/foundation-access.test.ts +1 -1
- package/template/apps/server/src/foundation-access.ts +1 -1
- package/template/apps/server/src/foundation.ts +21 -7
- package/template/apps/server/src/guards.test.ts +1 -1
- package/template/apps/server/src/guards.ts +3 -3
- package/template/apps/server/src/index.ts +28 -3
- package/template/{packages/modules → apps/server}/src/installed-business-modules.ts +2 -2
- package/template/apps/server/src/jobs/artifact-service.test.ts +1 -1
- package/template/apps/server/src/jobs/artifact-service.ts +2 -2
- package/template/apps/server/src/jobs/drizzle-artifact.ts +2 -2
- package/template/apps/server/src/jobs/drizzle-claim.ts +1 -1
- package/template/apps/server/src/jobs/drizzle-execution-repository.ts +2 -2
- package/template/apps/server/src/jobs/drizzle-execution.integration.test.ts +1 -1
- package/template/apps/server/src/jobs/drizzle-lease.ts +2 -2
- package/template/apps/server/src/jobs/drizzle-mappers.ts +3 -3
- package/template/apps/server/src/jobs/drizzle-recovery-repository.ts +1 -1
- package/template/apps/server/src/jobs/drizzle-repository.integration.test.ts +1 -1
- package/template/apps/server/src/jobs/drizzle-repository.ts +3 -3
- package/template/apps/server/src/jobs/execution-repository.ts +1 -1
- package/template/apps/server/src/jobs/execution.test.ts +2 -2
- package/template/apps/server/src/jobs/in-memory-claim.ts +1 -1
- package/template/apps/server/src/jobs/in-memory-execution.ts +1 -1
- package/template/apps/server/src/jobs/in-memory-lease.ts +1 -1
- package/template/apps/server/src/jobs/legacy-adapter.integration.test.ts +1 -1
- package/template/apps/server/src/jobs/legacy-adapter.test.ts +1 -1
- package/template/apps/server/src/jobs/legacy-adapter.ts +1 -1
- package/template/apps/server/src/jobs/legacy-service-runtime.ts +4 -2
- package/template/apps/server/src/jobs/repository.ts +2 -2
- package/template/apps/server/src/jobs/service.ts +2 -2
- package/template/apps/server/src/jobs/worker.ts +3 -2
- package/template/apps/server/src/license/legacy-license-resolver.ts +1 -1
- package/template/apps/server/src/license/license-resolver.test.ts +1 -1
- package/template/apps/server/src/license/license-resolver.ts +3 -3
- package/template/apps/server/src/license/routes-offline-code.test.ts +2 -2
- package/template/apps/server/src/license/routes.ts +1 -1
- package/template/apps/server/src/license/runtime-audit-reliability.test.ts +2 -2
- package/template/apps/server/src/license/runtime-reminder.test.ts +2 -2
- package/template/apps/server/src/license/runtime-service.test.ts +2 -2
- package/template/apps/server/src/license/runtime-service.ts +2 -2
- package/template/apps/server/src/module-composition.test.ts +1 -1
- package/template/apps/server/src/module-composition.ts +1 -1
- package/template/apps/server/src/module-host.test.ts +145 -0
- package/template/apps/server/src/module-host.ts +110 -0
- package/template/apps/server/src/notification/drizzle-repository.ts +2 -2
- package/template/apps/server/src/notification/repository.ts +1 -1
- package/template/apps/server/src/notification/routes.ts +1 -1
- package/template/apps/server/src/pagination.ts +1 -1
- package/template/apps/server/src/persistence.integration.test.ts +1 -1
- package/template/apps/server/src/persistence.ts +1 -1
- package/template/apps/server/src/profile/routes.ts +1 -1
- package/template/apps/server/src/route-guards.test.ts +1 -1
- package/template/apps/server/src/route-guards.ts +1 -1
- package/template/apps/server/src/runtime-feature.ts +125 -0
- package/template/apps/server/src/runtime-license.ts +1 -1
- package/template/apps/server/src/runtime.test.ts +48 -1
- package/template/apps/server/src/runtime.ts +17 -64
- package/template/apps/server/src/scheduler/audit.ts +1 -1
- package/template/apps/server/src/scheduler/definitions.test.ts +1 -1
- package/template/apps/server/src/scheduler/definitions.ts +2 -2
- package/template/apps/server/src/scheduler/drizzle-durable-links.ts +1 -1
- package/template/apps/server/src/scheduler/drizzle-mappers.ts +1 -1
- package/template/apps/server/src/scheduler/drizzle-repository.ts +1 -1
- package/template/apps/server/src/scheduler/execution-recorder.ts +1 -1
- package/template/apps/server/src/scheduler/history.ts +1 -1
- package/template/apps/server/src/scheduler/overview.ts +1 -1
- package/template/apps/server/src/scheduler/recovery-service.test.ts +1 -1
- package/template/apps/server/src/scheduler/recovery-service.ts +1 -1
- package/template/apps/server/src/scheduler/repository.ts +1 -1
- package/template/apps/server/src/scheduler/routes.ts +1 -1
- package/template/apps/server/src/scheduler/service-idle.test.ts +1 -1
- package/template/apps/server/src/scheduler/service.test.ts +1 -1
- package/template/apps/server/src/scheduler/service.ts +1 -1
- package/template/apps/server/src/scheduler/types.ts +1 -1
- package/template/apps/server/src/search/contracts.ts +2 -2
- package/template/apps/server/src/search/host.ts +1 -1
- package/template/apps/server/src/search/registry.ts +1 -1
- package/template/apps/server/src/search/routes.test.ts +1 -1
- package/template/apps/server/src/search/routes.ts +1 -1
- package/template/apps/server/src/search/service.ts +2 -2
- package/template/apps/server/src/search/test-support.ts +2 -2
- package/template/apps/server/src/session/routes.ts +1 -1
- package/template/apps/server/src/settings/drizzle-repository.ts +2 -2
- package/template/apps/server/src/settings/repository.ts +1 -1
- package/template/apps/server/src/settings/routes.test.ts +1 -1
- package/template/apps/server/src/settings/routes.ts +1 -1
- package/template/apps/server/src/settings/runtime.ts +1 -1
- package/template/apps/server/src/storage/blob-reference-registry.test.ts +1 -1
- package/template/apps/server/src/storage/blob-reference-registry.ts +1 -1
- package/template/apps/server/src/storage/drizzle-upload-repository.integration.test.ts +1 -1
- package/template/apps/server/src/storage/drizzle-upload-repository.ts +2 -2
- package/template/apps/server/src/storage/route-support.ts +1 -1
- package/template/apps/server/src/storage/routes.test.ts +1 -1
- package/template/apps/server/src/storage/routes.ts +2 -2
- package/template/apps/server/src/storage/runtime.ts +6 -4
- package/template/apps/server/src/system/audit-routes.ts +1 -1
- package/template/apps/server/src/system/department-routes.ts +1 -1
- package/template/apps/server/src/system/drizzle-repository.ts +1 -1
- package/template/apps/server/src/system/drizzle-scoped-repository.ts +1 -1
- package/template/apps/server/src/system/drizzle-system.ts +1 -1
- package/template/apps/server/src/system/entities.ts +1 -1
- package/template/apps/server/src/system/identity-route-config.ts +1 -1
- package/template/apps/server/src/system/interface-catalog.test.ts +3 -3
- package/template/apps/server/src/system/interface-catalog.ts +2 -2
- package/template/apps/server/src/system/menu-registry.ts +1 -1
- package/template/apps/server/src/system/menu-routes.ts +1 -1
- package/template/apps/server/src/system/operations.test.ts +1 -1
- package/template/apps/server/src/system/operations.ts +1 -1
- package/template/apps/server/src/system/redis-health.ts +1 -1
- package/template/apps/server/src/system/repository.ts +1 -1
- package/template/apps/server/src/system/resource-route-support.ts +1 -1
- package/template/apps/server/src/system/route-helpers.ts +1 -1
- package/template/apps/server/src/system/route-types.ts +1 -1
- package/template/apps/server/src/system/routes.test.ts +1 -1
- package/template/apps/server/src/system/routes.ts +1 -1
- package/template/apps/server/src/system/user-projection.ts +1 -1
- package/template/apps/server/src/work-order/data-scope.integration.test.ts +1 -1
- package/template/apps/server/src/work-order/drizzle-repository.integration.test.ts +1 -1
- package/template/apps/server/src/work-order/drizzle-repository.ts +2 -2
- package/template/apps/server/src/work-order/foundation-modules.test.ts +15 -5
- package/template/apps/server/src/work-order/repository.ts +1 -1
- package/template/apps/server/src/work-order/routes.test.ts +2 -2
- package/template/apps/server/src/work-order/routes.ts +2 -2
- package/template/apps/server/src/work-order/search-api.test.ts +3 -3
- package/template/apps/server/src/work-order/search-provider.test.ts +3 -3
- package/template/apps/server/src/work-order/service.ts +1 -1
- package/template/apps/server/src/work-order/task.test.ts +1 -1
- package/template/apps/server/src/work-order/task.ts +2 -2
- package/template/apps/server/src/workflow/drizzle-repository.integration.test.ts +2 -2
- package/template/apps/server/src/workflow/drizzle-repository.ts +3 -3
- package/template/apps/server/src/workflow/effects.test.ts +1 -1
- package/template/apps/server/src/workflow/effects.ts +1 -1
- package/template/apps/server/src/workflow/repository.ts +2 -2
- package/template/apps/server/src/workflow/routes.ts +3 -3
- package/template/apps/server/src/workflow/service.ts +1 -1
- package/template/apps/server/src/workflow/timeout-runtime.test.ts +1 -1
- package/template/apps/server/src/workflow/timeout-runtime.ts +2 -2
- package/template/apps/web/Dockerfile +2 -0
- package/template/apps/web/package.json +4 -4
- package/template/apps/web/runtime-server.ts +1 -1
- package/template/apps/web/src/app/layouts/AppLayout.vue +6 -0
- package/template/apps/web/src/components/auth/PasswordChangeForm.vue +1 -1
- package/template/apps/web/src/components/common/DataPagination.vue +1 -1
- package/template/apps/web/src/components/license/LicenseActivationCodeForm.vue +1 -1
- package/template/apps/web/src/components/license/LicenseFlow.webtest.ts +2 -2
- package/template/apps/web/src/composables/useModuleConfigurations.ts +1 -1
- package/template/apps/web/src/composables/useWatermarkSettings.ts +1 -0
- package/template/apps/web/src/composables/watermark-settings.ts +6 -0
- package/template/apps/web/src/composables/watermark-settings.webtest.ts +27 -1
- package/template/apps/web/src/layout/AppSidebar.vue +12 -3
- package/template/apps/web/src/layout/AppSidebar.webtest.ts +11 -0
- package/template/apps/web/src/layout/GlobalWatermark.vue +25 -8
- package/template/apps/web/src/layout/GlobalWatermark.webtest.ts +109 -0
- package/template/apps/web/src/layout/NavigationSearchDialog.vue +1 -1
- package/template/apps/web/src/layout/NotificationMenu.vue +1 -1
- package/template/apps/web/src/layout/navigation.ts +5 -1
- package/template/apps/web/src/layout/navigation.webtest.ts +1 -1
- package/template/apps/web/src/pages/configuration/components/ModuleConfigRollbackDialog.vue +1 -1
- package/template/apps/web/src/pages/configuration/components/ModuleConfigVersionList.vue +1 -1
- package/template/apps/web/src/pages/configuration/components/ModuleConfigurationEditor.vue +1 -1
- package/template/apps/web/src/pages/configuration/components/ModuleConfigurationEditor.webtest.ts +1 -1
- package/template/apps/web/src/pages/configuration/components/ModuleConfigurationWorkbench.vue +1 -1
- package/template/apps/web/src/pages/dashboard/dashboard-presenter.webtest.ts +1 -1
- package/template/apps/web/src/pages/settings/WatermarkSettingsSection.vue +21 -0
- package/template/apps/web/src/pages/system/SystemNotificationsPage.vue +2 -2
- package/template/apps/web/src/pages/system/components/AuditActionCell.vue +7 -2
- package/template/apps/web/src/pages/system/components/AuditLogFilters.vue +7 -2
- package/template/apps/web/src/pages/system/components/NotificationPublishForm.vue +1 -1
- package/template/apps/web/src/pages/system/components/SchedulerOperationsPanel.vue +1 -1
- package/template/apps/web/src/pages/system/components/SchedulerOperationsPanel.webtest.ts +1 -1
- package/template/apps/web/src/pages/system/components/SchedulerRunTable.vue +1 -1
- package/template/apps/web/src/pages/system/components/SchedulerRunTable.webtest.ts +1 -1
- package/template/apps/web/src/pages/system/components/SchedulerStaleRecoveryForm.vue +1 -1
- package/template/apps/web/src/pages/system/components/SchedulerStaleRecoveryForm.webtest.ts +1 -1
- package/template/apps/web/src/pages/system/components/SystemResourcePage.vue +1 -1
- package/template/apps/web/src/pages/system/components/SystemResourceTable.vue +10 -3
- package/template/apps/web/src/pages/system/components/role-policy/RolePermissionTree.vue +1 -1
- package/template/apps/web/src/pages/system/components/role-policy/RolePermissionTree.webtest.ts +1 -1
- package/template/apps/web/src/pages/system/components/role-policy/RolePolicyForm.vue +1 -1
- package/template/apps/web/src/pages/system/components/role-policy/permission-tree.ts +1 -1
- package/template/apps/web/src/pages/system/components/role-policy/permission-tree.webtest.ts +1 -1
- package/template/apps/web/src/pages/system/composables/useSchedulerOperations.ts +2 -2
- package/template/apps/web/src/pages/system/composables/useSchedulerOperations.webtest.ts +1 -1
- package/template/apps/web/src/pages/system/composables/useSystemResource.ts +1 -1
- package/template/apps/web/src/router/manifest-routes.ts +1 -1
- package/template/apps/web/src/router/manifest-routes.webtest.ts +1 -1
- package/template/apps/web/src/services/access-api.ts +10 -1
- package/template/apps/web/src/services/configuration-api.ts +1 -1
- package/template/apps/web/src/services/license-api.ts +1 -1
- package/template/apps/web/src/services/notification-api.ts +2 -2
- package/template/apps/web/src/services/operations-api.ts +1 -1
- package/template/apps/web/src/services/platform-settings-api.ts +2 -2
- package/template/apps/web/src/services/profile-api.ts +2 -2
- package/template/docs/architecture/durable-jobs.md +5 -0
- package/template/docs/architecture/module-manifest-composition.md +14 -7
- package/template/docs/architecture/object-storage.md +1 -1
- package/template/docs/development/crud-generator.md +4 -1
- package/template/docs/platform/audit-reliability.md +1 -1
- package/template/package.json +2 -1
- package/template/packages/config/package.json +15 -4
- package/template/packages/config/src/platform.ts +1 -1
- package/template/packages/crud-generator/package.json +1 -1
- package/template/packages/crud-generator/src/generator.test.ts +16 -0
- package/template/packages/crud-generator/src/templates/domain.ts +1 -1
- package/template/packages/crud-generator/src/templates/manifest.ts +2 -2
- package/template/packages/crud-generator/src/templates/project.ts +3 -3
- package/template/packages/crud-generator/src/templates/repository.ts +1 -1
- package/template/packages/crud-generator/src/templates/routes.ts +2 -2
- package/template/packages/crud-generator/src/validation.ts +22 -1
- package/template/packages/database/package.json +15 -5
- package/template/packages/database/src/bundle-validation.ts +218 -0
- package/template/packages/database/src/dialects.ts +1 -1
- package/template/packages/database/src/runner.test.ts +160 -13
- package/template/packages/database/src/runner.ts +95 -77
- package/template/packages/database/src/schema/governed-exports.ts +1 -1
- package/template/packages/database/src/schema/identity.ts +1 -1
- package/template/packages/database/src/schema/license-v1.ts +1 -1
- package/template/packages/database/src/schema/notifications.ts +1 -1
- package/template/packages/database/src/schema/platform-settings.ts +1 -1
- package/template/packages/database/src/schema/workflow.ts +1 -1
- package/template/packages/database/src/sql-store.ts +1 -1
- package/template/packages/database/src/store.ts +1 -1
- package/template/packages/example-work-order/index.ts +1 -0
- package/template/packages/example-work-order/package.json +4 -3
- package/template/packages/example-work-order/src/contract.ts +1 -1
- package/template/packages/example-work-order/src/manifest.ts +8 -3
- package/template/packages/example-work-order/src/migration-bundle.test.ts +43 -0
- package/template/packages/example-work-order/src/migration-bundle.ts +64 -0
- package/template/packages/jobs/index.ts +2 -0
- package/template/packages/jobs/package.json +29 -0
- package/template/packages/jobs/src/handlers.test.ts +72 -0
- package/template/{apps/server/src/jobs/handler-registry.ts → packages/jobs/src/handlers.ts} +4 -4
- package/template/{apps/server/src/jobs → packages/jobs/src}/types.ts +7 -1
- package/template/packages/{license-sdk → jobs}/tsconfig.json +0 -1
- package/template/packages/modules/index.ts +1 -1
- package/template/packages/modules/package.json +15 -5
- package/template/packages/modules/src/ai-operation-composition.test.ts +195 -0
- package/template/packages/modules/src/ai-operation-composition.ts +145 -0
- package/template/packages/modules/src/catalog-validation.ts +123 -0
- package/template/packages/modules/src/composition.test.ts +75 -2
- package/template/packages/modules/src/composition.ts +23 -39
- package/template/packages/modules/src/implementation-bindings.ts +70 -0
- package/template/packages/modules/src/manifest.ts +43 -12
- package/template/packages/modules/src/menu-composition.ts +1 -1
- package/template/packages/modules/src/system-api-binding.ts +1 -1
- package/template/packages/modules/src/system-api-data-governance.ts +1 -1
- package/template/packages/modules/src/system-api-permissions.ts +1 -1
- package/template/packages/modules/src/system-data-governance.ts +1 -1
- package/template/packages/modules/src/system-features.ts +1 -1
- package/template/packages/modules/src/system-governed-export-bindings.ts +1 -1
- package/template/packages/modules/src/system-module-catalog.ts +1 -1
- package/template/packages/server-sdk/index.ts +5 -0
- package/template/packages/server-sdk/package.json +25 -0
- package/template/packages/server-sdk/src/module-host.ts +29 -0
- package/template/packages/server-sdk/tsconfig.json +16 -0
- package/template/packages/shared/index.ts +2 -0
- package/template/packages/shared/package.json +14 -3
- package/template/packages/shared/src/audit.ts +22 -1
- package/template/packages/shared/src/license-catalog.test.ts +17 -0
- package/template/packages/shared/src/license-catalog.ts +33 -0
- package/template/packages/shared/src/migration.ts +39 -0
- package/template/packages/storage/package.json +14 -3
- package/template/packages/license-sdk/index.ts +0 -13
- package/template/packages/license-sdk/package.json +0 -18
- package/template/packages/license-sdk/src/bounded-json-body.test.ts +0 -65
- package/template/packages/license-sdk/src/bounded-json-body.ts +0 -135
- package/template/packages/license-sdk/src/canonical-json.test.ts +0 -28
- package/template/packages/license-sdk/src/canonical-json.ts +0 -104
- package/template/packages/license-sdk/src/client.test.ts +0 -82
- package/template/packages/license-sdk/src/client.ts +0 -86
- package/template/packages/license-sdk/src/device.ts +0 -46
- package/template/packages/license-sdk/src/file-storage.test.ts +0 -80
- package/template/packages/license-sdk/src/file-storage.ts +0 -77
- package/template/packages/license-sdk/src/installation.test.ts +0 -241
- package/template/packages/license-sdk/src/installation.ts +0 -150
- package/template/packages/license-sdk/src/license-parser.ts +0 -56
- package/template/packages/license-sdk/src/offline-code-base32.ts +0 -57
- package/template/packages/license-sdk/src/offline-code-decompression.ts +0 -55
- package/template/packages/license-sdk/src/offline-code-limits.ts +0 -10
- package/template/packages/license-sdk/src/offline-code-wire.ts +0 -72
- package/template/packages/license-sdk/src/offline-code.test.ts +0 -172
- package/template/packages/license-sdk/src/offline-code.ts +0 -319
- package/template/packages/license-sdk/src/payload.test.ts +0 -72
- package/template/packages/license-sdk/src/payload.ts +0 -201
- package/template/packages/license-sdk/src/storage.ts +0 -64
- package/template/packages/license-sdk/src/test-fixtures.ts +0 -59
- package/template/packages/license-sdk/src/v1-test-vector.ts +0 -49
- package/template/packages/license-sdk/src/validation.test.ts +0 -62
- package/template/packages/license-sdk/src/validation.ts +0 -143
- package/template/packages/license-sdk/src/verification.test.ts +0 -97
- package/template/packages/license-sdk/src/verification.ts +0 -199
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@southwind-ai/jobs",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"bun": ">=1.3.0"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"index.ts",
|
|
11
|
+
"src/handlers.ts",
|
|
12
|
+
"src/types.ts"
|
|
13
|
+
],
|
|
14
|
+
"scripts": {
|
|
15
|
+
"test": "bun test",
|
|
16
|
+
"typecheck": "tsc --noEmit --project tsconfig.json"
|
|
17
|
+
},
|
|
18
|
+
"dependencies": {
|
|
19
|
+
"@southwind-ai/storage": "workspace:*"
|
|
20
|
+
},
|
|
21
|
+
"exports": {
|
|
22
|
+
".": "./index.ts",
|
|
23
|
+
"./handlers": "./src/handlers.ts",
|
|
24
|
+
"./types": "./src/types.ts"
|
|
25
|
+
},
|
|
26
|
+
"publishConfig": {
|
|
27
|
+
"access": "public"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
DurableHandlerError,
|
|
5
|
+
DurableHandlerRegistry,
|
|
6
|
+
type DurableHandlerContext,
|
|
7
|
+
} from "./handlers.js";
|
|
8
|
+
|
|
9
|
+
describe("DurableHandlerRegistry", () => {
|
|
10
|
+
test("解析 payload 后执行已注册 handler", async () => {
|
|
11
|
+
const received: string[] = [];
|
|
12
|
+
const registry = new DurableHandlerRegistry().register({
|
|
13
|
+
key: "example.report.generate",
|
|
14
|
+
payload: {
|
|
15
|
+
parse(input) {
|
|
16
|
+
if (
|
|
17
|
+
typeof input !== "object" ||
|
|
18
|
+
input === null ||
|
|
19
|
+
!("reportId" in input) ||
|
|
20
|
+
typeof input.reportId !== "string"
|
|
21
|
+
) {
|
|
22
|
+
throw new DurableHandlerError(
|
|
23
|
+
"INVALID_PAYLOAD",
|
|
24
|
+
"reportId 无效",
|
|
25
|
+
false,
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
return { reportId: input.reportId };
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
execute(payload) {
|
|
32
|
+
received.push(payload.reportId);
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
await registry
|
|
37
|
+
.get("example.report.generate")
|
|
38
|
+
?.execute({ reportId: "report-1" }, createContext());
|
|
39
|
+
|
|
40
|
+
expect(received).toEqual(["report-1"]);
|
|
41
|
+
expect(registry.keys()).toEqual(["example.report.generate"]);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test("拒绝空 key 和重复注册", () => {
|
|
45
|
+
const registry = new DurableHandlerRegistry();
|
|
46
|
+
const definition = {
|
|
47
|
+
key: "example.sync",
|
|
48
|
+
payload: { parse: () => ({}) },
|
|
49
|
+
execute: () => undefined,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
expect(() => registry.register({ ...definition, key: " " })).toThrow(
|
|
53
|
+
"任务 handler key 不能为空",
|
|
54
|
+
);
|
|
55
|
+
registry.register(definition);
|
|
56
|
+
expect(() => registry.register(definition)).toThrow(
|
|
57
|
+
"任务 handler 重复注册:example.sync",
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
function createContext(): DurableHandlerContext {
|
|
63
|
+
return {
|
|
64
|
+
jobId: "job-1",
|
|
65
|
+
stageKey: "main",
|
|
66
|
+
attemptNumber: 1,
|
|
67
|
+
signal: new AbortController().signal,
|
|
68
|
+
heartbeat: async () => undefined,
|
|
69
|
+
progress: async () => undefined,
|
|
70
|
+
publishArtifact: async () => undefined,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ArtifactRef } from "@
|
|
1
|
+
import type { ArtifactRef } from "@southwind-ai/storage";
|
|
2
2
|
|
|
3
3
|
export interface PayloadParser<T> {
|
|
4
4
|
parse(input: unknown): T;
|
|
@@ -45,7 +45,7 @@ export interface RegisteredDurableHandler {
|
|
|
45
45
|
export class DurableHandlerRegistry {
|
|
46
46
|
private readonly handlers = new Map<string, RegisteredDurableHandler>();
|
|
47
47
|
|
|
48
|
-
register<T>(definition: DurableHandlerDefinition<T>) {
|
|
48
|
+
register<T>(definition: DurableHandlerDefinition<T>): this {
|
|
49
49
|
if (!definition.key.trim()) throw new Error("任务 handler key 不能为空");
|
|
50
50
|
if (this.handlers.has(definition.key)) {
|
|
51
51
|
throw new Error(`任务 handler 重复注册:${definition.key}`);
|
|
@@ -59,11 +59,11 @@ export class DurableHandlerRegistry {
|
|
|
59
59
|
return this;
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
get(key: string) {
|
|
62
|
+
get(key: string): RegisteredDurableHandler | undefined {
|
|
63
63
|
return this.handlers.get(key);
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
keys() {
|
|
66
|
+
keys(): string[] {
|
|
67
67
|
return [...this.handlers.keys()].sort();
|
|
68
68
|
}
|
|
69
69
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ArtifactRef } from "@
|
|
1
|
+
import type { ArtifactRef } from "@southwind-ai/storage";
|
|
2
2
|
|
|
3
3
|
export type DurableJobStatus =
|
|
4
4
|
| "queued"
|
|
@@ -178,3 +178,9 @@ export interface SubmitDurableJobResult {
|
|
|
178
178
|
job: DurableJob;
|
|
179
179
|
created: boolean;
|
|
180
180
|
}
|
|
181
|
+
|
|
182
|
+
export interface DurableJobs {
|
|
183
|
+
submit(input: SubmitDurableJob): Promise<SubmitDurableJobResult>;
|
|
184
|
+
get(id: string): Promise<DurableJobSnapshot | undefined>;
|
|
185
|
+
list(requestedBy: string, limit?: number): Promise<DurableJob[]>;
|
|
186
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export * from "./src/manifest.js";
|
|
2
2
|
export * from "./src/composition.js";
|
|
3
|
+
export * from "./src/catalog-validation.js";
|
|
3
4
|
export * from "./src/menu-composition.js";
|
|
4
5
|
export * from "./src/registry.js";
|
|
5
6
|
export * from "./src/system-modules.js";
|
|
6
7
|
export * from "./src/system-module-catalog.js";
|
|
7
8
|
export * from "./src/system-api-permissions.js";
|
|
8
|
-
export * from "./src/installed-business-modules.js";
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
{
|
|
2
|
-
"name": "@
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"
|
|
2
|
+
"name": "@southwind-ai/modules",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"license": "UNLICENSED",
|
|
5
5
|
"type": "module",
|
|
6
|
+
"engines": {
|
|
7
|
+
"bun": ">=1.3.0"
|
|
8
|
+
},
|
|
9
|
+
"files": [
|
|
10
|
+
"index.ts",
|
|
11
|
+
"src/**/*.ts",
|
|
12
|
+
"!src/**/*.test.ts"
|
|
13
|
+
],
|
|
6
14
|
"dependencies": {
|
|
7
|
-
"@
|
|
8
|
-
"@windy/shared": "workspace:*"
|
|
15
|
+
"@southwind-ai/shared": "workspace:*"
|
|
9
16
|
},
|
|
10
17
|
"exports": {
|
|
11
18
|
".": "./index.ts"
|
|
19
|
+
},
|
|
20
|
+
"publishConfig": {
|
|
21
|
+
"access": "public"
|
|
12
22
|
}
|
|
13
23
|
}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import type {
|
|
3
|
+
ModuleAiOperationDefinition,
|
|
4
|
+
ModuleManifest,
|
|
5
|
+
} from "./manifest.js";
|
|
6
|
+
import { validateModuleComposition } from "./composition.js";
|
|
7
|
+
|
|
8
|
+
describe("AI Operation Composition", () => {
|
|
9
|
+
test("统一注册 Agent、Document 与 Speech Operation 并绑定实现", () => {
|
|
10
|
+
const module = fixture("business");
|
|
11
|
+
module.aiOperations = [
|
|
12
|
+
operation("business.agent", "agent", ["business.tool"]),
|
|
13
|
+
operation("business.document", "document"),
|
|
14
|
+
operation("business.speech", "speech"),
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
expect(() =>
|
|
18
|
+
validateModuleComposition([module], {
|
|
19
|
+
aiOperations: module.aiOperations.map(({ key }) => key),
|
|
20
|
+
}),
|
|
21
|
+
).not.toThrow();
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test("Operation Key 全局唯一且必须使用所属模块命名空间", () => {
|
|
25
|
+
const first = fixture("first");
|
|
26
|
+
const second = fixture("second");
|
|
27
|
+
first.aiOperations = [operation("first.generate")];
|
|
28
|
+
second.aiOperations = [operation("first.generate")];
|
|
29
|
+
|
|
30
|
+
expect(() => validateModuleComposition([first, second])).toThrow(
|
|
31
|
+
"AI Operation Key 重复:first.generate",
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
second.aiOperations = [operation("foreign.generate")];
|
|
35
|
+
expect(() => validateModuleComposition([second])).toThrow(
|
|
36
|
+
"必须使用模块命名空间 second",
|
|
37
|
+
);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test.each([
|
|
41
|
+
["permissionKey", "missing.permission", "未注册权限"],
|
|
42
|
+
["featureKey", "missing.feature", "未注册Feature"],
|
|
43
|
+
["auditAction", "missing.audit", "未注册审计动作"],
|
|
44
|
+
] as const)("拒绝未知 %s 引用", (field, value, message) => {
|
|
45
|
+
const module = fixture("business");
|
|
46
|
+
const definition = operation("business.generate");
|
|
47
|
+
module.aiOperations = [{ ...definition, [field]: value }];
|
|
48
|
+
expect(() => validateModuleComposition([module])).toThrow(message);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("拒绝未知 Tool、空 capability 和非法限制", () => {
|
|
52
|
+
const module = fixture("business");
|
|
53
|
+
module.aiOperations = [
|
|
54
|
+
operation("business.generate", "agent", ["missing.tool"]),
|
|
55
|
+
];
|
|
56
|
+
expect(() => validateModuleComposition([module])).toThrow(
|
|
57
|
+
"未注册Agent Tool",
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
module.aiOperations[0] = {
|
|
61
|
+
...operation("business.generate"),
|
|
62
|
+
requiredCapabilities: [],
|
|
63
|
+
};
|
|
64
|
+
expect(() => validateModuleComposition([module])).toThrow(
|
|
65
|
+
"至少需要一个 capability",
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
module.aiOperations[0] = {
|
|
69
|
+
...operation("business.generate"),
|
|
70
|
+
limits: { ...operation("business.generate").limits, maxInputBytes: 0 },
|
|
71
|
+
};
|
|
72
|
+
expect(() => validateModuleComposition([module])).toThrow(
|
|
73
|
+
"上限必须是正整数",
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
test("拒绝空 schema、capability 和 Tool Key", () => {
|
|
78
|
+
const module = fixture("business");
|
|
79
|
+
module.aiOperations = [
|
|
80
|
+
{ ...operation("business.generate"), inputSchemaKey: " " },
|
|
81
|
+
];
|
|
82
|
+
expect(() => validateModuleComposition([module])).toThrow(
|
|
83
|
+
"Key 与引用字段不能为空",
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
module.aiOperations[0] = {
|
|
87
|
+
...operation("business.generate"),
|
|
88
|
+
requiredCapabilities: [" "],
|
|
89
|
+
};
|
|
90
|
+
expect(() => validateModuleComposition([module])).toThrow(
|
|
91
|
+
"capability 不能为空",
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
module.aiOperations[0] = {
|
|
95
|
+
...operation("business.generate"),
|
|
96
|
+
allowedToolKeys: [" "],
|
|
97
|
+
};
|
|
98
|
+
expect(() => validateModuleComposition([module])).toThrow("Tool 不能为空");
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
test("Operation Handler 必须与 Manifest 声明一一对应", () => {
|
|
102
|
+
const module = fixture("business");
|
|
103
|
+
module.aiOperations = [operation("business.generate")];
|
|
104
|
+
|
|
105
|
+
expect(() =>
|
|
106
|
+
validateModuleComposition([module], { aiOperations: [] }),
|
|
107
|
+
).toThrow("AI Operation business.generate 缺少 Handler");
|
|
108
|
+
expect(() =>
|
|
109
|
+
validateModuleComposition([module], {
|
|
110
|
+
aiOperations: ["business.generate", "business.undeclared"],
|
|
111
|
+
}),
|
|
112
|
+
).toThrow("AI Operation Handler business.undeclared 缺少 Manifest 声明");
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
function operation(
|
|
117
|
+
key: string,
|
|
118
|
+
kind: ModuleAiOperationDefinition["kind"] = "agent",
|
|
119
|
+
allowedToolKeys: readonly string[] = [],
|
|
120
|
+
): ModuleAiOperationDefinition {
|
|
121
|
+
const namespace = key.split(".")[0]!;
|
|
122
|
+
return {
|
|
123
|
+
key,
|
|
124
|
+
kind,
|
|
125
|
+
featureKey: `${namespace}.ai`,
|
|
126
|
+
permissionKey: `${namespace}.ai.execute`,
|
|
127
|
+
auditAction: `${namespace}.ai.execute`,
|
|
128
|
+
inputSchemaKey: `${namespace}.ai.input.v1`,
|
|
129
|
+
outputSchemaKey: `${namespace}.ai.output.v1`,
|
|
130
|
+
requiredCapabilities: ["text-generation"],
|
|
131
|
+
allowedToolKeys,
|
|
132
|
+
dataClassification: "internal",
|
|
133
|
+
execution: kind === "speech" ? "live" : "streaming",
|
|
134
|
+
publicNetworkAccess: "forbidden",
|
|
135
|
+
limits: {
|
|
136
|
+
maxDurationSeconds: 60,
|
|
137
|
+
maxInputBytes: 1_048_576,
|
|
138
|
+
maxOutputBytes: 1_048_576,
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function fixture(name: string): ModuleManifest {
|
|
144
|
+
const permissionKey = `${name}.ai.execute`;
|
|
145
|
+
const featureKey = `${name}.ai`;
|
|
146
|
+
return {
|
|
147
|
+
name,
|
|
148
|
+
version: "0.1.0",
|
|
149
|
+
label: name,
|
|
150
|
+
description: name,
|
|
151
|
+
menus: [],
|
|
152
|
+
adminRoutes: [],
|
|
153
|
+
permissions: [
|
|
154
|
+
{
|
|
155
|
+
key: permissionKey,
|
|
156
|
+
label: "执行 AI",
|
|
157
|
+
module: name,
|
|
158
|
+
resource: "ai",
|
|
159
|
+
action: "manage",
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
apiPermissions: [],
|
|
163
|
+
features: [
|
|
164
|
+
{
|
|
165
|
+
key: featureKey,
|
|
166
|
+
label: "AI",
|
|
167
|
+
module: name,
|
|
168
|
+
visible: "visible",
|
|
169
|
+
enabled: true,
|
|
170
|
+
stage: "stable",
|
|
171
|
+
},
|
|
172
|
+
],
|
|
173
|
+
migrations: [],
|
|
174
|
+
schemaExports: [],
|
|
175
|
+
tasks: [],
|
|
176
|
+
tools: [
|
|
177
|
+
{
|
|
178
|
+
key: `${name}.tool`,
|
|
179
|
+
label: "业务工具",
|
|
180
|
+
description: "AI Operation 测试工具。",
|
|
181
|
+
permissionKey,
|
|
182
|
+
featureKey,
|
|
183
|
+
auditAction: `${name}.ai.execute`,
|
|
184
|
+
},
|
|
185
|
+
],
|
|
186
|
+
providers: [],
|
|
187
|
+
auditActions: [
|
|
188
|
+
{
|
|
189
|
+
key: `${name}.ai.execute`,
|
|
190
|
+
label: "执行 AI",
|
|
191
|
+
description: "执行 AI Operation。",
|
|
192
|
+
},
|
|
193
|
+
],
|
|
194
|
+
};
|
|
195
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ModuleAiOperationDefinition,
|
|
3
|
+
ModuleManifest,
|
|
4
|
+
} from "./manifest.js";
|
|
5
|
+
|
|
6
|
+
interface AiOperationCatalogs {
|
|
7
|
+
permissions: ReadonlySet<string>;
|
|
8
|
+
features: ReadonlySet<string>;
|
|
9
|
+
audits: ReadonlySet<string>;
|
|
10
|
+
tools: ReadonlySet<string>;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function validateAiOperations(
|
|
14
|
+
modules: readonly ModuleManifest[],
|
|
15
|
+
catalogs: AiOperationCatalogs,
|
|
16
|
+
): ModuleAiOperationDefinition[] {
|
|
17
|
+
const operations = modules.flatMap((module) => module.aiOperations || []);
|
|
18
|
+
uniqueValues(
|
|
19
|
+
"AI Operation",
|
|
20
|
+
operations.map(({ key }) => key),
|
|
21
|
+
);
|
|
22
|
+
for (const module of modules) {
|
|
23
|
+
for (const operation of module.aiOperations || []) {
|
|
24
|
+
validateOperation(module.name, operation, catalogs);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return operations;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function validateAiOperationImplementations(
|
|
31
|
+
declarations: readonly ModuleAiOperationDefinition[],
|
|
32
|
+
implementations: readonly string[] | undefined,
|
|
33
|
+
): void {
|
|
34
|
+
if (!implementations) return;
|
|
35
|
+
const declared = new Set(declarations.map(({ key }) => key));
|
|
36
|
+
const registered = uniqueValues("AI Operation Handler", implementations);
|
|
37
|
+
for (const key of declared) {
|
|
38
|
+
if (!registered.has(key)) {
|
|
39
|
+
throw new Error(`AI Operation ${key} 缺少 Handler`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
for (const key of registered) {
|
|
43
|
+
if (!declared.has(key)) {
|
|
44
|
+
throw new Error(`AI Operation Handler ${key} 缺少 Manifest 声明`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function validateOperation(
|
|
50
|
+
moduleName: string,
|
|
51
|
+
operation: ModuleAiOperationDefinition,
|
|
52
|
+
catalogs: AiOperationCatalogs,
|
|
53
|
+
): void {
|
|
54
|
+
const strings = [
|
|
55
|
+
operation.key,
|
|
56
|
+
operation.featureKey,
|
|
57
|
+
operation.permissionKey,
|
|
58
|
+
operation.auditAction,
|
|
59
|
+
operation.inputSchemaKey,
|
|
60
|
+
operation.outputSchemaKey,
|
|
61
|
+
];
|
|
62
|
+
if (strings.some((value) => !value.trim())) {
|
|
63
|
+
throw new Error("AI Operation Key 与引用字段不能为空");
|
|
64
|
+
}
|
|
65
|
+
if (!operation.key.startsWith(`${moduleName}.`)) {
|
|
66
|
+
throw new Error(
|
|
67
|
+
`AI Operation ${operation.key} 必须使用模块命名空间 ${moduleName}`,
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
requiredReference(
|
|
71
|
+
operation.key,
|
|
72
|
+
"权限",
|
|
73
|
+
operation.permissionKey,
|
|
74
|
+
catalogs.permissions,
|
|
75
|
+
);
|
|
76
|
+
requiredReference(
|
|
77
|
+
operation.key,
|
|
78
|
+
"Feature",
|
|
79
|
+
operation.featureKey,
|
|
80
|
+
catalogs.features,
|
|
81
|
+
);
|
|
82
|
+
requiredReference(
|
|
83
|
+
operation.key,
|
|
84
|
+
"审计动作",
|
|
85
|
+
operation.auditAction,
|
|
86
|
+
catalogs.audits,
|
|
87
|
+
);
|
|
88
|
+
validateCapabilities(operation);
|
|
89
|
+
validateTools(operation, catalogs.tools);
|
|
90
|
+
validateLimits(operation);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function validateCapabilities(operation: ModuleAiOperationDefinition): void {
|
|
94
|
+
if (!operation.requiredCapabilities.length) {
|
|
95
|
+
throw new Error(`${operation.key} 至少需要一个 capability`);
|
|
96
|
+
}
|
|
97
|
+
validateNonEmptyValues(
|
|
98
|
+
`${operation.key} capability`,
|
|
99
|
+
operation.requiredCapabilities,
|
|
100
|
+
);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function validateTools(
|
|
104
|
+
operation: ModuleAiOperationDefinition,
|
|
105
|
+
tools: ReadonlySet<string>,
|
|
106
|
+
): void {
|
|
107
|
+
validateNonEmptyValues(`${operation.key} Tool`, operation.allowedToolKeys);
|
|
108
|
+
for (const toolKey of operation.allowedToolKeys) {
|
|
109
|
+
requiredReference(operation.key, "Agent Tool", toolKey, tools);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function validateLimits(operation: ModuleAiOperationDefinition): void {
|
|
114
|
+
const values = Object.values(operation.limits);
|
|
115
|
+
if (values.some((value) => !Number.isSafeInteger(value) || value <= 0)) {
|
|
116
|
+
throw new Error(`${operation.key} 运行与输入输出上限必须是正整数`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function validateNonEmptyValues(label: string, values: readonly string[]) {
|
|
121
|
+
if (values.some((value) => !value.trim())) {
|
|
122
|
+
throw new Error(`${label} 不能为空`);
|
|
123
|
+
}
|
|
124
|
+
uniqueValues(label, values);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function requiredReference(
|
|
128
|
+
operationKey: string,
|
|
129
|
+
label: string,
|
|
130
|
+
key: string,
|
|
131
|
+
catalog: ReadonlySet<string>,
|
|
132
|
+
): void {
|
|
133
|
+
if (!catalog.has(key)) {
|
|
134
|
+
throw new Error(`${operationKey} 引用了未注册${label}:${key}`);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
function uniqueValues(label: string, values: readonly string[]): Set<string> {
|
|
139
|
+
const result = new Set<string>();
|
|
140
|
+
for (const value of values) {
|
|
141
|
+
if (result.has(value)) throw new Error(`${label} Key 重复:${value}`);
|
|
142
|
+
result.add(value);
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AUDIT_ACTION_DEFINITIONS,
|
|
3
|
+
isAuditActionDefinition,
|
|
4
|
+
LICENSE_CATALOG,
|
|
5
|
+
type AuditActionDefinition,
|
|
6
|
+
type FeatureFlagDefinition,
|
|
7
|
+
type LicenseCatalogDefinition,
|
|
8
|
+
} from "@southwind-ai/shared";
|
|
9
|
+
import type { ModuleManifest } from "./manifest.js";
|
|
10
|
+
|
|
11
|
+
export interface PlatformCapabilityCatalogs {
|
|
12
|
+
auditActions: readonly AuditActionDefinition[];
|
|
13
|
+
licenseVersions: readonly LicenseCatalogDefinition[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function validateCapabilityCatalogs(
|
|
17
|
+
modules: readonly ModuleManifest[],
|
|
18
|
+
): PlatformCapabilityCatalogs {
|
|
19
|
+
const auditActions = composeAuditActionCatalog(modules);
|
|
20
|
+
validateFeatureCatalog(modules, LICENSE_CATALOG);
|
|
21
|
+
return {
|
|
22
|
+
auditActions,
|
|
23
|
+
licenseVersions: LICENSE_CATALOG,
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function composeAuditActionCatalog(
|
|
28
|
+
modules: readonly ModuleManifest[],
|
|
29
|
+
): AuditActionDefinition[] {
|
|
30
|
+
const definitions = new Map<string, AuditActionDefinition>(
|
|
31
|
+
AUDIT_ACTION_DEFINITIONS.map((definition) => [
|
|
32
|
+
definition.key,
|
|
33
|
+
{ ...definition },
|
|
34
|
+
]),
|
|
35
|
+
);
|
|
36
|
+
const registrations = modules.flatMap((module) => module.auditActions);
|
|
37
|
+
|
|
38
|
+
for (const registration of registrations) {
|
|
39
|
+
if (!isAuditActionDefinition(registration)) continue;
|
|
40
|
+
validateAuditDefinition(registration);
|
|
41
|
+
if (definitions.has(registration.key)) {
|
|
42
|
+
throw new Error(`审计动作定义重复:${registration.key}`);
|
|
43
|
+
}
|
|
44
|
+
definitions.set(registration.key, { ...registration });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
for (const registration of registrations) {
|
|
48
|
+
const key =
|
|
49
|
+
typeof registration === "string" ? registration : registration.key;
|
|
50
|
+
if (!definitions.has(key)) {
|
|
51
|
+
throw new Error(`引用了未定义审计动作:${key}`);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return [...definitions.values()].sort((left, right) =>
|
|
56
|
+
left.key.localeCompare(right.key),
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function validateFeatureCatalog(
|
|
61
|
+
modules: readonly ModuleManifest[],
|
|
62
|
+
licenseCatalog: readonly LicenseCatalogDefinition[],
|
|
63
|
+
): void {
|
|
64
|
+
const features = modules.flatMap((module) => module.features);
|
|
65
|
+
const byKey = new Map(features.map((feature) => [feature.key, feature]));
|
|
66
|
+
const licenseKeys = new Set(licenseCatalog.map(({ key }) => key));
|
|
67
|
+
|
|
68
|
+
for (const feature of features) {
|
|
69
|
+
for (const dependency of feature.dependencies || []) {
|
|
70
|
+
if (dependency === feature.key) {
|
|
71
|
+
throw new Error(`Feature ${feature.key} 不能依赖自身`);
|
|
72
|
+
}
|
|
73
|
+
if (!byKey.has(dependency)) {
|
|
74
|
+
throw new Error(
|
|
75
|
+
`Feature ${feature.key} 引用了未注册依赖:${dependency}`,
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
for (const version of feature.allowedLicenseVersions || []) {
|
|
80
|
+
if (!licenseKeys.has(version)) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
`Feature ${feature.key} 引用了未知 License 版本:${version}`,
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
validateFeatureCycles(features, byKey);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function validateAuditDefinition(definition: AuditActionDefinition): void {
|
|
92
|
+
if (
|
|
93
|
+
!definition.key.trim() ||
|
|
94
|
+
!definition.label.trim() ||
|
|
95
|
+
!definition.description.trim()
|
|
96
|
+
) {
|
|
97
|
+
throw new Error("审计动作 Key、名称和说明不能为空");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function validateFeatureCycles(
|
|
102
|
+
features: readonly FeatureFlagDefinition[],
|
|
103
|
+
byKey: ReadonlyMap<string, FeatureFlagDefinition>,
|
|
104
|
+
): void {
|
|
105
|
+
const visited = new Set<string>();
|
|
106
|
+
const visiting = new Set<string>();
|
|
107
|
+
|
|
108
|
+
const visit = (feature: FeatureFlagDefinition): void => {
|
|
109
|
+
if (visited.has(feature.key)) return;
|
|
110
|
+
if (visiting.has(feature.key)) {
|
|
111
|
+
throw new Error(`Feature 依赖存在循环:${feature.key}`);
|
|
112
|
+
}
|
|
113
|
+
visiting.add(feature.key);
|
|
114
|
+
for (const dependency of feature.dependencies || []) {
|
|
115
|
+
const target = byKey.get(dependency);
|
|
116
|
+
if (target) visit(target);
|
|
117
|
+
}
|
|
118
|
+
visiting.delete(feature.key);
|
|
119
|
+
visited.add(feature.key);
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
for (const feature of features) visit(feature);
|
|
123
|
+
}
|