@taskforcehq/taskforce 0.3.170 → 0.3.300
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 +52 -21
- package/dist/Taskforce.module.css +3394 -5981
- package/dist/TaskforceCore.CategoryFallback.test.js +5 -2
- package/dist/TaskforceCore.filter-persistence.test.js +402 -0
- package/dist/TaskforceCore.js +388 -71
- package/dist/TaskforceCore.routing.test.js +311 -0
- package/dist/TaskforceCore.test.js +3344 -615
- package/dist/TaskforceWidget.js +3 -2
- package/dist/__tests__/localizationCatalogs.test.js +48 -31
- package/dist/__tests__/workflowSimulation.test.js +2 -2
- package/dist/annotatedAttachments/AnnotatedAttachmentSessionStore.d.ts +60 -0
- package/dist/annotatedAttachments/AnnotatedAttachmentSessionStore.js +324 -0
- package/dist/annotatedAttachments/AnnotatedAttachmentSessionStore.test.js +278 -0
- package/dist/annotatedAttachments/payload.d.ts +2 -0
- package/dist/annotatedAttachments/payload.js +54 -0
- package/dist/annotatedAttachments/payload.test.js +67 -0
- package/dist/annotatedAttachments/service.d.ts +49 -0
- package/dist/annotatedAttachments/service.js +121 -0
- package/dist/annotatedAttachments/types.d.ts +86 -0
- package/dist/cli.js +74 -25
- package/dist/compat/deploymentCompat.d.ts +12 -0
- package/dist/compat/deploymentCompat.js +43 -0
- package/dist/compat/workspaceSyncCompat.d.ts +6 -0
- package/dist/compat/workspaceSyncCompat.js +79 -0
- package/dist/compat/workspaceSyncCompat.test.js +87 -0
- package/dist/components/features/AgentsModule.d.ts +5 -0
- package/dist/components/features/AgentsModule.js +131 -0
- package/dist/components/features/AgentsModule.test.js +102 -0
- package/dist/components/features/AnnotatedAttachmentWorkspace.d.ts +24 -0
- package/dist/components/features/AnnotatedAttachmentWorkspace.js +1942 -0
- package/dist/components/features/AnnotatedAttachmentWorkspace.test.js +2831 -0
- package/dist/components/features/DocumentGenerateModal.js +8 -16
- package/dist/components/features/DocumentIndex.d.ts +3 -4
- package/dist/components/features/DocumentIndex.js +22 -10
- package/dist/components/features/DocumentViewer.d.ts +6 -2
- package/dist/components/features/DocumentViewer.js +1000 -18
- package/dist/components/features/DocumentWorkspace.d.ts +40 -2
- package/dist/components/features/DocumentWorkspace.js +96 -16
- package/dist/components/features/DocumentWorkspace.test.js +1202 -0
- package/dist/components/features/InitiativesModule.d.ts +22 -0
- package/dist/components/features/InitiativesModule.js +33 -0
- package/dist/components/features/TaskSettings.d.ts +41 -32
- package/dist/components/features/TaskSettings.js +798 -313
- package/dist/components/features/TaskSettings.test.js +1221 -47
- package/dist/components/features/WorkflowsModule.d.ts +27 -0
- package/dist/components/features/WorkflowsModule.js +21 -0
- package/dist/components/features/documentWorkspaceFilters.d.ts +10 -0
- package/dist/components/features/documentWorkspaceFilters.js +11 -0
- package/dist/components/features/settings/CategoryManager.d.ts +2 -0
- package/dist/components/features/settings/CategoryManager.js +15 -8
- package/dist/components/features/settings/PriorityManager.d.ts +18 -0
- package/dist/components/features/settings/PriorityManager.js +51 -0
- package/dist/components/features/settings/TaxonomyEditor.d.ts +2 -1
- package/dist/components/features/settings/TaxonomyEditor.js +41 -18
- package/dist/components/features/settings/TaxonomyLibraryManager.d.ts +26 -0
- package/dist/components/features/settings/TaxonomyLibraryManager.js +301 -0
- package/dist/components/features/settings/TaxonomyLibraryManager.test.js +141 -0
- package/dist/components/features/settings/TaxonomyManager.d.ts +35 -12
- package/dist/components/features/settings/TaxonomyManager.js +59 -27
- package/dist/components/features/settings/TypeManager.d.ts +11 -0
- package/dist/components/features/settings/TypeManager.js +48 -11
- package/dist/components/features/settings/{WorkflowEditorPrototype.d.ts → WorkflowEditor.d.ts} +2 -2
- package/dist/components/features/settings/{WorkflowEditorPrototype.js → WorkflowEditor.js} +3 -3
- package/dist/components/task/TaskActionHeader.d.ts +12 -2
- package/dist/components/task/TaskActionHeader.js +64 -8
- package/dist/components/task/TaskActionHeader.test.js +73 -0
- package/dist/components/task/TaskCard.d.ts +14 -16
- package/dist/components/task/TaskCard.js +144 -174
- package/dist/components/task/TaskCard.test.js +416 -64
- package/dist/components/task/TaskContextUpload.d.ts +6 -5
- package/dist/components/task/TaskContextUpload.js +199 -64
- package/dist/components/task/TaskContextUpload.test.js +331 -14
- package/dist/components/task/TaskForm.d.ts +23 -29
- package/dist/components/task/TaskForm.js +348 -169
- package/dist/components/task/TaskForm.test.js +419 -23
- package/dist/components/task/TaskKanban.d.ts +20 -21
- package/dist/components/task/TaskKanban.js +176 -316
- package/dist/components/task/TaskKanban.planning-drop.test.js +93 -0
- package/dist/components/task/TaskList.d.ts +22 -11
- package/dist/components/task/TaskList.js +98 -12
- package/dist/components/task/TaskList.test.js +206 -7
- package/dist/components/task/TaskReferenceBadge.d.ts +12 -0
- package/dist/components/task/TaskReferenceBadge.js +5 -0
- package/dist/components/task/TaskStatusActions.d.ts +12 -0
- package/dist/components/task/TaskStatusActions.js +18 -0
- package/dist/components/task/TaskStatusActions.test.js +45 -0
- package/dist/components/ui/ImageReferenceBadge.d.ts +12 -0
- package/dist/components/ui/ImageReferenceBadge.js +5 -0
- package/dist/components/ui/LevelSelector.d.ts +2 -1
- package/dist/components/ui/LevelSelector.js +2 -2
- package/dist/components/ui/Markdown.d.ts +1 -2
- package/dist/components/ui/Markdown.js +2 -13
- package/dist/components/ui/Modal.d.ts +3 -2
- package/dist/components/ui/Modal.js +4 -3
- package/dist/components/ui/MultiSelectFilter.d.ts +3 -1
- package/dist/components/ui/MultiSelectFilter.js +2 -2
- package/dist/components/ui/ReferenceBadgeButton.d.ts +13 -0
- package/dist/components/ui/ReferenceBadgeButton.js +6 -0
- package/dist/components/ui/TaxonomyDropdown.d.ts +7 -1
- package/dist/components/ui/TaxonomyDropdown.js +58 -23
- package/dist/components/ui/TopNoticeLayer.d.ts +7 -0
- package/dist/components/ui/TopNoticeLayer.js +14 -0
- package/dist/components/ui/TopNoticeLayer.test.js +25 -0
- package/dist/components/views/AppShellHeader.d.ts +13 -0
- package/dist/components/views/AppShellHeader.js +19 -0
- package/dist/components/views/AppShellHeader.test.js +21 -0
- package/dist/components/views/PlanComparisonPage.d.ts +73 -0
- package/dist/components/views/PlanComparisonPage.js +196 -0
- package/dist/components/views/PlanComparisonPage.test.js +251 -0
- package/dist/components/views/PlansPage.d.ts +14 -0
- package/dist/components/views/PlansPage.js +355 -0
- package/dist/components/views/StandaloneLayout.d.ts +2 -2
- package/dist/components/views/StandaloneLayout.js +2212 -1194
- package/dist/components/views/WidgetView.d.ts +2 -2
- package/dist/components/views/WidgetView.js +149 -43
- package/dist/components/views/chrome/WorkspaceChromeSections.d.ts +57 -0
- package/dist/components/views/chrome/WorkspaceChromeSections.js +38 -0
- package/dist/components/views/chrome/WorkspaceChromeSections.test.js +54 -0
- package/dist/components/views/chrome/workspaceChrome.d.ts +31 -0
- package/dist/components/views/chrome/workspaceChrome.js +108 -0
- package/dist/components/views/chrome/workspaceChrome.test.js +52 -0
- package/dist/components/views/panels/DocumentFilterToolbar.d.ts +10 -0
- package/dist/components/views/panels/DocumentFilterToolbar.js +7 -0
- package/dist/components/views/panels/DocumentFilterToolbar.test.js +19 -0
- package/dist/components/views/panels/FilterToolbar.d.ts +66 -0
- package/dist/components/views/panels/FilterToolbar.js +21 -0
- package/dist/components/views/panels/FilterToolbar.test.d.ts +1 -0
- package/dist/components/views/panels/FilterToolbar.test.js +45 -0
- package/dist/components/views/panels/FilterToolbarControls.d.ts +46 -0
- package/dist/components/views/panels/FilterToolbarControls.js +61 -0
- package/dist/components/views/panels/PlanningDrawer.d.ts +115 -0
- package/dist/components/views/panels/PlanningDrawer.js +220 -0
- package/dist/components/views/panels/ScheduleSidebar.d.ts +52 -0
- package/dist/components/views/panels/ScheduleSidebar.js +127 -0
- package/dist/components/views/panels/scheduleUtils.d.ts +14 -0
- package/dist/components/views/panels/scheduleUtils.js +79 -0
- package/dist/components/views/teamManagementAccess.d.ts +6 -0
- package/dist/components/views/teamManagementAccess.js +18 -0
- package/dist/components/views/teamManagementAccess.test.d.ts +1 -0
- package/dist/components/views/teamManagementAccess.test.js +44 -0
- package/dist/config/clientDeployment.d.ts +2 -0
- package/dist/config/clientDeployment.js +13 -0
- package/dist/config/cloudEnvironment.d.ts +15 -0
- package/dist/config/cloudEnvironment.js +60 -0
- package/dist/config/deployment.d.ts +20 -0
- package/dist/config/deployment.js +67 -0
- package/dist/config/deployment.test.d.ts +1 -0
- package/dist/config/deployment.test.js +88 -0
- package/dist/config/envSchema.js +36 -8
- package/dist/config/envSchema.test.js +28 -0
- package/dist/core/AiProfileService.d.ts +66 -0
- package/dist/core/AiProfileService.js +320 -0
- package/dist/core/AiProfileService.test.d.ts +1 -0
- package/dist/core/AiProfileService.test.js +164 -0
- package/dist/core/AiProfiles.test.d.ts +1 -0
- package/dist/core/AiProfiles.test.js +449 -0
- package/dist/core/AttachmentLinkService.d.ts +15 -0
- package/dist/core/AttachmentLinkService.js +157 -0
- package/dist/core/AuthTokenService.d.ts +44 -0
- package/dist/core/AuthTokenService.js +207 -0
- package/dist/core/CreatedBy.test.js +134 -6
- package/dist/core/DeletedTaskLifecycleService.d.ts +33 -0
- package/dist/core/DeletedTaskLifecycleService.js +158 -0
- package/dist/core/DeletedTaskTrash.test.d.ts +1 -0
- package/dist/core/DeletedTaskTrash.test.js +104 -0
- package/dist/core/EntitlementsPolicy.test.js +78 -5
- package/dist/core/GlobalSettingsService.d.ts +16 -0
- package/dist/core/GlobalSettingsService.js +370 -0
- package/dist/core/JsonBackupRuntime.test.d.ts +1 -0
- package/dist/core/JsonBackupRuntime.test.js +155 -0
- package/dist/core/McpTokenService.d.ts +118 -0
- package/dist/core/McpTokenService.js +921 -0
- package/dist/core/PlanEntitlementService.d.ts +201 -0
- package/dist/core/PlanEntitlementService.js +1442 -0
- package/dist/core/PlanVersionPolicy.test.d.ts +1 -0
- package/dist/core/PlanVersionPolicy.test.js +178 -0
- package/dist/core/PlanningEntities.test.d.ts +1 -0
- package/dist/core/PlanningEntities.test.js +95 -0
- package/dist/core/ScheduleFields.test.js +15 -19
- package/dist/core/SignupMonetizationSettings.test.d.ts +1 -0
- package/dist/core/SignupMonetizationSettings.test.js +159 -0
- package/dist/core/Stats.test.d.ts +1 -0
- package/dist/core/Stats.test.js +36 -0
- package/dist/core/SyncReconciliationService.d.ts +93 -0
- package/dist/core/SyncReconciliationService.js +406 -0
- package/dist/core/SystemAdmin.test.js +578 -13
- package/dist/core/TaskActivityService.d.ts +21 -0
- package/dist/core/TaskActivityService.js +130 -0
- package/dist/core/TaskAttachmentsCanonical.test.d.ts +1 -0
- package/dist/core/TaskAttachmentsCanonical.test.js +306 -0
- package/dist/core/TaskAuditTimeline.test.d.ts +1 -0
- package/dist/core/TaskAuditTimeline.test.js +132 -0
- package/dist/core/TaskTaxonomyValidation.test.js +338 -15
- package/dist/core/Taskforce.d.ts +930 -183
- package/dist/core/Taskforce.ids.test.js +252 -0
- package/dist/core/Taskforce.js +3848 -2532
- package/dist/core/Taskforce.mcpAuth.test.d.ts +1 -0
- package/dist/core/Taskforce.mcpAuth.test.js +343 -0
- package/dist/core/Taskforce.realtimeMutation.test.js +57 -2
- package/dist/core/TaxonomySettingsService.d.ts +18 -0
- package/dist/core/TaxonomySettingsService.js +162 -0
- package/dist/core/WorkspaceDelete.test.js +32 -13
- package/dist/core/WorkspaceLifecycleService.d.ts +11 -0
- package/dist/core/WorkspaceLifecycleService.js +88 -0
- package/dist/core/WorkspacePermissions.test.js +95 -0
- package/dist/core/WorkspacePlanMode.test.js +114 -1
- package/dist/core/WorkspacePreferenceService.d.ts +41 -0
- package/dist/core/WorkspacePreferenceService.js +246 -0
- package/dist/core/WorkspaceSyncSettings.test.d.ts +1 -0
- package/dist/core/WorkspaceSyncSettings.test.js +65 -0
- package/dist/core/__tests__/TaskAttachmentsCanonical.test.d.ts +1 -0
- package/dist/core/__tests__/TaskAttachmentsCanonical.test.js +212 -0
- package/dist/core/shared.d.ts +36 -0
- package/dist/core/shared.js +128 -0
- package/dist/core/types.d.ts +614 -0
- package/dist/core/types.js +27 -0
- package/dist/documentReviews/DocumentReviewCommentStore.d.ts +56 -0
- package/dist/documentReviews/DocumentReviewCommentStore.js +230 -0
- package/dist/documentReviews/DocumentReviewSessionStore.d.ts +52 -0
- package/dist/documentReviews/DocumentReviewSessionStore.js +193 -0
- package/dist/documentReviews/DocumentReviewSessionStore.test.d.ts +1 -0
- package/dist/documentReviews/DocumentReviewSessionStore.test.js +127 -0
- package/dist/documentReviews/service.d.ts +68 -0
- package/dist/documentReviews/service.js +210 -0
- package/dist/documentReviews/types.d.ts +58 -0
- package/dist/documentReviews/types.js +1 -0
- package/dist/hooks/auth/useAuthGuardPolicy.d.ts +2 -0
- package/dist/hooks/auth/useAuthGuardPolicy.js +1 -0
- package/dist/hooks/tasks/useCurrentTaskRelations.d.ts +15 -0
- package/dist/hooks/tasks/useCurrentTaskRelations.js +37 -0
- package/dist/hooks/tasks/useTaskActions.d.ts +3 -0
- package/dist/hooks/tasks/useTaskActions.js +2 -0
- package/dist/hooks/tasks/useTaskEditorNavigation.d.ts +65 -0
- package/dist/hooks/tasks/useTaskEditorNavigation.js +235 -0
- package/dist/hooks/tasks/useTaskFilters.d.ts +2 -0
- package/dist/hooks/tasks/useTaskFilters.js +2 -0
- package/dist/hooks/tasks/useTaskFormActions.d.ts +58 -0
- package/dist/hooks/tasks/useTaskFormActions.js +365 -0
- package/dist/hooks/tasks/useTaskRelationships.d.ts +16 -0
- package/dist/hooks/tasks/useTaskRelationships.js +64 -0
- package/dist/hooks/ui/useResourceExport.d.ts +19 -0
- package/dist/hooks/ui/useResourceExport.js +84 -0
- package/dist/hooks/ui/useSettingsModel.d.ts +203 -0
- package/dist/hooks/ui/useSettingsModel.js +125 -0
- package/dist/hooks/ui/useSettingsPersistence.d.ts +36 -0
- package/dist/hooks/ui/useSettingsPersistence.js +254 -0
- package/dist/hooks/ui/useSettingsTaxonomyManagement.d.ts +119 -0
- package/dist/hooks/ui/useSettingsTaxonomyManagement.js +536 -0
- package/dist/hooks/ui/useUiNotice.d.ts +1 -0
- package/dist/hooks/ui/useUiNotice.js +1 -0
- package/dist/hooks/ui/useWorkflowTemplates.d.ts +37 -0
- package/dist/hooks/ui/useWorkflowTemplates.js +111 -0
- package/dist/hooks/ui/useZenMode.d.ts +5 -0
- package/dist/hooks/ui/useZenMode.js +32 -0
- package/dist/hooks/useFilterSort.d.ts +60 -0
- package/dist/hooks/useFilterSort.js +362 -0
- package/dist/hooks/useFilterSort.test.d.ts +1 -0
- package/dist/hooks/useFilterSort.test.js +333 -0
- package/dist/hooks/useRealtimeSync.d.ts +1 -0
- package/dist/hooks/useRealtimeSync.js +24 -9
- package/dist/hooks/useRealtimeSync.test.js +28 -1
- package/dist/hooks/useSyncOrchestrator.aiProfiles.test.d.ts +1 -0
- package/dist/hooks/useSyncOrchestrator.aiProfiles.test.js +34 -0
- package/dist/hooks/useSyncOrchestrator.d.ts +65 -103
- package/dist/hooks/useSyncOrchestrator.js +1538 -670
- package/dist/hooks/useSyncOrchestrator.retry-closure.test.js +700 -174
- package/dist/hooks/useTaskData.d.ts +35 -0
- package/dist/hooks/useTaskData.js +239 -0
- package/dist/hooks/useTaskData.test.d.ts +1 -0
- package/dist/hooks/useTaskData.test.js +119 -0
- package/dist/hooks/useTaskMutations.d.ts +46 -0
- package/dist/hooks/useTaskMutations.js +472 -0
- package/dist/hooks/useTaskMutations.test.d.ts +1 -0
- package/dist/hooks/useTaskMutations.test.js +80 -0
- package/dist/hooks/useTaskforce.contract.test.d.ts +1 -0
- package/dist/hooks/useTaskforce.contract.test.js +7 -0
- package/dist/hooks/useTaskforce.d.ts +260 -295
- package/dist/hooks/useTaskforce.js +1954 -2623
- package/dist/hooks/useTaskforce.priority-filters.test.js +6 -11
- package/dist/hooks/useTaskforce.sync-behavior.test.d.ts +1 -0
- package/dist/hooks/useTaskforce.sync-behavior.test.js +1120 -0
- package/dist/hooks/useUiNotice.d.ts +16 -0
- package/dist/hooks/useUiNotice.js +49 -0
- package/dist/hooks/useWorkspaceSyncController.d.ts +23 -46
- package/dist/hooks/useWorkspaceSyncController.js +280 -461
- package/dist/hooks/useWorkspaceSyncController.test.js +106 -199
- package/dist/hooks/workspace/useTaskforceApiRouting.d.ts +8 -0
- package/dist/hooks/workspace/useTaskforceApiRouting.js +91 -0
- package/dist/hooks/workspace/useTaskforceApiRouting.test.d.ts +1 -0
- package/dist/hooks/workspace/useTaskforceApiRouting.test.js +60 -0
- package/dist/hooks/workspace/useWorkspaceSyncController.d.ts +1 -0
- package/dist/hooks/workspace/useWorkspaceSyncController.js +1 -0
- package/dist/hooks/workspace/workspaceLocalState.d.ts +30 -0
- package/dist/hooks/workspace/workspaceLocalState.js +101 -0
- package/dist/localization/locales/en-US.d.ts +1 -8
- package/dist/localization/locales/en-US.js +4 -11
- package/dist/localization/locales/es-419.js +2 -9
- package/dist/localization/locales/pt-BR.js +2 -9
- package/dist/localization/localizationCatalogs.test.d.ts +1 -0
- package/dist/localization/localizationCatalogs.test.js +37 -0
- package/dist/main.d.ts +1 -0
- package/dist/main.js +9 -15
- package/dist/mcp/clientIntegrations.d.ts +33 -0
- package/dist/mcp/clientIntegrations.js +199 -0
- package/dist/mcp/clientIntegrations.test.d.ts +1 -0
- package/dist/mcp/clientIntegrations.test.js +110 -0
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +2 -0
- package/dist/mcp/optionResolution.test.js +6 -2
- package/dist/mcp/runtime.d.ts +120 -0
- package/dist/mcp/runtime.js +5668 -0
- package/dist/mcp/runtime.test.d.ts +1 -0
- package/dist/mcp/runtime.test.js +3293 -0
- package/dist/mcp/server.js +2 -1793
- package/dist/mcp/structuredCommentValidation.test.d.ts +1 -0
- package/dist/{__tests__ → mcp}/structuredCommentValidation.test.js +1 -1
- package/dist/mcp/structuredDocValidation.js +1 -2
- package/dist/mcp/structuredDocValidation.test.d.ts +1 -0
- package/dist/{__tests__ → mcp}/structuredDocValidation.test.js +9 -4
- package/dist/mcp/toolRegistry.d.ts +570 -0
- package/dist/mcp/toolRegistry.js +90 -0
- package/dist/mcp/toolRegistry.test.d.ts +1 -0
- package/dist/mcp/toolRegistry.test.js +30 -0
- package/dist/migrations/billingSchemaParity.test.js +111 -0
- package/dist/migrations/taskSchemaMigrations.d.ts +5 -0
- package/dist/migrations/taskSchemaMigrations.js +681 -39
- package/dist/migrations/taskSchemaMigrations.test.d.ts +1 -0
- package/dist/migrations/taskSchemaMigrations.test.js +210 -0
- package/dist/plugins/vite.js +13 -7
- package/dist/public/apple-touch-icon.png +0 -0
- package/dist/public/archive/phoenix/apple-touch-icon.png +0 -0
- package/dist/public/archive/phoenix/favicon.ico +0 -0
- package/dist/public/archive/phoenix/site.webmanifest +1 -0
- package/dist/public/favicon-96x96.png +0 -0
- package/dist/public/favicon.ico +0 -0
- package/dist/public/favicon.svg +17 -0
- package/dist/public/site.webmanifest +21 -1
- package/dist/public/web-app-manifest-192x192.png +0 -0
- package/dist/public/web-app-manifest-512x512.png +0 -0
- package/dist/releaseVersion.test.d.ts +1 -0
- package/dist/{__tests__/releaseVersion.test.js → releaseVersion.test.js} +1 -1
- package/dist/resources/templates/WORKFLOW_V2_POLICY.md +1 -1
- package/dist/resources/templates/workflow-sources/workflowDocs.mjs +62 -52
- package/dist/resources/templates/workflows/collaborate.yaml +11 -5
- package/dist/resources/templates/workflows/do.yaml +8 -2
- package/dist/resources/templates/workflows/evaluate.yaml +13 -7
- package/dist/resources/templates/workflows/execute.yaml +40 -23
- package/dist/resources/templates/workflows/plan.yaml +15 -8
- package/dist/resources/templates/workflows/review.yaml +14 -8
- package/dist/runtime/appGateDefinitions.d.ts +32 -0
- package/dist/runtime/appGateDefinitions.js +32 -0
- package/dist/runtime/appGates.d.ts +29 -0
- package/dist/runtime/appGates.js +53 -0
- package/dist/runtime/appGates.test.d.ts +1 -0
- package/dist/runtime/appGates.test.js +42 -0
- package/dist/runtime/migrationFlags.d.ts +1 -0
- package/dist/runtime/migrationFlags.js +1 -0
- package/dist/server/annotatedAttachmentsRoutes.test.d.ts +1 -0
- package/dist/server/annotatedAttachmentsRoutes.test.js +473 -0
- package/dist/server/auth.js +14 -2
- package/dist/server/auth.test.js +21 -1
- package/dist/server/cors.js +11 -5
- package/dist/server/cors.test.js +6 -0
- package/dist/server/documentReviewRoutes.test.d.ts +1 -0
- package/dist/server/documentReviewRoutes.test.js +157 -0
- package/dist/server/index.cookieProxy.test.js +46 -1
- package/dist/server/index.d.ts +20 -0
- package/dist/server/index.js +168 -41
- package/dist/server/index.rateLimit.test.js +6 -0
- package/dist/server/index.test.js +133 -2
- package/dist/server/mockStripe.d.ts +72 -0
- package/dist/server/mockStripe.js +357 -0
- package/dist/server/realtimeSyncWs.js +4 -0
- package/dist/server/routes/admin.d.ts +114 -0
- package/dist/server/routes/admin.js +2226 -0
- package/dist/server/routes/annotatedAttachments.d.ts +24 -0
- package/dist/server/routes/annotatedAttachments.js +235 -0
- package/dist/server/routes/auth.d.ts +61 -0
- package/dist/server/routes/auth.js +1296 -0
- package/dist/server/{routes.billing.d.ts → routes/billing.d.ts} +3 -2
- package/dist/server/routes/billing.js +2001 -0
- package/dist/server/routes/billing.test.d.ts +1 -0
- package/dist/server/routes/billing.test.js +1631 -0
- package/dist/server/routes/documentReviews.d.ts +11 -0
- package/dist/server/routes/documentReviews.js +191 -0
- package/dist/server/routes/documents.d.ts +118 -0
- package/dist/server/routes/documents.js +1113 -0
- package/dist/server/routes/resources.d.ts +25 -0
- package/dist/server/routes/resources.js +225 -0
- package/dist/server/routes/shared.d.ts +35 -0
- package/dist/server/routes/shared.js +305 -0
- package/dist/server/routes/shared.test.d.ts +1 -0
- package/dist/server/routes/shared.test.js +32 -0
- package/dist/server/{routes.sync.d.ts → routes/sync.d.ts} +5 -5
- package/dist/server/routes/sync.integration.test.d.ts +1 -0
- package/dist/server/routes/sync.integration.test.js +2003 -0
- package/dist/server/routes/sync.js +3143 -0
- package/dist/server/routes/tasks.d.ts +72 -0
- package/dist/server/routes/tasks.js +1252 -0
- package/dist/server/routes/workspaces.d.ts +32 -0
- package/dist/server/routes/workspaces.js +307 -0
- package/dist/server/routes.d.ts +8 -9
- package/dist/server/routes.js +968 -4092
- package/dist/server/routes.test.js +9043 -2415
- package/dist/server/runtimeMode.d.ts +1 -1
- package/dist/server/runtimeMode.js +3 -18
- package/dist/server/runtimeMode.test.js +3 -3
- package/dist/server/securityHeaders.d.ts +1 -1
- package/dist/server/securityHeaders.js +65 -6
- package/dist/server/securityHeaders.test.js +40 -2
- package/dist/services/templateEngine.test.d.ts +1 -0
- package/dist/{__tests__ → services}/templateEngine.test.js +1 -1
- package/dist/services/templates.test.d.ts +1 -0
- package/dist/{__tests__ → services}/templates.test.js +1 -1
- package/dist/services/workflowDocumentFixtures.test.d.ts +1 -0
- package/dist/{__tests__ → services}/workflowDocumentFixtures.test.js +4 -4
- package/dist/services/workflowExportMatrix.test.d.ts +1 -0
- package/dist/{__tests__ → services}/workflowExportMatrix.test.js +1 -1
- package/dist/services/workflowExportSnapshots.test.d.ts +1 -0
- package/dist/services/workflowGeneration.test.d.ts +1 -0
- package/dist/services/workflowSimulation.test.d.ts +1 -0
- package/dist/services/workflowSimulation.test.js +113 -0
- package/dist/services/workflowV2Policy.test.d.ts +1 -0
- package/dist/{__tests__ → services}/workflowV2Policy.test.js +2 -2
- package/dist/shared/aiProfileSurfaceType.d.ts +9 -0
- package/dist/shared/aiProfileSurfaceType.js +49 -0
- package/dist/shared/customTaxonomyLibrary.d.ts +11 -0
- package/dist/shared/customTaxonomyLibrary.js +276 -0
- package/dist/shared/customTaxonomyLibrary.test.d.ts +1 -0
- package/dist/shared/customTaxonomyLibrary.test.js +20 -0
- package/dist/shared/taxonomyCatalog.d.ts +19 -0
- package/dist/shared/taxonomyCatalog.js +36 -0
- package/dist/shared/taxonomyDefaults.d.ts +29 -0
- package/dist/shared/taxonomyDefaults.js +26 -0
- package/dist/shared/taxonomyLibrary.d.ts +15 -0
- package/dist/shared/taxonomyLibrary.js +98 -0
- package/dist/shared/taxonomyLibrary.test.d.ts +1 -0
- package/dist/shared/taxonomyLibrary.test.js +26 -0
- package/dist/shared/taxonomyState.d.ts +36 -0
- package/dist/shared/taxonomyState.js +73 -0
- package/dist/shared/taxonomyState.test.d.ts +1 -0
- package/dist/shared/taxonomyState.test.js +71 -0
- package/dist/shared/workflowDefaults.d.ts +9 -0
- package/dist/shared/workflowDefaults.js +11 -0
- package/dist/storage/documentIntegrity.d.ts +2 -0
- package/dist/storage/documentIntegrity.js +34 -17
- package/dist/storage/documentPurge.d.ts +2 -1
- package/dist/storage/documentPurge.js +35 -8
- package/dist/storage/index.d.ts +4 -0
- package/dist/storage/index.js +2 -0
- package/dist/storage/objectStorage.d.ts +1 -1
- package/dist/storage/objectStorageClient.d.ts +6 -4
- package/dist/storage/objectStorageClient.js +77 -29
- package/dist/storage/objectStorageClient.test.d.ts +1 -0
- package/dist/storage/objectStorageClient.test.js +57 -0
- package/dist/storage/objectStorageConfig.js +3 -1
- package/dist/storage/objectStorageConfig.test.d.ts +1 -0
- package/dist/storage/objectStorageConfig.test.js +38 -0
- package/dist/storage/postgresAdapter.d.ts +5 -0
- package/dist/storage/postgresAdapter.js +2 -2
- package/dist/storage/postgresAdapter.test.d.ts +1 -0
- package/dist/storage/postgresAdapter.test.js +29 -0
- package/dist/storage/taskAssetStore.d.ts +7 -4
- package/dist/storage/taskAssetStore.js +65 -60
- package/dist/storage/workspaceAssetStore.d.ts +122 -0
- package/dist/storage/workspaceAssetStore.js +496 -0
- package/dist/storage/workspaceAssetStore.test.d.ts +1 -0
- package/dist/storage/workspaceAssetStore.test.js +501 -0
- package/dist/sync/cloudSyncApi.d.ts +33 -2
- package/dist/sync/cloudSyncApi.js +37 -15
- package/dist/sync/cloudSyncApi.test.js +60 -3
- package/dist/sync/index.d.ts +2 -0
- package/dist/sync/index.js +3 -0
- package/dist/sync/syncService.d.ts +25 -0
- package/dist/sync/syncService.js +184 -16
- package/dist/sync/syncService.test.js +289 -25
- package/dist/sync/workspaceRepair.d.ts +114 -0
- package/dist/sync/workspaceRepair.js +566 -0
- package/dist/sync/workspaceSyncModel.d.ts +230 -2
- package/dist/sync/workspaceSyncModel.js +456 -17
- package/dist/sync/workspaceSyncModel.test.js +642 -0
- package/dist/sync/workspaceSyncState.d.ts +12 -0
- package/dist/sync/workspaceSyncState.js +12 -0
- package/dist/sync/workspaceSyncSurface.d.ts +33 -0
- package/dist/sync/workspaceSyncSurface.js +74 -0
- package/dist/types.d.ts +143 -18
- package/dist/types.js +9 -24
- package/dist/ui/assets/AgentsModule-TVmCgizS.js +1 -0
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-BaS2VwIr.css +1 -0
- package/dist/ui/assets/AnnotatedAttachmentWorkspace-CAyhnPeR.js +3 -0
- package/dist/ui/assets/DocumentWorkspace-BOCw5e4D.js +250 -0
- package/dist/ui/assets/DocumentWorkspace-C_8T8oz-.css +1 -0
- package/dist/ui/assets/InitiativesModule-CN0r02Oi.js +1 -0
- package/dist/ui/assets/PlansPage-BlVC_lRq.css +1 -0
- package/dist/ui/assets/PlansPage-FcQSNLZd.js +1 -0
- package/dist/ui/assets/TaskSettings-BwB9NtmJ.css +1 -0
- package/dist/ui/assets/TaskSettings-Cw5zYD1L.js +8 -0
- package/dist/ui/assets/WorkflowsModule-CY9R2zPB.js +5 -0
- package/dist/ui/assets/index-Bzqy5QGm.js +6 -0
- package/dist/ui/assets/index-DxRiI3tY.css +1 -0
- package/dist/ui/assets/vendor-dnd-DRzYolkg.js +5 -0
- package/dist/ui/assets/{vendor-icons-ZFG3SGwo.js → vendor-icons-QZyhEwgT.js} +1 -1
- package/dist/ui/assets/{vendor-markdown-CKYkQHfj.js → vendor-markdown-BUxTU7dS.js} +1 -1
- package/dist/ui/assets/vendor-react-CKJs5o3c.js +61 -0
- package/dist/ui/assets/vendor-router-BbWMxlnO.js +3 -0
- package/dist/ui/branding/logos/logo.png +0 -0
- package/dist/ui/branding/logos/logo_dark.svg +27 -0
- package/dist/ui/branding/logos/logo_favicon.svg +35 -0
- package/dist/ui/branding/logos/logo_light.svg +27 -0
- package/dist/ui/favicon/apple-touch-icon.png +0 -0
- package/dist/ui/favicon/archive/phoenix/apple-touch-icon.png +0 -0
- package/dist/ui/favicon/archive/phoenix/favicon.ico +0 -0
- package/dist/ui/favicon/archive/phoenix/site.webmanifest +1 -0
- package/dist/ui/favicon/favicon-96x96.png +0 -0
- package/dist/ui/favicon/favicon.ico +0 -0
- package/dist/ui/favicon/favicon.svg +17 -0
- package/dist/ui/favicon/site.webmanifest +21 -1
- package/dist/ui/favicon/web-app-manifest-192x192.png +0 -0
- package/dist/ui/favicon/web-app-manifest-512x512.png +0 -0
- package/dist/ui/index.html +10 -7
- package/dist/ui/product/screen_01.png +0 -0
- package/dist/ui/product/screen_02.png +0 -0
- package/dist/ui/product/screen_03.png +0 -0
- package/dist/utils/annotatedAttachments.d.ts +20 -0
- package/dist/utils/annotatedAttachments.js +74 -0
- package/dist/utils/annotatedAttachments.test.d.ts +1 -0
- package/dist/utils/annotatedAttachments.test.js +108 -0
- package/dist/utils/assignees.d.ts +26 -0
- package/dist/utils/assignees.js +132 -0
- package/dist/utils/canonicalAssetKind.d.ts +16 -0
- package/dist/utils/canonicalAssetKind.js +39 -0
- package/dist/utils/canonicalAssetKind.test.d.ts +1 -0
- package/dist/utils/canonicalAssetKind.test.js +24 -0
- package/dist/utils/coalescedRefresh.d.ts +5 -0
- package/dist/utils/coalescedRefresh.js +16 -0
- package/dist/utils/coalescedRefresh.test.d.ts +1 -0
- package/dist/utils/coalescedRefresh.test.js +30 -0
- package/dist/utils/constants.d.ts +16 -3
- package/dist/utils/constants.icons.test.js +2 -1
- package/dist/utils/constants.js +70 -13
- package/dist/utils/contextAssetEvents.d.ts +7 -0
- package/dist/utils/contextAssetEvents.js +6 -0
- package/dist/utils/contextFiles.d.ts +14 -3
- package/dist/utils/contextFiles.js +40 -8
- package/dist/utils/documentManagerApi.d.ts +6 -0
- package/dist/utils/documentManagerApi.js +19 -0
- package/dist/utils/documentNames.d.ts +24 -0
- package/dist/utils/documentNames.js +91 -0
- package/dist/utils/documentReferences.d.ts +9 -0
- package/dist/utils/documentReferences.js +11 -0
- package/dist/utils/entityReferences.d.ts +9 -0
- package/dist/utils/entityReferences.js +32 -0
- package/dist/utils/imageReferences.d.ts +9 -0
- package/dist/utils/imageReferences.js +11 -0
- package/dist/utils/planParser.d.ts +2 -2
- package/dist/utils/planParser.js +11 -11
- package/dist/utils/planParser.test.d.ts +1 -0
- package/dist/{__tests__ → utils}/planParser.test.js +22 -22
- package/dist/utils/planningReferences.d.ts +17 -0
- package/dist/utils/planningReferences.js +30 -0
- package/dist/utils/planningReferences.test.d.ts +1 -0
- package/dist/utils/planningReferences.test.js +17 -0
- package/dist/utils/taskActivity.d.ts +9 -0
- package/dist/utils/taskActivity.js +147 -0
- package/dist/utils/taskActivity.test.d.ts +1 -0
- package/dist/utils/taskActivity.test.js +34 -0
- package/dist/utils/taskDraftDefaults.d.ts +21 -0
- package/dist/utils/taskDraftDefaults.js +40 -0
- package/dist/utils/taskDraftDefaults.test.d.ts +1 -0
- package/dist/utils/taskDraftDefaults.test.js +34 -0
- package/dist/utils/taskNormalization.d.ts +25 -0
- package/dist/utils/taskNormalization.js +161 -0
- package/dist/utils/taskNormalization.test.d.ts +1 -0
- package/dist/utils/taskNormalization.test.js +158 -0
- package/dist/utils/taskReferences.d.ts +5 -0
- package/dist/utils/taskReferences.js +11 -0
- package/dist/utils/taskforceApiClient.d.ts +2 -0
- package/dist/utils/taskforceApiClient.js +101 -3
- package/dist/utils/taskforceApiClient.test.d.ts +1 -0
- package/dist/utils/taskforceApiClient.test.js +44 -0
- package/dist/utils/taxonomyFilterOptions.d.ts +2 -0
- package/dist/utils/taxonomyFilterOptions.js +17 -0
- package/dist/utils/taxonomyFormDefaults.d.ts +3 -0
- package/dist/utils/taxonomyFormDefaults.js +28 -0
- package/dist/utils/taxonomyFormDefaults.test.d.ts +1 -0
- package/dist/utils/taxonomyFormDefaults.test.js +63 -0
- package/dist/utils/taxonomyLifecycle.d.ts +3 -0
- package/dist/utils/taxonomyLifecycle.js +17 -0
- package/dist/utils/taxonomySorting.d.ts +7 -0
- package/dist/utils/taxonomySorting.js +74 -0
- package/dist/utils/theme.d.ts +15 -0
- package/dist/utils/theme.js +23 -0
- package/dist/utils/uiNotice.d.ts +7 -0
- package/dist/utils/uiNotice.js +6 -0
- package/dist/utils/uiNotice.test.d.ts +1 -0
- package/dist/utils/uiNotice.test.js +18 -0
- package/dist/utils/workspaceIdentity.d.ts +14 -0
- package/dist/utils/workspaceIdentity.js +21 -0
- package/dist/utils/workspaceIdentity.test.js +30 -1
- package/dist/utils/workspaceSyncPresentation.d.ts +20 -0
- package/dist/utils/workspaceSyncPresentation.js +21 -0
- package/dist/utils/workspaceSyncPresentation.test.d.ts +1 -0
- package/dist/utils/workspaceSyncPresentation.test.js +36 -0
- package/package.json +28 -23
- package/scripts/bootstrap-playwright-auth.mjs +155 -0
- package/scripts/check-compat-boundaries.mjs +41 -0
- package/scripts/check-env.ts +9 -2
- package/scripts/debug-login.mjs +32 -0
- package/scripts/migrate-planning-model.ts +233 -0
- package/scripts/migrate-task-data-assets.mjs +408 -0
- package/scripts/playwright-auth.sh +11 -0
- package/scripts/run-dev-proxy.sh +2 -0
- package/scripts/update-homebrew-formula.sh +2 -2
- package/scripts/with-esbuild.sh +11 -0
- package/src/resources/templates/WORKFLOW_V2_POLICY.md +1 -1
- package/src/resources/templates/workflow-sources/workflowDocs.mjs +62 -52
- package/src/resources/templates/workflows/collaborate.yaml +11 -5
- package/src/resources/templates/workflows/do.yaml +8 -2
- package/src/resources/templates/workflows/evaluate.yaml +13 -7
- package/src/resources/templates/workflows/execute.yaml +40 -23
- package/src/resources/templates/workflows/plan.yaml +15 -8
- package/src/resources/templates/workflows/review.yaml +14 -8
- package/dist/TaskforceScreenshot.d.ts +0 -11
- package/dist/TaskforceScreenshot.js +0 -113
- package/dist/compat/priorityCompat.d.ts +0 -2
- package/dist/compat/priorityCompat.js +0 -24
- package/dist/components/features/settings/TaxonomyManager 2.d.ts +0 -52
- package/dist/components/features/settings/TaxonomyManager 2.js +0 -75
- package/dist/components/task/TaskKanban 2.d.ts +0 -76
- package/dist/components/task/TaskKanban 2.js +0 -1004
- package/dist/components/task/TaskScreenshotSection.d.ts +0 -15
- package/dist/components/task/TaskScreenshotSection.js +0 -22
- package/dist/components/views/StandaloneLayout 2.d.ts +0 -8
- package/dist/components/views/StandaloneLayout 2.js +0 -1660
- package/dist/core/InitiativeTemplates.test.js +0 -50
- package/dist/core/ParentLifecycle.test.js +0 -98
- package/dist/migrations/clientMigrations.d.ts +0 -9
- package/dist/migrations/clientMigrations.js +0 -74
- package/dist/migrations/flags.d.ts +0 -6
- package/dist/migrations/flags.js +0 -8
- package/dist/migrations/taskMigrations.d.ts +0 -71
- package/dist/migrations/taskMigrations.js +0 -236
- package/dist/migrations/taskMigrations.test.js +0 -34
- package/dist/server/routes.billing.js +0 -991
- package/dist/server/routes.billing.test.js +0 -387
- package/dist/server/routes.sync.integration.test.js +0 -470
- package/dist/server/routes.sync.js +0 -1141
- package/dist/soak/syncSoakHarness.d.ts +0 -6
- package/dist/soak/syncSoakHarness.js +0 -10
- package/dist/ui/assets/index-0W5vyCpn.css +0 -1
- package/dist/ui/assets/index-MCZuNNfn.js +0 -23
- package/dist/ui/assets/logo_white_01-0Vx-iIIv.png +0 -0
- package/dist/ui/assets/vendor-dnd-BI1K77C1.js +0 -5
- package/dist/ui/assets/vendor-react-DdIDsh7f.js +0 -9
- package/dist/ui/assets/vendor-router-BtiNU7Dl.js +0 -3
- package/dist/utils/taskHierarchy.d.ts +0 -4
- package/dist/utils/taskHierarchy.js +0 -69
- package/dist/utils/taskHierarchy.test.js +0 -38
- package/dist/utils/taskParenting.d.ts +0 -3
- package/dist/utils/taskParenting.js +0 -24
- package/dist/utils/taskParenting.test.js +0 -21
- package/dist/utils/taskRelations.d.ts +0 -6
- package/dist/utils/taskRelations.js +0 -24
- package/dist/utils/taskRelations.test.js +0 -34
- package/scripts/check-compat-boundaries.js +0 -48
- /package/dist/{__tests__/planParser.test.d.ts → TaskforceCore.filter-persistence.test.d.ts} +0 -0
- /package/dist/{__tests__/releaseVersion.test.d.ts → TaskforceCore.routing.test.d.ts} +0 -0
- /package/dist/{__tests__/structuredCommentValidation.test.d.ts → annotatedAttachments/AnnotatedAttachmentSessionStore.test.d.ts} +0 -0
- /package/dist/{__tests__/structuredDocValidation.test.d.ts → annotatedAttachments/payload.test.d.ts} +0 -0
- /package/dist/{__tests__/templateEngine.test.d.ts → annotatedAttachments/types.js} +0 -0
- /package/dist/{__tests__/templates.test.d.ts → compat/workspaceSyncCompat.test.d.ts} +0 -0
- /package/dist/{__tests__/workflowDocumentFixtures.test.d.ts → components/features/AgentsModule.test.d.ts} +0 -0
- /package/dist/{__tests__/workflowExportMatrix.test.d.ts → components/features/AnnotatedAttachmentWorkspace.test.d.ts} +0 -0
- /package/dist/{__tests__/workflowExportSnapshots.test.d.ts → components/features/DocumentWorkspace.test.d.ts} +0 -0
- /package/dist/{__tests__/workflowGeneration.test.d.ts → components/features/settings/TaxonomyLibraryManager.test.d.ts} +0 -0
- /package/dist/{__tests__/workflowV2Policy.test.d.ts → components/task/TaskActionHeader.test.d.ts} +0 -0
- /package/dist/{core/InitiativeTemplates.test.d.ts → components/task/TaskKanban.planning-drop.test.d.ts} +0 -0
- /package/dist/{core/ParentLifecycle.test.d.ts → components/task/TaskStatusActions.test.d.ts} +0 -0
- /package/dist/{migrations/taskMigrations.test.d.ts → components/ui/TopNoticeLayer.test.d.ts} +0 -0
- /package/dist/{server/routes.billing.test.d.ts → components/views/AppShellHeader.test.d.ts} +0 -0
- /package/dist/{server/routes.sync.integration.test.d.ts → components/views/PlanComparisonPage.test.d.ts} +0 -0
- /package/dist/{utils/taskHierarchy.test.d.ts → components/views/chrome/WorkspaceChromeSections.test.d.ts} +0 -0
- /package/dist/{utils/taskParenting.test.d.ts → components/views/chrome/workspaceChrome.test.d.ts} +0 -0
- /package/dist/{utils/taskRelations.test.d.ts → components/views/panels/DocumentFilterToolbar.test.d.ts} +0 -0
- /package/dist/public/{android-chrome-192x192.png → archive/phoenix/android-chrome-192x192.png} +0 -0
- /package/dist/public/{android-chrome-512x512.png → archive/phoenix/android-chrome-512x512.png} +0 -0
- /package/dist/public/{favicon-16x16.png → archive/phoenix/favicon-16x16.png} +0 -0
- /package/dist/public/{favicon-32x32.png → archive/phoenix/favicon-32x32.png} +0 -0
- /package/dist/public/{favicon.png → archive/phoenix/favicon.png} +0 -0
- /package/dist/{__tests__ → services}/workflowExportSnapshots.test.js +0 -0
- /package/dist/{__tests__ → services}/workflowGeneration.test.js +0 -0
- /package/dist/ui/favicon/{android-chrome-192x192.png → archive/phoenix/android-chrome-192x192.png} +0 -0
- /package/dist/ui/favicon/{android-chrome-512x512.png → archive/phoenix/android-chrome-512x512.png} +0 -0
- /package/dist/ui/favicon/{favicon-16x16.png → archive/phoenix/favicon-16x16.png} +0 -0
- /package/dist/ui/favicon/{favicon-32x32.png → archive/phoenix/favicon-32x32.png} +0 -0
- /package/dist/ui/favicon/{favicon.png → archive/phoenix/favicon.png} +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { getDefaultTypeDefinition } from './taxonomyDefaults.js';
|
|
2
|
+
function sanitizeStringArray(input) {
|
|
3
|
+
if (!Array.isArray(input))
|
|
4
|
+
return undefined;
|
|
5
|
+
const values = input
|
|
6
|
+
.filter((entry) => typeof entry === 'string' && entry.trim().length > 0)
|
|
7
|
+
.map((entry) => entry.trim());
|
|
8
|
+
return values.length > 0 ? values : undefined;
|
|
9
|
+
}
|
|
10
|
+
export function hasWorkspaceTaxonomyStatePayload(input) {
|
|
11
|
+
if (!input || typeof input !== 'object' || Array.isArray(input))
|
|
12
|
+
return false;
|
|
13
|
+
const source = input;
|
|
14
|
+
return Array.isArray(source.categories)
|
|
15
|
+
|| Array.isArray(source.types)
|
|
16
|
+
|| Array.isArray(source.priorities)
|
|
17
|
+
|| Array.isArray(source.taxonomies)
|
|
18
|
+
|| (!!source.displayLabels && typeof source.displayLabels === 'object' && !Array.isArray(source.displayLabels));
|
|
19
|
+
}
|
|
20
|
+
export function normalizeWorkspaceTaxonomyStatePayload(input) {
|
|
21
|
+
const source = input || {};
|
|
22
|
+
const categories = Array.isArray(source.categories)
|
|
23
|
+
? source.categories.map((category) => (typeof category === 'string'
|
|
24
|
+
? { value: category.toLowerCase().replace(/\s+/g, '-'), label: category }
|
|
25
|
+
: category))
|
|
26
|
+
: [];
|
|
27
|
+
return {
|
|
28
|
+
categories,
|
|
29
|
+
types: Array.isArray(source.types)
|
|
30
|
+
? source.types.map((type) => {
|
|
31
|
+
const fallback = getDefaultTypeDefinition(type.value);
|
|
32
|
+
return {
|
|
33
|
+
...fallback,
|
|
34
|
+
...type,
|
|
35
|
+
aliases: Array.isArray(type.aliases)
|
|
36
|
+
? type.aliases.filter((alias) => typeof alias === 'string' && alias.trim().length > 0)
|
|
37
|
+
.map((alias) => alias.trim())
|
|
38
|
+
: undefined,
|
|
39
|
+
status: type.status === 'retired' ? 'retired' : 'active',
|
|
40
|
+
};
|
|
41
|
+
})
|
|
42
|
+
: [],
|
|
43
|
+
priorities: Array.isArray(source.priorities) ? source.priorities : [],
|
|
44
|
+
taxonomies: Array.isArray(source.taxonomies)
|
|
45
|
+
? source.taxonomies.map((taxonomy) => ({
|
|
46
|
+
...taxonomy,
|
|
47
|
+
aliases: sanitizeStringArray(taxonomy.aliases),
|
|
48
|
+
options: Array.isArray(taxonomy.options)
|
|
49
|
+
? taxonomy.options.map((option) => ({
|
|
50
|
+
...option,
|
|
51
|
+
aliases: sanitizeStringArray(option.aliases),
|
|
52
|
+
status: option.status === 'retired' ? 'retired' : 'active'
|
|
53
|
+
}))
|
|
54
|
+
: [],
|
|
55
|
+
status: taxonomy.status === 'retired' ? 'retired' : 'active',
|
|
56
|
+
formEnabled: taxonomy.formEnabled !== false,
|
|
57
|
+
filterEnabled: taxonomy.filterEnabled !== false,
|
|
58
|
+
sortEnabled: taxonomy.sortEnabled === true
|
|
59
|
+
}))
|
|
60
|
+
: [],
|
|
61
|
+
displayLabels: {
|
|
62
|
+
category: typeof source.displayLabels?.category === 'string' && source.displayLabels.category.trim().length > 0
|
|
63
|
+
? source.displayLabels.category.trim()
|
|
64
|
+
: undefined,
|
|
65
|
+
type: typeof source.displayLabels?.type === 'string' && source.displayLabels.type.trim().length > 0
|
|
66
|
+
? source.displayLabels.type.trim()
|
|
67
|
+
: undefined,
|
|
68
|
+
priority: typeof source.displayLabels?.priority === 'string' && source.displayLabels.priority.trim().length > 0
|
|
69
|
+
? source.displayLabels.priority.trim()
|
|
70
|
+
: undefined,
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { hasWorkspaceTaxonomyStatePayload, normalizeWorkspaceTaxonomyStatePayload } from './taxonomyState';
|
|
3
|
+
describe('taxonomyState helpers', () => {
|
|
4
|
+
it('normalizes legacy string categories into category records', () => {
|
|
5
|
+
const normalized = normalizeWorkspaceTaxonomyStatePayload({
|
|
6
|
+
categories: ['General', { value: 'research', label: 'Research' }],
|
|
7
|
+
types: [{ value: 'task', label: 'Task' }],
|
|
8
|
+
priorities: [{ value: 2, label: 'Medium' }],
|
|
9
|
+
taxonomies: []
|
|
10
|
+
});
|
|
11
|
+
expect(normalized.categories).toEqual([
|
|
12
|
+
{ value: 'general', label: 'General' },
|
|
13
|
+
{ value: 'research', label: 'Research' }
|
|
14
|
+
]);
|
|
15
|
+
expect(normalized.types).toEqual([{
|
|
16
|
+
value: 'task',
|
|
17
|
+
label: 'Task',
|
|
18
|
+
icon: 'CheckSquare',
|
|
19
|
+
color: 'blue-500',
|
|
20
|
+
aliases: undefined,
|
|
21
|
+
status: 'active'
|
|
22
|
+
}]);
|
|
23
|
+
expect(normalized.priorities).toEqual([{ value: 2, label: 'Medium' }]);
|
|
24
|
+
expect(normalized.taxonomies).toEqual([]);
|
|
25
|
+
expect(normalized.displayLabels).toEqual({});
|
|
26
|
+
});
|
|
27
|
+
it('fills missing arrays with empty collections', () => {
|
|
28
|
+
const normalized = normalizeWorkspaceTaxonomyStatePayload(undefined);
|
|
29
|
+
expect(normalized).toEqual({
|
|
30
|
+
categories: [],
|
|
31
|
+
types: [],
|
|
32
|
+
priorities: [],
|
|
33
|
+
taxonomies: [],
|
|
34
|
+
displayLabels: {}
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
it('sanitizes custom taxonomy aliases for taxonomies and options', () => {
|
|
38
|
+
const normalized = normalizeWorkspaceTaxonomyStatePayload({
|
|
39
|
+
taxonomies: [{
|
|
40
|
+
id: 'review-status',
|
|
41
|
+
label: 'Review Status',
|
|
42
|
+
aliases: [' review route ', '', 'workflow'],
|
|
43
|
+
widgetType: 'select',
|
|
44
|
+
isSystem: false,
|
|
45
|
+
multiSelect: false,
|
|
46
|
+
options: [
|
|
47
|
+
{ value: 'legal-review', label: 'Legal Review', aliases: [' legal ', '', 'lawyer'], status: 'retired' }
|
|
48
|
+
]
|
|
49
|
+
}]
|
|
50
|
+
});
|
|
51
|
+
expect(normalized.taxonomies).toEqual([
|
|
52
|
+
expect.objectContaining({
|
|
53
|
+
id: 'review-status',
|
|
54
|
+
aliases: ['review route', 'workflow'],
|
|
55
|
+
options: [
|
|
56
|
+
expect.objectContaining({
|
|
57
|
+
value: 'legal-review',
|
|
58
|
+
aliases: ['legal', 'lawyer'],
|
|
59
|
+
status: 'retired'
|
|
60
|
+
})
|
|
61
|
+
]
|
|
62
|
+
})
|
|
63
|
+
]);
|
|
64
|
+
});
|
|
65
|
+
it('detects unified taxonomy payloads', () => {
|
|
66
|
+
expect(hasWorkspaceTaxonomyStatePayload({ categories: [] })).toBe(true);
|
|
67
|
+
expect(hasWorkspaceTaxonomyStatePayload({ priorities: [] })).toBe(true);
|
|
68
|
+
expect(hasWorkspaceTaxonomyStatePayload({ foo: 'bar' })).toBe(false);
|
|
69
|
+
expect(hasWorkspaceTaxonomyStatePayload(null)).toBe(false);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface DefaultWorkflowDefinition {
|
|
2
|
+
value: string;
|
|
3
|
+
label: string;
|
|
4
|
+
color?: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare const DEFAULT_WORKFLOW_VALUE = "default";
|
|
8
|
+
export declare const BUILTIN_WORKFLOW_DEFINITIONS: readonly DefaultWorkflowDefinition[];
|
|
9
|
+
export declare function cloneDefaultWorkflowDefinitions(): DefaultWorkflowDefinition[];
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export const DEFAULT_WORKFLOW_VALUE = 'default';
|
|
2
|
+
export const BUILTIN_WORKFLOW_DEFINITIONS = [
|
|
3
|
+
{ value: DEFAULT_WORKFLOW_VALUE, label: 'Default', color: 'slate-500', icon: 'Circle' },
|
|
4
|
+
{ value: 'evaluate', label: 'Evaluate', color: 'amber-500', icon: 'Search' },
|
|
5
|
+
{ value: 'collaborate', label: 'Collaborate', color: 'blue-500', icon: 'Users' },
|
|
6
|
+
{ value: 'plan', label: 'Plan', color: 'teal-500', icon: 'FileText' },
|
|
7
|
+
{ value: 'review', label: 'Review', color: 'violet-500', icon: 'Microscope' },
|
|
8
|
+
];
|
|
9
|
+
export function cloneDefaultWorkflowDefinitions() {
|
|
10
|
+
return BUILTIN_WORKFLOW_DEFINITIONS.map((workflow) => ({ ...workflow }));
|
|
11
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ResolvedObjectStorageConfig } from './objectStorage.js';
|
|
2
2
|
import type { TaskAssetStore } from './taskAssetStore.js';
|
|
3
|
+
import type { WorkspaceAssetStore } from './workspaceAssetStore.js';
|
|
3
4
|
export type IntegrityIssueCode = 'missing_expected_local' | 'missing_expected_r2' | 'hash_mismatch_local' | 'hash_mismatch_r2' | 'missing_local_mirror' | 'missing_r2_mirror' | 'r2_check_failed';
|
|
4
5
|
export interface DocumentIntegrityIssue {
|
|
5
6
|
path: string;
|
|
@@ -25,4 +26,5 @@ export declare function scanDocumentIntegrity(params: {
|
|
|
25
26
|
requireMirror?: boolean;
|
|
26
27
|
limit?: number;
|
|
27
28
|
assetStore?: TaskAssetStore;
|
|
29
|
+
workspaceAssetStore?: WorkspaceAssetStore;
|
|
28
30
|
}): Promise<DocumentIntegrityScanResult>;
|
|
@@ -17,24 +17,38 @@ export async function scanDocumentIntegrity(params) {
|
|
|
17
17
|
const requireMirror = params.requireMirror === true;
|
|
18
18
|
const maxItems = Number.isFinite(params.limit) ? Math.max(1, Math.floor(Number(params.limit))) : 500;
|
|
19
19
|
const registry = new DocumentRegistry(params.basePath);
|
|
20
|
-
const
|
|
21
|
-
? params.
|
|
22
|
-
:
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
20
|
+
const canonicalEntries = params.workspaceAssetStore
|
|
21
|
+
? params.workspaceAssetStore.listAll({ includeDeleted: true, limit: maxItems })
|
|
22
|
+
: [];
|
|
23
|
+
const entriesRaw = canonicalEntries.length > 0
|
|
24
|
+
? canonicalEntries
|
|
25
|
+
: params.assetStore
|
|
26
|
+
? params.assetStore.listAll(maxItems)
|
|
27
|
+
: registry
|
|
28
|
+
.listAll()
|
|
29
|
+
.sort((a, b) => a.path.localeCompare(b.path))
|
|
30
|
+
.slice(0, maxItems);
|
|
26
31
|
const issues = [];
|
|
27
32
|
const byCode = {};
|
|
28
33
|
let skippedDeleted = 0;
|
|
29
34
|
const r2Client = params.objectStorage.provider === 'r2'
|
|
30
35
|
? new ObjectStorageClient(params.objectStorage)
|
|
31
36
|
: null;
|
|
37
|
+
const getEntryPath = (entry) => {
|
|
38
|
+
return 'storageKey' in entry ? entry.storageKey : entry.path;
|
|
39
|
+
};
|
|
40
|
+
const getEntryProvider = (entry) => {
|
|
41
|
+
return ('storageProvider' in entry ? entry.storageProvider : entry.provider) === 'r2' ? 'r2' : 'local';
|
|
42
|
+
};
|
|
43
|
+
const getEntryHash = (entry) => {
|
|
44
|
+
return 'contentSha256' in entry ? entry.contentSha256 : entry.sha256;
|
|
45
|
+
};
|
|
32
46
|
const addIssue = (entry, code, message) => {
|
|
33
47
|
issues.push({
|
|
34
|
-
path: entry
|
|
48
|
+
path: getEntryPath(entry),
|
|
35
49
|
code,
|
|
36
50
|
message,
|
|
37
|
-
expectedProvider: entry
|
|
51
|
+
expectedProvider: getEntryProvider(entry)
|
|
38
52
|
});
|
|
39
53
|
inc(byCode, code);
|
|
40
54
|
};
|
|
@@ -43,24 +57,27 @@ export async function scanDocumentIntegrity(params) {
|
|
|
43
57
|
skippedDeleted += 1;
|
|
44
58
|
continue;
|
|
45
59
|
}
|
|
46
|
-
const
|
|
60
|
+
const entryPath = getEntryPath(entry);
|
|
61
|
+
const entryProvider = getEntryProvider(entry);
|
|
62
|
+
const entryHash = getEntryHash(entry);
|
|
63
|
+
const localPath = path.resolve(params.basePath, entryPath);
|
|
47
64
|
const localInRoot = isPathInsideRoot(localPath, params.basePath);
|
|
48
65
|
const localExists = localInRoot && fs.existsSync(localPath);
|
|
49
66
|
let r2Exists = false;
|
|
50
67
|
let r2CheckFailed = false;
|
|
51
68
|
if (r2Client) {
|
|
52
69
|
try {
|
|
53
|
-
r2Exists = await r2Client.objectExists(
|
|
70
|
+
r2Exists = await r2Client.objectExists(entryPath);
|
|
54
71
|
}
|
|
55
72
|
catch (error) {
|
|
56
73
|
r2CheckFailed = true;
|
|
57
74
|
addIssue(entry, 'r2_check_failed', `Failed to verify R2 object existence: ${String(error?.message || error)}`);
|
|
58
75
|
}
|
|
59
76
|
}
|
|
60
|
-
if (
|
|
77
|
+
if (entryProvider === 'local' && !localExists) {
|
|
61
78
|
addIssue(entry, 'missing_expected_local', 'Registry expects a local file that does not exist on disk.');
|
|
62
79
|
}
|
|
63
|
-
if (
|
|
80
|
+
if (entryProvider === 'r2' && !r2Exists && !r2CheckFailed) {
|
|
64
81
|
addIssue(entry, 'missing_expected_r2', 'Registry expects an R2 object that does not exist.');
|
|
65
82
|
}
|
|
66
83
|
if (requireMirror) {
|
|
@@ -71,21 +88,21 @@ export async function scanDocumentIntegrity(params) {
|
|
|
71
88
|
addIssue(entry, 'missing_r2_mirror', 'R2 mirror copy is missing.');
|
|
72
89
|
}
|
|
73
90
|
}
|
|
74
|
-
if (verifyHash &&
|
|
91
|
+
if (verifyHash && entryProvider === 'local' && localExists) {
|
|
75
92
|
const localBuffer = fs.readFileSync(localPath);
|
|
76
93
|
const localHash = createDocumentHash(localBuffer);
|
|
77
|
-
if (localHash !==
|
|
94
|
+
if (localHash !== entryHash) {
|
|
78
95
|
addIssue(entry, 'hash_mismatch_local', 'Registry hash does not match local file bytes.');
|
|
79
96
|
}
|
|
80
97
|
}
|
|
81
|
-
if (verifyHash &&
|
|
82
|
-
const object = await r2Client.getObject(
|
|
98
|
+
if (verifyHash && entryProvider === 'r2' && r2Client && r2Exists && !r2CheckFailed) {
|
|
99
|
+
const object = await r2Client.getObject(entryPath);
|
|
83
100
|
if (!object) {
|
|
84
101
|
addIssue(entry, 'missing_expected_r2', 'Registry expects an R2 object that does not exist.');
|
|
85
102
|
}
|
|
86
103
|
else {
|
|
87
104
|
const objectHash = createDocumentHash(object.body);
|
|
88
|
-
if (objectHash !==
|
|
105
|
+
if (objectHash !== entryHash) {
|
|
89
106
|
addIssue(entry, 'hash_mismatch_r2', 'Registry hash does not match R2 object bytes.');
|
|
90
107
|
}
|
|
91
108
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ResolvedObjectStorageConfig } from './objectStorage.js';
|
|
2
2
|
import type { TaskAssetStore } from './taskAssetStore.js';
|
|
3
|
+
import type { WorkspaceAssetStore } from './workspaceAssetStore.js';
|
|
3
4
|
export interface DocumentPurgeSummary {
|
|
4
5
|
total: number;
|
|
5
6
|
purged: number;
|
|
@@ -7,8 +8,8 @@ export interface DocumentPurgeSummary {
|
|
|
7
8
|
}
|
|
8
9
|
export declare function purgeExpiredDocuments(params: {
|
|
9
10
|
basePath: string;
|
|
10
|
-
taskDataDir: string;
|
|
11
11
|
objectStorage: ResolvedObjectStorageConfig;
|
|
12
12
|
now?: Date;
|
|
13
13
|
assetStore?: TaskAssetStore;
|
|
14
|
+
workspaceAssetStore?: WorkspaceAssetStore;
|
|
14
15
|
}): Promise<DocumentPurgeSummary>;
|
|
@@ -4,9 +4,23 @@ import { DocumentRegistry } from './documentRegistry.js';
|
|
|
4
4
|
import { ObjectStorageClient } from './objectStorageClient.js';
|
|
5
5
|
export async function purgeExpiredDocuments(params) {
|
|
6
6
|
const registry = new DocumentRegistry(params.basePath);
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
const now = params.now || new Date();
|
|
8
|
+
const canonicalCandidates = params.workspaceAssetStore
|
|
9
|
+
? params.workspaceAssetStore.listPurgeCandidates(now)
|
|
10
|
+
: [];
|
|
11
|
+
const legacyCandidates = params.assetStore
|
|
12
|
+
? params.assetStore.listPurgeCandidates(now)
|
|
13
|
+
: registry.listPurgeCandidates(now);
|
|
14
|
+
const mergedCandidates = new Map();
|
|
15
|
+
for (const entry of canonicalCandidates) {
|
|
16
|
+
mergedCandidates.set(`canonical:${entry.storageKey}`, entry);
|
|
17
|
+
}
|
|
18
|
+
for (const entry of legacyCandidates) {
|
|
19
|
+
if (!mergedCandidates.has(`canonical:${entry.path}`)) {
|
|
20
|
+
mergedCandidates.set(`legacy:${entry.path}`, entry);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
const candidates = Array.from(mergedCandidates.values());
|
|
10
24
|
const summary = {
|
|
11
25
|
total: candidates.length,
|
|
12
26
|
purged: 0,
|
|
@@ -17,11 +31,19 @@ export async function purgeExpiredDocuments(params) {
|
|
|
17
31
|
: null;
|
|
18
32
|
for (const entry of candidates) {
|
|
19
33
|
try {
|
|
34
|
+
const storageKey = 'storageKey' in entry ? entry.storageKey : entry.path;
|
|
35
|
+
const workspaceId = entry?.workspaceId
|
|
36
|
+
? String(entry.workspaceId)
|
|
37
|
+
: (() => {
|
|
38
|
+
const normalized = String(storageKey || '').trim().replace(/\\/g, '/');
|
|
39
|
+
const match = normalized.match(/^workspaces\/([^/]+)\//);
|
|
40
|
+
return match?.[1] ? match[1] : 'default';
|
|
41
|
+
})();
|
|
20
42
|
if (objectStorageClient) {
|
|
21
|
-
await objectStorageClient.deleteObject(
|
|
43
|
+
await objectStorageClient.deleteObject(storageKey);
|
|
22
44
|
}
|
|
23
45
|
else {
|
|
24
|
-
const filePath = path.resolve(params.basePath,
|
|
46
|
+
const filePath = path.resolve(params.basePath, storageKey);
|
|
25
47
|
const storageRoot = path.resolve(params.basePath);
|
|
26
48
|
const relative = path.relative(storageRoot, filePath);
|
|
27
49
|
const insideStorageRoot = !relative.startsWith('..') && !path.isAbsolute(relative);
|
|
@@ -30,11 +52,16 @@ export async function purgeExpiredDocuments(params) {
|
|
|
30
52
|
}
|
|
31
53
|
}
|
|
32
54
|
if (params.assetStore) {
|
|
33
|
-
|
|
34
|
-
params.assetStore.remove(entry.path, workspaceId);
|
|
55
|
+
params.assetStore.remove(storageKey, workspaceId);
|
|
35
56
|
}
|
|
36
57
|
else {
|
|
37
|
-
registry.remove(
|
|
58
|
+
registry.remove(storageKey);
|
|
59
|
+
}
|
|
60
|
+
if (params.workspaceAssetStore) {
|
|
61
|
+
const canonical = params.workspaceAssetStore.getByStorageKey(storageKey, workspaceId);
|
|
62
|
+
if (canonical) {
|
|
63
|
+
params.workspaceAssetStore.remove(canonical.assetId, workspaceId);
|
|
64
|
+
}
|
|
38
65
|
}
|
|
39
66
|
summary.purged += 1;
|
|
40
67
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { DatabaseAdapter, DatabaseAdapterOptions, DatabaseStatement, DatabaseProvider } from './databaseAdapter.js';
|
|
2
|
+
export { createDatabaseAdapter } from './createDatabaseAdapter.js';
|
|
3
|
+
export { WorkspaceAssetStore } from './workspaceAssetStore.js';
|
|
4
|
+
export type { WorkspaceAssetEntry, WorkspaceAssetKind, WorkspaceAssetLinkEntry, WorkspaceAssetLinkRole, WorkspaceAssetScanStatus } from './workspaceAssetStore.js';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ResolvedObjectStorageConfig } from './objectStorage.js';
|
|
1
|
+
import type { ObjectStorageProvider, ResolvedObjectStorageConfig } from './objectStorage.js';
|
|
2
2
|
export interface StoredObject {
|
|
3
3
|
body: Buffer;
|
|
4
4
|
contentType: string;
|
|
@@ -6,13 +6,15 @@ export interface StoredObject {
|
|
|
6
6
|
export declare class ObjectStorageClient {
|
|
7
7
|
private readonly config;
|
|
8
8
|
constructor(config: ResolvedObjectStorageConfig);
|
|
9
|
-
provider():
|
|
9
|
+
provider(): ObjectStorageProvider;
|
|
10
10
|
keyForRelativePath(relativePath: string): string;
|
|
11
11
|
putObject(relativePath: string, body: Buffer, contentType: string): Promise<void>;
|
|
12
12
|
getObject(relativePath: string): Promise<StoredObject | null>;
|
|
13
13
|
objectExists(relativePath: string): Promise<boolean>;
|
|
14
14
|
deleteObject(relativePath: string): Promise<boolean>;
|
|
15
|
-
createSignedGetUrl(relativePath: string, expiresInSeconds: number
|
|
16
|
-
|
|
15
|
+
createSignedGetUrl(relativePath: string, expiresInSeconds: number, opts?: {
|
|
16
|
+
responseContentDisposition?: string | null;
|
|
17
|
+
}): string;
|
|
18
|
+
createSignedPutUrl(relativePath: string, expiresInSeconds: number, contentType?: string): string;
|
|
17
19
|
}
|
|
18
20
|
export declare function normalizeTaskDataRelativePath(rawPath: string): string | null;
|
|
@@ -2,6 +2,8 @@ import { createHash, createHmac } from 'crypto';
|
|
|
2
2
|
const AWS_ALGORITHM = 'AWS4-HMAC-SHA256';
|
|
3
3
|
const AWS_SERVICE = 's3';
|
|
4
4
|
const AWS_REGION = 'auto';
|
|
5
|
+
const TRANSIENT_GET_OBJECT_STATUS_CODES = new Set([408, 425, 429, 500, 502, 503, 504]);
|
|
6
|
+
const MAX_GET_OBJECT_ATTEMPTS = 3;
|
|
5
7
|
function sha256Hex(value) {
|
|
6
8
|
return createHash('sha256').update(value).digest('hex');
|
|
7
9
|
}
|
|
@@ -56,6 +58,25 @@ function createAmzDate(now = new Date()) {
|
|
|
56
58
|
const iso = now.toISOString();
|
|
57
59
|
return iso.replace(/[:-]|\.\d{3}/g, '');
|
|
58
60
|
}
|
|
61
|
+
function shouldRetryGetObjectStatus(status) {
|
|
62
|
+
return TRANSIENT_GET_OBJECT_STATUS_CODES.has(status);
|
|
63
|
+
}
|
|
64
|
+
function shouldRetryGetObjectError(error) {
|
|
65
|
+
if (!error || typeof error !== 'object')
|
|
66
|
+
return false;
|
|
67
|
+
const maybeError = error;
|
|
68
|
+
if (maybeError.name === 'AbortError' || maybeError.name === 'TimeoutError')
|
|
69
|
+
return true;
|
|
70
|
+
const message = String(maybeError.message || '').toLowerCase();
|
|
71
|
+
return message.includes('fetch failed')
|
|
72
|
+
|| message.includes('network')
|
|
73
|
+
|| message.includes('timed out')
|
|
74
|
+
|| message.includes('timeout')
|
|
75
|
+
|| message.includes('socket')
|
|
76
|
+
|| message.includes('econnreset')
|
|
77
|
+
|| message.includes('ecanceled')
|
|
78
|
+
|| message.includes('und_err');
|
|
79
|
+
}
|
|
59
80
|
function signRequest(params) {
|
|
60
81
|
const amzDate = createAmzDate(params.now);
|
|
61
82
|
const dateStamp = toDateStamp(amzDate);
|
|
@@ -131,31 +152,50 @@ export class ObjectStorageClient {
|
|
|
131
152
|
}
|
|
132
153
|
const key = this.keyForRelativePath(relativePath);
|
|
133
154
|
const url = new URL(`/${this.config.r2.bucket}/${key}`, this.config.r2.endpoint);
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
155
|
+
let lastError = null;
|
|
156
|
+
for (let attempt = 1; attempt <= MAX_GET_OBJECT_ATTEMPTS; attempt += 1) {
|
|
157
|
+
const payloadHash = sha256Hex('');
|
|
158
|
+
const signed = signRequest({
|
|
159
|
+
method: 'GET',
|
|
160
|
+
url,
|
|
161
|
+
accessKeyId: this.config.r2.accessKeyId,
|
|
162
|
+
secretAccessKey: this.config.r2.secretAccessKey,
|
|
163
|
+
payloadHash
|
|
164
|
+
});
|
|
165
|
+
try {
|
|
166
|
+
const response = await fetch(url, {
|
|
167
|
+
method: 'GET',
|
|
168
|
+
headers: {
|
|
169
|
+
'authorization': signed.authorization,
|
|
170
|
+
'x-amz-date': signed.amzDate,
|
|
171
|
+
'x-amz-content-sha256': payloadHash
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
if (response.status === 404)
|
|
175
|
+
return null;
|
|
176
|
+
if (!response.ok) {
|
|
177
|
+
const text = await response.text().catch(() => '');
|
|
178
|
+
const error = new Error(`Failed to read object (${response.status}): ${text || response.statusText}`);
|
|
179
|
+
if (attempt < MAX_GET_OBJECT_ATTEMPTS && shouldRetryGetObjectStatus(response.status)) {
|
|
180
|
+
lastError = error;
|
|
181
|
+
continue;
|
|
182
|
+
}
|
|
183
|
+
throw error;
|
|
184
|
+
}
|
|
185
|
+
const contentType = String(response.headers.get('content-type') || 'application/octet-stream');
|
|
186
|
+
const body = Buffer.from(await response.arrayBuffer());
|
|
187
|
+
return { body, contentType };
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
191
|
+
if (attempt < MAX_GET_OBJECT_ATTEMPTS && shouldRetryGetObjectError(normalizedError)) {
|
|
192
|
+
lastError = normalizedError;
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
throw normalizedError;
|
|
148
196
|
}
|
|
149
|
-
});
|
|
150
|
-
if (response.status === 404)
|
|
151
|
-
return null;
|
|
152
|
-
if (!response.ok) {
|
|
153
|
-
const text = await response.text().catch(() => '');
|
|
154
|
-
throw new Error(`Failed to read object (${response.status}): ${text || response.statusText}`);
|
|
155
197
|
}
|
|
156
|
-
|
|
157
|
-
const body = Buffer.from(await response.arrayBuffer());
|
|
158
|
-
return { body, contentType };
|
|
198
|
+
throw lastError || new Error('Failed to read object: unknown transient failure');
|
|
159
199
|
}
|
|
160
200
|
async objectExists(relativePath) {
|
|
161
201
|
if (this.config.provider !== 'r2' || !this.config.r2) {
|
|
@@ -217,7 +257,7 @@ export class ObjectStorageClient {
|
|
|
217
257
|
}
|
|
218
258
|
return true;
|
|
219
259
|
}
|
|
220
|
-
createSignedGetUrl(relativePath, expiresInSeconds) {
|
|
260
|
+
createSignedGetUrl(relativePath, expiresInSeconds, opts) {
|
|
221
261
|
if (this.config.provider !== 'r2' || !this.config.r2) {
|
|
222
262
|
throw new Error('R2 object storage is not configured.');
|
|
223
263
|
}
|
|
@@ -232,6 +272,9 @@ export class ObjectStorageClient {
|
|
|
232
272
|
url.searchParams.set('X-Amz-Date', amzDate);
|
|
233
273
|
url.searchParams.set('X-Amz-Expires', String(ttl));
|
|
234
274
|
url.searchParams.set('X-Amz-SignedHeaders', 'host');
|
|
275
|
+
if (typeof opts?.responseContentDisposition === 'string' && opts.responseContentDisposition.trim().length > 0) {
|
|
276
|
+
url.searchParams.set('response-content-disposition', opts.responseContentDisposition.trim());
|
|
277
|
+
}
|
|
235
278
|
const canonicalUri = encodeUriPath(url.pathname);
|
|
236
279
|
const canonicalQuery = buildCanonicalQuery(url.searchParams);
|
|
237
280
|
const canonicalRequest = [
|
|
@@ -253,7 +296,7 @@ export class ObjectStorageClient {
|
|
|
253
296
|
url.searchParams.set('X-Amz-Signature', signature);
|
|
254
297
|
return url.toString();
|
|
255
298
|
}
|
|
256
|
-
createSignedPutUrl(relativePath, expiresInSeconds) {
|
|
299
|
+
createSignedPutUrl(relativePath, expiresInSeconds, contentType) {
|
|
257
300
|
if (this.config.provider !== 'r2' || !this.config.r2) {
|
|
258
301
|
throw new Error('R2 object storage is not configured.');
|
|
259
302
|
}
|
|
@@ -267,15 +310,20 @@ export class ObjectStorageClient {
|
|
|
267
310
|
url.searchParams.set('X-Amz-Credential', `${this.config.r2.accessKeyId}/${credentialScope}`);
|
|
268
311
|
url.searchParams.set('X-Amz-Date', amzDate);
|
|
269
312
|
url.searchParams.set('X-Amz-Expires', String(ttl));
|
|
270
|
-
|
|
313
|
+
const normalizedContentType = String(contentType || '').trim();
|
|
314
|
+
const signedHeaders = normalizedContentType ? 'content-type;host' : 'host';
|
|
315
|
+
url.searchParams.set('X-Amz-SignedHeaders', signedHeaders);
|
|
271
316
|
const canonicalUri = encodeUriPath(url.pathname);
|
|
272
317
|
const canonicalQuery = buildCanonicalQuery(url.searchParams);
|
|
318
|
+
const canonicalHeaders = normalizedContentType
|
|
319
|
+
? `content-type:${normalizedContentType}\nhost:${url.host}\n`
|
|
320
|
+
: `host:${url.host}\n`;
|
|
273
321
|
const canonicalRequest = [
|
|
274
322
|
'PUT',
|
|
275
323
|
canonicalUri,
|
|
276
324
|
canonicalQuery,
|
|
277
|
-
|
|
278
|
-
|
|
325
|
+
canonicalHeaders,
|
|
326
|
+
signedHeaders,
|
|
279
327
|
'UNSIGNED-PAYLOAD'
|
|
280
328
|
].join('\n');
|
|
281
329
|
const stringToSign = [
|
|
@@ -294,7 +342,7 @@ export function normalizeTaskDataRelativePath(rawPath) {
|
|
|
294
342
|
const normalized = normalizeRelativePath(rawPath);
|
|
295
343
|
if (!normalized)
|
|
296
344
|
return null;
|
|
297
|
-
const allowedRoots = ['
|
|
345
|
+
const allowedRoots = ['users/', 'workspaces/', 'system/', 'tmp/', 'quarantine/'];
|
|
298
346
|
if (!allowedRoots.some((root) => normalized.startsWith(root)))
|
|
299
347
|
return null;
|
|
300
348
|
return normalized;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { ObjectStorageClient } from './objectStorageClient.js';
|
|
3
|
+
const TEST_CONFIG = {
|
|
4
|
+
provider: 'r2',
|
|
5
|
+
r2: {
|
|
6
|
+
accountId: 'acct-1',
|
|
7
|
+
bucket: 'taskforce-dev-assets',
|
|
8
|
+
endpoint: 'https://acct-1.r2.cloudflarestorage.com',
|
|
9
|
+
accessKeyId: 'access-key-1',
|
|
10
|
+
secretAccessKey: 'secret-key-1',
|
|
11
|
+
keyPrefix: '',
|
|
12
|
+
signedUploadTtlSeconds: 600,
|
|
13
|
+
signedDownloadTtlSeconds: 300
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
describe('ObjectStorageClient.getObject', () => {
|
|
17
|
+
afterEach(() => {
|
|
18
|
+
vi.unstubAllGlobals();
|
|
19
|
+
vi.restoreAllMocks();
|
|
20
|
+
});
|
|
21
|
+
it('retries transient upstream failures before succeeding', async () => {
|
|
22
|
+
const fetchMock = vi.fn()
|
|
23
|
+
.mockResolvedValueOnce(new Response('bad gateway', { status: 502, statusText: 'Bad Gateway' }))
|
|
24
|
+
.mockResolvedValueOnce(new Response('hello world', {
|
|
25
|
+
status: 200,
|
|
26
|
+
headers: { 'content-type': 'text/markdown' }
|
|
27
|
+
}));
|
|
28
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
29
|
+
const client = new ObjectStorageClient(TEST_CONFIG);
|
|
30
|
+
const result = await client.getObject('workspaces/workspace-1/assets/documents/doc-1.md');
|
|
31
|
+
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
32
|
+
expect(result).not.toBeNull();
|
|
33
|
+
expect(result?.contentType).toBe('text/markdown');
|
|
34
|
+
expect(result?.body.toString('utf8')).toBe('hello world');
|
|
35
|
+
});
|
|
36
|
+
it('returns null immediately for 404 responses without retrying', async () => {
|
|
37
|
+
const fetchMock = vi.fn().mockResolvedValue(new Response('', { status: 404, statusText: 'Not Found' }));
|
|
38
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
39
|
+
const client = new ObjectStorageClient(TEST_CONFIG);
|
|
40
|
+
const result = await client.getObject('workspaces/workspace-1/assets/documents/missing.md');
|
|
41
|
+
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
42
|
+
expect(result).toBeNull();
|
|
43
|
+
});
|
|
44
|
+
it('retries thrown transient fetch errors before succeeding', async () => {
|
|
45
|
+
const fetchMock = vi.fn()
|
|
46
|
+
.mockRejectedValueOnce(new TypeError('fetch failed'))
|
|
47
|
+
.mockResolvedValueOnce(new Response('recovered', {
|
|
48
|
+
status: 200,
|
|
49
|
+
headers: { 'content-type': 'text/plain' }
|
|
50
|
+
}));
|
|
51
|
+
vi.stubGlobal('fetch', fetchMock);
|
|
52
|
+
const client = new ObjectStorageClient(TEST_CONFIG);
|
|
53
|
+
const result = await client.getObject('workspaces/workspace-1/assets/documents/doc-2.txt');
|
|
54
|
+
expect(fetchMock).toHaveBeenCalledTimes(2);
|
|
55
|
+
expect(result?.body.toString('utf8')).toBe('recovered');
|
|
56
|
+
});
|
|
57
|
+
});
|