@kici-dev/orchestrator 0.0.0 → 0.1.2
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/LICENSE +661 -0
- package/README.md +1 -6
- package/dist/__test-helpers__/mock-db.d.ts +103 -0
- package/dist/__test-helpers__/mock-ws.d.ts +13 -0
- package/dist/agent/dispatcher.d.ts +231 -0
- package/dist/agent/ownership-tracker.d.ts +46 -0
- package/dist/agent/registry.d.ts +255 -0
- package/dist/agent/token-store.d.ts +96 -0
- package/dist/app.d.ts +234 -0
- package/dist/audit/access-log.d.ts +92 -0
- package/dist/audit/sampling-rate-limiter.d.ts +41 -0
- package/dist/cache/build-coordinator.d.ts +42 -0
- package/dist/cache/dep-cache.d.ts +51 -0
- package/dist/cache/index.d.ts +16 -0
- package/dist/cache/pending-builds.d.ts +14 -0
- package/dist/cache/pending-dynamics.d.ts +15 -0
- package/dist/cache/pending-inits.d.ts +19 -0
- package/dist/cache/pending-tracker.d.ts +65 -0
- package/dist/cache/source-cache.d.ts +30 -0
- package/dist/cli/api-client.d.ts +411 -0
- package/dist/cli/commands/access-log.d.ts +30 -0
- package/dist/cli/commands/agent-service/index.d.ts +15 -0
- package/dist/cli/commands/agent-service/install.d.ts +9 -0
- package/dist/cli/commands/agent-service/logs.d.ts +9 -0
- package/dist/cli/commands/agent-service/restart.d.ts +8 -0
- package/dist/cli/commands/agent-service/start.d.ts +8 -0
- package/dist/cli/commands/agent-service/status.d.ts +10 -0
- package/dist/cli/commands/agent-service/stop.d.ts +8 -0
- package/dist/cli/commands/agent-service/uninstall.d.ts +9 -0
- package/dist/cli/commands/agent-service/upgrade.d.ts +11 -0
- package/dist/cli/commands/agent.d.ts +10 -0
- package/dist/cli/commands/api-key.d.ts +12 -0
- package/dist/cli/commands/audit.d.ts +9 -0
- package/dist/cli/commands/backend.d.ts +17 -0
- package/dist/cli/commands/cold-store-impl.d.ts +101 -0
- package/dist/cli/commands/cold-store.d.ts +30 -0
- package/dist/cli/commands/config.d.ts +16 -0
- package/dist/cli/commands/db.d.ts +19 -0
- package/dist/cli/commands/debug-bundle.d.ts +16 -0
- package/dist/cli/commands/diagnose.d.ts +15 -0
- package/dist/cli/commands/environment.d.ts +24 -0
- package/dist/cli/commands/event-dlq.d.ts +19 -0
- package/dist/cli/commands/event-log.d.ts +27 -0
- package/dist/cli/commands/event.d.ts +4 -0
- package/dist/cli/commands/execution.d.ts +17 -0
- package/dist/cli/commands/inspect-bundle.d.ts +16 -0
- package/dist/cli/commands/maintenance.d.ts +4 -0
- package/dist/cli/commands/orchestrator-service/index.d.ts +12 -0
- package/dist/cli/commands/orchestrator-service/install.d.ts +10 -0
- package/dist/cli/commands/orchestrator-service/logs.d.ts +10 -0
- package/dist/cli/commands/orchestrator-service/restart.d.ts +8 -0
- package/dist/cli/commands/orchestrator-service/start.d.ts +8 -0
- package/dist/cli/commands/orchestrator-service/status.d.ts +10 -0
- package/dist/cli/commands/orchestrator-service/stop.d.ts +8 -0
- package/dist/cli/commands/orchestrator-service/uninstall.d.ts +9 -0
- package/dist/cli/commands/orchestrator-service/upgrade.d.ts +12 -0
- package/dist/cli/commands/org-settings.d.ts +17 -0
- package/dist/cli/commands/peer.d.ts +13 -0
- package/dist/cli/commands/queue.d.ts +16 -0
- package/dist/cli/commands/registration.d.ts +18 -0
- package/dist/cli/commands/rotate.d.ts +9 -0
- package/dist/cli/commands/runs.d.ts +34 -0
- package/dist/cli/commands/secret.d.ts +12 -0
- package/dist/cli/commands/shared/db.d.ts +16 -0
- package/dist/cli/commands/shared/versioned-upgrade.d.ts +38 -0
- package/dist/cli/commands/source.d.ts +24 -0
- package/dist/cli/commands/token.d.ts +10 -0
- package/dist/cli/commands/workflow.d.ts +31 -0
- package/dist/cli/join.d.ts +14 -0
- package/dist/cli/kici-admin.d.ts +13 -0
- package/dist/cli/lazy-deps/cache.d.ts +17 -0
- package/dist/cli/lazy-deps/downloader.d.ts +33 -0
- package/dist/cli/lazy-deps/registry.d.ts +43 -0
- package/dist/cli/service/compose.d.ts +25 -0
- package/dist/cli/service/index.d.ts +24 -0
- package/dist/cli/service/launchd.d.ts +34 -0
- package/dist/cli/service/platform-detect.d.ts +59 -0
- package/dist/cli/service/systemd.d.ts +41 -0
- package/dist/cli/service/types.d.ts +91 -0
- package/dist/cli/service/windows.d.ts +20 -0
- package/dist/cli/wizard/agent-wizard.d.ts +24 -0
- package/dist/cli/wizard/orchestrator-wizard.d.ts +38 -0
- package/dist/cli/wizard/prompts.d.ts +23 -0
- package/dist/cli.js +11435 -0
- package/dist/cluster/cluster-identity.d.ts +59 -0
- package/dist/cluster/coordinator.d.ts +204 -0
- package/dist/cluster/health-api.d.ts +30 -0
- package/dist/cluster/index.d.ts +24 -0
- package/dist/cluster/join-client.d.ts +75 -0
- package/dist/cluster/join-handler.d.ts +58 -0
- package/dist/cluster/join-token.d.ts +94 -0
- package/dist/cluster/orphan-recovery.d.ts +67 -0
- package/dist/cluster/peer-client.d.ts +190 -0
- package/dist/cluster/peer-credentials.d.ts +108 -0
- package/dist/cluster/peer-crypto.d.ts +57 -0
- package/dist/cluster/peer-handler.d.ts +97 -0
- package/dist/cluster/peer-registry.d.ts +186 -0
- package/dist/cluster/raft-state.d.ts +36 -0
- package/dist/cluster/raft.d.ts +140 -0
- package/dist/cold-store/load-access-log-range.d.ts +73 -0
- package/dist/cold-store/load-event-log-range.d.ts +62 -0
- package/dist/cold-store/load-secret-audit-log-range.d.ts +38 -0
- package/dist/cold-store/orchestrator-cold-store.d.ts +58 -0
- package/dist/cold-store/tables/access-log.d.ts +80 -0
- package/dist/cold-store/tables/event-log.d.ts +70 -0
- package/dist/cold-store/tables/execution-jobs.d.ts +63 -0
- package/dist/cold-store/tables/execution-runs.d.ts +81 -0
- package/dist/cold-store/tables/execution-steps.d.ts +65 -0
- package/dist/cold-store/tables/secret-audit-log.d.ts +77 -0
- package/dist/concurrency/dispatch-next-queued.d.ts +63 -0
- package/dist/concurrency/group-tracker.d.ts +51 -0
- package/dist/concurrency/index.d.ts +3 -0
- package/dist/concurrency/queue-manager.d.ts +68 -0
- package/dist/concurrency/waiters.d.ts +58 -0
- package/dist/config/encryption.d.ts +82 -0
- package/dist/config/env-overlay.d.ts +45 -0
- package/dist/config/index.d.ts +16 -0
- package/dist/config/loader.d.ts +26 -0
- package/dist/config/reload.d.ts +113 -0
- package/dist/config/resolver.d.ts +47 -0
- package/dist/config/schema.d.ts +210 -0
- package/dist/config/shared-store.d.ts +142 -0
- package/dist/config/types.d.ts +218 -0
- package/dist/config.d.ts +249 -0
- package/dist/cron/cron-scheduler.d.ts +78 -0
- package/dist/cron/cron-store.d.ts +38 -0
- package/dist/dashboard/handler.d.ts +243 -0
- package/dist/db/client.d.ts +13 -0
- package/dist/db/migration-provider.d.ts +9 -0
- package/dist/db/migrations/001_initial.d.ts +8 -0
- package/dist/db/migrations/002_config_versions_key_version.d.ts +16 -0
- package/dist/db/migrations/003_access_log.d.ts +26 -0
- package/dist/db/migrations/004_rename_bundle_to_source.d.ts +19 -0
- package/dist/db/migrations/005_cold_store_chunk_counter.d.ts +19 -0
- package/dist/db/migrations/006_runs_jobs_steps_archived_at.d.ts +38 -0
- package/dist/db/migrations/007_audit_logs_archived_at.d.ts +42 -0
- package/dist/db/migrations/008_event_log_archived_at.d.ts +40 -0
- package/dist/db/migrations/009_access_log_trigram.d.ts +15 -0
- package/dist/db/migrations/010_cold_store_chunks.d.ts +34 -0
- package/dist/db/migrations/011_drop_source_secrets_notify.d.ts +21 -0
- package/dist/db/migrations/012_peer_credentials_active_uniq.d.ts +28 -0
- package/dist/db/migrations/013_execution_log_bytes.d.ts +21 -0
- package/dist/db/migrations/014_kici_events_lease_retry.d.ts +36 -0
- package/dist/db/migrations/015_org_settings_customer_scoped.d.ts +30 -0
- package/dist/db/migrations/016_org_settings_allow_http_npm.d.ts +15 -0
- package/dist/db/migrations/017_org_id_widen.d.ts +4 -0
- package/dist/db/migrations/018_org_id_prefix_backfill.d.ts +4 -0
- package/dist/db/migrator.d.ts +32 -0
- package/dist/db/types.d.ts +1266 -0
- package/dist/diagnostics/bundle-reader.d.ts +48 -0
- package/dist/diagnostics/bundle-writer.d.ts +57 -0
- package/dist/diagnostics/checks/agents.d.ts +10 -0
- package/dist/diagnostics/checks/certs.d.ts +9 -0
- package/dist/diagnostics/checks/config.d.ts +10 -0
- package/dist/diagnostics/checks/db.d.ts +9 -0
- package/dist/diagnostics/checks/disk.d.ts +9 -0
- package/dist/diagnostics/checks/index.d.ts +17 -0
- package/dist/diagnostics/checks/ws.d.ts +9 -0
- package/dist/diagnostics/index.d.ts +13 -0
- package/dist/diagnostics/runner.d.ts +23 -0
- package/dist/diagnostics/types.d.ts +38 -0
- package/dist/entry-helpers.d.ts +93 -0
- package/dist/environments/binding-store.d.ts +27 -0
- package/dist/environments/environment-store.d.ts +74 -0
- package/dist/environments/held-runs.d.ts +64 -0
- package/dist/environments/index.d.ts +10 -0
- package/dist/environments/protection/branch-gate.d.ts +5 -0
- package/dist/environments/protection/concurrency-gate.d.ts +7 -0
- package/dist/environments/protection/pipeline.d.ts +18 -0
- package/dist/environments/protection/reviewer-gate.d.ts +7 -0
- package/dist/environments/protection/trust-gate.d.ts +7 -0
- package/dist/environments/protection/wait-timer-gate.d.ts +7 -0
- package/dist/environments/variable-store.d.ts +39 -0
- package/dist/events/circuit-breaker.d.ts +33 -0
- package/dist/events/event-emitter.d.ts +55 -0
- package/dist/events/event-retry-scanner.d.ts +52 -0
- package/dist/events/event-router.d.ts +183 -0
- package/dist/events/event-store.d.ts +157 -0
- package/dist/events/trust-store.d.ts +54 -0
- package/dist/events/types.d.ts +61 -0
- package/dist/helpers/ip-extraction.d.ts +29 -0
- package/dist/helpers/rate-limiter.d.ts +23 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.js +772 -0
- package/dist/lockfile-cache.d.ts +39 -0
- package/dist/metrics/agent-metrics-aggregator.d.ts +116 -0
- package/dist/metrics/metrics-reporter.d.ts +40 -0
- package/dist/metrics/prometheus.d.ts +261 -0
- package/dist/metrics/scheduled-jobs.d.ts +20 -0
- package/dist/orchestrator-core.d.ts +193 -0
- package/dist/pipeline/dispatch-matched-workflow.d.ts +102 -0
- package/dist/pipeline/inline-eval.d.ts +28 -0
- package/dist/pipeline/install-secrets-resolver.d.ts +73 -0
- package/dist/pipeline/manual-schedule.d.ts +21 -0
- package/dist/pipeline/needs-scheduler.d.ts +85 -0
- package/dist/pipeline/process-webhook.d.ts +38 -0
- package/dist/pipeline/processor.d.ts +326 -0
- package/dist/pipeline/rerun.d.ts +79 -0
- package/dist/pipeline/test-pipeline.d.ts +110 -0
- package/dist/provider-registry.d.ts +122 -0
- package/dist/providers/generic/index.d.ts +23 -0
- package/dist/providers/generic/normalizer.d.ts +112 -0
- package/dist/providers/generic/verification.d.ts +47 -0
- package/dist/providers/github/auth.d.ts +60 -0
- package/dist/providers/github/changed-files.d.ts +51 -0
- package/dist/providers/github/check-status-poster.d.ts +35 -0
- package/dist/providers/github/contributor-resolver.d.ts +30 -0
- package/dist/providers/github/index.d.ts +20 -0
- package/dist/providers/github/lock-file.d.ts +32 -0
- package/dist/providers/github/normalizer.d.ts +103 -0
- package/dist/providers/github/repo-url.d.ts +35 -0
- package/dist/providers/internal/index.d.ts +32 -0
- package/dist/providers/internal/lock-file-fetcher.d.ts +34 -0
- package/dist/providers/internal/normalizer.d.ts +89 -0
- package/dist/providers/internal/repo-url-builder.d.ts +42 -0
- package/dist/providers/universal-git/changed-files.d.ts +42 -0
- package/dist/providers/universal-git/clone-token.d.ts +83 -0
- package/dist/providers/universal-git/config.d.ts +192 -0
- package/dist/providers/universal-git/index.d.ts +55 -0
- package/dist/providers/universal-git/lock-file.d.ts +71 -0
- package/dist/providers/universal-git/normalizer.d.ts +90 -0
- package/dist/providers/universal-git/repo-url.d.ts +50 -0
- package/dist/providers/universal-git/ssh-auth.d.ts +94 -0
- package/dist/queue/bootstrap.d.ts +50 -0
- package/dist/queue/cleanup.d.ts +41 -0
- package/dist/queue/depth-refresher.d.ts +65 -0
- package/dist/queue/job-queue.d.ts +343 -0
- package/dist/queue/scheduled-job.d.ts +91 -0
- package/dist/registration/extractor.d.ts +44 -0
- package/dist/registration/registration-index.d.ts +162 -0
- package/dist/registration/registration-store.d.ts +111 -0
- package/dist/reporting/check-run-summary.d.ts +102 -0
- package/dist/reporting/commit-status.d.ts +382 -0
- package/dist/reporting/execution-tracker.d.ts +538 -0
- package/dist/reporting/fs-log-storage.d.ts +41 -0
- package/dist/reporting/log-pull-handler.d.ts +35 -0
- package/dist/reporting/log-storage.d.ts +70 -0
- package/dist/reporting/log-writer.d.ts +45 -0
- package/dist/reporting/s3-log-storage.d.ts +42 -0
- package/dist/reporting/step-log-buffer.d.ts +57 -0
- package/dist/routes/admin-access-log.d.ts +34 -0
- package/dist/routes/admin-backends.d.ts +28 -0
- package/dist/routes/admin-config.d.ts +57 -0
- package/dist/routes/admin-db.d.ts +20 -0
- package/dist/routes/admin-environments.d.ts +42 -0
- package/dist/routes/admin-errors.d.ts +4 -0
- package/dist/routes/admin-event-dlq.d.ts +39 -0
- package/dist/routes/admin-event-log.d.ts +42 -0
- package/dist/routes/admin-events.d.ts +46 -0
- package/dist/routes/admin-maintenance.d.ts +22 -0
- package/dist/routes/admin-org-settings.d.ts +29 -0
- package/dist/routes/admin-queue-execution.d.ts +27 -0
- package/dist/routes/admin-registrations.d.ts +37 -0
- package/dist/routes/admin-runs.d.ts +57 -0
- package/dist/routes/admin-scheduled-jobs.d.ts +36 -0
- package/dist/routes/admin-sources.d.ts +18 -0
- package/dist/routes/admin.d.ts +103 -0
- package/dist/routes/capabilities.d.ts +24 -0
- package/dist/routes/diagnostics.d.ts +16 -0
- package/dist/routes/health.d.ts +20 -0
- package/dist/routes/test-trigger.d.ts +41 -0
- package/dist/routes/uploads.d.ts +38 -0
- package/dist/routes/webhooks.d.ts +36 -0
- package/dist/scaler/bare-metal-backend.d.ts +107 -0
- package/dist/scaler/config.d.ts +303 -0
- package/dist/scaler/container-backend.d.ts +125 -0
- package/dist/scaler/file-tail.d.ts +23 -0
- package/dist/scaler/firecracker-api.d.ts +100 -0
- package/dist/scaler/firecracker-backend.d.ts +263 -0
- package/dist/scaler/index.d.ts +24 -0
- package/dist/scaler/ip-allocator.d.ts +177 -0
- package/dist/scaler/label-matcher.d.ts +73 -0
- package/dist/scaler/log-forwarder.d.ts +54 -0
- package/dist/scaler/machine-ledger.d.ts +160 -0
- package/dist/scaler/manager.d.ts +338 -0
- package/dist/scaler/nftables.d.ts +85 -0
- package/dist/scaler/types.d.ts +388 -0
- package/dist/scaler/warm-pool.d.ts +81 -0
- package/dist/secrets/audit-logger.d.ts +65 -0
- package/dist/secrets/backend-health.d.ts +60 -0
- package/dist/secrets/backend-registry.d.ts +68 -0
- package/dist/secrets/backend-sync.d.ts +40 -0
- package/dist/secrets/cleanup.d.ts +40 -0
- package/dist/secrets/config.d.ts +51 -0
- package/dist/secrets/crypto.d.ts +49 -0
- package/dist/secrets/ephemeral-keys.d.ts +49 -0
- package/dist/secrets/index.d.ts +17 -0
- package/dist/secrets/pg-secret-store.d.ts +105 -0
- package/dist/secrets/rbac.d.ts +47 -0
- package/dist/secrets/secret-output-store.d.ts +46 -0
- package/dist/secrets/secret-resolver.d.ts +137 -0
- package/dist/secrets/source-credentials.d.ts +61 -0
- package/dist/secrets/token-manager.d.ts +63 -0
- package/dist/secrets/vault-secret-store.d.ts +85 -0
- package/dist/security/comment-handler.d.ts +67 -0
- package/dist/security/contributor-cache.d.ts +75 -0
- package/dist/security/global-workflow-policy.d.ts +72 -0
- package/dist/security/lock-source.d.ts +34 -0
- package/dist/security/trust-resolver.d.ts +108 -0
- package/dist/security/workflow-diff.d.ts +26 -0
- package/dist/server.d.ts +17 -0
- package/dist/server.js +48055 -0
- package/dist/sources/index.d.ts +10 -0
- package/dist/sources/source-manager.d.ts +63 -0
- package/dist/sources/source-store.d.ts +79 -0
- package/dist/sources/source-validator.d.ts +16 -0
- package/dist/stale-detector/stale-run-detector.d.ts +109 -0
- package/dist/standalone.d.ts +20 -0
- package/dist/standalone.js +41546 -0
- package/dist/storage/blob-routes.d.ts +20 -0
- package/dist/storage/filesystem.d.ts +60 -0
- package/dist/storage/index.d.ts +20 -0
- package/dist/storage/s3.d.ts +68 -0
- package/dist/storage/sign-url.d.ts +45 -0
- package/dist/storage/types.d.ts +98 -0
- package/dist/webhook/dedup.d.ts +44 -0
- package/dist/webhook/event-log.d.ts +83 -0
- package/dist/webhook/generic-sources.d.ts +169 -0
- package/dist/webhook/handler.d.ts +23 -0
- package/dist/webhook/relay-buffer.d.ts +96 -0
- package/dist/webhook/verify-inbound.d.ts +78 -0
- package/dist/worker/in-memory-execution-tracker.d.ts +94 -0
- package/dist/worker/in-memory-job-queue.d.ts +74 -0
- package/dist/worker/static-agent-token-store.d.ts +58 -0
- package/dist/worker/worker-status.d.ts +36 -0
- package/dist/worker-core.d.ts +74 -0
- package/dist/ws/agent-api-registry.d.ts +49 -0
- package/dist/ws/agent-handler.d.ts +176 -0
- package/dist/ws/agent-heartbeat.d.ts +45 -0
- package/dist/ws/dashboard-backends-handler.d.ts +51 -0
- package/dist/ws/dashboard-diagnostics-handler.d.ts +56 -0
- package/dist/ws/dashboard-env-handler.d.ts +107 -0
- package/dist/ws/dashboard-global-workflows-handler.d.ts +72 -0
- package/dist/ws/dashboard-registrations-handler.d.ts +84 -0
- package/dist/ws/event-buffer.d.ts +16 -0
- package/dist/ws/observer-handler.d.ts +42 -0
- package/dist/ws/observer-registry.d.ts +88 -0
- package/dist/ws/platform-client.d.ts +270 -0
- package/dist/ws/server-options.d.ts +15 -0
- package/package.json +87 -7
- package/sbom.spdx.json +14370 -0
- package/index.js +0 -3
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal webhook normalizer for E2E tests.
|
|
3
|
+
*
|
|
4
|
+
* Implements the WebhookNormalizer interface from @kici-dev/engine for internal
|
|
5
|
+
* webhook sources. Used by the provider-agnostic E2E test suite to trigger the
|
|
6
|
+
* full webhook processing pipeline without GitHub dependencies.
|
|
7
|
+
*
|
|
8
|
+
* Verification is always skipped (internal sources use verification='none').
|
|
9
|
+
* Event type and routing key are extracted from custom headers.
|
|
10
|
+
*/
|
|
11
|
+
import type { WebhookNormalizer, SimulatedEvent, AccessCacheInvalidation } from '@kici-dev/engine';
|
|
12
|
+
/**
|
|
13
|
+
* Internal provider implementation of WebhookNormalizer.
|
|
14
|
+
*
|
|
15
|
+
* Maps internal webhook headers and payloads to KiCI's universal SimulatedEvent format.
|
|
16
|
+
* Designed for E2E tests where payloads use normalized provider-agnostic structures
|
|
17
|
+
* (e.g., {ref: 'refs/heads/master', repository: {full_name: 'test/repo'}}).
|
|
18
|
+
*/
|
|
19
|
+
export declare class InternalWebhookNormalizer implements WebhookNormalizer {
|
|
20
|
+
readonly provider: "internal";
|
|
21
|
+
/**
|
|
22
|
+
* Extract routing key from internal webhook headers.
|
|
23
|
+
*
|
|
24
|
+
* Checks x-kici-routing-key first (explicit routing), then falls back
|
|
25
|
+
* to x-kici-source-id (generic source ID format).
|
|
26
|
+
*/
|
|
27
|
+
extractRoutingKey(headers: Record<string, string>, _payload: unknown): string | null;
|
|
28
|
+
/**
|
|
29
|
+
* Extract delivery ID for deduplication.
|
|
30
|
+
*
|
|
31
|
+
* Checks x-delivery-id first, falls back to x-request-id.
|
|
32
|
+
*/
|
|
33
|
+
extractDeliveryId(headers: Record<string, string>): string | null;
|
|
34
|
+
/**
|
|
35
|
+
* Extract event type from x-event-type header.
|
|
36
|
+
*/
|
|
37
|
+
extractEventType(headers: Record<string, string>): string | null;
|
|
38
|
+
/**
|
|
39
|
+
* Verify signature -- always returns true.
|
|
40
|
+
*
|
|
41
|
+
* Internal sources use verification='none'. Actual verification is not
|
|
42
|
+
* needed for E2E test infrastructure where both sender and receiver
|
|
43
|
+
* are controlled by the test harness.
|
|
44
|
+
*/
|
|
45
|
+
verifySignature(_body: string, _headers: Record<string, string>, _secret: string): boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Extract repository identifier from an internal webhook payload.
|
|
48
|
+
*
|
|
49
|
+
* Internal events mimic GitHub-shaped payloads in E2E tests,
|
|
50
|
+
* so we extract from payload.repository.full_name if present.
|
|
51
|
+
*/
|
|
52
|
+
extractRepoIdentifier(payload: unknown): string | null;
|
|
53
|
+
/**
|
|
54
|
+
* Extract ref from an internal webhook payload.
|
|
55
|
+
*
|
|
56
|
+
* Internal events use GitHub-shaped payloads, so extraction logic
|
|
57
|
+
* mirrors GitHub's: push -> payload.after, PR -> payload.pull_request.head.sha.
|
|
58
|
+
*/
|
|
59
|
+
extractRef(eventType: string, payload: unknown): string;
|
|
60
|
+
/**
|
|
61
|
+
* Extract credentials -- internal sources carry no provider credentials.
|
|
62
|
+
*/
|
|
63
|
+
extractCredentials(_payload: unknown): Record<string, unknown>;
|
|
64
|
+
/**
|
|
65
|
+
* Normalize an internal webhook event into a SimulatedEvent.
|
|
66
|
+
*
|
|
67
|
+
* Extracts branch information from payload.ref (stripping refs/heads/ prefix)
|
|
68
|
+
* and preserves the raw payload for trigger matching. Falls back to '__internal__'
|
|
69
|
+
* when no ref is present.
|
|
70
|
+
*/
|
|
71
|
+
normalizeEvent(eventType: string, _action: string | null, payload: unknown): SimulatedEvent | null;
|
|
72
|
+
/**
|
|
73
|
+
* Map membership-related internal webhook events to ContributorCache
|
|
74
|
+
* invalidations.
|
|
75
|
+
*
|
|
76
|
+
* Internal E2E payloads are GitHub-shaped by design, so the mapping
|
|
77
|
+
* mirrors the GitHub normalizer exactly:
|
|
78
|
+
*
|
|
79
|
+
* - `member`: repo-user
|
|
80
|
+
* - `organization`: user-in-org
|
|
81
|
+
* - `membership`: user-in-org
|
|
82
|
+
* - `team` (repo-scoped actions only): repo
|
|
83
|
+
*
|
|
84
|
+
* This lets Bucket C E2E tests exercise the invalidation path through
|
|
85
|
+
* `sendInternalWebhook()` without requiring a real GitHub App.
|
|
86
|
+
*/
|
|
87
|
+
getAccessCacheInvalidations(eventType: string, _action: string | null, payload: unknown): AccessCacheInvalidation[];
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=normalizer.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal repo URL builder for E2E tests.
|
|
3
|
+
*
|
|
4
|
+
* Implements the RepoUrlBuilder interface from @kici-dev/engine by returning
|
|
5
|
+
* file:// URLs for local filesystem access, or network URLs (git://, http://)
|
|
6
|
+
* when a cloneUrlBase is configured for remote agent support.
|
|
7
|
+
*/
|
|
8
|
+
import type { RepoUrlBuilder } from '@kici-dev/engine';
|
|
9
|
+
/**
|
|
10
|
+
* Internal provider implementation of RepoUrlBuilder.
|
|
11
|
+
*
|
|
12
|
+
* Builds clone URLs for repository access. When cloneUrlBase is set (e.g. to
|
|
13
|
+
* a git:// daemon URL), uses it for clone URLs so remote agents on different
|
|
14
|
+
* machines can clone. Otherwise falls back to file:// URLs for local access.
|
|
15
|
+
*/
|
|
16
|
+
export declare class InternalRepoUrlBuilder implements RepoUrlBuilder {
|
|
17
|
+
private readonly repoBasePath;
|
|
18
|
+
private readonly cloneUrlBase?;
|
|
19
|
+
readonly provider: "internal";
|
|
20
|
+
/**
|
|
21
|
+
* @param repoBasePath - Base directory where test repos live on disk
|
|
22
|
+
* @param cloneUrlBase - Optional URL base for clone operations (e.g. git://host/path).
|
|
23
|
+
* When set, overrides the default file:// URL construction.
|
|
24
|
+
*/
|
|
25
|
+
constructor(repoBasePath: string, cloneUrlBase?: string | undefined);
|
|
26
|
+
/**
|
|
27
|
+
* Build a clone URL for a repo.
|
|
28
|
+
*
|
|
29
|
+
* If cloneUrlBase is set, uses it directly (for remote agents).
|
|
30
|
+
* If repoIdentifier already starts with 'file://', returns it as-is.
|
|
31
|
+
* Otherwise, prepends 'file://' and the repoBasePath.
|
|
32
|
+
*/
|
|
33
|
+
buildCloneUrl(repoIdentifier: string): string;
|
|
34
|
+
/**
|
|
35
|
+
* Build a raw file URL -- returns empty string.
|
|
36
|
+
*
|
|
37
|
+
* Internal repos have no web UI, so raw file URLs are not applicable.
|
|
38
|
+
* The lock file is fetched via InternalLockFileFetcher (filesystem) instead.
|
|
39
|
+
*/
|
|
40
|
+
buildRawFileUrl(_repoIdentifier: string, _ref: string, _path: string): string;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=repo-url-builder.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal-git changed-files fetcher.
|
|
3
|
+
*
|
|
4
|
+
* Implements the `ChangedFilesFetcher` interface from `@kici-dev/engine` for
|
|
5
|
+
* universal-git sources. Unlike the GitHub fetcher, this implementation does
|
|
6
|
+
* not make REST API calls — every supported forge (Forgejo, Gitea, Gogs,
|
|
7
|
+
* GitLab repo webhook, plain GitHub repo webhook) already includes the full
|
|
8
|
+
* `commits[].{added,modified,removed}` arrays in the push payload, so we
|
|
9
|
+
* extract them via JSONPath from the already-delivered webhook body.
|
|
10
|
+
*
|
|
11
|
+
* For PR events we return an empty list: the upstream trigger matcher treats
|
|
12
|
+
* empty changed-files as "match any path", which is the safest default when
|
|
13
|
+
* we don't have per-PR diff data. A follow-up can add an optional REST
|
|
14
|
+
* fetcher if source authors want PR path filtering.
|
|
15
|
+
*/
|
|
16
|
+
import type { ChangedFilesFetcher } from '@kici-dev/engine';
|
|
17
|
+
import { type UniversalGitConfig } from './config.js';
|
|
18
|
+
/**
|
|
19
|
+
* Universal-git implementation of ChangedFilesFetcher.
|
|
20
|
+
*
|
|
21
|
+
* One instance per universal-git source, configured with the source's
|
|
22
|
+
* expanded `payloadPaths` + `eventMapping`.
|
|
23
|
+
*/
|
|
24
|
+
export declare class UniversalGitChangedFilesFetcher implements ChangedFilesFetcher {
|
|
25
|
+
readonly provider: "generic";
|
|
26
|
+
private readonly paths;
|
|
27
|
+
private readonly eventMapping;
|
|
28
|
+
constructor(params: {
|
|
29
|
+
config: UniversalGitConfig;
|
|
30
|
+
});
|
|
31
|
+
/**
|
|
32
|
+
* Extract changed files from the webhook payload.
|
|
33
|
+
*
|
|
34
|
+
* @param _repoIdentifier Unused — all data is in `payload`.
|
|
35
|
+
* @param eventType Raw header event type (pre-mapping).
|
|
36
|
+
* @param payload The webhook body the forge delivered.
|
|
37
|
+
* @param _credentials Unused — no REST call is made.
|
|
38
|
+
*/
|
|
39
|
+
getChangedFiles(_repoIdentifier: string, eventType: string, payload: unknown, _credentials: unknown): Promise<string[]>;
|
|
40
|
+
private classifyEvent;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=changed-files.d.ts.map
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal-git clone-token provider.
|
|
3
|
+
*
|
|
4
|
+
* Implements the `CloneTokenProvider` interface from `@kici-dev/engine` for
|
|
5
|
+
* universal-git sources. Unlike GitHub — which mints a fresh installation
|
|
6
|
+
* token via JWT — universal-git auth is entirely static: the customer stores
|
|
7
|
+
* a long-lived PAT / Basic-auth password / SSH private key in the
|
|
8
|
+
* orchestrator's secret store, and we resolve + return it verbatim at
|
|
9
|
+
* dispatch time.
|
|
10
|
+
*
|
|
11
|
+
* The value returned here is the raw secret material:
|
|
12
|
+
* - `credentialType === 'pat' | 'basic'`: the PAT / password string
|
|
13
|
+
* - `credentialType === 'ssh'`: the PEM-encoded private key (the agent
|
|
14
|
+
* materializes it to a tempfile and wires `GIT_SSH_COMMAND` — see
|
|
15
|
+
* Phase 4 dispatch protocol + agent work)
|
|
16
|
+
*
|
|
17
|
+
* The token's "kind" (basic vs ssh) is NOT carried through this interface;
|
|
18
|
+
* it is propagated via `QueuedJobInput.gitAuth` in Phase 4. For Phase 2 we
|
|
19
|
+
* expose a richer `issueGitAuth()` method on this class that the dispatcher
|
|
20
|
+
* can call directly once Phase 4 adds `sourceAuth`/`workflowAuth` to the
|
|
21
|
+
* dispatch schema.
|
|
22
|
+
*/
|
|
23
|
+
import type { CloneTokenProvider, ProviderGitAuth } from '@kici-dev/engine';
|
|
24
|
+
import type { SecretResolver } from '../../secrets/secret-resolver.js';
|
|
25
|
+
import type { UniversalGitConfig } from './config.js';
|
|
26
|
+
/**
|
|
27
|
+
* Structured auth material the agent needs to clone a universal-git repo.
|
|
28
|
+
*
|
|
29
|
+
* Phase 4: serialized into the new `sourceAuth` / `workflowAuth` fields on
|
|
30
|
+
* `jobDispatchSchema`. The shape matches `ProviderGitAuth` from
|
|
31
|
+
* `@kici-dev/engine` with additional SSH fields pulled from the source
|
|
32
|
+
* config (`sshHostKeyPolicy`, `sshKnownHostsPem`).
|
|
33
|
+
*/
|
|
34
|
+
export interface UniversalGitAuth extends ProviderGitAuth {
|
|
35
|
+
kind: 'basic' | 'ssh';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Universal-git implementation of CloneTokenProvider.
|
|
39
|
+
*
|
|
40
|
+
* Bound to a single source (orgId + sourceId + config). The orchestrator
|
|
41
|
+
* constructs one per registered universal-git source.
|
|
42
|
+
*/
|
|
43
|
+
export declare class UniversalGitCloneTokenProvider implements CloneTokenProvider {
|
|
44
|
+
private readonly params;
|
|
45
|
+
readonly provider: "generic";
|
|
46
|
+
constructor(params: {
|
|
47
|
+
orgId: string;
|
|
48
|
+
sourceId: string;
|
|
49
|
+
config: UniversalGitConfig;
|
|
50
|
+
secretResolver: SecretResolver;
|
|
51
|
+
});
|
|
52
|
+
/**
|
|
53
|
+
* Create a clone token — the raw secret material (PAT / password / SSH key).
|
|
54
|
+
*
|
|
55
|
+
* The orchestrator dispatch pipeline currently threads this string into
|
|
56
|
+
* `jobDispatch.token`, which the agent uses as HTTPS Basic-auth password
|
|
57
|
+
* via `http.extraHeader`. SSH support requires the Phase 4 dispatch-schema
|
|
58
|
+
* split (sourceAuth.kind = 'ssh') — which is where the agent gains the
|
|
59
|
+
* ability to materialize the PEM key and wire `GIT_SSH_COMMAND`.
|
|
60
|
+
*
|
|
61
|
+
* @returns The resolved secret string, or `null` when the secret is
|
|
62
|
+
* missing (source misconfigured — caller treats this as a clone failure).
|
|
63
|
+
*/
|
|
64
|
+
createCloneToken(_repoIdentifier: string, _credentials: unknown): Promise<string | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Richer variant that returns the full `UniversalGitAuth` shape instead
|
|
67
|
+
* of just the secret string. The Phase 4 dispatcher calls this via the
|
|
68
|
+
* `CloneTokenProvider.issueGitAuth?` interface hook so the agent
|
|
69
|
+
* receives the auth `kind` + `user` + SSH host-key policy alongside the
|
|
70
|
+
* secret.
|
|
71
|
+
*
|
|
72
|
+
* The method signature matches `CloneTokenProvider.issueGitAuth?` but
|
|
73
|
+
* universal-git ignores the inbound `repoIdentifier` / `credentials`
|
|
74
|
+
* args — the secret lives under a per-source scope (`__source__/<id>`)
|
|
75
|
+
* and is bound to the source at construction time, not to the inbound
|
|
76
|
+
* webhook.
|
|
77
|
+
*/
|
|
78
|
+
issueGitAuth(_repoIdentifier?: string, _credentials?: unknown, opts?: {
|
|
79
|
+
runId?: string;
|
|
80
|
+
jobId?: string;
|
|
81
|
+
}): Promise<UniversalGitAuth | null>;
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=clone-token.d.ts.map
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema + preset table for universal-git source configuration.
|
|
3
|
+
*
|
|
4
|
+
* A universal-git source is a `generic_webhook_sources` row with a non-null
|
|
5
|
+
* `git_config` column. The config carries everything the orchestrator needs
|
|
6
|
+
* to build clone URLs, fetch lock files, parse changed files, and issue
|
|
7
|
+
* clone credentials against a user-supplied git server (Forgejo / Gitea /
|
|
8
|
+
* Gogs / GitLab repo-webhook / plain GitHub repo-webhook).
|
|
9
|
+
*
|
|
10
|
+
* Presets expand into full `payloadPaths` for each supported forge; custom
|
|
11
|
+
* (preset-less) configs spell out the paths explicitly. Adding a new forge
|
|
12
|
+
* means adding a row to `UNIVERSAL_GIT_PRESETS` — no new migration, no
|
|
13
|
+
* provider code changes.
|
|
14
|
+
*/
|
|
15
|
+
import { z } from 'zod';
|
|
16
|
+
/**
|
|
17
|
+
* Preset identifier. Picks a canonical payload-path bundle for a forge whose
|
|
18
|
+
* webhook shape is close enough to GitHub's that JSONPath extraction works
|
|
19
|
+
* verbatim.
|
|
20
|
+
*/
|
|
21
|
+
export declare const UniversalGitPreset: z.ZodEnum<{
|
|
22
|
+
custom: "custom";
|
|
23
|
+
forgejo: "forgejo";
|
|
24
|
+
gitea: "gitea";
|
|
25
|
+
gogs: "gogs";
|
|
26
|
+
"gitlab-repo": "gitlab-repo";
|
|
27
|
+
"github-repo": "github-repo";
|
|
28
|
+
}>;
|
|
29
|
+
export type UniversalGitPreset = z.infer<typeof UniversalGitPreset>;
|
|
30
|
+
/**
|
|
31
|
+
* Credential type for the git clone step. `pat` and `basic` both use HTTPS
|
|
32
|
+
* Basic auth (PAT is Basic auth with user=`x-access-token` or user=`oauth2`
|
|
33
|
+
* depending on forge); `ssh` uses an SSH key + `GIT_SSH_COMMAND`.
|
|
34
|
+
*/
|
|
35
|
+
export declare const UniversalGitCredentialType: z.ZodEnum<{
|
|
36
|
+
basic: "basic";
|
|
37
|
+
pat: "pat";
|
|
38
|
+
ssh: "ssh";
|
|
39
|
+
}>;
|
|
40
|
+
export type UniversalGitCredentialType = z.infer<typeof UniversalGitCredentialType>;
|
|
41
|
+
/**
|
|
42
|
+
* SSH host-key verification policy. `accept-new` auto-trusts the forge on
|
|
43
|
+
* first connection (safe default for private ops but logs a one-time
|
|
44
|
+
* warning). `pinned` requires `sshKnownHostsPem` and refuses any host key
|
|
45
|
+
* that doesn't match — use for production-grade supply-chain hardening.
|
|
46
|
+
*/
|
|
47
|
+
export declare const SshHostKeyPolicy: z.ZodEnum<{
|
|
48
|
+
"accept-new": "accept-new";
|
|
49
|
+
pinned: "pinned";
|
|
50
|
+
}>;
|
|
51
|
+
export type SshHostKeyPolicy = z.infer<typeof SshHostKeyPolicy>;
|
|
52
|
+
/**
|
|
53
|
+
* Reference to a secret in the orchestrator's secret store. Resolved at
|
|
54
|
+
* dispatch time via `SecretResolver.resolveNamed()`. The secret itself lives
|
|
55
|
+
* at scope `__source__/<sourceId>`, key = `credentialRef.key`, optionally
|
|
56
|
+
* in a specific backend via `credentialRef.store` (defaults to `pg`).
|
|
57
|
+
*/
|
|
58
|
+
export declare const CredentialRefSchema: z.ZodObject<{
|
|
59
|
+
key: z.ZodString;
|
|
60
|
+
store: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, z.core.$strip>;
|
|
62
|
+
export type CredentialRef = z.infer<typeof CredentialRefSchema>;
|
|
63
|
+
/**
|
|
64
|
+
* Payload extraction paths (JSONPath). Each preset supplies canonical values;
|
|
65
|
+
* `custom` requires all fields to be set explicitly.
|
|
66
|
+
*/
|
|
67
|
+
export declare const UniversalGitPayloadPathsSchema: z.ZodObject<{
|
|
68
|
+
repoIdentifier: z.ZodString;
|
|
69
|
+
pushRef: z.ZodString;
|
|
70
|
+
pushSha: z.ZodString;
|
|
71
|
+
defaultBranch: z.ZodString;
|
|
72
|
+
commitsAdded: z.ZodString;
|
|
73
|
+
commitsModified: z.ZodString;
|
|
74
|
+
commitsRemoved: z.ZodString;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
export type UniversalGitPayloadPaths = z.infer<typeof UniversalGitPayloadPathsSchema>;
|
|
77
|
+
/**
|
|
78
|
+
* Header-to-event-name mapping. Most forges send an `X-Event-Type`-style
|
|
79
|
+
* header; a few send different names for the same semantic event (e.g.
|
|
80
|
+
* Gogs sends `push` while GitLab sends `Push Hook`). The universal-git
|
|
81
|
+
* normalizer uses this map to collapse forge-specific values into the
|
|
82
|
+
* kici-internal `push` / `pull_request` / ... event names.
|
|
83
|
+
*/
|
|
84
|
+
export declare const EventMappingSchema: z.ZodObject<{
|
|
85
|
+
push: z.ZodArray<z.ZodString>;
|
|
86
|
+
pullRequest: z.ZodArray<z.ZodString>;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
export type EventMapping = z.infer<typeof EventMappingSchema>;
|
|
89
|
+
/**
|
|
90
|
+
* Complete universal-git configuration stored in `generic_webhook_sources.git_config`.
|
|
91
|
+
*
|
|
92
|
+
* Validation refinements (enforced by Zod):
|
|
93
|
+
* - `credentialType === 'ssh'` implies `credentialUser` is unused (ignored).
|
|
94
|
+
* - `sshHostKeyPolicy === 'pinned'` requires `sshKnownHostsPem`.
|
|
95
|
+
* - `preset === 'custom'` requires explicit `payloadPaths` and `eventMapping`.
|
|
96
|
+
* - Non-custom presets ignore caller-supplied `payloadPaths` / `eventMapping`
|
|
97
|
+
* in favour of the preset defaults (see `expandUniversalGitConfig`).
|
|
98
|
+
*/
|
|
99
|
+
export declare const UniversalGitConfigSchema: z.ZodObject<{
|
|
100
|
+
preset: z.ZodEnum<{
|
|
101
|
+
custom: "custom";
|
|
102
|
+
forgejo: "forgejo";
|
|
103
|
+
gitea: "gitea";
|
|
104
|
+
gogs: "gogs";
|
|
105
|
+
"gitlab-repo": "gitlab-repo";
|
|
106
|
+
"github-repo": "github-repo";
|
|
107
|
+
}>;
|
|
108
|
+
gitUrlTemplate: z.ZodString;
|
|
109
|
+
credentialRef: z.ZodObject<{
|
|
110
|
+
key: z.ZodString;
|
|
111
|
+
store: z.ZodOptional<z.ZodString>;
|
|
112
|
+
}, z.core.$strip>;
|
|
113
|
+
credentialType: z.ZodEnum<{
|
|
114
|
+
basic: "basic";
|
|
115
|
+
pat: "pat";
|
|
116
|
+
ssh: "ssh";
|
|
117
|
+
}>;
|
|
118
|
+
credentialUser: z.ZodOptional<z.ZodString>;
|
|
119
|
+
sshHostKeyPolicy: z.ZodDefault<z.ZodEnum<{
|
|
120
|
+
"accept-new": "accept-new";
|
|
121
|
+
pinned: "pinned";
|
|
122
|
+
}>>;
|
|
123
|
+
sshKnownHostsPem: z.ZodOptional<z.ZodString>;
|
|
124
|
+
payloadPaths: z.ZodOptional<z.ZodObject<{
|
|
125
|
+
repoIdentifier: z.ZodString;
|
|
126
|
+
pushRef: z.ZodString;
|
|
127
|
+
pushSha: z.ZodString;
|
|
128
|
+
defaultBranch: z.ZodString;
|
|
129
|
+
commitsAdded: z.ZodString;
|
|
130
|
+
commitsModified: z.ZodString;
|
|
131
|
+
commitsRemoved: z.ZodString;
|
|
132
|
+
}, z.core.$strip>>;
|
|
133
|
+
eventMapping: z.ZodOptional<z.ZodObject<{
|
|
134
|
+
push: z.ZodArray<z.ZodString>;
|
|
135
|
+
pullRequest: z.ZodArray<z.ZodString>;
|
|
136
|
+
}, z.core.$strip>>;
|
|
137
|
+
}, z.core.$strip>;
|
|
138
|
+
export type UniversalGitConfig = z.infer<typeof UniversalGitConfigSchema>;
|
|
139
|
+
/**
|
|
140
|
+
* Canonical preset definitions. Expanded into full `payloadPaths` +
|
|
141
|
+
* `eventMapping` by `expandUniversalGitConfig`. Every forge in this table
|
|
142
|
+
* emits push / PR payloads that are structurally identical to GitHub's at
|
|
143
|
+
* the fields we care about (repository.full_name, commits[].added, etc.).
|
|
144
|
+
*
|
|
145
|
+
* `webhookEventHeader` is the HTTP header each forge sets on outbound
|
|
146
|
+
* webhook deliveries to communicate the event type. It is consumed by the
|
|
147
|
+
* generic webhook ingester (`generic_webhook_sources.event_type_header`) to
|
|
148
|
+
* classify the event before passing it to the universal-git normalizer. The
|
|
149
|
+
* source manager auto-populates the row's `event_type_header` from this
|
|
150
|
+
* field when an operator picks a preset and does not override the header
|
|
151
|
+
* explicitly.
|
|
152
|
+
*/
|
|
153
|
+
export declare const UNIVERSAL_GIT_PRESETS: Record<Exclude<UniversalGitPreset, 'custom'>, {
|
|
154
|
+
payloadPaths: UniversalGitPayloadPaths;
|
|
155
|
+
eventMapping: EventMapping;
|
|
156
|
+
webhookEventHeader: string;
|
|
157
|
+
}>;
|
|
158
|
+
/**
|
|
159
|
+
* Resolve the canonical webhook event-type header for a preset. Returns
|
|
160
|
+
* `null` when the preset is `custom` (operator must supply the header
|
|
161
|
+
* explicitly via `eventTypeHeader`).
|
|
162
|
+
*/
|
|
163
|
+
export declare function presetWebhookEventHeader(preset: UniversalGitPreset): string | null;
|
|
164
|
+
/**
|
|
165
|
+
* Expand a validated `UniversalGitConfig` into a form where `payloadPaths`
|
|
166
|
+
* and `eventMapping` are always populated. Non-custom presets pull from
|
|
167
|
+
* `UNIVERSAL_GIT_PRESETS`; `custom` passes through the caller-supplied
|
|
168
|
+
* values (Zod has already enforced that both are present).
|
|
169
|
+
*/
|
|
170
|
+
export declare function expandUniversalGitConfig(config: UniversalGitConfig): UniversalGitConfig & {
|
|
171
|
+
payloadPaths: UniversalGitPayloadPaths;
|
|
172
|
+
eventMapping: EventMapping;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* Parse a raw value (e.g. `git_config` JSONB from the DB) into a validated
|
|
176
|
+
* `UniversalGitConfig`. Returns `null` when the input is null/undefined;
|
|
177
|
+
* throws a ZodError on any other invalid shape.
|
|
178
|
+
*/
|
|
179
|
+
export declare function parseUniversalGitConfig(raw: unknown): UniversalGitConfig | null;
|
|
180
|
+
/**
|
|
181
|
+
* Safe-parse variant. Returns `{ ok: true, config }` on success, or
|
|
182
|
+
* `{ ok: false, error }` on validation failure. Null/undefined inputs
|
|
183
|
+
* produce `{ ok: true, config: null }`.
|
|
184
|
+
*/
|
|
185
|
+
export declare function safeParseUniversalGitConfig(raw: unknown): {
|
|
186
|
+
ok: true;
|
|
187
|
+
config: UniversalGitConfig | null;
|
|
188
|
+
} | {
|
|
189
|
+
ok: false;
|
|
190
|
+
error: z.ZodError;
|
|
191
|
+
};
|
|
192
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal-git provider bundle factory + barrel re-exports.
|
|
3
|
+
*
|
|
4
|
+
* A universal-git source is a `generic_webhook_sources` row with a non-null
|
|
5
|
+
* `git_config` column. At startup (and on config reload) the orchestrator
|
|
6
|
+
* walks every such row and calls `createUniversalGitProviderBundle()` to
|
|
7
|
+
* register a ProviderBundle under the source's routing key.
|
|
8
|
+
*
|
|
9
|
+
* Classes:
|
|
10
|
+
* - `UniversalGitWebhookNormalizer` — normalizes push/PR payloads for any
|
|
11
|
+
* forge whose webhook body is declared via JSONPath (`payloadPaths`).
|
|
12
|
+
* - `UniversalGitLockFileFetcher` — shallow-clones the repo, sparse on
|
|
13
|
+
* `.kici/`, reads `kici.lock.json` (5 MiB cap, 30 s budget).
|
|
14
|
+
* - `UniversalGitChangedFilesFetcher` — extracts `commits[]` diffs via
|
|
15
|
+
* JSONPath; no REST call.
|
|
16
|
+
* - `UniversalGitCloneTokenProvider` — resolves the source-scoped secret
|
|
17
|
+
* and returns the raw PAT/Basic/SSH material.
|
|
18
|
+
* - `UniversalGitRepoUrlBuilder` — substitutes `{owner}`/`{name}`/`{repo}`
|
|
19
|
+
* in the source's `gitUrlTemplate`.
|
|
20
|
+
*
|
|
21
|
+
* No `ContributorResolver` or `CheckStatusPoster` is wired for v1 — forge
|
|
22
|
+
* API support for those is uneven and adding it is a separate phase.
|
|
23
|
+
*/
|
|
24
|
+
import type { ProviderBundle } from '../../provider-registry.js';
|
|
25
|
+
import type { GenericWebhookSource } from '../../db/types.js';
|
|
26
|
+
import type { SecretResolver } from '../../secrets/secret-resolver.js';
|
|
27
|
+
import { type UniversalGitConfig } from './config.js';
|
|
28
|
+
export { UniversalGitWebhookNormalizer } from './normalizer.js';
|
|
29
|
+
export { UniversalGitLockFileFetcher, LockFileTooLargeError } from './lock-file.js';
|
|
30
|
+
export { UniversalGitChangedFilesFetcher } from './changed-files.js';
|
|
31
|
+
export { UniversalGitCloneTokenProvider, type UniversalGitAuth } from './clone-token.js';
|
|
32
|
+
export { UniversalGitRepoUrlBuilder, splitRepoIdentifier } from './repo-url.js';
|
|
33
|
+
export { prepareSshAuth, prepareSshAuthSync, composeGitSshCommand, type SshAuthArtefacts, type SshAuthArtefactsSync, type PrepareSshAuthOptions, } from './ssh-auth.js';
|
|
34
|
+
export { UniversalGitConfigSchema, parseUniversalGitConfig, safeParseUniversalGitConfig, expandUniversalGitConfig, presetWebhookEventHeader, UNIVERSAL_GIT_PRESETS, type UniversalGitConfig, type UniversalGitPreset, type UniversalGitCredentialType, type CredentialRef, } from './config.js';
|
|
35
|
+
/**
|
|
36
|
+
* Normalize a `generic_webhook_sources` row's `git_config` into a parsed
|
|
37
|
+
* `UniversalGitConfig`. The column is `ColumnType<string | Record<...> |
|
|
38
|
+
* null, ...>` so it can arrive as either a JSON string (when the DB driver
|
|
39
|
+
* hasn't auto-parsed JSONB) or a plain object (when it has).
|
|
40
|
+
*/
|
|
41
|
+
export declare function parseSourceGitConfig(raw: string | Record<string, unknown> | null | undefined): UniversalGitConfig | null;
|
|
42
|
+
/**
|
|
43
|
+
* Build a complete `ProviderBundle` for one universal-git source.
|
|
44
|
+
*
|
|
45
|
+
* The caller is responsible for invoking this at startup + config reload
|
|
46
|
+
* for every `generic_webhook_sources` row whose `git_config` is non-null,
|
|
47
|
+
* and for (un)registering the bundle against `providerRegistry` under the
|
|
48
|
+
* source's routing key (format: `generic:<orgId>:<sourceId>`).
|
|
49
|
+
*
|
|
50
|
+
* Returns `null` when the source has no `git_config` (i.e. it is a plain
|
|
51
|
+
* generic webhook, not a universal-git source) — callers can rely on this
|
|
52
|
+
* to differentiate the two shapes without re-parsing the row.
|
|
53
|
+
*/
|
|
54
|
+
export declare function createUniversalGitProviderBundle(source: Pick<GenericWebhookSource, 'id' | 'customer_id' | 'routing_key' | 'git_config'>, secretResolver: SecretResolver): ProviderBundle | null;
|
|
55
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal-git lock file fetcher.
|
|
3
|
+
*
|
|
4
|
+
* Implements `LockFileFetcher` from `@kici-dev/engine` by shallow-cloning the
|
|
5
|
+
* source repo into a temporary directory, scoped to the `^\.kici/` path
|
|
6
|
+
* whitelist via git sparse-checkout. This keeps the payload tiny (tens of
|
|
7
|
+
* KiB for a normal workflows bundle) even when the repo itself is large.
|
|
8
|
+
*
|
|
9
|
+
* Safety caps (all enforced):
|
|
10
|
+
* - **5 MiB max** for the cloned `.kici/kici.lock.json` file. Rejected
|
|
11
|
+
* with `LockFileTooLargeError` when exceeded.
|
|
12
|
+
* - **30 s timeout** on each git invocation. The wall-clock budget for
|
|
13
|
+
* an entire fetch cycle (all git calls combined) is also 30 s.
|
|
14
|
+
* - **Path whitelist `^\.kici/`.** Enforced by `sparse-checkout set
|
|
15
|
+
* --cone .kici` so nothing outside that prefix ever hits disk.
|
|
16
|
+
*
|
|
17
|
+
* Auth:
|
|
18
|
+
* - HTTPS Basic (PAT / basic-auth): injected via `git -c
|
|
19
|
+
* http.extraHeader=Authorization: Basic <base64>` so the secret never
|
|
20
|
+
* appears in the repo URL / logs.
|
|
21
|
+
* - SSH: materialized via `prepareSshAuthSync()` and surfaced through
|
|
22
|
+
* `GIT_SSH_COMMAND`; tempfiles are always cleaned up in a `finally`.
|
|
23
|
+
*
|
|
24
|
+
* This fetcher is used at two sites:
|
|
25
|
+
* - Registration: when a default-branch push arrives for a universal-git
|
|
26
|
+
* source, the processor calls `fetchLockFile(repoId, sha, credentials)`
|
|
27
|
+
* to re-read the workflow manifest.
|
|
28
|
+
* - Global-workflow dispatch: cross-provider globals resolve the lock
|
|
29
|
+
* file via the registration's provider bundle.
|
|
30
|
+
*/
|
|
31
|
+
import type { LockFileFetcher, LockFile } from '@kici-dev/engine';
|
|
32
|
+
import type { SecretResolver } from '../../secrets/secret-resolver.js';
|
|
33
|
+
import type { UniversalGitConfig } from './config.js';
|
|
34
|
+
/**
|
|
35
|
+
* Typed error for the 5 MiB cap. Callers can differentiate this from
|
|
36
|
+
* generic fetch failures for metrics / logging.
|
|
37
|
+
*/
|
|
38
|
+
export declare class LockFileTooLargeError extends Error {
|
|
39
|
+
readonly repoIdentifier: string;
|
|
40
|
+
readonly sizeBytes: number;
|
|
41
|
+
readonly limitBytes: number;
|
|
42
|
+
constructor(repoIdentifier: string, sizeBytes: number, limitBytes?: number);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Universal-git implementation of LockFileFetcher.
|
|
46
|
+
*
|
|
47
|
+
* Bound to a single source (orgId + sourceId + config). The orchestrator
|
|
48
|
+
* constructs one per registered universal-git source.
|
|
49
|
+
*/
|
|
50
|
+
export declare class UniversalGitLockFileFetcher implements LockFileFetcher {
|
|
51
|
+
private readonly params;
|
|
52
|
+
readonly provider: "generic";
|
|
53
|
+
private readonly repoUrlBuilder;
|
|
54
|
+
constructor(params: {
|
|
55
|
+
orgId: string;
|
|
56
|
+
sourceId: string;
|
|
57
|
+
config: UniversalGitConfig;
|
|
58
|
+
secretResolver: SecretResolver;
|
|
59
|
+
});
|
|
60
|
+
/**
|
|
61
|
+
* Shallow-clone the source repo at `ref` into a private tempdir, read
|
|
62
|
+
* `.kici/kici.lock.json`, and tear down.
|
|
63
|
+
*
|
|
64
|
+
* @returns The parsed `LockFile` on success, or `null` when the path
|
|
65
|
+
* doesn't exist in the repo (i.e. user hasn't added a lock file yet).
|
|
66
|
+
* Throws on any other failure — caller catches + emits
|
|
67
|
+
* `kici_universal_git_registration_errors_total{reason}`.
|
|
68
|
+
*/
|
|
69
|
+
fetchLockFile(repoIdentifier: string, ref: string, _credentials: unknown): Promise<LockFile | null>;
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=lock-file.d.ts.map
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Universal-git webhook normalizer.
|
|
3
|
+
*
|
|
4
|
+
* Implements the `WebhookNormalizer` interface from `@kici-dev/engine` for any
|
|
5
|
+
* forge that emits GitHub-shaped push / PR payloads. The structure of each
|
|
6
|
+
* forge's payload is declared via JSONPath expressions in the source's
|
|
7
|
+
* `git_config.payloadPaths`, so a single class covers Forgejo, Gitea, Gogs,
|
|
8
|
+
* GitLab repo webhooks, and plain-GitHub repo webhooks.
|
|
9
|
+
*
|
|
10
|
+
* Signatures are verified per source in the upstream generic-webhook
|
|
11
|
+
* verification path (HMAC-SHA256 / plain token / IP allow-list); this
|
|
12
|
+
* normalizer therefore short-circuits `verifySignature` and relies on the
|
|
13
|
+
* caller's pre-verification, same as `GenericWebhookNormalizer`.
|
|
14
|
+
*/
|
|
15
|
+
import type { WebhookNormalizer, SimulatedEvent } from '@kici-dev/engine';
|
|
16
|
+
import { type UniversalGitConfig } from './config.js';
|
|
17
|
+
/**
|
|
18
|
+
* Webhook normalizer for universal-git sources.
|
|
19
|
+
*
|
|
20
|
+
* Each instance is bound to one source's expanded config (preset-resolved
|
|
21
|
+
* `payloadPaths` + `eventMapping`). The orchestrator constructs one per
|
|
22
|
+
* registered `generic_webhook_sources` row with a non-null `git_config`.
|
|
23
|
+
*/
|
|
24
|
+
export declare class UniversalGitWebhookNormalizer implements WebhookNormalizer {
|
|
25
|
+
readonly provider: "generic";
|
|
26
|
+
private readonly routingKey;
|
|
27
|
+
private readonly paths;
|
|
28
|
+
private readonly eventMapping;
|
|
29
|
+
constructor(params: {
|
|
30
|
+
routingKey: string;
|
|
31
|
+
config: UniversalGitConfig;
|
|
32
|
+
});
|
|
33
|
+
/**
|
|
34
|
+
* Routing key is pre-assigned per source. The generic source-id header is
|
|
35
|
+
* still honoured for test compatibility, but the orchestrator pipeline
|
|
36
|
+
* already knows the routing key by the time this is invoked.
|
|
37
|
+
*/
|
|
38
|
+
extractRoutingKey(headers: Record<string, string>, _payload: unknown): string | null;
|
|
39
|
+
/**
|
|
40
|
+
* Most universal-git forges send one of the following (in priority order).
|
|
41
|
+
* Returning null lets the pipeline fall back to request-level dedup.
|
|
42
|
+
*/
|
|
43
|
+
extractDeliveryId(headers: Record<string, string>): string | null;
|
|
44
|
+
/**
|
|
45
|
+
* Event type header varies per forge. We accept all common spellings;
|
|
46
|
+
* `normalizeEvent` collapses the value back to KiCI's canonical names via
|
|
47
|
+
* the source's `eventMapping`.
|
|
48
|
+
*/
|
|
49
|
+
extractEventType(headers: Record<string, string>): string | null;
|
|
50
|
+
/**
|
|
51
|
+
* Signature verification is performed by the generic webhook pipeline
|
|
52
|
+
* upstream; the normalizer only cooperates by returning `true`.
|
|
53
|
+
*/
|
|
54
|
+
verifySignature(_body: string, _headers: Record<string, string>, _secret: string): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Normalize the forge payload into a `SimulatedEvent`. Uses JSONPath
|
|
57
|
+
* extraction for the repo identifier + ref + SHA so the same code works
|
|
58
|
+
* against every supported forge.
|
|
59
|
+
*/
|
|
60
|
+
normalizeEvent(eventType: string, action: string | null, payload: unknown): SimulatedEvent | null;
|
|
61
|
+
/**
|
|
62
|
+
* Repo identifier via JSONPath. Returns `null` when the expression
|
|
63
|
+
* yields no match — callers treat this as "no repo context".
|
|
64
|
+
*/
|
|
65
|
+
extractRepoIdentifier(payload: unknown): string | null;
|
|
66
|
+
/**
|
|
67
|
+
* Git ref / SHA extraction. For push, we resolve `pushSha`; for PR-shaped
|
|
68
|
+
* events, we fall back to `pull_request.head.sha` (or `object_attributes.last_commit.id`
|
|
69
|
+
* for GitLab). Unknown event types resolve to `HEAD` so the orchestrator
|
|
70
|
+
* can still evaluate triggers against the default branch.
|
|
71
|
+
*/
|
|
72
|
+
extractRef(eventType: string, payload: unknown): string;
|
|
73
|
+
/**
|
|
74
|
+
* Universal-git sources carry no provider-native auth in the payload —
|
|
75
|
+
* the orchestrator resolves `credentialRef` out-of-band via the secret
|
|
76
|
+
* store. This method therefore returns an empty record.
|
|
77
|
+
*/
|
|
78
|
+
extractCredentials(_payload: unknown): Record<string, unknown>;
|
|
79
|
+
/**
|
|
80
|
+
* Extension hook used by the processor's `isDefaultBranchPush` check so it
|
|
81
|
+
* does not need to hardcode `payload.repository.default_branch`. The
|
|
82
|
+
* engine interface does not yet declare this method; it is consumed via
|
|
83
|
+
* an optional chain (`normalizer.extractDefaultBranch?.(payload)`), so it
|
|
84
|
+
* is safe to ship ahead of the interface change in Phase 3.
|
|
85
|
+
*/
|
|
86
|
+
extractDefaultBranch(payload: unknown): string | null;
|
|
87
|
+
/** Classify the raw event header against the source's eventMapping. */
|
|
88
|
+
private classifyEvent;
|
|
89
|
+
}
|
|
90
|
+
//# sourceMappingURL=normalizer.d.ts.map
|