@flowdular/sdk 0.2.4 → 0.3.1
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 +130 -3
- 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/cli-extension/SKILL.md +1 -1
- package/.ai/skills/deploy-operate/SKILL.md +119 -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/0005_approvals_grant_audit.down.sql +4 -0
- package/modules/approvals/migrations/0005_approvals_grant_audit.up.sql +20 -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 +327 -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 +107 -0
- package/modules/approvals/src/domain/grant.ts +69 -0
- package/modules/approvals/src/domain/types.ts +168 -0
- package/modules/approvals/src/index.ts +61 -0
- package/modules/approvals/src/platform.ts +136 -0
- package/modules/approvals/src/server/index.ts +42 -0
- package/modules/approvals/src/server/runtime.ts +185 -0
- package/modules/approvals/src/services/approvals-service.ts +637 -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 +783 -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 +256 -0
- package/modules/approvals/src/services/notifications.ts +95 -0
- package/modules/approvals/src/services/repository.ts +169 -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/0003_connectors_rotation_inventory.down.sql +2 -0
- package/modules/connectors/migrations/0003_connectors_rotation_inventory.up.sql +19 -0
- package/modules/connectors/migrations/README.md +3 -0
- package/modules/connectors/module.json +32 -0
- package/modules/{automations-workflows-integration → connectors}/package.json +28 -26
- package/modules/connectors/spec/module.yaml +448 -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/cli/commands.json +17 -0
- package/modules/connectors/src/cli/index.ts +126 -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-rotation.ts +221 -0
- package/modules/connectors/src/services/credential-vault.ts +194 -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 +202 -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/0003_documents_rotation_inventory.down.sql +2 -0
- package/modules/documents/migrations/0003_documents_rotation_inventory.up.sql +18 -0
- package/modules/documents/migrations/README.md +3 -0
- package/modules/documents/module.json +32 -0
- package/modules/documents/package.json +50 -0
- package/modules/documents/spec/module.yaml +248 -0
- package/modules/documents/src/acl/permissions.ts +6 -0
- package/modules/documents/src/api/endpoints.ts +401 -0
- package/modules/documents/src/cli/commands.json +17 -0
- package/modules/documents/src/cli/index.ts +145 -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 +270 -0
- package/modules/documents/src/services/documents-service.ts +590 -0
- package/modules/documents/src/services/index.ts +18 -0
- package/modules/documents/src/services/migration.ts +117 -0
- package/modules/documents/src/services/repository.ts +58 -0
- package/modules/documents/src/services/storage-rotation.ts +157 -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/0003_exports_rotation_inventory.down.sql +1 -0
- package/modules/exports/migrations/0003_exports_rotation_inventory.up.sql +9 -0
- package/modules/exports/migrations/README.md +3 -0
- package/modules/exports/module.json +32 -0
- package/modules/exports/package.json +45 -0
- package/modules/exports/spec/module.yaml +230 -0
- package/modules/exports/src/acl/permissions.ts +6 -0
- package/modules/exports/src/api/endpoints.ts +211 -0
- package/modules/exports/src/cli/commands.json +17 -0
- package/modules/exports/src/cli/index.ts +145 -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 +50 -0
- package/modules/exports/src/server/runtime.ts +160 -0
- package/modules/exports/src/services/data-classes.ts +59 -0
- package/modules/exports/src/services/database-repository.ts +403 -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 +116 -0
- package/modules/exports/src/services/repository.ts +96 -0
- package/modules/exports/src/services/storage-rotation.ts +138 -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 +180 -0
- package/packages/database/src/decoders.ts +25 -0
- package/packages/database/src/index.ts +17 -0
- package/packages/database/src/migrations.ts +7 -0
- package/packages/database/src/record-history.ts +5 -14
- package/packages/harness/src/index.ts +2 -0
- package/packages/harness/src/runtime.ts +378 -2
- package/packages/harness/src/tool-adapters.ts +20 -9
- package/packages/kernel/src/acl.ts +179 -0
- package/packages/kernel/src/approval-grant.ts +310 -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 +85 -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 +238 -0
- package/packages/storage/src/index.ts +49 -0
- package/packages/storage/src/local.ts +75 -0
- package/packages/storage/src/port.ts +262 -0
- package/packages/storage/src/read-token.ts +130 -0
- package/packages/storage/src/reseal.ts +128 -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,780 @@
|
|
|
1
|
+
import type { DatabaseHandle, DatabaseTransaction } from '@flowdular/sdk/database';
|
|
2
|
+
import { integer, runDatabaseMigrations } from '@flowdular/sdk/database';
|
|
3
|
+
import type { DataClassExportSink } from '@flowdular/sdk/kernel';
|
|
4
|
+
import type { ImportMode } from '../domain/ports.ts';
|
|
5
|
+
import {
|
|
6
|
+
type ClaimedImportJob,
|
|
7
|
+
type ImportJob,
|
|
8
|
+
type ImportJobRouting,
|
|
9
|
+
type ImportJobRow,
|
|
10
|
+
type ImportJobStatus,
|
|
11
|
+
type ImportMapping,
|
|
12
|
+
type ImportRequester,
|
|
13
|
+
type ImportRowOutcome,
|
|
14
|
+
} from '../domain/types.ts';
|
|
15
|
+
import { databaseMigrations } from './migration.ts';
|
|
16
|
+
import type {
|
|
17
|
+
ClaimJobInput,
|
|
18
|
+
ImportJobPage,
|
|
19
|
+
ImportJobQuery,
|
|
20
|
+
ImportJobResult,
|
|
21
|
+
ImportRepository,
|
|
22
|
+
ImportRowOutcomeCounts,
|
|
23
|
+
ImportRowPage,
|
|
24
|
+
ImportSweepInput,
|
|
25
|
+
} from './repository.ts';
|
|
26
|
+
|
|
27
|
+
const JOB_COLUMNS = `id, tenant_id, target, document_id, document_ref, mode,
|
|
28
|
+
dry_run, valid_only, status, total_rows, valid_rows, written_rows,
|
|
29
|
+
failed_rows, requester_account_id, requester_json, columns_json,
|
|
30
|
+
failure_code, claimed_at, started_at, completed_at, traceparent`;
|
|
31
|
+
|
|
32
|
+
const ROW_COLUMNS = `id, tenant_id, job_id, row_number, outcome, field, reason,
|
|
33
|
+
record_ref`;
|
|
34
|
+
|
|
35
|
+
/* Queries stay explicit and every value travels through the parameter channel;
|
|
36
|
+
no import data is ever concatenated into SQL. */
|
|
37
|
+
const SQL = {
|
|
38
|
+
insertJob: `INSERT INTO import_jobs (${JOB_COLUMNS})
|
|
39
|
+
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15,
|
|
40
|
+
$16, $17, $18, $19, $20, $21)`,
|
|
41
|
+
|
|
42
|
+
findJob: `SELECT ${JOB_COLUMNS} FROM import_jobs
|
|
43
|
+
WHERE tenant_id = $1 AND id = $2`,
|
|
44
|
+
|
|
45
|
+
/* The `from` statuses are appended as bound parameters by `advanceJob`: the
|
|
46
|
+
adapter's parameter channel carries scalars, not arrays. */
|
|
47
|
+
advanceJob: `UPDATE import_jobs
|
|
48
|
+
SET status = $3, total_rows = $4, valid_rows = $5, written_rows = $6,
|
|
49
|
+
failed_rows = $7, failure_code = $8, completed_at = $9,
|
|
50
|
+
claimed_at = NULL
|
|
51
|
+
WHERE tenant_id = $1 AND id = $2 AND status IN `,
|
|
52
|
+
|
|
53
|
+
continueJob: `UPDATE import_jobs SET status = 'writing', valid_only = $3
|
|
54
|
+
WHERE tenant_id = $1 AND id = $2 AND status = 'validated'
|
|
55
|
+
RETURNING ${JOB_COLUMNS}`,
|
|
56
|
+
|
|
57
|
+
/* One statement, so two platform processes cannot both take one job. A
|
|
58
|
+
claim older than the lease belonged to a process that is gone. */
|
|
59
|
+
claimJob: `UPDATE import_jobs SET claimed_at = $3
|
|
60
|
+
WHERE tenant_id = $1 AND id = $2
|
|
61
|
+
AND status IN ('parsing', 'writing')
|
|
62
|
+
AND (claimed_at IS NULL OR claimed_at <= $4)
|
|
63
|
+
RETURNING ${JOB_COLUMNS}`,
|
|
64
|
+
|
|
65
|
+
/* Renewed once per batch by the stage that holds the claim. The status guard
|
|
66
|
+
keeps a job that already settled from looking claimed again, and the claim
|
|
67
|
+
guard keeps a stage whose lease lapsed from renewing a claim that is now
|
|
68
|
+
somebody else's. */
|
|
69
|
+
heartbeatJob: `UPDATE import_jobs SET claimed_at = $3
|
|
70
|
+
WHERE tenant_id = $1 AND id = $2 AND claimed_at = $4
|
|
71
|
+
AND status IN ('parsing', 'writing')`,
|
|
72
|
+
|
|
73
|
+
/* Read through the cross-tenant background lease, which is granted these
|
|
74
|
+
four columns and no others. */
|
|
75
|
+
listPendingJobs: `SELECT tenant_id, id, status, started_at
|
|
76
|
+
FROM import_jobs
|
|
77
|
+
WHERE status IN ('parsing', 'writing')
|
|
78
|
+
ORDER BY started_at, tenant_id, id
|
|
79
|
+
LIMIT $1`,
|
|
80
|
+
|
|
81
|
+
deleteJobRows:
|
|
82
|
+
'DELETE FROM import_job_rows WHERE tenant_id = $1 AND job_id = $2',
|
|
83
|
+
|
|
84
|
+
listJobRows: `SELECT ${ROW_COLUMNS} FROM import_job_rows
|
|
85
|
+
WHERE tenant_id = $1 AND job_id = $2 AND row_number > $3
|
|
86
|
+
ORDER BY row_number LIMIT $4`,
|
|
87
|
+
|
|
88
|
+
listValidRowNumbers: `SELECT row_number FROM import_job_rows
|
|
89
|
+
WHERE tenant_id = $1 AND job_id = $2 AND outcome = 'valid'
|
|
90
|
+
ORDER BY row_number`,
|
|
91
|
+
|
|
92
|
+
countRowOutcomes: `SELECT outcome, count(*) AS rows FROM import_job_rows
|
|
93
|
+
WHERE tenant_id = $1 AND job_id = $2
|
|
94
|
+
GROUP BY outcome`,
|
|
95
|
+
|
|
96
|
+
findMapping: `SELECT id, tenant_id, target, columns_json, updated_at
|
|
97
|
+
FROM import_mappings WHERE tenant_id = $1 AND target = $2`,
|
|
98
|
+
|
|
99
|
+
saveMapping: `INSERT INTO import_mappings
|
|
100
|
+
(id, tenant_id, target, columns_json, updated_at)
|
|
101
|
+
VALUES ($1, $2, $3, $4, $5)
|
|
102
|
+
ON CONFLICT (tenant_id, target) DO UPDATE
|
|
103
|
+
SET columns_json = EXCLUDED.columns_json, updated_at = EXCLUDED.updated_at
|
|
104
|
+
RETURNING id, tenant_id, target, columns_json, updated_at`,
|
|
105
|
+
|
|
106
|
+
/* A job nobody continued is settled before the retention gate sees it, so an
|
|
107
|
+
abandoned validated job leaves the queue instead of waiting out its whole
|
|
108
|
+
retention as work in flight. */
|
|
109
|
+
expireValidatedJobs: `UPDATE import_jobs
|
|
110
|
+
SET status = 'cancelled', completed_at = $4, claimed_at = NULL
|
|
111
|
+
WHERE tenant_id = $1 AND id IN (
|
|
112
|
+
SELECT id FROM import_jobs
|
|
113
|
+
WHERE tenant_id = $1 AND status = 'validated' AND started_at < $2
|
|
114
|
+
ORDER BY started_at, id LIMIT $3)`,
|
|
115
|
+
|
|
116
|
+
/* The batch is chosen once and both deletes read that one set: two
|
|
117
|
+
independently ordered LIMIT subqueries could pick different jobs on a tie
|
|
118
|
+
and leave outcomes behind whose job is gone. */
|
|
119
|
+
sweepJobs: `WITH doomed AS (
|
|
120
|
+
SELECT id FROM import_jobs
|
|
121
|
+
WHERE tenant_id = $1 AND started_at < $2
|
|
122
|
+
AND status IN ('completed', 'failed', 'cancelled')
|
|
123
|
+
ORDER BY started_at, id LIMIT $3
|
|
124
|
+
), swept_rows AS (
|
|
125
|
+
DELETE FROM import_job_rows
|
|
126
|
+
WHERE tenant_id = $1 AND job_id IN (SELECT id FROM doomed)
|
|
127
|
+
)
|
|
128
|
+
DELETE FROM import_jobs
|
|
129
|
+
WHERE tenant_id = $1 AND id IN (SELECT id FROM doomed)`,
|
|
130
|
+
|
|
131
|
+
exportPage: `SELECT ${JOB_COLUMNS} FROM import_jobs
|
|
132
|
+
WHERE tenant_id = $1 AND (started_at, id) > ($2, $3)
|
|
133
|
+
ORDER BY started_at, id LIMIT $4`,
|
|
134
|
+
|
|
135
|
+
exportRowsPage: `SELECT ${ROW_COLUMNS} FROM import_job_rows
|
|
136
|
+
WHERE tenant_id = $1 AND (job_id, row_number) > ($2, $3)
|
|
137
|
+
ORDER BY job_id, row_number LIMIT $4`,
|
|
138
|
+
|
|
139
|
+
exportMappingsPage: `SELECT id, tenant_id, target, columns_json, updated_at
|
|
140
|
+
FROM import_mappings WHERE tenant_id = $1 AND target > $2
|
|
141
|
+
ORDER BY target LIMIT $3`,
|
|
142
|
+
} as const;
|
|
143
|
+
|
|
144
|
+
interface JobRow {
|
|
145
|
+
id: string;
|
|
146
|
+
tenant_id: string;
|
|
147
|
+
target: string;
|
|
148
|
+
document_id: string;
|
|
149
|
+
document_ref: string;
|
|
150
|
+
mode: ImportMode;
|
|
151
|
+
dry_run: number | string;
|
|
152
|
+
valid_only: number | string;
|
|
153
|
+
status: ImportJobStatus;
|
|
154
|
+
total_rows: number | bigint | string;
|
|
155
|
+
valid_rows: number | bigint | string;
|
|
156
|
+
written_rows: number | bigint | string;
|
|
157
|
+
failed_rows: number | bigint | string;
|
|
158
|
+
requester_account_id: string;
|
|
159
|
+
requester_json: string;
|
|
160
|
+
columns_json: string;
|
|
161
|
+
failure_code: string | null;
|
|
162
|
+
claimed_at: number | bigint | string | null;
|
|
163
|
+
started_at: number | bigint | string;
|
|
164
|
+
completed_at: number | bigint | string | null;
|
|
165
|
+
traceparent: string | null;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
interface OutcomeRow {
|
|
169
|
+
id: string;
|
|
170
|
+
tenant_id: string;
|
|
171
|
+
job_id: string;
|
|
172
|
+
row_number: number | bigint | string;
|
|
173
|
+
outcome: ImportRowOutcome;
|
|
174
|
+
field: string | null;
|
|
175
|
+
reason: string | null;
|
|
176
|
+
record_ref: string | null;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
function optionalInteger(
|
|
180
|
+
value: number | bigint | string | null,
|
|
181
|
+
field: string,
|
|
182
|
+
): number | null {
|
|
183
|
+
return value === null ? null : integer(value, field);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/* A column written by this module, so a parse failure is corruption rather than
|
|
187
|
+
input; the stable message names the column instead of leaking the payload. */
|
|
188
|
+
function jsonObject(raw: string, field: string): Record<string, string> {
|
|
189
|
+
let parsed: unknown;
|
|
190
|
+
try {
|
|
191
|
+
parsed = JSON.parse(raw);
|
|
192
|
+
} catch {
|
|
193
|
+
throw new Error(`The import database returned an invalid ${field}.`);
|
|
194
|
+
}
|
|
195
|
+
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
|
|
196
|
+
throw new Error(`The import database returned an invalid ${field}.`);
|
|
197
|
+
}
|
|
198
|
+
return parsed as Record<string, string>;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function requesterOf(raw: string): ImportRequester {
|
|
202
|
+
const parsed = jsonObject(raw, 'requester') as unknown as ImportRequester;
|
|
203
|
+
return {
|
|
204
|
+
accountId: String(parsed.accountId ?? ''),
|
|
205
|
+
email: String(parsed.email ?? ''),
|
|
206
|
+
displayName: String(parsed.displayName ?? ''),
|
|
207
|
+
role: String(parsed.role ?? ''),
|
|
208
|
+
scopes: Array.isArray(parsed.scopes) ? parsed.scopes.map(String) : [],
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function jobFromRow(row: JobRow): ImportJob {
|
|
213
|
+
return {
|
|
214
|
+
id: row.id,
|
|
215
|
+
tenantId: row.tenant_id,
|
|
216
|
+
target: row.target,
|
|
217
|
+
documentId: row.document_id,
|
|
218
|
+
documentRef: row.document_ref,
|
|
219
|
+
mode: row.mode,
|
|
220
|
+
dryRun: Number(row.dry_run) === 1,
|
|
221
|
+
validOnly: Number(row.valid_only) === 1,
|
|
222
|
+
status: row.status,
|
|
223
|
+
totalRows: integer(row.total_rows, 'row count'),
|
|
224
|
+
validRows: integer(row.valid_rows, 'row count'),
|
|
225
|
+
writtenRows: integer(row.written_rows, 'row count'),
|
|
226
|
+
failedRows: integer(row.failed_rows, 'row count'),
|
|
227
|
+
requesterAccountId: row.requester_account_id,
|
|
228
|
+
requester: requesterOf(row.requester_json),
|
|
229
|
+
columns: jsonObject(row.columns_json, 'mapping'),
|
|
230
|
+
failureCode: row.failure_code,
|
|
231
|
+
claimedAt: optionalInteger(row.claimed_at, 'timestamp'),
|
|
232
|
+
startedAt: integer(row.started_at, 'timestamp'),
|
|
233
|
+
completedAt: optionalInteger(row.completed_at, 'timestamp'),
|
|
234
|
+
traceparent: row.traceparent,
|
|
235
|
+
};
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function rowFromRow(row: OutcomeRow): ImportJobRow {
|
|
239
|
+
return {
|
|
240
|
+
id: row.id,
|
|
241
|
+
tenantId: row.tenant_id,
|
|
242
|
+
jobId: row.job_id,
|
|
243
|
+
rowNumber: integer(row.row_number, 'row number'),
|
|
244
|
+
outcome: row.outcome,
|
|
245
|
+
field: row.field,
|
|
246
|
+
reason: row.reason,
|
|
247
|
+
recordRef: row.record_ref,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function jobParameters(job: ImportJob): readonly (string | number | null)[] {
|
|
252
|
+
return [
|
|
253
|
+
job.id,
|
|
254
|
+
job.tenantId,
|
|
255
|
+
job.target,
|
|
256
|
+
job.documentId,
|
|
257
|
+
job.documentRef,
|
|
258
|
+
job.mode,
|
|
259
|
+
job.dryRun ? 1 : 0,
|
|
260
|
+
job.validOnly ? 1 : 0,
|
|
261
|
+
job.status,
|
|
262
|
+
job.totalRows,
|
|
263
|
+
job.validRows,
|
|
264
|
+
job.writtenRows,
|
|
265
|
+
job.failedRows,
|
|
266
|
+
job.requesterAccountId,
|
|
267
|
+
JSON.stringify(job.requester),
|
|
268
|
+
JSON.stringify(job.columns),
|
|
269
|
+
job.failureCode,
|
|
270
|
+
job.claimedAt,
|
|
271
|
+
job.startedAt,
|
|
272
|
+
job.completedAt,
|
|
273
|
+
job.traceparent,
|
|
274
|
+
];
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/** Rows per INSERT; eight parameters each stays far inside the bind limit. */
|
|
278
|
+
const INSERT_CHUNK = 250;
|
|
279
|
+
const EXPORT_PAGE = 500;
|
|
280
|
+
|
|
281
|
+
export async function migrateImportDatabase(
|
|
282
|
+
database: DatabaseHandle,
|
|
283
|
+
): Promise<void> {
|
|
284
|
+
await runDatabaseMigrations(database, 'import.core', databaseMigrations);
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export interface ImportDatabaseHandles {
|
|
288
|
+
readonly runtime: DatabaseHandle;
|
|
289
|
+
/** Cross-tenant, read only, granted the job routing columns alone. */
|
|
290
|
+
readonly background: DatabaseHandle;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export class DatabaseImportRepository implements ImportRepository {
|
|
294
|
+
readonly #handles: ImportDatabaseHandles;
|
|
295
|
+
|
|
296
|
+
constructor(handles: ImportDatabaseHandles) {
|
|
297
|
+
this.#handles = handles;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
async createJob(job: ImportJob): Promise<ImportJob> {
|
|
301
|
+
await this.#handles.runtime.transaction(
|
|
302
|
+
(transaction) =>
|
|
303
|
+
transaction.execute({
|
|
304
|
+
text: SQL.insertJob,
|
|
305
|
+
parameters: jobParameters(job),
|
|
306
|
+
}),
|
|
307
|
+
{ access: 'write', tenantId: job.tenantId },
|
|
308
|
+
);
|
|
309
|
+
return job;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
async findJob(tenantId: string, id: string): Promise<ImportJob | null> {
|
|
313
|
+
const result = await this.#handles.runtime.transaction(
|
|
314
|
+
(transaction) =>
|
|
315
|
+
transaction.query<JobRow>({
|
|
316
|
+
text: SQL.findJob,
|
|
317
|
+
parameters: [tenantId, id],
|
|
318
|
+
}),
|
|
319
|
+
{ access: 'read', tenantId },
|
|
320
|
+
);
|
|
321
|
+
const row = result.rows[0];
|
|
322
|
+
return row ? jobFromRow(row) : null;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
async listJobs(
|
|
326
|
+
tenantId: string,
|
|
327
|
+
query: ImportJobQuery,
|
|
328
|
+
): Promise<ImportJobPage> {
|
|
329
|
+
const parameters: (string | number)[] = [tenantId];
|
|
330
|
+
let text = `SELECT ${JOB_COLUMNS} FROM import_jobs WHERE tenant_id = $1`;
|
|
331
|
+
if (query.status) {
|
|
332
|
+
parameters.push(query.status);
|
|
333
|
+
text += ` AND status = $${parameters.length}`;
|
|
334
|
+
}
|
|
335
|
+
if (query.target) {
|
|
336
|
+
parameters.push(query.target);
|
|
337
|
+
text += ` AND target = $${parameters.length}`;
|
|
338
|
+
}
|
|
339
|
+
if (query.cursor) {
|
|
340
|
+
parameters.push(query.cursor.startedAt, query.cursor.id);
|
|
341
|
+
text += ` AND (started_at, id) < ($${parameters.length - 1}, $${parameters.length})`;
|
|
342
|
+
}
|
|
343
|
+
/* One row past the page tells the caller there is another page without a
|
|
344
|
+
second count over the workspace's jobs. */
|
|
345
|
+
parameters.push(query.limit + 1);
|
|
346
|
+
text += ` ORDER BY started_at DESC, id DESC LIMIT $${parameters.length}`;
|
|
347
|
+
const result = await this.#handles.runtime.transaction(
|
|
348
|
+
(transaction) => transaction.query<JobRow>({ text, parameters }),
|
|
349
|
+
{ access: 'read', tenantId },
|
|
350
|
+
);
|
|
351
|
+
const items = result.rows.slice(0, query.limit).map(jobFromRow);
|
|
352
|
+
const last = items[items.length - 1];
|
|
353
|
+
return {
|
|
354
|
+
items,
|
|
355
|
+
nextCursor:
|
|
356
|
+
result.rows.length > query.limit && last
|
|
357
|
+
? { startedAt: last.startedAt, id: last.id }
|
|
358
|
+
: null,
|
|
359
|
+
};
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
async advanceJob(
|
|
363
|
+
tenantId: string,
|
|
364
|
+
id: string,
|
|
365
|
+
from: readonly ImportJobStatus[],
|
|
366
|
+
result: ImportJobResult,
|
|
367
|
+
): Promise<ImportJob | null> {
|
|
368
|
+
const parameters: (string | number | null)[] = [
|
|
369
|
+
tenantId,
|
|
370
|
+
id,
|
|
371
|
+
result.status,
|
|
372
|
+
result.totalRows,
|
|
373
|
+
result.validRows,
|
|
374
|
+
result.writtenRows,
|
|
375
|
+
result.failedRows,
|
|
376
|
+
result.failureCode,
|
|
377
|
+
result.completedAt,
|
|
378
|
+
];
|
|
379
|
+
const placeholders = from.map((status) => {
|
|
380
|
+
parameters.push(status);
|
|
381
|
+
return `$${parameters.length}`;
|
|
382
|
+
});
|
|
383
|
+
const answered = await this.#handles.runtime.transaction(
|
|
384
|
+
(transaction) =>
|
|
385
|
+
transaction.query<JobRow>({
|
|
386
|
+
text:
|
|
387
|
+
`${SQL.advanceJob}(${placeholders.join(', ')})` +
|
|
388
|
+
` RETURNING ${JOB_COLUMNS}`,
|
|
389
|
+
parameters,
|
|
390
|
+
}),
|
|
391
|
+
{ access: 'write', tenantId },
|
|
392
|
+
);
|
|
393
|
+
const row = answered.rows[0];
|
|
394
|
+
return row ? jobFromRow(row) : null;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
async continueJob(
|
|
398
|
+
tenantId: string,
|
|
399
|
+
id: string,
|
|
400
|
+
validOnly: boolean,
|
|
401
|
+
): Promise<ImportJob | null> {
|
|
402
|
+
const result = await this.#handles.runtime.transaction(
|
|
403
|
+
(transaction) =>
|
|
404
|
+
transaction.query<JobRow>({
|
|
405
|
+
text: SQL.continueJob,
|
|
406
|
+
parameters: [tenantId, id, validOnly ? 1 : 0],
|
|
407
|
+
}),
|
|
408
|
+
{ access: 'write', tenantId },
|
|
409
|
+
);
|
|
410
|
+
const row = result.rows[0];
|
|
411
|
+
return row ? jobFromRow(row) : null;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
async claimJob(input: ClaimJobInput): Promise<ClaimedImportJob | null> {
|
|
415
|
+
const result = await this.#handles.runtime.transaction(
|
|
416
|
+
(transaction) =>
|
|
417
|
+
transaction.query<JobRow>({
|
|
418
|
+
text: SQL.claimJob,
|
|
419
|
+
parameters: [
|
|
420
|
+
input.tenantId,
|
|
421
|
+
input.id,
|
|
422
|
+
input.claimedAt,
|
|
423
|
+
input.staleBefore,
|
|
424
|
+
],
|
|
425
|
+
}),
|
|
426
|
+
{ access: 'write', tenantId: input.tenantId },
|
|
427
|
+
);
|
|
428
|
+
const row = result.rows[0];
|
|
429
|
+
/* The statement wrote this instant, so it is the claim the stage renews
|
|
430
|
+
under rather than whatever the row carried before. */
|
|
431
|
+
return row ? { ...jobFromRow(row), claimedAt: input.claimedAt } : null;
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
async heartbeatJob(
|
|
435
|
+
tenantId: string,
|
|
436
|
+
id: string,
|
|
437
|
+
at: number,
|
|
438
|
+
claimedAt: number,
|
|
439
|
+
): Promise<boolean> {
|
|
440
|
+
const result = await this.#handles.runtime.transaction(
|
|
441
|
+
(transaction) =>
|
|
442
|
+
transaction.execute({
|
|
443
|
+
text: SQL.heartbeatJob,
|
|
444
|
+
parameters: [tenantId, id, at, claimedAt],
|
|
445
|
+
}),
|
|
446
|
+
{ access: 'write', tenantId },
|
|
447
|
+
);
|
|
448
|
+
return result.affectedRows > 0;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
async listPendingJobs(limit: number): Promise<readonly ImportJobRouting[]> {
|
|
452
|
+
const result = await this.#handles.background.query<{
|
|
453
|
+
tenant_id: string;
|
|
454
|
+
id: string;
|
|
455
|
+
status: ImportJobStatus;
|
|
456
|
+
started_at: number | bigint | string;
|
|
457
|
+
}>({ text: SQL.listPendingJobs, parameters: [limit] });
|
|
458
|
+
return result.rows.map((row) => ({
|
|
459
|
+
tenantId: row.tenant_id,
|
|
460
|
+
id: row.id,
|
|
461
|
+
status: row.status,
|
|
462
|
+
startedAt: integer(row.started_at, 'timestamp'),
|
|
463
|
+
}));
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
async replaceJobRows(
|
|
467
|
+
tenantId: string,
|
|
468
|
+
jobId: string,
|
|
469
|
+
rows: readonly ImportJobRow[],
|
|
470
|
+
): Promise<void> {
|
|
471
|
+
await this.#handles.runtime.transaction(
|
|
472
|
+
async (transaction) => {
|
|
473
|
+
await transaction.execute({
|
|
474
|
+
text: SQL.deleteJobRows,
|
|
475
|
+
parameters: [tenantId, jobId],
|
|
476
|
+
});
|
|
477
|
+
await this.#insertRows(transaction, rows);
|
|
478
|
+
},
|
|
479
|
+
{ access: 'write', tenantId },
|
|
480
|
+
);
|
|
481
|
+
}
|
|
482
|
+
|
|
483
|
+
async recordJobRows(
|
|
484
|
+
tenantId: string,
|
|
485
|
+
rows: readonly ImportJobRow[],
|
|
486
|
+
): Promise<void> {
|
|
487
|
+
if (rows.length === 0) return;
|
|
488
|
+
await this.#handles.runtime.transaction(
|
|
489
|
+
(transaction) => this.#insertRows(transaction, rows),
|
|
490
|
+
{ access: 'write', tenantId },
|
|
491
|
+
);
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
async listJobRows(
|
|
495
|
+
tenantId: string,
|
|
496
|
+
jobId: string,
|
|
497
|
+
limit: number,
|
|
498
|
+
after = 0,
|
|
499
|
+
): Promise<ImportRowPage> {
|
|
500
|
+
const result = await this.#handles.runtime.transaction(
|
|
501
|
+
(transaction) =>
|
|
502
|
+
transaction.query<OutcomeRow>({
|
|
503
|
+
text: SQL.listJobRows,
|
|
504
|
+
parameters: [tenantId, jobId, after, limit + 1],
|
|
505
|
+
}),
|
|
506
|
+
{ access: 'read', tenantId },
|
|
507
|
+
);
|
|
508
|
+
const items = result.rows.slice(0, limit).map(rowFromRow);
|
|
509
|
+
const last = items[items.length - 1];
|
|
510
|
+
return {
|
|
511
|
+
items,
|
|
512
|
+
nextCursor: result.rows.length > limit && last ? last.rowNumber : null,
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
async listValidRowNumbers(
|
|
517
|
+
tenantId: string,
|
|
518
|
+
jobId: string,
|
|
519
|
+
): Promise<readonly number[]> {
|
|
520
|
+
const result = await this.#handles.runtime.transaction(
|
|
521
|
+
(transaction) =>
|
|
522
|
+
transaction.query<{ row_number: number | bigint | string }>({
|
|
523
|
+
text: SQL.listValidRowNumbers,
|
|
524
|
+
parameters: [tenantId, jobId],
|
|
525
|
+
}),
|
|
526
|
+
{ access: 'read', tenantId },
|
|
527
|
+
);
|
|
528
|
+
return result.rows.map((row) => integer(row.row_number, 'row number'));
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
async countRowOutcomes(
|
|
532
|
+
tenantId: string,
|
|
533
|
+
jobId: string,
|
|
534
|
+
): Promise<ImportRowOutcomeCounts> {
|
|
535
|
+
const result = await this.#handles.runtime.transaction(
|
|
536
|
+
(transaction) =>
|
|
537
|
+
transaction.query<{
|
|
538
|
+
outcome: ImportRowOutcome;
|
|
539
|
+
rows: number | bigint | string;
|
|
540
|
+
}>({ text: SQL.countRowOutcomes, parameters: [tenantId, jobId] }),
|
|
541
|
+
{ access: 'read', tenantId },
|
|
542
|
+
);
|
|
543
|
+
const counts: Record<ImportRowOutcome, number> = {
|
|
544
|
+
valid: 0,
|
|
545
|
+
invalid: 0,
|
|
546
|
+
created: 0,
|
|
547
|
+
updated: 0,
|
|
548
|
+
skipped: 0,
|
|
549
|
+
failed: 0,
|
|
550
|
+
};
|
|
551
|
+
for (const row of result.rows) {
|
|
552
|
+
counts[row.outcome] = integer(row.rows, 'row count');
|
|
553
|
+
}
|
|
554
|
+
return counts;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
async findMapping(
|
|
558
|
+
tenantId: string,
|
|
559
|
+
target: string,
|
|
560
|
+
): Promise<ImportMapping | null> {
|
|
561
|
+
const result = await this.#handles.runtime.transaction(
|
|
562
|
+
(transaction) =>
|
|
563
|
+
transaction.query<{
|
|
564
|
+
id: string;
|
|
565
|
+
tenant_id: string;
|
|
566
|
+
target: string;
|
|
567
|
+
columns_json: string;
|
|
568
|
+
updated_at: number | bigint | string;
|
|
569
|
+
}>({ text: SQL.findMapping, parameters: [tenantId, target] }),
|
|
570
|
+
{ access: 'read', tenantId },
|
|
571
|
+
);
|
|
572
|
+
const row = result.rows[0];
|
|
573
|
+
return row
|
|
574
|
+
? {
|
|
575
|
+
id: row.id,
|
|
576
|
+
tenantId: row.tenant_id,
|
|
577
|
+
target: row.target,
|
|
578
|
+
columns: jsonObject(row.columns_json, 'mapping'),
|
|
579
|
+
updatedAt: integer(row.updated_at, 'timestamp'),
|
|
580
|
+
}
|
|
581
|
+
: null;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
async saveMapping(mapping: ImportMapping): Promise<ImportMapping> {
|
|
585
|
+
await this.#handles.runtime.transaction(
|
|
586
|
+
(transaction) =>
|
|
587
|
+
transaction.execute({
|
|
588
|
+
text: SQL.saveMapping,
|
|
589
|
+
parameters: [
|
|
590
|
+
mapping.id,
|
|
591
|
+
mapping.tenantId,
|
|
592
|
+
mapping.target,
|
|
593
|
+
JSON.stringify(mapping.columns),
|
|
594
|
+
mapping.updatedAt,
|
|
595
|
+
],
|
|
596
|
+
}),
|
|
597
|
+
{ access: 'write', tenantId: mapping.tenantId },
|
|
598
|
+
);
|
|
599
|
+
return mapping;
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
async sweepJobs(tenantId: string, input: ImportSweepInput): Promise<number> {
|
|
603
|
+
return this.#handles.runtime.transaction(
|
|
604
|
+
async (transaction) => {
|
|
605
|
+
/* An abandoned job settles first, so this pass can already remove one
|
|
606
|
+
whose retention has run out as well. */
|
|
607
|
+
await transaction.execute({
|
|
608
|
+
text: SQL.expireValidatedJobs,
|
|
609
|
+
parameters: [tenantId, input.abandonedBefore, input.limit, input.at],
|
|
610
|
+
});
|
|
611
|
+
const removed = await transaction.execute({
|
|
612
|
+
text: SQL.sweepJobs,
|
|
613
|
+
parameters: [tenantId, input.settledBefore, input.limit],
|
|
614
|
+
});
|
|
615
|
+
return removed.affectedRows;
|
|
616
|
+
},
|
|
617
|
+
{ access: 'write', tenantId },
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
|
|
621
|
+
/**
|
|
622
|
+
* Everything the class holds for one workspace: the jobs, the row outcomes
|
|
623
|
+
* of each of them and the saved mappings. Each table is walked by its own
|
|
624
|
+
* ascending key, so no page holds more than `EXPORT_PAGE` rows however long
|
|
625
|
+
* the history is, and every record names its kind because one sink carries
|
|
626
|
+
* all three. The reported range covers the records that carry a time of
|
|
627
|
+
* their own; a row outcome is dated by the job it belongs to.
|
|
628
|
+
*/
|
|
629
|
+
async exportJobs(
|
|
630
|
+
tenantId: string,
|
|
631
|
+
sink: DataClassExportSink,
|
|
632
|
+
): Promise<{ rows: number; from: Date | null; to: Date | null }> {
|
|
633
|
+
let rows = 0;
|
|
634
|
+
let from: Date | null = null;
|
|
635
|
+
let to: Date | null = null;
|
|
636
|
+
const observe = (value: number): void => {
|
|
637
|
+
const instant = new Date(value);
|
|
638
|
+
if (from === null || instant < from) from = instant;
|
|
639
|
+
if (to === null || instant > to) to = instant;
|
|
640
|
+
};
|
|
641
|
+
const page = <Row extends object>(
|
|
642
|
+
text: string,
|
|
643
|
+
parameters: (string | number)[],
|
|
644
|
+
) =>
|
|
645
|
+
this.#handles.runtime.transaction(
|
|
646
|
+
(transaction) => transaction.query<Row>({ text, parameters }),
|
|
647
|
+
{ access: 'read', tenantId },
|
|
648
|
+
);
|
|
649
|
+
|
|
650
|
+
let job: { startedAt: number; id: string } = { startedAt: 0, id: '' };
|
|
651
|
+
for (;;) {
|
|
652
|
+
const found = await page<JobRow>(SQL.exportPage, [
|
|
653
|
+
tenantId,
|
|
654
|
+
job.startedAt,
|
|
655
|
+
job.id,
|
|
656
|
+
EXPORT_PAGE,
|
|
657
|
+
]);
|
|
658
|
+
for (const row of found.rows) {
|
|
659
|
+
const record = jobFromRow(row);
|
|
660
|
+
await sink.write({
|
|
661
|
+
record: 'job',
|
|
662
|
+
id: record.id,
|
|
663
|
+
target: record.target,
|
|
664
|
+
documentId: record.documentId,
|
|
665
|
+
mode: record.mode,
|
|
666
|
+
dryRun: record.dryRun,
|
|
667
|
+
status: record.status,
|
|
668
|
+
totalRows: record.totalRows,
|
|
669
|
+
validRows: record.validRows,
|
|
670
|
+
writtenRows: record.writtenRows,
|
|
671
|
+
failedRows: record.failedRows,
|
|
672
|
+
requesterAccountId: record.requesterAccountId,
|
|
673
|
+
columns: record.columns,
|
|
674
|
+
failureCode: record.failureCode,
|
|
675
|
+
startedAt: new Date(record.startedAt).toISOString(),
|
|
676
|
+
completedAt:
|
|
677
|
+
record.completedAt === null
|
|
678
|
+
? null
|
|
679
|
+
: new Date(record.completedAt).toISOString(),
|
|
680
|
+
});
|
|
681
|
+
rows += 1;
|
|
682
|
+
observe(record.startedAt);
|
|
683
|
+
job = { startedAt: record.startedAt, id: record.id };
|
|
684
|
+
}
|
|
685
|
+
if (found.rows.length < EXPORT_PAGE) break;
|
|
686
|
+
}
|
|
687
|
+
|
|
688
|
+
let outcome: { jobId: string; rowNumber: number } = {
|
|
689
|
+
jobId: '',
|
|
690
|
+
rowNumber: 0,
|
|
691
|
+
};
|
|
692
|
+
for (;;) {
|
|
693
|
+
const found = await page<OutcomeRow>(SQL.exportRowsPage, [
|
|
694
|
+
tenantId,
|
|
695
|
+
outcome.jobId,
|
|
696
|
+
outcome.rowNumber,
|
|
697
|
+
EXPORT_PAGE,
|
|
698
|
+
]);
|
|
699
|
+
for (const row of found.rows) {
|
|
700
|
+
const record = rowFromRow(row);
|
|
701
|
+
await sink.write({
|
|
702
|
+
record: 'row-outcome',
|
|
703
|
+
id: record.id,
|
|
704
|
+
jobId: record.jobId,
|
|
705
|
+
rowNumber: record.rowNumber,
|
|
706
|
+
outcome: record.outcome,
|
|
707
|
+
field: record.field,
|
|
708
|
+
reason: record.reason,
|
|
709
|
+
recordRef: record.recordRef,
|
|
710
|
+
});
|
|
711
|
+
rows += 1;
|
|
712
|
+
outcome = { jobId: record.jobId, rowNumber: record.rowNumber };
|
|
713
|
+
}
|
|
714
|
+
if (found.rows.length < EXPORT_PAGE) break;
|
|
715
|
+
}
|
|
716
|
+
|
|
717
|
+
let target = '';
|
|
718
|
+
for (;;) {
|
|
719
|
+
const found = await page<{
|
|
720
|
+
id: string;
|
|
721
|
+
target: string;
|
|
722
|
+
columns_json: string;
|
|
723
|
+
updated_at: number | bigint | string;
|
|
724
|
+
}>(SQL.exportMappingsPage, [tenantId, target, EXPORT_PAGE]);
|
|
725
|
+
for (const row of found.rows) {
|
|
726
|
+
const updatedAt = integer(row.updated_at, 'timestamp');
|
|
727
|
+
await sink.write({
|
|
728
|
+
record: 'mapping',
|
|
729
|
+
id: row.id,
|
|
730
|
+
target: row.target,
|
|
731
|
+
columns: jsonObject(row.columns_json, 'mapping'),
|
|
732
|
+
updatedAt: new Date(updatedAt).toISOString(),
|
|
733
|
+
});
|
|
734
|
+
rows += 1;
|
|
735
|
+
observe(updatedAt);
|
|
736
|
+
target = row.target;
|
|
737
|
+
}
|
|
738
|
+
if (found.rows.length < EXPORT_PAGE) break;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
return { rows, from, to };
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
async #insertRows(
|
|
745
|
+
transaction: DatabaseTransaction,
|
|
746
|
+
rows: readonly ImportJobRow[],
|
|
747
|
+
): Promise<void> {
|
|
748
|
+
for (let start = 0; start < rows.length; start += INSERT_CHUNK) {
|
|
749
|
+
const chunk = rows.slice(start, start + INSERT_CHUNK);
|
|
750
|
+
const values: string[] = [];
|
|
751
|
+
const parameters: (string | number | null)[] = [];
|
|
752
|
+
for (const row of chunk) {
|
|
753
|
+
const base = parameters.length;
|
|
754
|
+
values.push(
|
|
755
|
+
`($${base + 1}, $${base + 2}, $${base + 3}, $${base + 4},` +
|
|
756
|
+
` $${base + 5}, $${base + 6}, $${base + 7}, $${base + 8})`,
|
|
757
|
+
);
|
|
758
|
+
parameters.push(
|
|
759
|
+
row.id,
|
|
760
|
+
row.tenantId,
|
|
761
|
+
row.jobId,
|
|
762
|
+
row.rowNumber,
|
|
763
|
+
row.outcome,
|
|
764
|
+
row.field,
|
|
765
|
+
row.reason,
|
|
766
|
+
row.recordRef,
|
|
767
|
+
);
|
|
768
|
+
}
|
|
769
|
+
await transaction.execute({
|
|
770
|
+
text:
|
|
771
|
+
`INSERT INTO import_job_rows (${ROW_COLUMNS}) VALUES ` +
|
|
772
|
+
`${values.join(', ')}
|
|
773
|
+
ON CONFLICT (tenant_id, job_id, row_number) DO UPDATE
|
|
774
|
+
SET outcome = EXCLUDED.outcome, field = EXCLUDED.field,
|
|
775
|
+
reason = EXCLUDED.reason, record_ref = EXCLUDED.record_ref`,
|
|
776
|
+
parameters,
|
|
777
|
+
});
|
|
778
|
+
}
|
|
779
|
+
}
|
|
780
|
+
}
|