@flowdular/sdk 0.2.4 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.ai/agents/sandbox/business-manager.md +5 -1
- package/.ai/blueprints/author-spec/README.md +1 -1
- package/.ai/blueprints/author-spec/spec-requirements.yaml +44 -0
- package/.ai/blueprints/author-spec/steps.yaml +5 -5
- package/.ai/blueprints/author-spec/templates/module.yaml +99 -3
- package/.ai/blueprints/edit-module/gates.yaml +4 -0
- package/.ai/blueprints/edit-module/required-files.yaml +9 -0
- package/.ai/blueprints/new-module/gates.yaml +4 -0
- package/.ai/blueprints/new-module/spec-requirements.yaml +2 -2
- package/.ai/blueprints/release/gates.yaml +4 -0
- package/.ai/platform-capabilities.md +128 -0
- package/.ai/policies/capabilities.yaml +100 -0
- package/.ai/policies/path-ownership.yaml +5 -2
- package/.ai/policies/task-budgets.yaml +5 -3
- package/.ai/references/catalog/module.json +4 -4
- package/.ai/references/catalog/package.json +2 -2
- package/.ai/references/catalog/spec/module.yaml +5 -3
- package/.ai/references/catalog/src/platform.ts +2 -0
- package/.ai/references/catalog/src/services/catalog-service.ts +89 -1
- package/.ai/references/catalog/src/services/data-classes.ts +47 -0
- package/.ai/references/catalog/src/services/database-repository.ts +98 -1
- package/.ai/references/catalog/src/services/repository.ts +22 -1
- package/.ai/references/catalog/tests/data-classes.test.ts +157 -0
- package/.ai/references/catalog.provenance.json +12 -10
- package/.ai/skills/README.md +10 -0
- package/.ai/skills/agent-tool-design/SKILL.md +1 -2
- package/.ai/skills/auth-security-review/SKILL.md +1 -1
- package/.ai/skills/business-agent-design/SKILL.md +0 -1
- package/.ai/skills/deploy-operate/SKILL.md +114 -0
- package/.ai/skills/module-new/SKILL.md +29 -3
- package/.ai/skills/module-update/SKILL.md +9 -3
- package/.ai/skills/perf-audit/SKILL.md +0 -1
- package/.ai/skills/release-eject-pr/SKILL.md +0 -1
- package/.ai/skills/spec-interview/SKILL.md +120 -0
- package/.ai/skills/test-hardening/SKILL.md +1 -0
- package/.ai/skills/ux-design/SKILL.md +34 -3
- package/.ai/skills/variables/SKILL.md +0 -2
- package/.ai/skills/workflow-development/SKILL.md +0 -1
- package/AGENTS.md +4 -0
- package/docs/agent-contract.md +2 -2
- package/docs/design-system.md +185 -31
- package/modules/access/migrations/0001_access_core.down.sql +1 -0
- package/modules/access/migrations/0001_access_core.up.sql +28 -0
- package/modules/access/migrations/README.md +3 -0
- package/modules/access/module.json +33 -0
- package/modules/access/package.json +43 -0
- package/modules/access/spec/module.yaml +225 -0
- package/modules/access/src/acl/permissions.ts +6 -0
- package/modules/access/src/api/endpoints.ts +244 -0
- package/modules/access/src/client/ActivityView.tsrx +245 -0
- package/modules/access/src/client/AttestationsView.tsrx +176 -0
- package/modules/access/src/client/ReviewView.tsrx +586 -0
- package/modules/access/src/client/api.ts +132 -0
- package/modules/access/src/client/contribution.tsrx +41 -0
- package/modules/access/src/client/index.ts +41 -0
- package/modules/access/src/client/navigation.ts +57 -0
- package/modules/access/src/client/presentation.ts +69 -0
- package/modules/access/src/client/state.ts +72 -0
- package/modules/access/src/domain/types.ts +189 -0
- package/modules/access/src/index.ts +38 -0
- package/modules/access/src/platform.ts +60 -0
- package/modules/access/src/server/index.ts +42 -0
- package/modules/access/src/server/runtime.ts +105 -0
- package/modules/access/src/services/access-service.ts +298 -0
- package/modules/access/src/services/audit-window.ts +78 -0
- package/modules/access/src/services/auth-directory.ts +72 -0
- package/modules/access/src/services/changes.ts +91 -0
- package/modules/access/src/services/data-classes.ts +28 -0
- package/modules/access/src/services/database-repository.ts +185 -0
- package/modules/access/src/services/directory.ts +102 -0
- package/modules/access/src/services/index.ts +33 -0
- package/modules/access/src/services/list-exports.ts +150 -0
- package/modules/access/src/services/migration.ts +54 -0
- package/modules/access/src/services/repository.ts +30 -0
- package/modules/access/src/services/review.ts +178 -0
- package/modules/access/translations/en.json +155 -0
- package/modules/access/translations/pl.json +155 -0
- package/modules/agents/migrations/0022_credential_rotation_inventory.down.sql +2 -0
- package/modules/agents/migrations/0022_credential_rotation_inventory.up.sql +7 -0
- package/modules/agents/migrations/0023_agents_retention_indexes.down.sql +2 -0
- package/modules/agents/migrations/0023_agents_retention_indexes.up.sql +9 -0
- package/modules/agents/migrations/0024_agent_meter_refusals.down.sql +3 -0
- package/modules/agents/migrations/0024_agent_meter_refusals.up.sql +22 -0
- package/modules/agents/migrations/0025_agent_list_indexes.down.sql +3 -0
- package/modules/agents/migrations/0025_agent_list_indexes.up.sql +11 -0
- package/modules/agents/module.json +30 -4
- package/modules/agents/package.json +2 -1
- package/modules/agents/spec/module.yaml +63 -5
- package/modules/agents/src/api/endpoints.ts +291 -33
- package/modules/agents/src/cli/commands.json +11 -0
- package/modules/agents/src/cli/index.ts +45 -0
- package/modules/agents/src/client/AgentDashboardWidget.tsrx +19 -11
- package/modules/agents/src/client/AgentDefinitionList.tsrx +53 -10
- package/modules/agents/src/client/AgentPlaygroundView.tsrx +4 -4
- package/modules/agents/src/client/AgentProceduresView.tsrx +2 -2
- package/modules/agents/src/client/AgentRunsView.tsrx +143 -40
- package/modules/agents/src/client/AgentsView.tsrx +109 -33
- package/modules/agents/src/client/api.ts +99 -21
- package/modules/agents/src/client/state.ts +97 -0
- package/modules/agents/src/domain/types.ts +44 -4
- package/modules/agents/src/platform.ts +42 -0
- package/modules/agents/src/server/action-execution.ts +201 -106
- package/modules/agents/src/server/runtime.ts +32 -0
- package/modules/agents/src/services/agent-service.ts +158 -30
- package/modules/agents/src/services/credential-rotation.ts +185 -0
- package/modules/agents/src/services/credential-vault.ts +71 -46
- package/modules/agents/src/services/data-classes.ts +176 -0
- package/modules/agents/src/services/database-repository.ts +393 -101
- package/modules/agents/src/services/metering.ts +111 -0
- package/modules/agents/src/services/migration.ts +109 -0
- package/modules/agents/src/services/module-agent-preflight.ts +17 -9
- package/modules/agents/src/services/notifications.ts +98 -0
- package/modules/agents/src/services/provider-repository.ts +9 -18
- package/modules/agents/src/services/provider-service.ts +1 -9
- package/modules/agents/src/services/reports.ts +107 -0
- package/modules/agents/src/services/repository.ts +86 -6
- package/modules/agents/src/services/usage-service.ts +2 -0
- package/modules/agents/src/services/worker.ts +114 -4
- package/modules/agents/src/settings.ts +14 -3
- package/modules/agents/translations/en.json +14 -4
- package/modules/agents/translations/pl.json +14 -4
- package/modules/approvals/migrations/0001_approvals_core.down.sql +3 -0
- package/modules/approvals/migrations/0001_approvals_core.up.sql +78 -0
- package/modules/approvals/migrations/0002_approvals_expiry_routing_role.down.sql +2 -0
- package/modules/approvals/migrations/0002_approvals_expiry_routing_role.up.sql +19 -0
- package/modules/approvals/migrations/0003_approvals_retention_indexes.down.sql +6 -0
- package/modules/approvals/migrations/0003_approvals_retention_indexes.up.sql +14 -0
- package/modules/approvals/migrations/0004_approvals_inbox_keyset_indexes.down.sql +5 -0
- package/modules/approvals/migrations/0004_approvals_inbox_keyset_indexes.up.sql +12 -0
- package/modules/approvals/migrations/README.md +3 -0
- package/modules/approvals/module.json +34 -0
- package/modules/approvals/package.json +43 -0
- package/modules/approvals/spec/module.yaml +318 -0
- package/modules/approvals/src/acl/permissions.ts +7 -0
- package/modules/approvals/src/api/endpoints.ts +457 -0
- package/modules/approvals/src/client/ApprovalRequestDrawer.tsrx +138 -0
- package/modules/approvals/src/client/ApprovalsView.tsrx +562 -0
- package/modules/approvals/src/client/PendingCountWidget.tsrx +52 -0
- package/modules/approvals/src/client/api.ts +203 -0
- package/modules/approvals/src/client/approvals.css +51 -0
- package/modules/approvals/src/client/contribution.tsrx +44 -0
- package/modules/approvals/src/client/index.ts +26 -0
- package/modules/approvals/src/client/navigation.ts +39 -0
- package/modules/approvals/src/client/pending-count.ts +26 -0
- package/modules/approvals/src/client/presentation.ts +52 -0
- package/modules/approvals/src/client/state.ts +141 -0
- package/modules/approvals/src/domain/capability.ts +95 -0
- package/modules/approvals/src/domain/types.ts +154 -0
- package/modules/approvals/src/index.ts +52 -0
- package/modules/approvals/src/platform.ts +128 -0
- package/modules/approvals/src/server/index.ts +42 -0
- package/modules/approvals/src/server/runtime.ts +181 -0
- package/modules/approvals/src/services/approvals-service.ts +557 -0
- package/modules/approvals/src/services/callbacks.ts +75 -0
- package/modules/approvals/src/services/data-classes.ts +167 -0
- package/modules/approvals/src/services/database-repository.ts +724 -0
- package/modules/approvals/src/services/eligibility.ts +121 -0
- package/modules/approvals/src/services/expiry-runner.ts +81 -0
- package/modules/approvals/src/services/index.ts +31 -0
- package/modules/approvals/src/services/migration.ts +222 -0
- package/modules/approvals/src/services/notifications.ts +95 -0
- package/modules/approvals/src/services/repository.ts +161 -0
- package/modules/approvals/src/services/service-error.ts +70 -0
- package/modules/approvals/src/settings.ts +102 -0
- package/modules/approvals/translations/en.json +104 -0
- package/modules/approvals/translations/pl.json +104 -0
- package/modules/audit/migrations/0001_audit_core.down.sql +8 -0
- package/modules/audit/migrations/0001_audit_core.up.sql +107 -0
- package/modules/audit/migrations/0002_audit_sweep_routing_role.down.sql +2 -0
- package/modules/audit/migrations/0002_audit_sweep_routing_role.up.sql +21 -0
- package/modules/audit/migrations/0003_audit_export_request.down.sql +12 -0
- package/modules/audit/migrations/0003_audit_export_request.up.sql +40 -0
- package/modules/audit/migrations/0004_audit_hold_seal_erasure.down.sql +17 -0
- package/modules/audit/migrations/0004_audit_hold_seal_erasure.up.sql +192 -0
- package/modules/audit/migrations/0005_audit_event_format.down.sql +17 -0
- package/modules/audit/migrations/0005_audit_event_format.up.sql +60 -0
- package/modules/audit/migrations/0006_audit_own_class_walks.down.sql +3 -0
- package/modules/audit/migrations/0006_audit_own_class_walks.up.sql +14 -0
- package/modules/audit/migrations/README.md +3 -0
- package/modules/audit/module.json +32 -0
- package/modules/audit/package.json +49 -0
- package/modules/audit/spec/module.yaml +809 -0
- package/modules/audit/src/acl/permissions.ts +7 -0
- package/modules/audit/src/api/endpoints.ts +315 -0
- package/modules/audit/src/cli/commands.json +95 -0
- package/modules/audit/src/cli/index.ts +658 -0
- package/modules/audit/src/client/DataClassesView.tsrx +420 -0
- package/modules/audit/src/client/ExportsView.tsrx +256 -0
- package/modules/audit/src/client/HoldsView.tsrx +604 -0
- package/modules/audit/src/client/SweepsView.tsrx +251 -0
- package/modules/audit/src/client/api.ts +185 -0
- package/modules/audit/src/client/contribution.tsrx +52 -0
- package/modules/audit/src/client/index.ts +23 -0
- package/modules/audit/src/client/navigation.ts +74 -0
- package/modules/audit/src/client/presentation.ts +105 -0
- package/modules/audit/src/client/state.ts +86 -0
- package/modules/audit/src/domain/data-classes.ts +16 -0
- package/modules/audit/src/domain/types.ts +339 -0
- package/modules/audit/src/index.ts +76 -0
- package/modules/audit/src/platform.ts +44 -0
- package/modules/audit/src/server/index.ts +177 -0
- package/modules/audit/src/server/runtime.ts +303 -0
- package/modules/audit/src/services/anchor-key.ts +143 -0
- package/modules/audit/src/services/anchor-rotation.ts +147 -0
- package/modules/audit/src/services/audit-runners.ts +278 -0
- package/modules/audit/src/services/backup-guard.ts +95 -0
- package/modules/audit/src/services/database-repository.ts +1946 -0
- package/modules/audit/src/services/declared-classes.ts +64 -0
- package/modules/audit/src/services/erasure-port.ts +126 -0
- package/modules/audit/src/services/erasure-service.ts +770 -0
- package/modules/audit/src/services/export-directory.ts +106 -0
- package/modules/audit/src/services/export-service.ts +714 -0
- package/modules/audit/src/services/hold-service.ts +295 -0
- package/modules/audit/src/services/index.ts +17 -0
- package/modules/audit/src/services/migration.ts +658 -0
- package/modules/audit/src/services/own-classes.ts +318 -0
- package/modules/audit/src/services/platform-version.ts +23 -0
- package/modules/audit/src/services/repository.ts +495 -0
- package/modules/audit/src/services/retention-service.ts +191 -0
- package/modules/audit/src/services/seal-service.ts +769 -0
- package/modules/audit/src/services/service-error.ts +61 -0
- package/modules/audit/src/services/subject-keys.ts +90 -0
- package/modules/audit/src/services/sweep-service.ts +298 -0
- package/modules/audit/src/services/zip.ts +217 -0
- package/modules/audit/src/settings.ts +69 -0
- package/modules/audit/translations/en.json +210 -0
- package/modules/audit/translations/pl.json +210 -0
- package/modules/auth/README.md +77 -29
- package/modules/auth/migrations/0016_external_identities.up.sql +16 -0
- package/modules/auth/migrations/0017_mfa_key_id.up.sql +8 -0
- package/modules/auth/migrations/0018_retire_bundled_module_scopes.up.sql +29 -0
- package/modules/auth/migrations/0019_notifications_member_scopes.up.sql +44 -0
- package/modules/auth/migrations/0020_identity_providers.up.sql +61 -0
- package/modules/auth/migrations/0021_membership_status.up.sql +19 -0
- package/modules/auth/migrations/0022_auth_provider_scopes.up.sql +45 -0
- package/modules/auth/migrations/0023_enterprise_module_scopes.down.sql +19 -0
- package/modules/auth/migrations/0023_enterprise_module_scopes.up.sql +71 -0
- package/modules/auth/migrations/0024_approvals_member_scopes.down.sql +22 -0
- package/modules/auth/migrations/0024_approvals_member_scopes.up.sql +48 -0
- package/modules/auth/migrations/0025_audit_holds_owner_scope.down.sql +21 -0
- package/modules/auth/migrations/0025_audit_holds_owner_scope.up.sql +47 -0
- package/modules/auth/migrations/0026_auth_export_keyset_indexes.down.sql +6 -0
- package/modules/auth/migrations/0026_auth_export_keyset_indexes.up.sql +15 -0
- package/modules/auth/migrations/0027_workflow_automation_profile_scopes.down.sql +34 -0
- package/modules/auth/migrations/0027_workflow_automation_profile_scopes.up.sql +72 -0
- package/modules/auth/migrations/0028_auth_member_search_prefix_indexes.down.sql +6 -0
- package/modules/auth/migrations/0028_auth_member_search_prefix_indexes.up.sql +21 -0
- package/modules/auth/migrations/0029_reports_exports_access_scopes.down.sql +22 -0
- package/modules/auth/migrations/0029_reports_exports_access_scopes.up.sql +56 -0
- package/modules/auth/migrations/0030_auth_membership_keyset_index.down.sql +4 -0
- package/modules/auth/migrations/0030_auth_membership_keyset_index.up.sql +10 -0
- package/modules/auth/migrations/0031_membership_scope_backfills_under_rls.down.sql +4 -0
- package/modules/auth/migrations/0031_membership_scope_backfills_under_rls.up.sql +31 -0
- package/modules/auth/migrations/0032_audit_actor_service.down.sql +9 -0
- package/modules/auth/migrations/0032_audit_actor_service.up.sql +10 -0
- package/modules/auth/migrations/0033_auth_account_keyset_indexes.down.sql +5 -0
- package/modules/auth/migrations/0033_auth_account_keyset_indexes.up.sql +23 -0
- package/modules/auth/module.json +3 -3
- package/modules/auth/package.json +2 -1
- package/modules/auth/spec/module.yaml +372 -3
- package/modules/auth/src/acl/scopes.ts +50 -6
- package/modules/auth/src/cli/commands.json +11 -0
- package/modules/auth/src/cli/greenfield.ts +2 -2
- package/modules/auth/src/cli/index.ts +14 -0
- package/modules/auth/src/cli/secrets.ts +114 -0
- package/modules/auth/src/client/AuthenticationCore.tsrx +61 -8
- package/modules/auth/src/client/api.ts +72 -6
- package/modules/auth/src/client/contribution.tsrx +23 -0
- package/modules/auth/src/client/index.ts +6 -0
- package/modules/auth/src/client/providers/IdentityProviderForm.tsrx +191 -0
- package/modules/auth/src/client/providers/IdentityProvidersView.tsrx +358 -0
- package/modules/auth/src/client/providers/api.ts +128 -0
- package/modules/auth/src/client/providers/provider-columns.tsrx +60 -0
- package/modules/auth/src/client/providers/state.ts +35 -0
- package/modules/auth/src/client/security/SecurityView.tsrx +9 -1
- package/modules/auth/src/client/state.ts +15 -1
- package/modules/auth/src/domain/types.ts +55 -0
- package/modules/auth/src/index.ts +11 -1
- package/modules/auth/src/middleware/authentication.ts +4 -0
- package/modules/auth/src/server/endpoints.ts +467 -171
- package/modules/auth/src/server/http.ts +3 -2
- package/modules/auth/src/server/index.ts +22 -1
- package/modules/auth/src/server/membership-endpoints.ts +62 -0
- package/modules/auth/src/server/mfa-enforcement.ts +156 -0
- package/modules/auth/src/server/oidc.ts +389 -0
- package/modules/auth/src/server/provider-endpoints.ts +246 -0
- package/modules/auth/src/server/provider-host.ts +77 -0
- package/modules/auth/src/server/runtime.ts +231 -55
- package/modules/auth/src/services/auth-service-error.ts +7 -2
- package/modules/auth/src/services/auth-service.ts +948 -51
- package/modules/auth/src/services/data-classes.ts +236 -0
- package/modules/auth/src/services/database-repository.ts +853 -71
- package/modules/auth/src/services/identity-provider-service.ts +571 -0
- package/modules/auth/src/services/mail-delivery.ts +16 -16
- package/modules/auth/src/services/mail-message.ts +54 -0
- package/modules/auth/src/services/mail-port.ts +24 -0
- package/modules/auth/src/services/mail-smtp.ts +85 -0
- package/modules/auth/src/services/mfa-rotation.ts +144 -0
- package/modules/auth/src/services/migration.ts +810 -0
- package/modules/auth/src/services/password.ts +14 -0
- package/modules/auth/src/services/provider-secret-rotation.ts +169 -0
- package/modules/auth/src/services/provider-secrets.ts +136 -0
- package/modules/auth/src/services/repository.ts +321 -5
- package/modules/auth/src/services/session-sweep-runner.ts +73 -0
- package/modules/auth/src/services/settings-store.ts +10 -83
- package/modules/auth/src/services/totp.ts +88 -62
- package/modules/auth/src/services/validation.ts +194 -7
- package/modules/auth/src/settings.ts +18 -0
- package/modules/auth/translations/en.json +84 -1
- package/modules/auth/translations/pl.json +84 -1
- package/modules/automations/migrations/0005_secret_rotation_inventory.down.sql +1 -0
- package/modules/automations/migrations/0005_secret_rotation_inventory.up.sql +6 -0
- package/modules/automations/migrations/0006_automations_list_sort_indexes.down.sql +4 -0
- package/modules/automations/migrations/0006_automations_list_sort_indexes.up.sql +11 -0
- package/modules/automations/module.json +24 -6
- package/modules/automations/package.json +4 -1
- package/modules/automations/spec/module.yaml +81 -7
- package/modules/automations/src/api/endpoints.ts +202 -28
- package/modules/automations/src/cli/commands.json +17 -0
- package/modules/automations/src/cli/index.ts +114 -0
- package/modules/automations/src/client/AutomationScheduleForm.tsrx +77 -19
- package/modules/automations/src/client/AutomationSchedulesView.tsrx +144 -40
- package/modules/automations/src/client/AutomationTriggersView.tsrx +131 -32
- package/modules/automations/src/client/api.ts +62 -19
- package/modules/automations/src/client/presentation.ts +20 -2
- package/modules/automations/src/client/state.ts +84 -0
- package/modules/automations/src/domain/cadence.ts +99 -3
- package/modules/automations/src/domain/cron.ts +366 -0
- package/modules/automations/src/domain/time-zone.ts +61 -0
- package/modules/automations/src/platform.ts +38 -4
- package/modules/automations/src/server/index.ts +11 -0
- package/modules/automations/src/server/runtime.ts +46 -22
- package/modules/{automations-workflows-integration/src/server/adapter.ts → automations/src/server/workflow-target.ts} +13 -14
- package/modules/{automations-workflows-integration/src/server/tools.ts → automations/src/server/workflow-tools.ts} +0 -0
- package/modules/automations/src/services/data-classes.ts +62 -0
- package/modules/automations/src/services/database-repository.ts +152 -38
- package/modules/automations/src/services/migration.ts +119 -9
- package/modules/automations/src/services/repository.ts +52 -1
- package/modules/automations/src/services/schedule-runner.ts +84 -0
- package/modules/automations/src/services/schedule-service.ts +152 -26
- package/modules/automations/src/services/secret-rotation.ts +176 -0
- package/modules/automations/src/services/secret-vault.ts +68 -41
- package/modules/automations/src/services/trigger-service.ts +13 -10
- package/modules/automations/translations/en.json +15 -2
- package/modules/automations/translations/pl.json +15 -2
- package/modules/connectors/migrations/0001_connectors_core.down.sql +3 -0
- package/modules/connectors/migrations/0001_connectors_core.up.sql +72 -0
- package/modules/connectors/migrations/0002_connectors_call_keys.down.sql +3 -0
- package/modules/connectors/migrations/0002_connectors_call_keys.up.sql +18 -0
- package/modules/connectors/migrations/README.md +3 -0
- package/modules/connectors/module.json +28 -0
- package/modules/{automations-workflows-integration → connectors}/package.json +27 -26
- package/modules/connectors/spec/module.yaml +447 -0
- package/modules/connectors/src/acl/permissions.ts +6 -0
- package/modules/connectors/src/agent/tools.ts +180 -0
- package/modules/connectors/src/api/endpoints.ts +572 -0
- package/modules/connectors/src/client/ConnectorCallsView.tsrx +358 -0
- package/modules/connectors/src/client/ConnectorForm.tsrx +424 -0
- package/modules/connectors/src/client/ConnectorsView.tsrx +711 -0
- package/modules/connectors/src/client/api.ts +281 -0
- package/modules/connectors/src/client/consent.ts +48 -0
- package/modules/connectors/src/client/contribution.tsrx +37 -0
- package/modules/connectors/src/client/index.ts +22 -0
- package/modules/connectors/src/client/navigation.ts +42 -0
- package/modules/connectors/src/client/presentation.ts +38 -0
- package/modules/connectors/src/client/state.ts +175 -0
- package/modules/connectors/src/domain/calls.ts +70 -0
- package/modules/connectors/src/domain/definitions.ts +190 -0
- package/modules/connectors/src/domain/http-json.ts +68 -0
- package/modules/connectors/src/domain/types.ts +185 -0
- package/modules/connectors/src/index.ts +64 -0
- package/modules/connectors/src/platform.ts +56 -0
- package/modules/connectors/src/server/index.ts +66 -0
- package/modules/connectors/src/server/runtime.ts +163 -0
- package/modules/connectors/src/services/call-service.ts +903 -0
- package/modules/connectors/src/services/connectors-service.ts +653 -0
- package/modules/connectors/src/services/credential-vault.ts +188 -0
- package/modules/connectors/src/services/data-classes.ts +158 -0
- package/modules/connectors/src/services/database-repository.ts +897 -0
- package/modules/connectors/src/services/egress.ts +261 -0
- package/modules/connectors/src/services/index.ts +19 -0
- package/modules/connectors/src/services/migration.ts +166 -0
- package/modules/connectors/src/services/repository.ts +175 -0
- package/modules/connectors/src/services/service-error.ts +46 -0
- package/modules/connectors/src/settings.ts +69 -0
- package/modules/connectors/translations/en.json +191 -0
- package/modules/connectors/translations/pl.json +191 -0
- package/modules/directory/migrations/0001_directory_core.down.sql +5 -0
- package/modules/directory/migrations/0001_directory_core.up.sql +111 -0
- package/modules/directory/migrations/README.md +3 -0
- package/modules/directory/module.json +27 -0
- package/modules/directory/package.json +46 -0
- package/modules/directory/spec/module.yaml +351 -0
- package/modules/directory/src/acl/permissions.ts +7 -0
- package/modules/directory/src/api/endpoints.ts +478 -0
- package/modules/directory/src/api/scim-endpoints.ts +516 -0
- package/modules/directory/src/client/GroupMappingsView.tsrx +430 -0
- package/modules/directory/src/client/ProvisioningLogView.tsrx +248 -0
- package/modules/directory/src/client/ScimTokensView.tsrx +587 -0
- package/modules/directory/src/client/api.ts +222 -0
- package/modules/directory/src/client/contribution.tsrx +46 -0
- package/modules/directory/src/client/index.ts +22 -0
- package/modules/directory/src/client/navigation.ts +57 -0
- package/modules/directory/src/client/presentation.ts +143 -0
- package/modules/directory/src/client/state.ts +173 -0
- package/modules/directory/src/domain/scim.ts +346 -0
- package/modules/directory/src/domain/types.ts +166 -0
- package/modules/directory/src/index.ts +44 -0
- package/modules/directory/src/platform.ts +43 -0
- package/modules/directory/src/server/index.ts +17 -0
- package/modules/directory/src/server/runtime.ts +124 -0
- package/modules/directory/src/services/auth-port.ts +127 -0
- package/modules/directory/src/services/data-classes.ts +41 -0
- package/modules/directory/src/services/database-repository.ts +1067 -0
- package/modules/directory/src/services/directory-service.ts +311 -0
- package/modules/directory/src/services/index.ts +43 -0
- package/modules/directory/src/services/migration.ts +146 -0
- package/modules/directory/src/services/provisioning-service.ts +1420 -0
- package/modules/directory/src/services/rate-limiter.ts +103 -0
- package/modules/directory/src/services/repository.ts +208 -0
- package/modules/directory/src/services/service-error.ts +42 -0
- package/modules/directory/src/services/token-service.ts +215 -0
- package/modules/directory/src/settings.ts +86 -0
- package/modules/directory/translations/en.json +185 -0
- package/modules/directory/translations/pl.json +185 -0
- package/modules/documents/migrations/0001_documents_core.down.sql +1 -0
- package/modules/documents/migrations/0001_documents_core.up.sql +35 -0
- package/modules/documents/migrations/0002_documents_files_page.down.sql +1 -0
- package/modules/documents/migrations/0002_documents_files_page.up.sql +6 -0
- package/modules/documents/migrations/README.md +3 -0
- package/modules/documents/module.json +28 -0
- package/modules/documents/package.json +49 -0
- package/modules/documents/spec/module.yaml +247 -0
- package/modules/documents/src/acl/permissions.ts +6 -0
- package/modules/documents/src/api/endpoints.ts +401 -0
- package/modules/documents/src/client/DocumentUploader.tsrx +148 -0
- package/modules/documents/src/client/DocumentsView.tsrx +540 -0
- package/modules/documents/src/client/api.ts +209 -0
- package/modules/documents/src/client/contribution.tsrx +29 -0
- package/modules/documents/src/client/download.ts +70 -0
- package/modules/documents/src/client/index.ts +22 -0
- package/modules/documents/src/client/navigation.ts +25 -0
- package/modules/documents/src/client/presentation.ts +110 -0
- package/modules/documents/src/client/state.ts +117 -0
- package/modules/documents/src/domain/attachments.ts +84 -0
- package/modules/documents/src/domain/types.ts +80 -0
- package/modules/documents/src/index.ts +46 -0
- package/modules/documents/src/platform.ts +61 -0
- package/modules/documents/src/server/index.ts +30 -0
- package/modules/documents/src/server/runtime.ts +107 -0
- package/modules/documents/src/services/attachments.ts +39 -0
- package/modules/documents/src/services/data-classes.ts +25 -0
- package/modules/documents/src/services/database-repository.ts +259 -0
- package/modules/documents/src/services/documents-service.ts +586 -0
- package/modules/documents/src/services/index.ts +18 -0
- package/modules/documents/src/services/migration.ts +82 -0
- package/modules/documents/src/services/repository.ts +48 -0
- package/modules/documents/src/settings.ts +107 -0
- package/modules/documents/translations/en.json +111 -0
- package/modules/documents/translations/pl.json +111 -0
- package/modules/exports/migrations/0001_exports_core.down.sql +2 -0
- package/modules/exports/migrations/0001_exports_core.up.sql +28 -0
- package/modules/exports/migrations/0002_exports_job_routing_role.down.sql +4 -0
- package/modules/exports/migrations/0002_exports_job_routing_role.up.sql +21 -0
- package/modules/exports/migrations/README.md +3 -0
- package/modules/exports/module.json +28 -0
- package/modules/exports/package.json +44 -0
- package/modules/exports/spec/module.yaml +229 -0
- package/modules/exports/src/acl/permissions.ts +6 -0
- package/modules/exports/src/api/endpoints.ts +211 -0
- package/modules/exports/src/client/ExportsView.tsrx +327 -0
- package/modules/exports/src/client/api.ts +133 -0
- package/modules/exports/src/client/contribution.tsrx +31 -0
- package/modules/exports/src/client/index.ts +20 -0
- package/modules/exports/src/client/navigation.ts +25 -0
- package/modules/exports/src/client/presentation.ts +53 -0
- package/modules/exports/src/client/state.ts +56 -0
- package/modules/exports/src/domain/lists.ts +29 -0
- package/modules/exports/src/domain/types.ts +120 -0
- package/modules/exports/src/index.ts +41 -0
- package/modules/exports/src/platform.ts +80 -0
- package/modules/exports/src/server/index.ts +51 -0
- package/modules/exports/src/server/runtime.ts +160 -0
- package/modules/exports/src/services/data-classes.ts +56 -0
- package/modules/exports/src/services/database-repository.ts +405 -0
- package/modules/exports/src/services/export-runner.ts +123 -0
- package/modules/exports/src/services/export-service.ts +356 -0
- package/modules/exports/src/services/index.ts +6 -0
- package/modules/exports/src/services/list-registry.ts +105 -0
- package/modules/exports/src/services/migration.ts +89 -0
- package/modules/exports/src/services/repository.ts +97 -0
- package/modules/exports/src/settings.ts +70 -0
- package/modules/exports/translations/en.json +69 -0
- package/modules/exports/translations/pl.json +69 -0
- package/modules/import/migrations/0001_import_core.down.sql +6 -0
- package/modules/import/migrations/0001_import_core.up.sql +61 -0
- package/modules/import/migrations/0002_import_job_routing_role.down.sql +4 -0
- package/modules/import/migrations/0002_import_job_routing_role.up.sql +20 -0
- package/modules/import/migrations/0003_import_jobs_export_index.down.sql +1 -0
- package/modules/import/migrations/0003_import_jobs_export_index.up.sql +7 -0
- package/modules/import/migrations/0004_import_jobs_traceparent.down.sql +1 -0
- package/modules/import/migrations/0004_import_jobs_traceparent.up.sql +7 -0
- package/modules/import/migrations/README.md +3 -0
- package/modules/import/module.json +37 -0
- package/modules/import/package.json +50 -0
- package/modules/import/spec/module.yaml +335 -0
- package/modules/import/src/acl/permissions.ts +6 -0
- package/modules/import/src/api/endpoints.ts +400 -0
- package/modules/import/src/client/ImportJobDrawer.tsrx +229 -0
- package/modules/import/src/client/ImportsView.tsrx +455 -0
- package/modules/import/src/client/NewImportForm.tsrx +274 -0
- package/modules/import/src/client/api.ts +243 -0
- package/modules/import/src/client/contribution.tsrx +29 -0
- package/modules/import/src/client/index.ts +23 -0
- package/modules/import/src/client/navigation.ts +25 -0
- package/modules/import/src/client/presentation.ts +59 -0
- package/modules/import/src/client/state.ts +43 -0
- package/modules/import/src/domain/csv.ts +258 -0
- package/modules/import/src/domain/ports.ts +157 -0
- package/modules/import/src/domain/types.ts +179 -0
- package/modules/import/src/index.ts +58 -0
- package/modules/import/src/platform.ts +60 -0
- package/modules/import/src/server/index.ts +49 -0
- package/modules/import/src/server/runtime.ts +158 -0
- package/modules/import/src/services/csv-source.ts +121 -0
- package/modules/import/src/services/data-classes.ts +63 -0
- package/modules/import/src/services/database-repository.ts +780 -0
- package/modules/import/src/services/import-runner.ts +127 -0
- package/modules/import/src/services/import-service.ts +872 -0
- package/modules/import/src/services/index.ts +6 -0
- package/modules/import/src/services/migration.ts +156 -0
- package/modules/import/src/services/port-registry.ts +158 -0
- package/modules/import/src/services/repository.ts +147 -0
- package/modules/import/src/settings.ts +70 -0
- package/modules/import/translations/en.json +175 -0
- package/modules/import/translations/pl.json +175 -0
- package/modules/metering/migrations/0001_metering_core.down.sql +6 -0
- package/modules/metering/migrations/0001_metering_core.up.sql +119 -0
- package/modules/metering/migrations/0002_metering_bucket_export.down.sql +3 -0
- package/modules/metering/migrations/0002_metering_bucket_export.up.sql +5 -0
- package/modules/metering/migrations/README.md +3 -0
- package/modules/metering/module.json +46 -0
- package/modules/metering/package.json +50 -0
- package/modules/metering/spec/module.yaml +269 -0
- package/modules/metering/src/acl/permissions.ts +5 -0
- package/modules/metering/src/api/endpoints.ts +104 -0
- package/modules/metering/src/cli/commands.json +28 -0
- package/modules/metering/src/cli/index.ts +246 -0
- package/modules/metering/src/client/LimitsView.tsrx +170 -0
- package/modules/metering/src/client/UsageSummaryWidget.tsrx +63 -0
- package/modules/metering/src/client/UsageView.tsrx +205 -0
- package/modules/metering/src/client/api.ts +91 -0
- package/modules/metering/src/client/contribution.tsrx +42 -0
- package/modules/metering/src/client/index.ts +26 -0
- package/modules/metering/src/client/navigation.ts +54 -0
- package/modules/metering/src/client/presentation.ts +63 -0
- package/modules/metering/src/client/state.ts +31 -0
- package/modules/metering/src/domain/meters.ts +100 -0
- package/modules/metering/src/domain/types.ts +71 -0
- package/modules/metering/src/index.ts +51 -0
- package/modules/metering/src/platform.ts +84 -0
- package/modules/metering/src/server/index.ts +40 -0
- package/modules/metering/src/server/runtime.ts +165 -0
- package/modules/metering/src/services/data-classes.ts +34 -0
- package/modules/metering/src/services/database-repository.ts +574 -0
- package/modules/metering/src/services/index.ts +9 -0
- package/modules/metering/src/services/meter-registry.ts +145 -0
- package/modules/metering/src/services/metering-service.ts +441 -0
- package/modules/metering/src/services/migration.ts +183 -0
- package/modules/metering/src/services/notifications.ts +75 -0
- package/modules/metering/src/services/reports.ts +105 -0
- package/modules/metering/src/services/repository.ts +132 -0
- package/modules/metering/src/services/service-error.ts +46 -0
- package/modules/metering/src/settings.ts +47 -0
- package/modules/metering/translations/en.json +68 -0
- package/modules/metering/translations/pl.json +68 -0
- package/modules/notifications/migrations/0001_notifications_core.down.sql +1 -0
- package/modules/notifications/migrations/0001_notifications_core.up.sql +26 -0
- package/modules/notifications/migrations/0002_notifications_preferences.down.sql +1 -0
- package/modules/notifications/migrations/0002_notifications_preferences.up.sql +17 -0
- package/modules/notifications/migrations/0003_notifications_webhook_subscriptions.down.sql +1 -0
- package/modules/notifications/migrations/0003_notifications_webhook_subscriptions.up.sql +30 -0
- package/modules/notifications/migrations/0004_notifications_deliveries.down.sql +1 -0
- package/modules/notifications/migrations/0004_notifications_deliveries.up.sql +35 -0
- package/modules/notifications/migrations/0005_notifications_delivery_routing_role.down.sql +2 -0
- package/modules/notifications/migrations/0005_notifications_delivery_routing_role.up.sql +17 -0
- package/modules/notifications/migrations/0006_notifications_delivery_title.down.sql +1 -0
- package/modules/notifications/migrations/0006_notifications_delivery_title.up.sql +11 -0
- package/modules/notifications/migrations/0007_notifications_secret_rotation_inventory.down.sql +2 -0
- package/modules/notifications/migrations/0007_notifications_secret_rotation_inventory.up.sql +19 -0
- package/modules/notifications/migrations/0008_notifications_delivery_claim.down.sql +8 -0
- package/modules/notifications/migrations/0008_notifications_delivery_claim.up.sql +19 -0
- package/modules/notifications/migrations/0009_notifications_kind_approvals.down.sql +16 -0
- package/modules/notifications/migrations/0009_notifications_kind_approvals.up.sql +18 -0
- package/modules/notifications/migrations/0010_notifications_kind_meter_threshold.down.sql +16 -0
- package/modules/notifications/migrations/0010_notifications_kind_meter_threshold.up.sql +18 -0
- package/modules/notifications/migrations/0011_notifications_retention_keyset.down.sql +5 -0
- package/modules/notifications/migrations/0011_notifications_retention_keyset.up.sql +15 -0
- package/modules/notifications/migrations/0012_notifications_email_channel.down.sql +12 -0
- package/modules/notifications/migrations/0012_notifications_email_channel.up.sql +38 -0
- package/modules/notifications/migrations/0013_notifications_list_pages.down.sql +5 -0
- package/modules/notifications/migrations/0013_notifications_list_pages.up.sql +13 -0
- package/modules/notifications/migrations/README.md +3 -0
- package/modules/notifications/module.json +32 -0
- package/modules/notifications/package.json +49 -0
- package/modules/notifications/spec/module.yaml +718 -0
- package/modules/notifications/src/acl/permissions.ts +11 -0
- package/modules/notifications/src/api/endpoints.ts +814 -0
- package/modules/notifications/src/cli/commands.json +17 -0
- package/modules/notifications/src/cli/index.ts +126 -0
- package/modules/notifications/src/client/DeliveriesView.tsrx +483 -0
- package/modules/notifications/src/client/FactList.tsrx +24 -0
- package/modules/notifications/src/client/NotificationPreferencesView.tsrx +240 -0
- package/modules/notifications/src/client/NotificationsInboxView.tsrx +592 -0
- package/modules/notifications/src/client/UnreadCountWidget.tsrx +62 -0
- package/modules/notifications/src/client/WebhookForm.tsrx +297 -0
- package/modules/notifications/src/client/WebhooksView.tsrx +637 -0
- package/modules/notifications/src/client/api.ts +382 -0
- package/modules/notifications/src/client/contribution.tsrx +83 -0
- package/modules/notifications/src/client/inbox.ts +41 -0
- package/modules/notifications/src/client/index.ts +29 -0
- package/modules/notifications/src/client/navigation.ts +92 -0
- package/modules/notifications/src/client/notifications.css +70 -0
- package/modules/notifications/src/client/presentation.ts +81 -0
- package/modules/notifications/src/client/state.ts +246 -0
- package/modules/notifications/src/client/unread-count.ts +26 -0
- package/modules/notifications/src/domain/locale.ts +47 -0
- package/modules/notifications/src/domain/publish.ts +46 -0
- package/modules/notifications/src/domain/types.ts +186 -0
- package/modules/notifications/src/index.ts +62 -0
- package/modules/notifications/src/platform.ts +85 -0
- package/modules/notifications/src/server/index.ts +82 -0
- package/modules/notifications/src/server/runtime.ts +251 -0
- package/modules/notifications/src/services/data-classes.ts +139 -0
- package/modules/notifications/src/services/database-repository.ts +1334 -0
- package/modules/notifications/src/services/delivery-payload.ts +93 -0
- package/modules/notifications/src/services/delivery-runner.ts +170 -0
- package/modules/notifications/src/services/delivery-service.ts +811 -0
- package/modules/notifications/src/services/egress.ts +239 -0
- package/modules/notifications/src/services/email-channel.ts +93 -0
- package/modules/notifications/src/services/index.ts +23 -0
- package/modules/notifications/src/services/migration.ts +572 -0
- package/modules/notifications/src/services/notifications-service.ts +297 -0
- package/modules/notifications/src/services/paging.ts +60 -0
- package/modules/notifications/src/services/publish-service.ts +133 -0
- package/modules/notifications/src/services/repository.ts +342 -0
- package/modules/notifications/src/services/secret-rotation.ts +177 -0
- package/modules/notifications/src/services/secret-vault.ts +168 -0
- package/modules/notifications/src/services/service-error.ts +67 -0
- package/modules/notifications/src/services/signature.ts +81 -0
- package/modules/notifications/src/services/webhook-service.ts +307 -0
- package/modules/notifications/src/settings.ts +130 -0
- package/modules/notifications/translations/en.json +255 -0
- package/modules/notifications/translations/pl.json +255 -0
- package/modules/profile/module.json +3 -3
- package/modules/profile/package.json +1 -1
- package/modules/profile/spec/module.yaml +3 -3
- package/modules/profile/src/services/database-repository.ts +3 -13
- package/modules/reports/module.json +28 -0
- package/modules/reports/package.json +42 -0
- package/modules/reports/spec/module.yaml +231 -0
- package/modules/reports/src/acl/permissions.ts +5 -0
- package/modules/reports/src/api/endpoints.ts +72 -0
- package/modules/reports/src/client/ReportsSummaryWidget.tsrx +52 -0
- package/modules/reports/src/client/ReportsView.tsrx +246 -0
- package/modules/reports/src/client/api.ts +65 -0
- package/modules/reports/src/client/contribution.tsrx +36 -0
- package/modules/reports/src/client/index.ts +18 -0
- package/modules/reports/src/client/navigation.ts +39 -0
- package/modules/reports/src/client/presentation.ts +123 -0
- package/modules/reports/src/client/state.ts +28 -0
- package/modules/reports/src/domain/providers.ts +115 -0
- package/modules/reports/src/domain/types.ts +44 -0
- package/modules/reports/src/index.ts +47 -0
- package/modules/reports/src/platform.ts +37 -0
- package/modules/reports/src/server/index.ts +21 -0
- package/modules/reports/src/server/runtime.ts +40 -0
- package/modules/reports/src/services/index.ts +17 -0
- package/modules/reports/src/services/provider-registry.ts +144 -0
- package/modules/reports/src/services/range.ts +65 -0
- package/modules/reports/src/services/reports-service.ts +316 -0
- package/modules/reports/src/services/service-error.ts +26 -0
- package/modules/reports/src/settings.ts +49 -0
- package/modules/reports/translations/en.json +35 -0
- package/modules/reports/translations/pl.json +35 -0
- package/modules/sandbox/module.json +4 -4
- package/modules/sandbox/package.json +1 -1
- package/modules/sandbox/spec/module.yaml +3 -3
- package/modules/sandbox/src/services/database-repository.ts +14 -23
- package/modules/sandbox/src/services/directory.ts +16 -0
- package/modules/sandbox/src/services/sandbox-service.ts +13 -11
- package/modules/search/migrations/0001_search_core.down.sql +1 -0
- package/modules/search/migrations/0001_search_core.up.sql +22 -0
- package/modules/search/migrations/0002_search_recent_export.down.sql +3 -0
- package/modules/search/migrations/0002_search_recent_export.up.sql +5 -0
- package/modules/search/migrations/README.md +3 -0
- package/modules/search/module.json +28 -0
- package/modules/search/package.json +43 -0
- package/modules/search/spec/module.yaml +177 -0
- package/modules/search/src/acl/permissions.ts +5 -0
- package/modules/search/src/api/endpoints.ts +221 -0
- package/modules/search/src/client/SearchView.tsrx +346 -0
- package/modules/search/src/client/api.ts +157 -0
- package/modules/search/src/client/contribution.tsrx +31 -0
- package/modules/search/src/client/index.ts +17 -0
- package/modules/search/src/client/navigation.ts +97 -0
- package/modules/search/src/client/search.css +56 -0
- package/modules/search/src/client/state.ts +113 -0
- package/modules/search/src/domain/data-classes.ts +73 -0
- package/modules/search/src/domain/providers.ts +88 -0
- package/modules/search/src/domain/types.ts +56 -0
- package/modules/search/src/index.ts +46 -0
- package/modules/search/src/platform.ts +42 -0
- package/modules/search/src/server/index.ts +25 -0
- package/modules/search/src/server/runtime.ts +123 -0
- package/modules/search/src/services/database-repository.ts +163 -0
- package/modules/search/src/services/index.ts +21 -0
- package/modules/search/src/services/migration.ts +65 -0
- package/modules/search/src/services/provider-registry.ts +137 -0
- package/modules/search/src/services/repository.ts +43 -0
- package/modules/search/src/services/search-service.ts +442 -0
- package/modules/search/src/services/service-error.ts +35 -0
- package/modules/search/src/settings.ts +68 -0
- package/modules/search/translations/en.json +45 -0
- package/modules/search/translations/pl.json +45 -0
- package/modules/system/module.json +2 -2
- package/modules/system/package.json +1 -1
- package/modules/system/spec/module.yaml +30 -3
- package/modules/system/src/client/FlagsPanel.tsrx +127 -0
- package/modules/system/src/client/ModuleSettingRow.tsrx +17 -7
- package/modules/system/src/client/ModuleSettingsSection.tsrx +10 -71
- package/modules/system/src/client/ModulesView.tsrx +91 -65
- package/modules/system/src/client/flags.ts +35 -0
- package/modules/system/src/client/index.ts +8 -0
- package/modules/system/src/client/navigation.ts +8 -0
- package/modules/system/src/client/settings-state.ts +159 -0
- package/modules/system/src/client/state.ts +2 -0
- package/modules/system/src/domain/time-zone.ts +105 -0
- package/modules/system/src/index.ts +12 -0
- package/modules/system/src/platform.ts +5 -1
- package/modules/system/src/server/endpoints.ts +72 -21
- package/modules/system/src/settings.ts +28 -0
- package/modules/system/translations/en.json +17 -0
- package/modules/system/translations/pl.json +17 -0
- package/modules/users/module.json +30 -4
- package/modules/users/package.json +4 -1
- package/modules/users/spec/module.yaml +290 -7
- package/modules/users/src/api/endpoints.ts +228 -15
- package/modules/users/src/client/InviteMemberForm.tsrx +2 -2
- package/modules/users/src/client/MemberDrawer.tsrx +142 -26
- package/modules/users/src/client/UserAccountForm.tsrx +2 -2
- package/modules/users/src/client/UsersView.tsrx +432 -71
- package/modules/users/src/client/api.ts +106 -12
- package/modules/users/src/client/contribution.tsrx +5 -0
- package/modules/users/src/client/member-columns.tsrx +22 -9
- package/modules/users/src/client/state.ts +172 -7
- package/modules/users/src/domain/lists.ts +9 -0
- package/modules/users/src/index.ts +11 -0
- package/modules/users/src/platform.ts +50 -1
- package/modules/users/src/services/member-export.ts +51 -0
- package/modules/users/src/services/member-import.ts +249 -0
- package/modules/users/src/services/member-search.ts +145 -0
- package/modules/users/src/services/users-service.ts +117 -4
- package/modules/users/translations/en.json +57 -8
- package/modules/users/translations/pl.json +57 -8
- package/modules/workflows/migrations/0004_payload_rotation_inventory.up.sql +17 -0
- package/modules/workflows/migrations/0005_workflows_human_approval.up.sql +28 -0
- package/modules/workflows/migrations/0006_workflows_retention_indexes.up.sql +11 -0
- package/modules/workflows/migrations/0007_workflows_erasure_subject_indexes.up.sql +17 -0
- package/modules/workflows/migrations/0008_workflows_subject_account.up.sql +24 -0
- package/modules/workflows/migrations/0009_workflows_definition_list_indexes.up.sql +9 -0
- package/modules/workflows/module.json +34 -6
- package/modules/workflows/package.json +2 -1
- package/modules/workflows/spec/module.yaml +26 -9
- package/modules/workflows/src/api/endpoints.ts +131 -25
- package/modules/workflows/src/cli/commands.json +17 -0
- package/modules/workflows/src/cli/index.ts +114 -0
- package/modules/workflows/src/client/WorkflowExecutionHistory.tsrx +36 -27
- package/modules/workflows/src/client/WorkflowInspector.tsrx +116 -0
- package/modules/workflows/src/client/WorkflowNodePalette.tsrx +1 -0
- package/modules/workflows/src/client/WorkflowsView.tsrx +236 -99
- package/modules/workflows/src/client/api.ts +54 -34
- package/modules/workflows/src/client/canvas-model.ts +12 -0
- package/modules/workflows/src/client/state.ts +95 -0
- package/modules/workflows/src/domain/events.ts +25 -11
- package/modules/workflows/src/domain/graph.ts +135 -1
- package/modules/workflows/src/domain/types.ts +91 -4
- package/modules/workflows/src/platform.ts +12 -0
- package/modules/workflows/src/server/runtime.ts +78 -5
- package/modules/workflows/src/services/approvals.ts +62 -0
- package/modules/workflows/src/services/cursors.ts +37 -0
- package/modules/workflows/src/services/data-classes.ts +232 -0
- package/modules/workflows/src/services/database-repository.ts +660 -171
- package/modules/workflows/src/services/migration.ts +240 -0
- package/modules/workflows/src/services/notifications.ts +98 -0
- package/modules/workflows/src/services/payload-codec.ts +51 -28
- package/modules/workflows/src/services/payload-rotation.ts +171 -0
- package/modules/workflows/src/services/repository.ts +123 -8
- package/modules/workflows/src/services/simulation.ts +7 -0
- package/modules/workflows/src/services/worker.ts +446 -25
- package/modules/workflows/src/services/workflows-service.ts +264 -103
- package/modules/workflows/translations/en.json +12 -4
- package/modules/workflows/translations/pl.json +12 -4
- package/modules.json +48 -4
- package/package.json +64 -6
- package/packages/client/package.json +1 -0
- package/packages/client/src/ApplicationShell.tsrx +43 -0
- package/packages/client/src/contributions.ts +55 -0
- package/packages/client/src/i18n/locales/en.json +5 -0
- package/packages/client/src/i18n/locales/pl.json +5 -0
- package/packages/client/src/index.ts +13 -1
- package/packages/client/src/routing.ts +22 -0
- package/packages/client/src/shell/CommandPalette.tsrx +223 -11
- package/packages/client/src/shell/command-search.ts +126 -0
- package/packages/client/src/shell/command.ts +30 -0
- package/packages/client/src/shell/navigation.ts +12 -0
- package/packages/client/src/shell/palette-keys.ts +27 -0
- package/packages/client/src/shell/shell.css +7 -0
- package/packages/contracts/schemas/module-spec.schema.json +287 -1
- package/packages/contracts/schemas/module.schema.json +25 -0
- package/packages/contracts/src/index.ts +144 -1
- package/packages/database/src/backup.ts +179 -0
- package/packages/database/src/decoders.ts +25 -0
- package/packages/database/src/index.ts +17 -0
- package/packages/database/src/record-history.ts +5 -14
- package/packages/harness/src/index.ts +2 -0
- package/packages/harness/src/runtime.ts +218 -1
- package/packages/harness/src/tool-adapters.ts +19 -1
- package/packages/kernel/src/acl.ts +179 -0
- package/packages/kernel/src/capability-registry.ts +69 -2
- package/packages/kernel/src/data-class-registry.ts +354 -0
- package/packages/kernel/src/index.ts +65 -4
- package/packages/kernel/src/keyring.ts +208 -0
- package/packages/kernel/src/module-compatibility.ts +35 -4
- package/packages/kernel/src/module-registry.ts +49 -2
- package/packages/kernel/src/module-settings.ts +189 -27
- package/packages/server/package.json +2 -1
- package/packages/server/src/composition.ts +38 -0
- package/packages/server/src/endpoint.ts +104 -47
- package/packages/server/src/export/csv.ts +34 -0
- package/packages/server/src/export/definition.ts +346 -0
- package/packages/server/src/export/index.ts +61 -0
- package/packages/server/src/export/run.ts +116 -0
- package/packages/server/src/index.ts +155 -0
- package/packages/server/src/jobs/index.ts +93 -0
- package/packages/server/src/jobs/runner.ts +486 -0
- package/packages/server/src/log.ts +291 -0
- package/packages/server/src/mail/config.ts +184 -0
- package/packages/server/src/mail/contracts.ts +251 -0
- package/packages/server/src/mail/index.ts +31 -0
- package/packages/server/src/mail/port.ts +101 -0
- package/packages/server/src/mail/smtp.ts +191 -0
- package/packages/server/src/mail/template.ts +105 -0
- package/packages/server/src/metrics.ts +447 -0
- package/packages/server/src/pagination.ts +246 -0
- package/packages/server/src/trace/context.ts +103 -0
- package/packages/server/src/trace/egress.ts +66 -0
- package/packages/server/src/trace/error-sink.ts +296 -0
- package/packages/server/src/trace/exporter.ts +295 -0
- package/packages/server/src/trace/index.ts +60 -0
- package/packages/server/src/trace/job-sink.ts +172 -0
- package/packages/server/src/trace/tracer.ts +338 -0
- package/packages/server/src/web.ts +5 -1
- package/packages/storage/package.json +40 -0
- package/packages/storage/src/config.ts +189 -0
- package/packages/storage/src/content-type.ts +124 -0
- package/packages/storage/src/contracts.ts +112 -0
- package/packages/storage/src/envelope.ts +189 -0
- package/packages/storage/src/index.ts +43 -0
- package/packages/storage/src/local.ts +75 -0
- package/packages/storage/src/port.ts +251 -0
- package/packages/storage/src/read-token.ts +130 -0
- package/packages/storage/src/s3.ts +144 -0
- package/packages/storage/src/scanner.ts +22 -0
- package/packages/storage/src/sigv4.ts +104 -0
- package/packages/storage/src/store.ts +13 -0
- package/packages/ui/package.json +1 -0
- package/packages/ui/src/components/Button.tsrx +3 -0
- package/packages/ui/src/components/ConfirmDialog.tsrx +13 -2
- package/packages/ui/src/components/DateField.tsrx +92 -0
- package/packages/ui/src/components/DatePicker.tsrx +525 -0
- package/packages/ui/src/components/DateRangeField.tsrx +93 -0
- package/packages/ui/src/components/Drawer.tsrx +10 -1
- package/packages/ui/src/components/FileUpload.tsrx +158 -0
- package/packages/ui/src/components/Pagination.tsrx +130 -0
- package/packages/ui/src/components/Select.tsrx +78 -0
- package/packages/ui/src/components/Table.tsrx +498 -81
- package/packages/ui/src/components/Tabs.tsrx +53 -0
- package/packages/ui/src/components/ToastHost.tsrx +48 -0
- package/packages/ui/src/components/calendar.ts +243 -0
- package/packages/ui/src/components/date-field.ts +62 -0
- package/packages/ui/src/components/file-upload.ts +49 -0
- package/packages/ui/src/components/focus-trap.ts +62 -0
- package/packages/ui/src/components/pagination.ts +68 -0
- package/packages/ui/src/components/table-sorting.ts +49 -0
- package/packages/ui/src/components/tabs.ts +61 -0
- package/packages/ui/src/components/toast-store.ts +116 -0
- package/packages/ui/src/icons/Icon.tsrx +5 -0
- package/packages/ui/src/index.ts +45 -0
- package/packages/ui/src/styles/components.css +598 -0
- package/modules/automations-workflows-integration/module.json +0 -27
- package/modules/automations-workflows-integration/spec/module.yaml +0 -93
- package/modules/automations-workflows-integration/src/index.ts +0 -14
- package/modules/automations-workflows-integration/src/platform.ts +0 -24
- package/modules/automations-workflows-integration/src/server/index.ts +0 -11
- package/modules/automations-workflows-integration/translations/en.json +0 -21
- package/modules/automations-workflows-integration/translations/pl.json +0 -21
- package/modules/workflows/src/services/cursor-codec.ts +0 -62
|
@@ -0,0 +1,714 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { mkdir, open, rm } from 'node:fs/promises';
|
|
3
|
+
import { resolve } from 'node:path';
|
|
4
|
+
import type {
|
|
5
|
+
DataClassDeclaration,
|
|
6
|
+
DataClassExportSink,
|
|
7
|
+
PlatformDataClassRegistry,
|
|
8
|
+
} from '@flowdular/sdk/kernel';
|
|
9
|
+
import { JOB_CLAIM_LOST } from '@flowdular/sdk/server';
|
|
10
|
+
import {
|
|
11
|
+
AUDIT_EVENT_ACTIONS,
|
|
12
|
+
type AuditDataClass,
|
|
13
|
+
type AuditExportRun,
|
|
14
|
+
type ExportRunSummary,
|
|
15
|
+
} from '../domain/types.ts';
|
|
16
|
+
import type { BackupEvidence, BackupGuard } from './backup-guard.ts';
|
|
17
|
+
import { DeclaredDataClasses } from './declared-classes.ts';
|
|
18
|
+
import { exportOutputDirectory } from './export-directory.ts';
|
|
19
|
+
import { readPlatformVersion } from './platform-version.ts';
|
|
20
|
+
import type { AuditRepository } from './repository.ts';
|
|
21
|
+
import { AuditRetentionService } from './retention-service.ts';
|
|
22
|
+
import { AuditServiceError } from './service-error.ts';
|
|
23
|
+
import { StoredZipWriter } from './zip.ts';
|
|
24
|
+
|
|
25
|
+
export const EXPORT_FORMAT_VERSION = 'audit-export/1';
|
|
26
|
+
|
|
27
|
+
/** Bounds. A hostile or broken owner must not grow the process or the disk. */
|
|
28
|
+
export const EXPORT_LIMITS = {
|
|
29
|
+
rowBytes: 262_144,
|
|
30
|
+
rowsPerClass: 1_000_000,
|
|
31
|
+
/** Classes and exclusions one run row names before it says so. */
|
|
32
|
+
summaryEntries: 256,
|
|
33
|
+
} as const;
|
|
34
|
+
|
|
35
|
+
/** Requested runs one pass takes, so one pass never holds the loop. */
|
|
36
|
+
export const EXPORT_ROUTING_PAGE = 20;
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* How often the platform looks for requested runs. An operator waits for the
|
|
40
|
+
* answer, so the loop is faster than the retention sweep; an idle deployment
|
|
41
|
+
* pays one indexed routing read per interval and nothing else.
|
|
42
|
+
*/
|
|
43
|
+
export const EXPORT_POLL_INTERVAL_MS = 5_000;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* How long a claim holds a run. A platform process that died mid-export leaves
|
|
47
|
+
* its claim behind; after this the next process takes the run over rather than
|
|
48
|
+
* leaving the operator waiting for a process that is gone.
|
|
49
|
+
*/
|
|
50
|
+
export const EXPORT_CLAIM_TIMEOUT_MS = 15 * 60_000;
|
|
51
|
+
|
|
52
|
+
/** How long the operator command waits for the platform to answer a run. */
|
|
53
|
+
export const EXPORT_WAIT = {
|
|
54
|
+
timeoutMs: 10 * 60_000,
|
|
55
|
+
pollMs: 1_000,
|
|
56
|
+
} as const;
|
|
57
|
+
|
|
58
|
+
/** Stable reasons a class is in the manifest but not in the archive. */
|
|
59
|
+
export const EXPORT_EXCLUSIONS = {
|
|
60
|
+
declared: 'DECLARED_NOT_EXPORTABLE',
|
|
61
|
+
noOperation: 'NO_EXPORT_OPERATION',
|
|
62
|
+
ownerNotComposed: 'OWNER_MODULE_NOT_COMPOSED',
|
|
63
|
+
} as const;
|
|
64
|
+
|
|
65
|
+
/** The exclusions that leave the archive short of what the workspace holds. */
|
|
66
|
+
const INCOMPLETE_REASONS: readonly string[] = [
|
|
67
|
+
EXPORT_EXCLUSIONS.noOperation,
|
|
68
|
+
EXPORT_EXCLUSIONS.ownerNotComposed,
|
|
69
|
+
];
|
|
70
|
+
|
|
71
|
+
function incompleteExclusions(
|
|
72
|
+
exclusions: readonly { readonly reason: string }[],
|
|
73
|
+
): boolean {
|
|
74
|
+
return exclusions.some((entry) => INCOMPLETE_REASONS.includes(entry.reason));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface ExportedClass {
|
|
78
|
+
readonly classId: string;
|
|
79
|
+
readonly moduleId: string;
|
|
80
|
+
readonly label: string;
|
|
81
|
+
/** Path of the JSON Lines entry inside the archive. */
|
|
82
|
+
readonly file: string;
|
|
83
|
+
readonly rows: number;
|
|
84
|
+
readonly from: string | null;
|
|
85
|
+
readonly to: string | null;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export interface ExportExclusion {
|
|
89
|
+
readonly classId: string;
|
|
90
|
+
readonly moduleId: string;
|
|
91
|
+
readonly label: string;
|
|
92
|
+
readonly reason: string;
|
|
93
|
+
/** The owner module's own words when it declared the class not exportable. */
|
|
94
|
+
readonly declaredReason: string | null;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface ExportManifest {
|
|
98
|
+
readonly formatVersion: string;
|
|
99
|
+
readonly generatedAt: string;
|
|
100
|
+
readonly platformVersion: string;
|
|
101
|
+
readonly workspace: {
|
|
102
|
+
readonly tenantId: string;
|
|
103
|
+
readonly slug: string | null;
|
|
104
|
+
readonly name: string | null;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* True when every class the workspace holds was either exported or excluded
|
|
108
|
+
* by its own declaration. False when a class has no composed owner or no
|
|
109
|
+
* export operation, which the exclusions name one by one.
|
|
110
|
+
*/
|
|
111
|
+
readonly complete: boolean;
|
|
112
|
+
readonly backup: {
|
|
113
|
+
readonly manifestPath: string;
|
|
114
|
+
readonly createdAt: string;
|
|
115
|
+
readonly adapter: string;
|
|
116
|
+
readonly platformVersion: string;
|
|
117
|
+
readonly keys: readonly {
|
|
118
|
+
readonly variable: string;
|
|
119
|
+
readonly fingerprint: string | null;
|
|
120
|
+
}[];
|
|
121
|
+
};
|
|
122
|
+
readonly classes: readonly ExportedClass[];
|
|
123
|
+
readonly exclusions: readonly ExportExclusion[];
|
|
124
|
+
readonly totals: { readonly classes: number; readonly rows: number };
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export interface ExportRequestInput {
|
|
128
|
+
readonly tenantId: string;
|
|
129
|
+
readonly slug?: string | null;
|
|
130
|
+
readonly name?: string | null;
|
|
131
|
+
/** The operator label recorded on the export run. */
|
|
132
|
+
readonly requestedBy: string;
|
|
133
|
+
/** Absolute and inside the directory the deployment allows. */
|
|
134
|
+
readonly outputDirectory: string;
|
|
135
|
+
/** Without it the platform counts through every owner and writes nothing. */
|
|
136
|
+
readonly apply: boolean;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export interface ExportRefusal {
|
|
140
|
+
readonly reason: string;
|
|
141
|
+
readonly detail: string;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface ExportResult {
|
|
145
|
+
/** An archive was written. False for a plan and for a refused run. */
|
|
146
|
+
readonly applied: boolean;
|
|
147
|
+
readonly dryRun: boolean;
|
|
148
|
+
readonly refused: ExportRefusal | null;
|
|
149
|
+
readonly archivePath: string | null;
|
|
150
|
+
readonly archiveDigest: string | null;
|
|
151
|
+
readonly manifest: ExportManifest | null;
|
|
152
|
+
readonly run: AuditExportRun;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface ExportServiceOptions {
|
|
156
|
+
readonly repository: AuditRepository;
|
|
157
|
+
readonly registry: PlatformDataClassRegistry;
|
|
158
|
+
readonly retention: AuditRetentionService;
|
|
159
|
+
readonly backup: BackupGuard;
|
|
160
|
+
readonly environment: NodeJS.ProcessEnv;
|
|
161
|
+
readonly workspaceRoot: string;
|
|
162
|
+
/** Recorded in the manifest; read from the workspace configuration once. */
|
|
163
|
+
readonly platformVersion?: () => Promise<string>;
|
|
164
|
+
readonly now?: () => number;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
interface ClassPlan {
|
|
168
|
+
readonly record: AuditDataClass;
|
|
169
|
+
readonly declaration: DataClassDeclaration | null;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* One per-workspace export, in two halves. The operator command records the
|
|
174
|
+
* request and waits; the running platform, the only process holding the sealed
|
|
175
|
+
* data class registry with every owner port, performs it. Every read runs
|
|
176
|
+
* under the workspace's own transaction inside the owning module, so row-level
|
|
177
|
+
* security is what enforces the boundary: audit.core opens no foreign table
|
|
178
|
+
* and holds no foreign lease.
|
|
179
|
+
*/
|
|
180
|
+
export class AuditExportService {
|
|
181
|
+
readonly #repository: AuditRepository;
|
|
182
|
+
readonly #declared: DeclaredDataClasses;
|
|
183
|
+
readonly #retention: AuditRetentionService;
|
|
184
|
+
readonly #backup: BackupGuard;
|
|
185
|
+
readonly #environment: NodeJS.ProcessEnv;
|
|
186
|
+
readonly #workspaceRoot: string;
|
|
187
|
+
readonly #platformVersion: () => Promise<string>;
|
|
188
|
+
readonly #now: () => number;
|
|
189
|
+
#version: Promise<string> | undefined;
|
|
190
|
+
|
|
191
|
+
constructor(options: ExportServiceOptions) {
|
|
192
|
+
this.#repository = options.repository;
|
|
193
|
+
this.#declared = new DeclaredDataClasses(options.registry);
|
|
194
|
+
this.#retention = options.retention;
|
|
195
|
+
this.#backup = options.backup;
|
|
196
|
+
this.#environment = options.environment;
|
|
197
|
+
this.#workspaceRoot = options.workspaceRoot;
|
|
198
|
+
this.#platformVersion =
|
|
199
|
+
options.platformVersion ??
|
|
200
|
+
(() => readPlatformVersion(this.#workspaceRoot));
|
|
201
|
+
this.#now = options.now ?? Date.now;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/**
|
|
205
|
+
* Records what the operator asked for. The directory is checked here so the
|
|
206
|
+
* command answers a bad request immediately instead of recording a run the
|
|
207
|
+
* platform will only refuse.
|
|
208
|
+
*/
|
|
209
|
+
async request(input: ExportRequestInput): Promise<AuditExportRun> {
|
|
210
|
+
return this.#repository.startExportRun({
|
|
211
|
+
tenantId: input.tenantId,
|
|
212
|
+
formatVersion: EXPORT_FORMAT_VERSION,
|
|
213
|
+
requestedBy: input.requestedBy,
|
|
214
|
+
outputDirectory: this.#directory(input.outputDirectory),
|
|
215
|
+
dryRun: !input.apply,
|
|
216
|
+
workspaceSlug: input.slug ?? null,
|
|
217
|
+
workspaceName: input.name ?? null,
|
|
218
|
+
startedAt: this.#now(),
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Answers one claimed run. It records a failure as the run's own outcome
|
|
224
|
+
* rather than throwing, because the operator reads the ledger, not this
|
|
225
|
+
* process's log. The one thing it does throw is a lost claim: that run
|
|
226
|
+
* belongs to the process holding it now, and this one settles nothing.
|
|
227
|
+
*/
|
|
228
|
+
async perform(
|
|
229
|
+
run: AuditExportRun,
|
|
230
|
+
signal?: AbortSignal,
|
|
231
|
+
): Promise<ExportResult> {
|
|
232
|
+
try {
|
|
233
|
+
await this.#event(run, AUDIT_EVENT_ACTIONS.exportStarted, {
|
|
234
|
+
formatVersion: run.formatVersion,
|
|
235
|
+
requestedBy: run.requestedBy,
|
|
236
|
+
dryRun: run.dryRun,
|
|
237
|
+
});
|
|
238
|
+
const backup = await this.#backup();
|
|
239
|
+
if (!backup.ok) {
|
|
240
|
+
return await this.#fail(run, backup.reason, backup.detail);
|
|
241
|
+
}
|
|
242
|
+
/* The stored request is data: the directory the deployment allows may
|
|
243
|
+
have changed, or the row may have been edited. */
|
|
244
|
+
const directory = run.dryRun
|
|
245
|
+
? null
|
|
246
|
+
: this.#directory(run.outputDirectory ?? '');
|
|
247
|
+
const plans = await this.#plan(run.tenantId);
|
|
248
|
+
return directory === null
|
|
249
|
+
? await this.#count(run, plans, backup.evidence, signal)
|
|
250
|
+
: await this.#archive(run, directory, plans, backup.evidence, signal);
|
|
251
|
+
} catch (error) {
|
|
252
|
+
/* The lease lapsed and another loop reclaimed the run while this one
|
|
253
|
+
was working. Recording a failure here would settle a row that is
|
|
254
|
+
somebody else's work now. */
|
|
255
|
+
if (signal?.aborted) throw error;
|
|
256
|
+
return this.#fail(
|
|
257
|
+
run,
|
|
258
|
+
error instanceof AuditServiceError ? error.code : 'EXPORT_FAILED',
|
|
259
|
+
error instanceof Error ? error.message : String(error),
|
|
260
|
+
);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* The claim fence, read once per class. The runner renews the claim on its
|
|
266
|
+
* own timer and aborts this signal when a renewal matches nothing, so a run
|
|
267
|
+
* longer than the lease stops here instead of writing an archive for a claim
|
|
268
|
+
* it no longer holds.
|
|
269
|
+
*/
|
|
270
|
+
#checkpoint(signal: AbortSignal | undefined): void {
|
|
271
|
+
if (!signal?.aborted) return;
|
|
272
|
+
throw new AuditServiceError(
|
|
273
|
+
JOB_CLAIM_LOST,
|
|
274
|
+
'Another process took this export run over while it was running.',
|
|
275
|
+
409,
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
#directory(requested: string): string {
|
|
280
|
+
return exportOutputDirectory({
|
|
281
|
+
environment: this.#environment,
|
|
282
|
+
workspaceRoot: this.#workspaceRoot,
|
|
283
|
+
requested,
|
|
284
|
+
});
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async #plan(tenantId: string): Promise<readonly ClassPlan[]> {
|
|
288
|
+
/* The stored rows are the workspace's own view, so a class whose module
|
|
289
|
+
is no longer composed is still named instead of quietly vanishing. */
|
|
290
|
+
await this.#retention.materialize(tenantId);
|
|
291
|
+
const stored = await this.#repository.listDataClasses(tenantId);
|
|
292
|
+
return stored.map((record) => ({
|
|
293
|
+
record,
|
|
294
|
+
declaration: this.#declared.resolve(record.classId)?.declaration ?? null,
|
|
295
|
+
}));
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/** The plan reads through the same owner ports and writes no archive. */
|
|
299
|
+
async #count(
|
|
300
|
+
run: AuditExportRun,
|
|
301
|
+
plans: readonly ClassPlan[],
|
|
302
|
+
backup: BackupEvidence,
|
|
303
|
+
signal: AbortSignal | undefined,
|
|
304
|
+
): Promise<ExportResult> {
|
|
305
|
+
const classes: ExportedClass[] = [];
|
|
306
|
+
const exclusions: ExportExclusion[] = [];
|
|
307
|
+
for (const plan of plans) {
|
|
308
|
+
this.#checkpoint(signal);
|
|
309
|
+
const excluded = exclusionFor(plan);
|
|
310
|
+
if (excluded) {
|
|
311
|
+
exclusions.push(excluded);
|
|
312
|
+
continue;
|
|
313
|
+
}
|
|
314
|
+
let rows = 0;
|
|
315
|
+
const summary = await runOwnerExport(plan, run.tenantId, async () => {
|
|
316
|
+
rows += 1;
|
|
317
|
+
bound(rows, plan.record.classId);
|
|
318
|
+
});
|
|
319
|
+
classes.push(exportedClass(plan.record, rows, summary));
|
|
320
|
+
}
|
|
321
|
+
const manifest = await this.#manifest(run, backup, classes, exclusions);
|
|
322
|
+
return this.#complete(run, manifest, null, null);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
async #archive(
|
|
326
|
+
run: AuditExportRun,
|
|
327
|
+
directory: string,
|
|
328
|
+
plans: readonly ClassPlan[],
|
|
329
|
+
backup: BackupEvidence,
|
|
330
|
+
signal: AbortSignal | undefined,
|
|
331
|
+
): Promise<ExportResult> {
|
|
332
|
+
/* The mode reaches only the directories this call creates; one that
|
|
333
|
+
already exists keeps the mode it was made with. */
|
|
334
|
+
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
335
|
+
const archivePath = resolve(directory, archiveName(run));
|
|
336
|
+
const digest = createHash('sha256');
|
|
337
|
+
/* A claim taken over from a process that died leaves that process's
|
|
338
|
+
partial archive at this path; it is this run's own file, and the
|
|
339
|
+
archive is created exclusively so nothing else can be written over. */
|
|
340
|
+
await rm(archivePath, { force: true });
|
|
341
|
+
const handle = await open(archivePath, 'wx', 0o600);
|
|
342
|
+
const classes: ExportedClass[] = [];
|
|
343
|
+
const exclusions: ExportExclusion[] = [];
|
|
344
|
+
try {
|
|
345
|
+
const writer = new StoredZipWriter(
|
|
346
|
+
{
|
|
347
|
+
write: async (data) => {
|
|
348
|
+
digest.update(data);
|
|
349
|
+
await handle.write(data);
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
new Date(run.startedAt),
|
|
353
|
+
);
|
|
354
|
+
for (const plan of plans) {
|
|
355
|
+
this.#checkpoint(signal);
|
|
356
|
+
const excluded = exclusionFor(plan);
|
|
357
|
+
if (excluded) {
|
|
358
|
+
exclusions.push(excluded);
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
const file = entryName(plan.record.classId);
|
|
362
|
+
await writer.addEntry(file);
|
|
363
|
+
let rows = 0;
|
|
364
|
+
const summary = await runOwnerExport(
|
|
365
|
+
plan,
|
|
366
|
+
run.tenantId,
|
|
367
|
+
async (row) => {
|
|
368
|
+
rows += 1;
|
|
369
|
+
bound(rows, plan.record.classId);
|
|
370
|
+
await writer.write(jsonLine(row, plan.record.classId));
|
|
371
|
+
},
|
|
372
|
+
);
|
|
373
|
+
await writer.closeEntry();
|
|
374
|
+
classes.push(exportedClass(plan.record, rows, summary, file));
|
|
375
|
+
}
|
|
376
|
+
const manifest = await this.#manifest(run, backup, classes, exclusions);
|
|
377
|
+
await writer.addEntry('manifest.json');
|
|
378
|
+
await writer.write(
|
|
379
|
+
Buffer.from(`${JSON.stringify(manifest, null, '\t')}\n`, 'utf8'),
|
|
380
|
+
);
|
|
381
|
+
await writer.closeEntry();
|
|
382
|
+
await writer.finish();
|
|
383
|
+
await handle.close();
|
|
384
|
+
return this.#complete(run, manifest, archivePath, digest.digest('hex'));
|
|
385
|
+
} catch (error) {
|
|
386
|
+
/* An export is complete or it does not exist: a half-written archive
|
|
387
|
+
would be read as the workspace's data. The run itself is recorded
|
|
388
|
+
as failed by the caller, which is the one place that records it. */
|
|
389
|
+
await handle.close().catch(() => undefined);
|
|
390
|
+
await rm(archivePath, { force: true });
|
|
391
|
+
throw error;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
async #complete(
|
|
396
|
+
run: AuditExportRun,
|
|
397
|
+
manifest: ExportManifest,
|
|
398
|
+
archivePath: string | null,
|
|
399
|
+
archiveDigest: string | null,
|
|
400
|
+
): Promise<ExportResult> {
|
|
401
|
+
const summary = runSummary(manifest);
|
|
402
|
+
const finished = await this.#repository.finishExportRun({
|
|
403
|
+
tenantId: run.tenantId,
|
|
404
|
+
id: run.id,
|
|
405
|
+
status: 'completed',
|
|
406
|
+
classes: manifest.totals.classes,
|
|
407
|
+
rows: manifest.totals.rows,
|
|
408
|
+
archiveDigest,
|
|
409
|
+
archivePath,
|
|
410
|
+
reason: null,
|
|
411
|
+
summary,
|
|
412
|
+
completedAt: this.#now(),
|
|
413
|
+
});
|
|
414
|
+
await this.#event(run, AUDIT_EVENT_ACTIONS.exportCompleted, {
|
|
415
|
+
archiveDigest,
|
|
416
|
+
classes: manifest.totals.classes,
|
|
417
|
+
rows: manifest.totals.rows,
|
|
418
|
+
complete: manifest.complete,
|
|
419
|
+
dryRun: run.dryRun,
|
|
420
|
+
});
|
|
421
|
+
return {
|
|
422
|
+
applied: archivePath !== null,
|
|
423
|
+
dryRun: run.dryRun,
|
|
424
|
+
refused: null,
|
|
425
|
+
archivePath,
|
|
426
|
+
archiveDigest,
|
|
427
|
+
manifest,
|
|
428
|
+
run: finished ?? { ...run, status: 'completed', summary },
|
|
429
|
+
};
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
async #fail(
|
|
433
|
+
run: AuditExportRun,
|
|
434
|
+
reason: string,
|
|
435
|
+
detail: string,
|
|
436
|
+
): Promise<ExportResult> {
|
|
437
|
+
const code = reason.slice(0, 64);
|
|
438
|
+
const at = this.#now();
|
|
439
|
+
const failed = await this.#repository.finishExportRun({
|
|
440
|
+
tenantId: run.tenantId,
|
|
441
|
+
id: run.id,
|
|
442
|
+
status: 'failed',
|
|
443
|
+
classes: 0,
|
|
444
|
+
rows: 0,
|
|
445
|
+
archiveDigest: null,
|
|
446
|
+
archivePath: null,
|
|
447
|
+
reason: code,
|
|
448
|
+
summary: null,
|
|
449
|
+
completedAt: at,
|
|
450
|
+
});
|
|
451
|
+
await this.#event(run, AUDIT_EVENT_ACTIONS.exportFailed, {
|
|
452
|
+
reason: code,
|
|
453
|
+
detail,
|
|
454
|
+
});
|
|
455
|
+
return {
|
|
456
|
+
applied: false,
|
|
457
|
+
dryRun: run.dryRun,
|
|
458
|
+
refused: { reason: code, detail },
|
|
459
|
+
archivePath: null,
|
|
460
|
+
archiveDigest: null,
|
|
461
|
+
manifest: null,
|
|
462
|
+
run: failed ?? { ...run, status: 'failed', reason: code },
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
async #manifest(
|
|
467
|
+
run: AuditExportRun,
|
|
468
|
+
backup: BackupEvidence,
|
|
469
|
+
classes: readonly ExportedClass[],
|
|
470
|
+
exclusions: readonly ExportExclusion[],
|
|
471
|
+
): Promise<ExportManifest> {
|
|
472
|
+
return {
|
|
473
|
+
formatVersion: EXPORT_FORMAT_VERSION,
|
|
474
|
+
generatedAt: new Date(this.#now()).toISOString(),
|
|
475
|
+
platformVersion: await (this.#version ??= this.#platformVersion()),
|
|
476
|
+
workspace: {
|
|
477
|
+
tenantId: run.tenantId,
|
|
478
|
+
slug: run.workspaceSlug,
|
|
479
|
+
name: run.workspaceName,
|
|
480
|
+
},
|
|
481
|
+
complete: !incompleteExclusions(exclusions),
|
|
482
|
+
backup: {
|
|
483
|
+
manifestPath: backup.manifestPath,
|
|
484
|
+
createdAt: backup.createdAt,
|
|
485
|
+
adapter: backup.adapter,
|
|
486
|
+
platformVersion: backup.platformVersion,
|
|
487
|
+
keys: backup.keys.map((key) => ({
|
|
488
|
+
variable: key.variable,
|
|
489
|
+
fingerprint: key.fingerprint,
|
|
490
|
+
})),
|
|
491
|
+
},
|
|
492
|
+
classes,
|
|
493
|
+
exclusions,
|
|
494
|
+
totals: {
|
|
495
|
+
classes: classes.length,
|
|
496
|
+
rows: classes.reduce((total, entry) => total + entry.rows, 0),
|
|
497
|
+
},
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
async #event(
|
|
502
|
+
run: AuditExportRun,
|
|
503
|
+
action: string,
|
|
504
|
+
metadata: Readonly<Record<string, unknown>>,
|
|
505
|
+
): Promise<void> {
|
|
506
|
+
await this.#repository.appendAuditEvent({
|
|
507
|
+
tenantId: run.tenantId,
|
|
508
|
+
actorId: run.requestedBy,
|
|
509
|
+
action,
|
|
510
|
+
subjectType: 'export-run',
|
|
511
|
+
subjectId: run.id,
|
|
512
|
+
metadata,
|
|
513
|
+
occurredAt: this.#now(),
|
|
514
|
+
});
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/**
|
|
519
|
+
* Waits for the platform to answer one run. The command that recorded the
|
|
520
|
+
* request polls the row it wrote: only the running platform holds the sealed
|
|
521
|
+
* registry, so a deployment whose platform is down never answers and the wait
|
|
522
|
+
* ends with a stable reason naming the run.
|
|
523
|
+
*/
|
|
524
|
+
export async function awaitExportRun(
|
|
525
|
+
repository: AuditRepository,
|
|
526
|
+
tenantId: string,
|
|
527
|
+
id: string,
|
|
528
|
+
options: {
|
|
529
|
+
readonly timeoutMs?: number;
|
|
530
|
+
readonly pollMs?: number;
|
|
531
|
+
readonly now?: () => number;
|
|
532
|
+
readonly sleep?: (ms: number) => Promise<void>;
|
|
533
|
+
} = {},
|
|
534
|
+
): Promise<AuditExportRun> {
|
|
535
|
+
const now = options.now ?? Date.now;
|
|
536
|
+
const sleep =
|
|
537
|
+
options.sleep ??
|
|
538
|
+
((ms: number) =>
|
|
539
|
+
new Promise<void>((settle) => {
|
|
540
|
+
setTimeout(settle, ms).unref?.();
|
|
541
|
+
}));
|
|
542
|
+
const pollMs = options.pollMs ?? EXPORT_WAIT.pollMs;
|
|
543
|
+
const deadline = now() + (options.timeoutMs ?? EXPORT_WAIT.timeoutMs);
|
|
544
|
+
for (;;) {
|
|
545
|
+
const run = await repository.getExportRun(tenantId, id);
|
|
546
|
+
if (!run) {
|
|
547
|
+
throw new AuditServiceError(
|
|
548
|
+
'EXPORT_RUN_NOT_FOUND',
|
|
549
|
+
`The export run ${id} is no longer recorded in this workspace.`,
|
|
550
|
+
404,
|
|
551
|
+
);
|
|
552
|
+
}
|
|
553
|
+
if (run.status !== 'started') return run;
|
|
554
|
+
if (now() >= deadline) {
|
|
555
|
+
throw new AuditServiceError(
|
|
556
|
+
'EXPORT_NOT_ANSWERED',
|
|
557
|
+
`The export run ${id} is still requested. Only the running platform performs an export; start it and read the run with "flowdular audit export" history.`,
|
|
558
|
+
504,
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
await sleep(pollMs);
|
|
562
|
+
}
|
|
563
|
+
}
|
|
564
|
+
|
|
565
|
+
function runSummary(manifest: ExportManifest): ExportRunSummary {
|
|
566
|
+
const cap = EXPORT_LIMITS.summaryEntries;
|
|
567
|
+
return {
|
|
568
|
+
complete: manifest.complete,
|
|
569
|
+
classes: manifest.classes.slice(0, cap).map((entry) => ({
|
|
570
|
+
classId: entry.classId,
|
|
571
|
+
rows: entry.rows,
|
|
572
|
+
from: entry.from,
|
|
573
|
+
to: entry.to,
|
|
574
|
+
})),
|
|
575
|
+
exclusions: manifest.exclusions.slice(0, cap).map((entry) => ({
|
|
576
|
+
classId: entry.classId,
|
|
577
|
+
reason: entry.reason,
|
|
578
|
+
})),
|
|
579
|
+
/* The archive carries every class; one stored row names at most `cap` of
|
|
580
|
+
them, and says so rather than looking complete. */
|
|
581
|
+
truncated:
|
|
582
|
+
manifest.classes.length > cap || manifest.exclusions.length > cap,
|
|
583
|
+
};
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
function exclusionFor(plan: ClassPlan): ExportExclusion | null {
|
|
587
|
+
const base = {
|
|
588
|
+
classId: plan.record.classId,
|
|
589
|
+
moduleId: plan.record.moduleId,
|
|
590
|
+
label: plan.record.label,
|
|
591
|
+
};
|
|
592
|
+
if (!plan.declaration) {
|
|
593
|
+
return {
|
|
594
|
+
...base,
|
|
595
|
+
reason: EXPORT_EXCLUSIONS.ownerNotComposed,
|
|
596
|
+
declaredReason: null,
|
|
597
|
+
};
|
|
598
|
+
}
|
|
599
|
+
if (!plan.declaration.exportable) {
|
|
600
|
+
return {
|
|
601
|
+
...base,
|
|
602
|
+
reason: EXPORT_EXCLUSIONS.declared,
|
|
603
|
+
declaredReason: plan.declaration.excludedReason ?? null,
|
|
604
|
+
};
|
|
605
|
+
}
|
|
606
|
+
if (!plan.declaration.export) {
|
|
607
|
+
return {
|
|
608
|
+
...base,
|
|
609
|
+
reason: EXPORT_EXCLUSIONS.noOperation,
|
|
610
|
+
declaredReason: null,
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
return null;
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
/* `exclusionFor` answered null for this plan, so both are present. */
|
|
617
|
+
function exportOperation(
|
|
618
|
+
plan: ClassPlan,
|
|
619
|
+
): NonNullable<DataClassDeclaration['export']> {
|
|
620
|
+
const operation = plan.declaration?.export;
|
|
621
|
+
if (!operation) {
|
|
622
|
+
throw new AuditServiceError(
|
|
623
|
+
'OWNER_EXPORT_FAILED',
|
|
624
|
+
`${plan.record.classId} has no export operation.`,
|
|
625
|
+
500,
|
|
626
|
+
);
|
|
627
|
+
}
|
|
628
|
+
return operation;
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
/* Foreign code. A failure is the export's failure: an archive missing a class
|
|
632
|
+
it claims to carry is worse than no archive. */
|
|
633
|
+
async function runOwnerExport(
|
|
634
|
+
plan: ClassPlan,
|
|
635
|
+
tenantId: string,
|
|
636
|
+
write: DataClassExportSink['write'],
|
|
637
|
+
): Promise<{ from: Date | null; to: Date | null }> {
|
|
638
|
+
try {
|
|
639
|
+
const summary = await exportOperation(plan)({ tenantId, sink: { write } });
|
|
640
|
+
return { from: summary?.from ?? null, to: summary?.to ?? null };
|
|
641
|
+
} catch (error) {
|
|
642
|
+
if (error instanceof AuditServiceError) throw error;
|
|
643
|
+
throw new AuditServiceError(
|
|
644
|
+
'OWNER_EXPORT_FAILED',
|
|
645
|
+
`${plan.record.moduleId} could not export ${plan.record.classId}: ${
|
|
646
|
+
error instanceof Error ? error.message : String(error)
|
|
647
|
+
}`,
|
|
648
|
+
502,
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
function exportedClass(
|
|
654
|
+
record: AuditDataClass,
|
|
655
|
+
rows: number,
|
|
656
|
+
summary: { from: Date | null; to: Date | null },
|
|
657
|
+
file = entryName(record.classId),
|
|
658
|
+
): ExportedClass {
|
|
659
|
+
return {
|
|
660
|
+
classId: record.classId,
|
|
661
|
+
moduleId: record.moduleId,
|
|
662
|
+
label: record.label,
|
|
663
|
+
file,
|
|
664
|
+
/* The count the sink saw, not the one the owner reported: the archive is
|
|
665
|
+
the record, so the manifest states what it actually holds. */
|
|
666
|
+
rows,
|
|
667
|
+
from: isoOrNull(summary.from),
|
|
668
|
+
to: isoOrNull(summary.to),
|
|
669
|
+
};
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
function isoOrNull(value: Date | null): string | null {
|
|
673
|
+
return value instanceof Date && Number.isFinite(value.getTime())
|
|
674
|
+
? value.toISOString()
|
|
675
|
+
: null;
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
function entryName(classId: string): string {
|
|
679
|
+
return `classes/${classId}.jsonl`;
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
function bound(rows: number, classId: string): void {
|
|
683
|
+
if (rows > EXPORT_LIMITS.rowsPerClass) {
|
|
684
|
+
throw new AuditServiceError(
|
|
685
|
+
'EXPORT_CLASS_TOO_LARGE',
|
|
686
|
+
`${classId} exported more than ${EXPORT_LIMITS.rowsPerClass} rows.`,
|
|
687
|
+
507,
|
|
688
|
+
);
|
|
689
|
+
}
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
function jsonLine(row: Record<string, unknown>, classId: string): Buffer {
|
|
693
|
+
const line = Buffer.from(`${JSON.stringify(row)}\n`, 'utf8');
|
|
694
|
+
if (line.byteLength > EXPORT_LIMITS.rowBytes) {
|
|
695
|
+
throw new AuditServiceError(
|
|
696
|
+
'EXPORT_ROW_TOO_LARGE',
|
|
697
|
+
`${classId} exported a row larger than ${EXPORT_LIMITS.rowBytes} bytes.`,
|
|
698
|
+
507,
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
return line;
|
|
702
|
+
}
|
|
703
|
+
|
|
704
|
+
/* The run id is part of the name: two requests of one workspace can carry the
|
|
705
|
+
same start time, and each archive is the record of exactly one run. */
|
|
706
|
+
function archiveName(run: AuditExportRun): string {
|
|
707
|
+
const stamp = new Date(run.startedAt)
|
|
708
|
+
.toISOString()
|
|
709
|
+
.replaceAll(/[:.]/g, '')
|
|
710
|
+
.replace(/-/g, '');
|
|
711
|
+
const safe = run.tenantId.replaceAll(/[^A-Za-z0-9_-]/g, '-').slice(0, 64);
|
|
712
|
+
const suffix = run.id.replaceAll(/[^A-Za-z0-9]/g, '').slice(0, 8);
|
|
713
|
+
return `audit-export-${safe}-${stamp}-${suffix}.zip`;
|
|
714
|
+
}
|