@kici-dev/shared 0.5.0 → 0.6.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/dist/cold-store/chunk-id.js +3 -2
- package/dist/cold-store/config.js +3 -3
- package/dist/container-runtime.d.ts +148 -0
- package/dist/container-runtime.js +298 -0
- package/dist/container-runtime.test.d.ts +2 -0
- package/dist/db-admin.d.ts +0 -1079
- package/dist/db-admin.js +1 -1819
- package/dist/db.js +2 -1
- package/dist/diagnostics/bundle-archive.d.ts +7 -9
- package/dist/diagnostics/bundle-archive.js +12 -85
- package/dist/diagnostics/bundle-chunks.js +1 -1
- package/dist/env/define-env.d.ts +7 -6
- package/dist/env/define-env.js +8 -7
- package/dist/graceful-shutdown.d.ts +6 -2
- package/dist/graceful-shutdown.js +1 -1
- package/dist/idempotency-files.js +2 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -3
- package/dist/telemetry/init.js +2 -1
- package/package.json +13 -7
- package/sbom.spdx.json +391 -391
package/dist/db-admin.d.ts
CHANGED
|
@@ -26,16 +26,6 @@ export declare function parseDatabaseUrl(databaseUrl: string): ParsedDatabaseUrl
|
|
|
26
26
|
* Redact the password from a libpq URL for safe logging.
|
|
27
27
|
*/
|
|
28
28
|
export declare function maskDatabaseUrl(databaseUrl: string): string;
|
|
29
|
-
/**
|
|
30
|
-
* DROP `dbName` (if it exists). Terminates existing backend connections
|
|
31
|
-
* so the DROP doesn't block. Idempotent — drops are IF EXISTS.
|
|
32
|
-
*
|
|
33
|
-
* Used by e2e cleanup after a full-lifecycle service-deploy test tears
|
|
34
|
-
* down its isolated database. Shares the same admin-URL + identifier-
|
|
35
|
-
* validation + backend-termination scaffolding as dropAndCreateDatabase
|
|
36
|
-
* so the two helpers cannot drift.
|
|
37
|
-
*/
|
|
38
|
-
export declare function dropDatabaseDirect(databaseUrl: string): Promise<void>;
|
|
39
29
|
/**
|
|
40
30
|
* Drop `dbName` (if it exists), then recreate it owned by `owner`. Terminates
|
|
41
31
|
* existing backend connections so the DROP doesn't block.
|
|
@@ -140,20 +130,6 @@ export interface PurgeStaleExecutionResult {
|
|
|
140
130
|
* service restarts).
|
|
141
131
|
*/
|
|
142
132
|
export declare function clearDispatchQueueDirect(databaseUrl: string): Promise<void>;
|
|
143
|
-
/**
|
|
144
|
-
* TRUNCATE the three scaler-state tables on the orchestrator DB (direct SQL).
|
|
145
|
-
*
|
|
146
|
-
* These tables (`scaler_reservations`, `scaler_spawning_agents`,
|
|
147
|
-
* `scaler_agent_jobs`) hold in-flight scaler bookkeeping that a boot / Raft
|
|
148
|
-
* leader switch rehydrates via `ScalerManager.recoverState`. A row for an agent
|
|
149
|
-
* that spawned but never registered (or whose reservation leaked) is counted as
|
|
150
|
-
* used capacity forever, so a warm-reused orchestrator DB can accumulate stale
|
|
151
|
-
* reservations that push `used` past the resource cap and stop every future
|
|
152
|
-
* scale-up. E2E setups that reuse a warm orch DB call this before the
|
|
153
|
-
* orchestrator starts so it rehydrates a clean slate — the DB analog of
|
|
154
|
-
* allocating a fresh machine-ledger directory per run.
|
|
155
|
-
*/
|
|
156
|
-
export declare function clearScalerStateDirect(databaseUrl: string): Promise<void>;
|
|
157
133
|
/**
|
|
158
134
|
* DELETE orphan execution_runs + execution_jobs for routing keys other than
|
|
159
135
|
* `routingKey` (and rows with NULL routing_key). Returns row counts.
|
|
@@ -542,15 +518,6 @@ export declare function showExecutionRunDirect(databaseUrl: string, opts: {
|
|
|
542
518
|
run: ExecutionRunRow;
|
|
543
519
|
jobs: ExecutionJobRow[];
|
|
544
520
|
}>;
|
|
545
|
-
/**
|
|
546
|
-
* READ-ONLY: list execution_jobs for a given execution_runs.id. Ordered by
|
|
547
|
-
* created_at ASC so downstream diffs show timeline order.
|
|
548
|
-
*/
|
|
549
|
-
export declare function listExecutionJobsDirect(databaseUrl: string, opts: {
|
|
550
|
-
runId: string;
|
|
551
|
-
}): Promise<{
|
|
552
|
-
jobs: ExecutionJobRow[];
|
|
553
|
-
}>;
|
|
554
521
|
export interface WorkflowRegistrationRow {
|
|
555
522
|
id: string;
|
|
556
523
|
repo_identifier: string;
|
|
@@ -678,33 +645,6 @@ export interface EmitKiciEventOpts {
|
|
|
678
645
|
export declare function emitKiciEventDirect(databaseUrl: string, opts: EmitKiciEventOpts): Promise<{
|
|
679
646
|
eventId: string;
|
|
680
647
|
}>;
|
|
681
|
-
export interface SeedGenericWebhookSourceOpts {
|
|
682
|
-
orgId: string;
|
|
683
|
-
name: string;
|
|
684
|
-
/** Pre-computed deterministic UUID (caller derives via sha256(orgId:name)) */
|
|
685
|
-
sourceId: string;
|
|
686
|
-
/** Pre-computed routing key (caller uses `generic:${orgId}:${name}`) */
|
|
687
|
-
routingKey: string;
|
|
688
|
-
verificationMethod?: string;
|
|
689
|
-
/** 'generic' (Stripe-shaped) or 'local' (github-shaped via LocalWebhookNormalizer,
|
|
690
|
-
* a git repo present on the agent filesystem cloned via file://). */
|
|
691
|
-
providerType?: 'generic' | 'local';
|
|
692
|
-
/** For `providerType='local'`: the per-source `{ repoBasePath, cloneUrlBase? }`
|
|
693
|
-
* stored in `git_config`. The orchestrator reads `repoBasePath` from this row
|
|
694
|
-
* at registration time to build the local provider bundle. */
|
|
695
|
-
gitConfig?: Record<string, unknown>;
|
|
696
|
-
}
|
|
697
|
-
/**
|
|
698
|
-
* Upsert a row into `generic_webhook_sources`. Uses
|
|
699
|
-
* `ON CONFLICT (routing_key) DO UPDATE` so warm-start mode (where the source
|
|
700
|
-
* may already exist from a prior run) is idempotent.
|
|
701
|
-
*
|
|
702
|
-
* IMPORTANT: callers must invoke this BEFORE the orchestrator starts, because
|
|
703
|
-
* GenericSourceManager caches sources at boot and does not reload them later.
|
|
704
|
-
* This helper supersedes seedGenericWebhookSource() in
|
|
705
|
-
* e2e/helpers/local-webhook.ts.
|
|
706
|
-
*/
|
|
707
|
-
export declare function seedGenericWebhookSourceDirect(databaseUrl: string, opts: SeedGenericWebhookSourceOpts): Promise<void>;
|
|
708
648
|
/**
|
|
709
649
|
* Return `{ current: true }` if the applied migration count matches the
|
|
710
650
|
* provider's migration count AND the content hash in `_migration_content_hash`
|
|
@@ -731,215 +671,6 @@ export declare function isSchemaCurrent(pool: pg.Pool, provider: MigrationProvid
|
|
|
731
671
|
export declare function purgeSecretBackendsDirect(databaseUrl: string): Promise<{
|
|
732
672
|
deleted: number;
|
|
733
673
|
}>;
|
|
734
|
-
/**
|
|
735
|
-
* Check if an API key exists in the Platform DB (api_keys table — orchestrator-
|
|
736
|
-
* managed, NOT user_api_keys). Returns true when a row matches the hashed key.
|
|
737
|
-
*/
|
|
738
|
-
export declare function apiKeyExistsDirect(databaseUrl: string, apiKey: string): Promise<boolean>;
|
|
739
|
-
/**
|
|
740
|
-
* Insert an api_keys row (Platform-side orchestrator credential). Used by
|
|
741
|
-
* e2e setup to seed an orchestrator authentication token. Returns the id.
|
|
742
|
-
*/
|
|
743
|
-
export declare function seedApiKeyInlineDirect(databaseUrl: string, opts: {
|
|
744
|
-
keyName: string;
|
|
745
|
-
orgId: string;
|
|
746
|
-
fullKey: string;
|
|
747
|
-
}): Promise<{
|
|
748
|
-
keyId: string;
|
|
749
|
-
}>;
|
|
750
|
-
/**
|
|
751
|
-
* Lookup a `platform_connections` row by connection_id. Returns true when
|
|
752
|
-
* present. Used by the orphan-sweeper e2e test.
|
|
753
|
-
*/
|
|
754
|
-
export declare function platformConnectionExistsDirect(databaseUrl: string, connectionId: string): Promise<boolean>;
|
|
755
|
-
/**
|
|
756
|
-
* Count `webhook_sources` rows for a given orchestrator_connection_id.
|
|
757
|
-
* Used by the orphan-sweeper e2e test to assert the FK CASCADE introduced
|
|
758
|
-
* by Platform migration 017 actually fires when the parent
|
|
759
|
-
* `platform_connections` row is deleted.
|
|
760
|
-
*/
|
|
761
|
-
/**
|
|
762
|
-
* Look up a Platform-side `webhook_sources` row by routing key. Returns the
|
|
763
|
-
* row (org_id + provider + connection) or null. Used by E2E to assert that a
|
|
764
|
-
* source added at runtime on the orchestrator propagated to the Platform's
|
|
765
|
-
* `webhook_sources` table (the dashboard-visible source list) without a
|
|
766
|
-
* restart.
|
|
767
|
-
*/
|
|
768
|
-
export declare function getWebhookSourceByRoutingKeyDirect(databaseUrl: string, routingKey: string): Promise<{
|
|
769
|
-
routing_key: string;
|
|
770
|
-
org_id: string;
|
|
771
|
-
provider: string;
|
|
772
|
-
} | null>;
|
|
773
|
-
export declare function countWebhookSourcesByConnectionIdDirect(databaseUrl: string, connectionId: string): Promise<number>;
|
|
774
|
-
/**
|
|
775
|
-
* Find a `user_api_keys.id` preferring rows scoped to `preferredOrgId`, else
|
|
776
|
-
* any row in the table. Used by orphan-sweeper test to get a realistic
|
|
777
|
-
* `key_id` for platform_connections seeding.
|
|
778
|
-
*/
|
|
779
|
-
export declare function findAnyUserApiKeyIdDirect(databaseUrl: string, preferredOrgId: string): Promise<string | null>;
|
|
780
|
-
/**
|
|
781
|
-
* Seed or refresh a synthetic GitHub webhook source on the Platform DB.
|
|
782
|
-
* Used by HMAC E2E tests that post to `/webhook/:orgId/github`.
|
|
783
|
-
* Idempotent — refreshes the secret/org_id via ON CONFLICT DO UPDATE,
|
|
784
|
-
* and clears stale rows with a different routing_key under the same
|
|
785
|
-
* (org_id, provider, connection_id) triple.
|
|
786
|
-
*/
|
|
787
|
-
export declare function seedSyntheticGithubSourceDirect(databaseUrl: string, opts: {
|
|
788
|
-
routingKey: string;
|
|
789
|
-
orgId: string;
|
|
790
|
-
/** Display name pushed by the orchestrator on register. Optional. */
|
|
791
|
-
name?: string;
|
|
792
|
-
/** Fine-grained subtype (e.g. 'github_app'). Optional. */
|
|
793
|
-
subtype?: string;
|
|
794
|
-
/** GitHub App slug. Optional. */
|
|
795
|
-
slug?: string;
|
|
796
|
-
}): Promise<void>;
|
|
797
|
-
/**
|
|
798
|
-
* Seed a webhook secret into the orchestrator's `scoped_secrets` table,
|
|
799
|
-
* encrypted with the caller-supplied key. Ensures a `sources` row exists
|
|
800
|
-
* for the routing_key. Used by e2e setup on the orchestrator DB side.
|
|
801
|
-
*
|
|
802
|
-
* encryptFn takes plaintext + AAD and returns ciphertext bytes. The
|
|
803
|
-
* caller owns the crypto primitive so this helper stays decoupled from
|
|
804
|
-
* the orchestrator's PgSecretStore crypto module.
|
|
805
|
-
*
|
|
806
|
-
* `customerId` is the org the source belongs to, and passing it is what makes
|
|
807
|
-
* this seed faithful to a deployed environment. `sources.customer_id` carries a
|
|
808
|
-
* column DEFAULT of `'__default__'`, so a row inserted without it lands on the
|
|
809
|
-
* no-tenant anchor — and `resolveOrgId` then reports `'__default__'` for every
|
|
810
|
-
* event on that routing key, which denies org-scoped features (global-workflow
|
|
811
|
-
* registration, the multi-provider lock fallback) for reasons that surface
|
|
812
|
-
* nowhere near the source row. Supplied on both paths so a row an earlier seed
|
|
813
|
-
* left on the default anchor is repaired rather than inherited; that is exactly
|
|
814
|
-
* what the staging deploy's own `updateSourcesCustomerId()` step does after the
|
|
815
|
-
* fact. Omit it only when the caller genuinely has no org (a single-tenant
|
|
816
|
-
* fixture), never because it is inconvenient to thread.
|
|
817
|
-
*/
|
|
818
|
-
export declare function seedWebhookSecretDirect(databaseUrl: string, opts: {
|
|
819
|
-
routingKey: string;
|
|
820
|
-
webhookSecret: string;
|
|
821
|
-
encryptFn: (plaintext: string, aad: string) => string | Buffer;
|
|
822
|
-
/** Org that owns the source. Written on insert and reasserted on an existing row. */
|
|
823
|
-
customerId?: string;
|
|
824
|
-
}): Promise<{
|
|
825
|
-
sourceId: string;
|
|
826
|
-
}>;
|
|
827
|
-
/**
|
|
828
|
-
* Seed a source private key into the orchestrator's `scoped_secrets` table.
|
|
829
|
-
* encryptFn signature matches seedWebhookSecretDirect. Returns null if the
|
|
830
|
-
* sources row is missing (matches legacy warning-and-skip behaviour).
|
|
831
|
-
*/
|
|
832
|
-
export declare function seedSourcePrivateKeyDirect(databaseUrl: string, opts: {
|
|
833
|
-
routingKey: string;
|
|
834
|
-
privateKey: string;
|
|
835
|
-
encryptFn: (plaintext: string, aad: string) => string | Buffer;
|
|
836
|
-
}): Promise<{
|
|
837
|
-
sourceId: string;
|
|
838
|
-
} | null>;
|
|
839
|
-
/**
|
|
840
|
-
* Bump `registry_versions.version` for the default registry and return the
|
|
841
|
-
* new value. Used by cron-scheduler e2e to retrigger index after a manual
|
|
842
|
-
* workflow change.
|
|
843
|
-
*/
|
|
844
|
-
export declare function bumpRegistryVersionDirect(databaseUrl: string): Promise<number>;
|
|
845
|
-
/**
|
|
846
|
-
* Poll `kici_events` for an event matching `eventName` created after `since`.
|
|
847
|
-
* Returns the newest match, or throws on timeout. Used by e2e event-routing tests.
|
|
848
|
-
*/
|
|
849
|
-
export declare function pollKiciEventsDirect(databaseUrl: string, opts: {
|
|
850
|
-
eventName: string;
|
|
851
|
-
since: Date;
|
|
852
|
-
timeoutMs?: number;
|
|
853
|
-
pollIntervalMs?: number;
|
|
854
|
-
payloadFilter?: {
|
|
855
|
-
key: string;
|
|
856
|
-
value: string;
|
|
857
|
-
};
|
|
858
|
-
}): Promise<Record<string, unknown>>;
|
|
859
|
-
/**
|
|
860
|
-
* Ping a PostgreSQL database; retries until `SELECT 1` succeeds or the
|
|
861
|
-
* timeout expires. Used by e2e startup to wait for Postgres readiness.
|
|
862
|
-
*/
|
|
863
|
-
export declare function waitForPostgresDirect(databaseUrl: string, opts?: {
|
|
864
|
-
timeoutMs?: number;
|
|
865
|
-
intervalMs?: number;
|
|
866
|
-
}): Promise<void>;
|
|
867
|
-
/**
|
|
868
|
-
* Wait for a specific execution_runs row to reach a terminal status.
|
|
869
|
-
* Used by test-pipeline e2e to gate on run completion. Terminal statuses
|
|
870
|
-
* are success / failed / cancelled / timed_out_stale.
|
|
871
|
-
*/
|
|
872
|
-
export declare function waitForRunCompletionDirect(databaseUrl: string, runId: string, opts?: {
|
|
873
|
-
timeoutMs?: number;
|
|
874
|
-
intervalMs?: number;
|
|
875
|
-
}): Promise<{
|
|
876
|
-
status: string;
|
|
877
|
-
}>;
|
|
878
|
-
/**
|
|
879
|
-
* DELETE from execution_jobs + execution_runs where started_at > since.
|
|
880
|
-
* Used by e2e cleanup for tests that want explicit post-test row cleanup.
|
|
881
|
-
*/
|
|
882
|
-
export declare function cleanupExecutionRowsDirect(databaseUrl: string, since: Date): Promise<{
|
|
883
|
-
runs: number;
|
|
884
|
-
jobs: number;
|
|
885
|
-
}>;
|
|
886
|
-
/**
|
|
887
|
-
* Check whether the schema is "current" by comparing applied migration count
|
|
888
|
-
* and content hash against a caller-supplied set of migration files.
|
|
889
|
-
* Returns false if the migration table is missing, counts mismatch, or the
|
|
890
|
-
* stored hash differs from the caller-supplied hash. Used by e2e warm-start.
|
|
891
|
-
*/
|
|
892
|
-
export declare function isSchemaCurrentFromFilesDirect(databaseUrl: string, opts: {
|
|
893
|
-
tableName?: string;
|
|
894
|
-
expectedCount: number;
|
|
895
|
-
expectedContentHash: string;
|
|
896
|
-
}): Promise<boolean>;
|
|
897
|
-
/**
|
|
898
|
-
* Store a migration content hash in the `_migration_content_hash` marker
|
|
899
|
-
* table. Creates the table if missing. Used by e2e freshDatabase() after
|
|
900
|
-
* migrations run so warm-start detection can compare on next run.
|
|
901
|
-
*/
|
|
902
|
-
export declare function storeMigrationContentHashInTableDirect(databaseUrl: string, opts: {
|
|
903
|
-
tableName?: string;
|
|
904
|
-
contentHash: string;
|
|
905
|
-
}): Promise<void>;
|
|
906
|
-
/**
|
|
907
|
-
* Insert a join_tokens row (orchestrator DB) for cluster peer auth.
|
|
908
|
-
* Used by cluster e2e helpers to provision a shared secret the second
|
|
909
|
-
* orchestrator will use when joining the cluster.
|
|
910
|
-
*/
|
|
911
|
-
export declare function createJoinTokenDirect(databaseUrl: string, opts: {
|
|
912
|
-
id: string;
|
|
913
|
-
tokenHash: string;
|
|
914
|
-
routingInfo: Record<string, unknown>;
|
|
915
|
-
role: string;
|
|
916
|
-
createdBy: string;
|
|
917
|
-
expiresAt: Date;
|
|
918
|
-
}): Promise<void>;
|
|
919
|
-
/**
|
|
920
|
-
* Delete join_tokens rows by `created_by` (orchestrator DB). Used by cluster
|
|
921
|
-
* E2E tests to clean up test-provisioned tokens between runs.
|
|
922
|
-
*/
|
|
923
|
-
export declare function deleteJoinTokensByCreatedByDirect(databaseUrl: string, opts: {
|
|
924
|
-
createdBy: string;
|
|
925
|
-
}): Promise<void>;
|
|
926
|
-
/**
|
|
927
|
-
* Update the routing_key on `sources` rows for a given provider. Used by
|
|
928
|
-
* cluster e2e to swap the staging routing key for an isolated test key
|
|
929
|
-
* (and to restore it on teardown).
|
|
930
|
-
*
|
|
931
|
-
* `whereRoutingKey`: optional filter on the current routing_key. When
|
|
932
|
-
* present only rows matching it are updated; when absent the provider
|
|
933
|
-
* filter alone is used (with an implicit `!= newRoutingKey` guard so the
|
|
934
|
-
* update is idempotent).
|
|
935
|
-
*/
|
|
936
|
-
export declare function updateSourceRoutingKeyDirect(databaseUrl: string, opts: {
|
|
937
|
-
provider: string;
|
|
938
|
-
newRoutingKey: string;
|
|
939
|
-
whereRoutingKey?: string;
|
|
940
|
-
}): Promise<{
|
|
941
|
-
updated: number;
|
|
942
|
-
}>;
|
|
943
674
|
/**
|
|
944
675
|
* Delete peer_credentials rows whose instance_id does NOT match a pattern.
|
|
945
676
|
* Used by cluster e2e to wipe stale staging peer credentials while leaving
|
|
@@ -950,569 +681,6 @@ export declare function prunePeerCredentialsDirect(databaseUrl: string, opts: {
|
|
|
950
681
|
}): Promise<{
|
|
951
682
|
deleted: number;
|
|
952
683
|
}>;
|
|
953
|
-
/**
|
|
954
|
-
* Poll Platform until at least `minRegistrations` distinct orchestrator
|
|
955
|
-
* connections are BOTH registered for the routing key (row in webhook_sources)
|
|
956
|
-
* AND live (row in platform_connections with status='connected'). The live-
|
|
957
|
-
* connection join is critical — Platform's webhook_sources rows persist after
|
|
958
|
-
* a connection disconnects (the orphan sweeper eventually reaps them), so a
|
|
959
|
-
* naive COUNT(DISTINCT) on webhook_sources alone would inflate the number
|
|
960
|
-
* and mask a missing coordinator registration.
|
|
961
|
-
*/
|
|
962
|
-
export declare function waitForPlatformRegistrationsDirect(platformDbUrl: string, routingKey: string, opts?: {
|
|
963
|
-
minRegistrations?: number;
|
|
964
|
-
timeoutMs?: number;
|
|
965
|
-
intervalMs?: number;
|
|
966
|
-
}): Promise<void>;
|
|
967
|
-
/**
|
|
968
|
-
* Seed a generic_webhook_sources row with a custom `event_type_header` and
|
|
969
|
-
* `git_config` payload. Used by universal-git e2e (Forgejo) to register
|
|
970
|
-
* an ingest endpoint that extracts the event type from Gitea-style headers.
|
|
971
|
-
*/
|
|
972
|
-
export interface SeedUniversalGitSourceOpts {
|
|
973
|
-
orgId: string;
|
|
974
|
-
sourceId: string;
|
|
975
|
-
sourceName: string;
|
|
976
|
-
routingKey: string;
|
|
977
|
-
gitConfig: Record<string, unknown>;
|
|
978
|
-
eventTypeHeader?: string;
|
|
979
|
-
}
|
|
980
|
-
export declare function seedUniversalGitSourceDirect(databaseUrl: string, opts: SeedUniversalGitSourceOpts): Promise<void>;
|
|
981
|
-
/**
|
|
982
|
-
* Seed the ci-security orchestrator fixtures expected by the security
|
|
983
|
-
* pipeline e2e: sources row for dashboard orgId resolution, context,
|
|
984
|
-
* two execution_runs (unknown + trusted), two execution_jobs, and a
|
|
985
|
-
* security held_run for the unknown contributor.
|
|
986
|
-
*
|
|
987
|
-
* Returns the ids so the caller can assert downstream.
|
|
988
|
-
*/
|
|
989
|
-
export interface SeedCiSecurityFixturesOpts {
|
|
990
|
-
orgId: string;
|
|
991
|
-
contextName?: string;
|
|
992
|
-
sourceName?: string;
|
|
993
|
-
sourceRoutingKey?: string;
|
|
994
|
-
runsRoutingKey: string;
|
|
995
|
-
unknownRunId: string;
|
|
996
|
-
unknownDeliveryId: string;
|
|
997
|
-
unknownJobId: string;
|
|
998
|
-
trustedRunId: string;
|
|
999
|
-
trustedDeliveryId: string;
|
|
1000
|
-
trustedJobId: string;
|
|
1001
|
-
/**
|
|
1002
|
-
* Second PR on the SAME repo (`repo_identifier='.'`, `pr_number=2`) with its
|
|
1003
|
-
* own pending security hold. Seeded so PR-scoping tests can prove that a
|
|
1004
|
-
* `/kici approve` on the first PR (pr_number=1) leaves this one held.
|
|
1005
|
-
*/
|
|
1006
|
-
secondPrRunId: string;
|
|
1007
|
-
secondPrDeliveryId: string;
|
|
1008
|
-
secondPrJobId: string;
|
|
1009
|
-
/**
|
|
1010
|
-
* Hold on a DIFFERENT repo (`repo_identifier='other/repo'`, `pr_number=1`) —
|
|
1011
|
-
* same PR number as the first hold but a different repo, proving the scoping
|
|
1012
|
-
* isolates on repo as well as PR number.
|
|
1013
|
-
*/
|
|
1014
|
-
otherRepoRunId: string;
|
|
1015
|
-
otherRepoDeliveryId: string;
|
|
1016
|
-
otherRepoJobId: string;
|
|
1017
|
-
/**
|
|
1018
|
-
* Workflow-modification hold (`repo_identifier='.'`, `pr_number=3`,
|
|
1019
|
-
* `reason='workflow_modification'`) — the hold a non-trusted contributor's
|
|
1020
|
-
* workflow-editing PR produces. Seeded so the PR-scoped `/kici approve`
|
|
1021
|
-
* (which joins on `pr_number`) can find and resolve it.
|
|
1022
|
-
*/
|
|
1023
|
-
wfModRunId: string;
|
|
1024
|
-
wfModDeliveryId: string;
|
|
1025
|
-
wfModJobId: string;
|
|
1026
|
-
/**
|
|
1027
|
-
* Fork-PR hold (`repo_identifier='.'`, `pr_number=4`, `reason='fork_pr'`) —
|
|
1028
|
-
* the hold the org trust policy's fork arm produces. Reachable only since the
|
|
1029
|
-
* policy became enforced, so it is seeded to prove PR-scoped selection and
|
|
1030
|
-
* approval work for it exactly as they do for the workflow-modification hold.
|
|
1031
|
-
*/
|
|
1032
|
-
forkPrRunId: string;
|
|
1033
|
-
forkPrDeliveryId: string;
|
|
1034
|
-
forkPrJobId: string;
|
|
1035
|
-
}
|
|
1036
|
-
export interface SeedCiSecurityFixturesResult {
|
|
1037
|
-
/**
|
|
1038
|
-
* The context name the fixture seeded (the `contextName` option, or its
|
|
1039
|
-
* default). Assertions build the expected `held_runs.reason` from this rather
|
|
1040
|
-
* than re-deriving the name, so an override cannot desync them.
|
|
1041
|
-
*/
|
|
1042
|
-
contextName: string;
|
|
1043
|
-
envId: string;
|
|
1044
|
-
/** Held run for the unknown contributor (repo `.`, pr_number 1). */
|
|
1045
|
-
heldRunId: string;
|
|
1046
|
-
/** Held run for the same-repo second PR (repo `.`, pr_number 2). */
|
|
1047
|
-
secondHeldRunId: string;
|
|
1048
|
-
/** Held run for the different-repo run (repo `other/repo`, pr_number 1). */
|
|
1049
|
-
otherRepoHeldRunId: string;
|
|
1050
|
-
/** Held run for the workflow-modification PR (repo `.`, pr_number 3). */
|
|
1051
|
-
wfModHeldRunId: string;
|
|
1052
|
-
/** Held run for the fork PR (repo `.`, pr_number 4). */
|
|
1053
|
-
forkPrHeldRunId: string;
|
|
1054
|
-
}
|
|
1055
|
-
/** repo_identifier used for the different-repo isolation hold. */
|
|
1056
|
-
export declare const CI_SECURITY_OTHER_REPO = "other/repo";
|
|
1057
|
-
export declare function seedCiSecurityFixturesDirect(databaseUrl: string, opts: SeedCiSecurityFixturesOpts): Promise<SeedCiSecurityFixturesResult>;
|
|
1058
|
-
/**
|
|
1059
|
-
* Poll `execution_runs` for the newest run started since `since` whose status
|
|
1060
|
-
* is in `statuses`, returning that status. Resolves `{ status: null }` if the
|
|
1061
|
-
* deadline passes before any run reaches a target status.
|
|
1062
|
-
*
|
|
1063
|
-
* Callers wanting "did the run finish?" pass the terminal status set and read
|
|
1064
|
-
* the landed status — a terminal failure is reported immediately rather than
|
|
1065
|
-
* indistinguishable from a timeout. Used by the cluster reroute tests to gate
|
|
1066
|
-
* on a workflow reaching a terminal state after a webhook trigger.
|
|
1067
|
-
*
|
|
1068
|
-
* Pass `deliveryId` to scope the poll to the caller's own delivery. A `since`
|
|
1069
|
-
* window alone does NOT identify a run: any workflow reaching a terminal state
|
|
1070
|
-
* inside the same window matches, so a neighbouring run — including one whose
|
|
1071
|
-
* failure is the point of some other test — is reported as if it were the
|
|
1072
|
-
* caller's. The stored `delivery_id` is the source-prefixed form
|
|
1073
|
-
* (`generic:<org>:<source>:<caller-id>`), so the caller's id is matched as a
|
|
1074
|
-
* suffix.
|
|
1075
|
-
*/
|
|
1076
|
-
export declare function waitForExecutionRunReachesStatusSinceDirect(databaseUrl: string, opts: {
|
|
1077
|
-
since: Date;
|
|
1078
|
-
statuses: readonly string[];
|
|
1079
|
-
/** Scope to one delivery. Omit only when the caller genuinely wants "any run". */
|
|
1080
|
-
deliveryId?: string;
|
|
1081
|
-
timeoutMs?: number;
|
|
1082
|
-
intervalMs?: number;
|
|
1083
|
-
}): Promise<{
|
|
1084
|
-
status: string | null;
|
|
1085
|
-
}>;
|
|
1086
|
-
/**
|
|
1087
|
-
* Fetch the most recent `execution_runs` row matching `status`, plus its
|
|
1088
|
-
* `execution_jobs`. Used by cluster reroute tests to confirm the run +
|
|
1089
|
-
* its jobs completed successfully.
|
|
1090
|
-
*
|
|
1091
|
-
* Pass `deliveryId` to scope to the caller's own delivery — "the newest run
|
|
1092
|
-
* with this status" is otherwise satisfied by any concurrent workflow, so the
|
|
1093
|
-
* returned `run_id` can belong to a different test.
|
|
1094
|
-
*/
|
|
1095
|
-
export interface LatestExecutionRunResult {
|
|
1096
|
-
run: {
|
|
1097
|
-
run_id: string;
|
|
1098
|
-
workflow_name: string;
|
|
1099
|
-
status: string;
|
|
1100
|
-
};
|
|
1101
|
-
jobs: Array<{
|
|
1102
|
-
job_id: string;
|
|
1103
|
-
job_name: string;
|
|
1104
|
-
status: string;
|
|
1105
|
-
}>;
|
|
1106
|
-
}
|
|
1107
|
-
export declare function latestExecutionRunByStatusDirect(databaseUrl: string, opts: {
|
|
1108
|
-
status: string;
|
|
1109
|
-
/** Scope to one delivery. Omit only when the caller genuinely wants "any run". */
|
|
1110
|
-
deliveryId?: string;
|
|
1111
|
-
}): Promise<LatestExecutionRunResult | null>;
|
|
1112
|
-
/**
|
|
1113
|
-
* Wait for a `execution_jobs` row joined against the most recent
|
|
1114
|
-
* `execution_runs` for a given workflow name with started_at >= since,
|
|
1115
|
-
* returning the job's status + error + run_id. Used by secrets-pipeline
|
|
1116
|
-
* to gate on terminal job status.
|
|
1117
|
-
*/
|
|
1118
|
-
export interface WaitForLatestJobResult {
|
|
1119
|
-
status: string | null;
|
|
1120
|
-
errorMessage: string | null;
|
|
1121
|
-
runId: string | null;
|
|
1122
|
-
}
|
|
1123
|
-
export declare function waitForLatestExecutionJobStatusDirect(databaseUrl: string, opts: {
|
|
1124
|
-
workflowName: string;
|
|
1125
|
-
since: Date;
|
|
1126
|
-
terminalStatuses?: readonly string[];
|
|
1127
|
-
timeoutMs?: number;
|
|
1128
|
-
intervalMs?: number;
|
|
1129
|
-
}): Promise<WaitForLatestJobResult>;
|
|
1130
|
-
/**
|
|
1131
|
-
* READ-ONLY: return information_schema column names for `tableName`,
|
|
1132
|
-
* ordered by ordinal_position. Used by e2e tests to verify migrations
|
|
1133
|
-
* produced expected schema shape. Returns empty array if the table
|
|
1134
|
-
* doesn't exist.
|
|
1135
|
-
*/
|
|
1136
|
-
export interface ColumnInfo {
|
|
1137
|
-
name: string;
|
|
1138
|
-
dataType: string;
|
|
1139
|
-
}
|
|
1140
|
-
export declare function describeTableColumnsDirect(databaseUrl: string, opts: {
|
|
1141
|
-
tableName: string;
|
|
1142
|
-
}): Promise<ColumnInfo[]>;
|
|
1143
|
-
/**
|
|
1144
|
-
* READ-ONLY: return true if a table exists in the public schema.
|
|
1145
|
-
*/
|
|
1146
|
-
export declare function tableExistsDirect(databaseUrl: string, opts: {
|
|
1147
|
-
tableName: string;
|
|
1148
|
-
schema?: string;
|
|
1149
|
-
}): Promise<boolean>;
|
|
1150
|
-
/**
|
|
1151
|
-
* Raw INSERT into kici_events with custom chain_depth + expiry window.
|
|
1152
|
-
* Used by event-routing e2e to test circuit-breaker + TTL behavior
|
|
1153
|
-
* beyond what `emitKiciEventDirect` exposes (which hardcodes depth=0
|
|
1154
|
-
* and 1h expiry). Returns the inserted id.
|
|
1155
|
-
*/
|
|
1156
|
-
export interface InsertKiciEventRawOpts {
|
|
1157
|
-
eventName: string;
|
|
1158
|
-
payload: Record<string, unknown>;
|
|
1159
|
-
sourceRoutingKey?: string;
|
|
1160
|
-
chainDepth?: number;
|
|
1161
|
-
/** ISO string or relative '1 hour' / '-1 hour'. Use negative for expired. */
|
|
1162
|
-
expiresIn?: string;
|
|
1163
|
-
}
|
|
1164
|
-
export declare function insertKiciEventRawDirect(databaseUrl: string, opts: InsertKiciEventRawOpts): Promise<{
|
|
1165
|
-
id: string;
|
|
1166
|
-
}>;
|
|
1167
|
-
/**
|
|
1168
|
-
* READ-ONLY: return a kici_events row by id, or null. Callers decode
|
|
1169
|
-
* `payload` as they need. Used by event-routing e2e after an INSERT.
|
|
1170
|
-
*/
|
|
1171
|
-
export interface KiciEventRow {
|
|
1172
|
-
id: string;
|
|
1173
|
-
event_name: string;
|
|
1174
|
-
payload: Record<string, unknown>;
|
|
1175
|
-
chain_depth: number;
|
|
1176
|
-
source_routing_key: string | null;
|
|
1177
|
-
source_repo: string | null;
|
|
1178
|
-
processed: boolean | null;
|
|
1179
|
-
expires_at: string;
|
|
1180
|
-
created_at: string;
|
|
1181
|
-
}
|
|
1182
|
-
export declare function showKiciEventDirect(databaseUrl: string, opts: {
|
|
1183
|
-
id: string;
|
|
1184
|
-
}): Promise<KiciEventRow | null>;
|
|
1185
|
-
/**
|
|
1186
|
-
* READ-ONLY: list kici_events with filter hooks used by e2e tests:
|
|
1187
|
-
* by `event_name`, minimum `chain_depth`, expiry window. Returns the
|
|
1188
|
-
* rows with chain_depth ordered ascending. Callers apply assertions.
|
|
1189
|
-
*/
|
|
1190
|
-
export declare function listKiciEventsDirect(databaseUrl: string, opts?: {
|
|
1191
|
-
eventName?: string;
|
|
1192
|
-
minChainDepth?: number;
|
|
1193
|
-
/** When true, return only rows past their expires_at. */
|
|
1194
|
-
onlyExpired?: boolean;
|
|
1195
|
-
/** When set, cap to this many rows. */
|
|
1196
|
-
limit?: number;
|
|
1197
|
-
}): Promise<KiciEventRow[]>;
|
|
1198
|
-
/**
|
|
1199
|
-
* DELETE kici_events by id or event_name. Returns the number of rows
|
|
1200
|
-
* deleted. Used by event-routing teardown.
|
|
1201
|
-
*/
|
|
1202
|
-
export declare function deleteKiciEventsDirect(databaseUrl: string, opts: {
|
|
1203
|
-
id?: string;
|
|
1204
|
-
eventName?: string;
|
|
1205
|
-
}): Promise<{
|
|
1206
|
-
deleted: number;
|
|
1207
|
-
}>;
|
|
1208
|
-
/**
|
|
1209
|
-
* INSERT a kici_events row with an explicit created_at. Lets a test place
|
|
1210
|
-
* many events on the exact same timestamp so the catch-up keyset cursor's
|
|
1211
|
-
* same-created_at tie handling is genuinely exercised (the default-NOW insert
|
|
1212
|
-
* path cannot force ties deterministically). Returns the inserted id.
|
|
1213
|
-
*/
|
|
1214
|
-
export declare function insertKiciEventAtDirect(databaseUrl: string, opts: {
|
|
1215
|
-
eventName: string;
|
|
1216
|
-
createdAt: Date;
|
|
1217
|
-
payload?: Record<string, unknown>;
|
|
1218
|
-
chainDepth?: number;
|
|
1219
|
-
sourceRoutingKey?: string | null;
|
|
1220
|
-
expiresIn?: string;
|
|
1221
|
-
}): Promise<{
|
|
1222
|
-
id: string;
|
|
1223
|
-
}>;
|
|
1224
|
-
/**
|
|
1225
|
-
* Page through unprocessed, non-DLQ kici_events for a given event_name using
|
|
1226
|
-
* the same composite `(created_at, id)` keyset cursor + `ORDER BY created_at
|
|
1227
|
-
* ASC, id ASC` that EventStore.getUnprocessedSince runs. Keep this SQL in sync
|
|
1228
|
-
* with `packages/orchestrator/src/events/event-store.ts`.
|
|
1229
|
-
*
|
|
1230
|
-
* Returns every id seen across all pages in traversal order (with duplicates
|
|
1231
|
-
* preserved so the caller can assert none occur) plus the page count. This is
|
|
1232
|
-
* the real-Postgres guard that the keyset cursor pages the entire backlog —
|
|
1233
|
-
* including same-created_at ties across a page boundary — with no skip and no
|
|
1234
|
-
* duplicate.
|
|
1235
|
-
*/
|
|
1236
|
-
export declare function paginateUnprocessedEventsKeysetDirect(databaseUrl: string, opts: {
|
|
1237
|
-
eventName: string;
|
|
1238
|
-
batchSize?: number;
|
|
1239
|
-
}): Promise<{
|
|
1240
|
-
ids: string[];
|
|
1241
|
-
pages: number;
|
|
1242
|
-
}>;
|
|
1243
|
-
/**
|
|
1244
|
-
* Simulate a NOTIFY on `kici_event_channel` and verify a LISTEN client
|
|
1245
|
-
* receives it. Used by event-routing e2e to prove the infrastructure
|
|
1246
|
-
* the EventRouter uses for real-time delivery is functional. Owns the
|
|
1247
|
-
* pool for the full test to keep the listen/notify correlated.
|
|
1248
|
-
*/
|
|
1249
|
-
export declare function verifyKiciEventNotifyDirect(databaseUrl: string, opts: {
|
|
1250
|
-
payload: string;
|
|
1251
|
-
waitMs?: number;
|
|
1252
|
-
}): Promise<{
|
|
1253
|
-
received: string[];
|
|
1254
|
-
}>;
|
|
1255
|
-
export interface CrossRepoTrustRow {
|
|
1256
|
-
id: string;
|
|
1257
|
-
source_repo: string;
|
|
1258
|
-
source_routing_key: string;
|
|
1259
|
-
target_repo: string;
|
|
1260
|
-
target_routing_key: string;
|
|
1261
|
-
allowed_events: string[] | null;
|
|
1262
|
-
}
|
|
1263
|
-
/**
|
|
1264
|
-
* INSERT a cross_repo_trust row. Returns the new id and allowed_events
|
|
1265
|
-
* array. Used by generic-webhook + event-routing e2e until a proper
|
|
1266
|
-
* `kici-admin trust` CLI ships.
|
|
1267
|
-
*/
|
|
1268
|
-
export declare function seedCrossRepoTrustDirect(databaseUrl: string, opts: {
|
|
1269
|
-
sourceRepo: string;
|
|
1270
|
-
sourceRoutingKey: string;
|
|
1271
|
-
targetRepo: string;
|
|
1272
|
-
targetRoutingKey: string;
|
|
1273
|
-
allowedEvents?: string[];
|
|
1274
|
-
}): Promise<{
|
|
1275
|
-
id: string;
|
|
1276
|
-
allowedEvents: string[] | null;
|
|
1277
|
-
}>;
|
|
1278
|
-
/**
|
|
1279
|
-
* READ-ONLY: list cross_repo_trust rows by source_routing_key. Used by
|
|
1280
|
-
* generic-webhook e2e to find a trust row it just inserted.
|
|
1281
|
-
*/
|
|
1282
|
-
export declare function listCrossRepoTrustBySourceRoutingKeyDirect(databaseUrl: string, opts: {
|
|
1283
|
-
sourceRoutingKey: string;
|
|
1284
|
-
}): Promise<CrossRepoTrustRow[]>;
|
|
1285
|
-
/**
|
|
1286
|
-
* DELETE cross_repo_trust rows. Deletes by id, or asserts uniqueness
|
|
1287
|
-
* check error on duplicate INSERT (handled by caller). Returns row count.
|
|
1288
|
-
*/
|
|
1289
|
-
export declare function deleteCrossRepoTrustDirect(databaseUrl: string, opts: {
|
|
1290
|
-
id: string;
|
|
1291
|
-
}): Promise<{
|
|
1292
|
-
deleted: number;
|
|
1293
|
-
}>;
|
|
1294
|
-
/**
|
|
1295
|
-
* Direct INSERT with duplicate-key detection. Used by event-routing
|
|
1296
|
-
* e2e to verify the unique constraint enforces. Throws on duplicate;
|
|
1297
|
-
* caller asserts the error message matches /unique/i.
|
|
1298
|
-
*/
|
|
1299
|
-
export declare function insertCrossRepoTrustStrictDirect(databaseUrl: string, opts: {
|
|
1300
|
-
sourceRepo: string;
|
|
1301
|
-
sourceRoutingKey: string;
|
|
1302
|
-
targetRepo: string;
|
|
1303
|
-
targetRoutingKey: string;
|
|
1304
|
-
}): Promise<void>;
|
|
1305
|
-
/**
|
|
1306
|
-
* Cleanup helper for workflow_registrations. Accepts id, routingKey,
|
|
1307
|
-
* or repoIdentifier filter (exactly one). Returns delete count.
|
|
1308
|
-
*/
|
|
1309
|
-
export declare function deleteWorkflowRegistrationsDirect(databaseUrl: string, opts: {
|
|
1310
|
-
id?: string;
|
|
1311
|
-
routingKey?: string;
|
|
1312
|
-
repoIdentifier?: string;
|
|
1313
|
-
}): Promise<{
|
|
1314
|
-
deleted: number;
|
|
1315
|
-
}>;
|
|
1316
|
-
/**
|
|
1317
|
-
* READ-ONLY: workflow_registrations by id — returns null when missing.
|
|
1318
|
-
* Pulls the full row so tests can assert lock_entry contents + trigger_types.
|
|
1319
|
-
*/
|
|
1320
|
-
export interface WorkflowRegistrationFullRow extends WorkflowRegistrationRow {
|
|
1321
|
-
lock_entry: unknown;
|
|
1322
|
-
}
|
|
1323
|
-
export declare function getWorkflowRegistrationByIdDirect(databaseUrl: string, opts: {
|
|
1324
|
-
id: string;
|
|
1325
|
-
}): Promise<WorkflowRegistrationFullRow | null>;
|
|
1326
|
-
/**
|
|
1327
|
-
* READ-ONLY: return the count + optional rows + latest updated_at for
|
|
1328
|
-
* workflow_registrations scoped to a routing key. Used by forgejo e2e
|
|
1329
|
-
* to wait for extraction + verify re-extraction bumped updated_at.
|
|
1330
|
-
*/
|
|
1331
|
-
export interface RegistrationsScopedResult {
|
|
1332
|
-
count: number;
|
|
1333
|
-
latestUpdatedAt: Date | null;
|
|
1334
|
-
rows: Array<{
|
|
1335
|
-
workflow_name: string;
|
|
1336
|
-
is_global: boolean;
|
|
1337
|
-
}>;
|
|
1338
|
-
}
|
|
1339
|
-
export declare function listRegistrationsByRoutingKeyDirect(databaseUrl: string, opts: {
|
|
1340
|
-
routingKey: string;
|
|
1341
|
-
onlyGlobal?: boolean;
|
|
1342
|
-
}): Promise<RegistrationsScopedResult>;
|
|
1343
|
-
/**
|
|
1344
|
-
* Poll `workflow_registrations` for at least `minCount` rows for a
|
|
1345
|
-
* routing key. Returns the rows or throws on timeout (keeps parity with
|
|
1346
|
-
* the forgejo helper pattern it replaces).
|
|
1347
|
-
*/
|
|
1348
|
-
export declare function waitForRegistrationsByRoutingKeyDirect(databaseUrl: string, opts: {
|
|
1349
|
-
routingKey: string;
|
|
1350
|
-
minCount?: number;
|
|
1351
|
-
onlyGlobal?: boolean;
|
|
1352
|
-
timeoutMs?: number;
|
|
1353
|
-
intervalMs?: number;
|
|
1354
|
-
}): Promise<Array<{
|
|
1355
|
-
workflow_name: string;
|
|
1356
|
-
is_global: boolean;
|
|
1357
|
-
}>>;
|
|
1358
|
-
/**
|
|
1359
|
-
* Wait for `workflow_registrations.updated_at` for a routing key to
|
|
1360
|
-
* exceed `baselineUpdatedAt`. Used by forgejo rotated-PAT e2e.
|
|
1361
|
-
*/
|
|
1362
|
-
export declare function waitForRegistrationsUpdatedAtAdvanceDirect(databaseUrl: string, opts: {
|
|
1363
|
-
routingKey: string;
|
|
1364
|
-
baselineUpdatedAt: Date | null;
|
|
1365
|
-
timeoutMs?: number;
|
|
1366
|
-
intervalMs?: number;
|
|
1367
|
-
}): Promise<{
|
|
1368
|
-
advanced: boolean;
|
|
1369
|
-
latestUpdatedAt: Date | null;
|
|
1370
|
-
}>;
|
|
1371
|
-
/**
|
|
1372
|
-
* UPDATE a workflow_registrations row's commit_sha. Used by cron-scheduler
|
|
1373
|
-
* e2e where the manual-schedule handler rejects null commit SHAs.
|
|
1374
|
-
*/
|
|
1375
|
-
export declare function updateWorkflowRegistrationCommitShaDirect(databaseUrl: string, opts: {
|
|
1376
|
-
id: string;
|
|
1377
|
-
commitSha: string;
|
|
1378
|
-
}): Promise<void>;
|
|
1379
|
-
/**
|
|
1380
|
-
* Lock-entry seeding for the admin-API e2e, which uses a custom
|
|
1381
|
-
* shape (cron schedule). Returns the inserted id.
|
|
1382
|
-
*/
|
|
1383
|
-
export declare function insertWorkflowRegistrationRawDirect(databaseUrl: string, opts: {
|
|
1384
|
-
routingKey: string;
|
|
1385
|
-
repoIdentifier: string;
|
|
1386
|
-
workflowName: string;
|
|
1387
|
-
lockEntry: Record<string, unknown>;
|
|
1388
|
-
triggerTypes: string[];
|
|
1389
|
-
customerId: string;
|
|
1390
|
-
isGlobal?: boolean;
|
|
1391
|
-
disabled?: boolean;
|
|
1392
|
-
commitSha?: string;
|
|
1393
|
-
id?: string;
|
|
1394
|
-
}): Promise<{
|
|
1395
|
-
id: string;
|
|
1396
|
-
}>;
|
|
1397
|
-
/**
|
|
1398
|
-
* INSERT with a STRICT shape (no ON CONFLICT). Used by registration-schema
|
|
1399
|
-
* e2e to prove the unique constraint rejects duplicates. Throws the raw
|
|
1400
|
-
* DB error (caller matches /unique/i).
|
|
1401
|
-
*/
|
|
1402
|
-
export declare function insertWorkflowRegistrationStrictDirect(databaseUrl: string, opts: {
|
|
1403
|
-
routingKey: string;
|
|
1404
|
-
repoIdentifier: string;
|
|
1405
|
-
workflowName: string;
|
|
1406
|
-
lockEntryJson?: string;
|
|
1407
|
-
triggerTypes: readonly string[];
|
|
1408
|
-
customerId: string;
|
|
1409
|
-
}): Promise<{
|
|
1410
|
-
id: string | null;
|
|
1411
|
-
}>;
|
|
1412
|
-
/**
|
|
1413
|
-
* READ-ONLY: latest registry_versions.version, or null if the default
|
|
1414
|
-
* row is missing. Used by registration-admin-api e2e to bracket a
|
|
1415
|
-
* refresh call.
|
|
1416
|
-
*/
|
|
1417
|
-
export declare function getRegistryVersionDirect(databaseUrl: string, opts?: {
|
|
1418
|
-
id?: string;
|
|
1419
|
-
}): Promise<number | null>;
|
|
1420
|
-
/**
|
|
1421
|
-
* UPDATE `registry_versions.version = version + 1` WHERE id (default).
|
|
1422
|
-
* Simpler than `bumpRegistryVersionDirect` — used by global-workflow
|
|
1423
|
-
* e2e which wants the side-effect (force index refresh) without the
|
|
1424
|
-
* return value.
|
|
1425
|
-
*/
|
|
1426
|
-
export declare function bumpRegistryVersionSimpleDirect(databaseUrl: string, opts?: {
|
|
1427
|
-
id?: string;
|
|
1428
|
-
}): Promise<void>;
|
|
1429
|
-
/**
|
|
1430
|
-
* Seed cron_last_fired for a registration with an `-INTERVAL` offset so
|
|
1431
|
-
* the scheduler fires on the next evaluation. Upsert via ON CONFLICT.
|
|
1432
|
-
*/
|
|
1433
|
-
export declare function upsertCronLastFiredDirect(databaseUrl: string, opts: {
|
|
1434
|
-
registrationId: string;
|
|
1435
|
-
agoInterval: string;
|
|
1436
|
-
scheduleKey: string;
|
|
1437
|
-
}): Promise<void>;
|
|
1438
|
-
/**
|
|
1439
|
-
* READ-ONLY: count cron_last_fired rows for a registration. Used by
|
|
1440
|
-
* registration-schema e2e to assert the FK cascade deletes the row.
|
|
1441
|
-
*/
|
|
1442
|
-
export declare function countCronLastFiredDirect(databaseUrl: string, opts: {
|
|
1443
|
-
registrationId: string;
|
|
1444
|
-
}): Promise<number>;
|
|
1445
|
-
/**
|
|
1446
|
-
* INSERT a cron_last_fired row with an explicit timestamp. Used by
|
|
1447
|
-
* registration-schema e2e to set up the FK cascade test.
|
|
1448
|
-
*/
|
|
1449
|
-
export declare function insertCronLastFiredNowDirect(databaseUrl: string, opts: {
|
|
1450
|
-
registrationId: string;
|
|
1451
|
-
scheduleKey: string;
|
|
1452
|
-
}): Promise<void>;
|
|
1453
|
-
/**
|
|
1454
|
-
* DELETE cron_last_fired rows for a registration. Teardown helper.
|
|
1455
|
-
*/
|
|
1456
|
-
export declare function deleteCronLastFiredDirect(databaseUrl: string, opts: {
|
|
1457
|
-
registrationId: string;
|
|
1458
|
-
}): Promise<void>;
|
|
1459
|
-
/**
|
|
1460
|
-
* DELETE execution_runs by workflow_name. Teardown helper for
|
|
1461
|
-
* manual-schedule e2e.
|
|
1462
|
-
*/
|
|
1463
|
-
export declare function deleteExecutionRunsByWorkflowNameDirect(databaseUrl: string, opts: {
|
|
1464
|
-
workflowName: string;
|
|
1465
|
-
}): Promise<{
|
|
1466
|
-
deleted: number;
|
|
1467
|
-
}>;
|
|
1468
|
-
/**
|
|
1469
|
-
* READ-ONLY: SELECT generic_webhook_sources by routing_key.
|
|
1470
|
-
* Used by forgejo e2e to assert the source exists with correct git_config.
|
|
1471
|
-
*/
|
|
1472
|
-
export declare function getGenericWebhookSourceByRoutingKeyDirect(databaseUrl: string, opts: {
|
|
1473
|
-
routingKey: string;
|
|
1474
|
-
}): Promise<{
|
|
1475
|
-
id: string;
|
|
1476
|
-
git_config: unknown;
|
|
1477
|
-
customer_id: string | null;
|
|
1478
|
-
} | null>;
|
|
1479
|
-
/**
|
|
1480
|
-
* READ-ONLY: list active (enabled=true) generic_webhook_sources.
|
|
1481
|
-
* Used by cluster-leader-failover e2e to prove the seeded source exists
|
|
1482
|
-
* before a leader crash.
|
|
1483
|
-
*/
|
|
1484
|
-
export declare function listActiveGenericWebhookSourcesDirect(databaseUrl: string): Promise<Array<{
|
|
1485
|
-
id: string;
|
|
1486
|
-
customer_id: string | null;
|
|
1487
|
-
routing_key: string;
|
|
1488
|
-
}>>;
|
|
1489
|
-
/**
|
|
1490
|
-
* UPDATE generic_webhook_sources.verification_config for a source by
|
|
1491
|
-
* name + customer_id. Used by the generic-webhook-auth e2e which seeds
|
|
1492
|
-
* sources and then writes custom auth configs.
|
|
1493
|
-
*/
|
|
1494
|
-
export declare function updateGenericWebhookVerificationConfigDirect(databaseUrl: string, opts: {
|
|
1495
|
-
name: string;
|
|
1496
|
-
customerId: string;
|
|
1497
|
-
verificationConfig: Record<string, unknown>;
|
|
1498
|
-
}): Promise<void>;
|
|
1499
|
-
/**
|
|
1500
|
-
* DELETE generic_webhook_sources by name list. Teardown for the auth
|
|
1501
|
-
* e2e, which seeded 3 sources by name.
|
|
1502
|
-
*/
|
|
1503
|
-
export declare function deleteGenericWebhookSourcesByNameDirect(databaseUrl: string, opts: {
|
|
1504
|
-
names: readonly string[];
|
|
1505
|
-
}): Promise<{
|
|
1506
|
-
deleted: number;
|
|
1507
|
-
}>;
|
|
1508
|
-
/**
|
|
1509
|
-
* UPDATE generic_webhook_sources.deleted_at = NULL for a row by id.
|
|
1510
|
-
* Used by the generic-webhook e2e to restore a soft-deleted source
|
|
1511
|
-
* after the soft-delete test ran — there is no CLI-level undelete.
|
|
1512
|
-
*/
|
|
1513
|
-
export declare function restoreSoftDeletedGenericWebhookSourceDirect(databaseUrl: string, opts: {
|
|
1514
|
-
id: string;
|
|
1515
|
-
}): Promise<void>;
|
|
1516
684
|
/**
|
|
1517
685
|
* One entry in any of the three repo-pattern lists stored on `org_settings`.
|
|
1518
686
|
* `routingKey` is the source-qualifier; when absent, the entry applies to
|
|
@@ -1522,144 +690,6 @@ export interface OrgSettingsRepoPatternEntry {
|
|
|
1522
690
|
routingKey?: string;
|
|
1523
691
|
pattern: string;
|
|
1524
692
|
}
|
|
1525
|
-
/**
|
|
1526
|
-
* UPSERT the per-org global-workflow repo lists for a customer/org id. The
|
|
1527
|
-
* three list fields are each optional; each list is a jsonb array of
|
|
1528
|
-
* `{routingKey?, pattern}` entries. Pass `null` to clear a list.
|
|
1529
|
-
*
|
|
1530
|
-
* The master enable switch is NOT set here: it is fleet-wide
|
|
1531
|
-
* (`cluster_settings.global_workflows_enabled`) — use
|
|
1532
|
-
* {@link setClusterGlobalWorkflowsEnabledDirect}.
|
|
1533
|
-
*/
|
|
1534
|
-
export interface UpsertOrgSettingsOpts {
|
|
1535
|
-
customerId: string;
|
|
1536
|
-
allowedRepos?: OrgSettingsRepoPatternEntry[] | null;
|
|
1537
|
-
deniedRepos?: OrgSettingsRepoPatternEntry[] | null;
|
|
1538
|
-
elevatedRepos?: OrgSettingsRepoPatternEntry[] | null;
|
|
1539
|
-
}
|
|
1540
|
-
export declare function upsertOrgSettingsGlobalWorkflowsDirect(databaseUrl: string, opts: UpsertOrgSettingsOpts): Promise<void>;
|
|
1541
|
-
/**
|
|
1542
|
-
* Set (or clear) the fleet-wide global-workflows master switch directly.
|
|
1543
|
-
*
|
|
1544
|
-
* Direct-DB by design, matching every other `*Direct` helper here: these exist
|
|
1545
|
-
* for E2E seeding, which must set the switch BEFORE an orchestrator is up and
|
|
1546
|
-
* therefore cannot go through the admin HTTP API. Operators use
|
|
1547
|
-
* `kici-admin cluster-settings set --global-workflows-enabled <bool>`.
|
|
1548
|
-
*
|
|
1549
|
-
* Passing `null` clears the override, so the orchestrator's configured default
|
|
1550
|
-
* applies. Upserts the singleton `id='default'` row, so it works against a
|
|
1551
|
-
* fresh database with no cluster_settings row at all.
|
|
1552
|
-
*
|
|
1553
|
-
* `cluster_settings.version` is left untouched: seeding happens before any
|
|
1554
|
-
* worker reads the row, so there is nothing to invalidate yet — the operator
|
|
1555
|
-
* PATCH path (admin-cluster-settings.ts) owns the version bump for live changes.
|
|
1556
|
-
*/
|
|
1557
|
-
export declare function setClusterGlobalWorkflowsEnabledDirect(databaseUrl: string, enabled: boolean | null): Promise<void>;
|
|
1558
|
-
/**
|
|
1559
|
-
* UPDATE org_settings.global_workflow_denied_repos for a customer/org id.
|
|
1560
|
-
* Assumes the row exists (upsertOrgSettingsGlobalWorkflowsDirect was
|
|
1561
|
-
* called earlier in the test).
|
|
1562
|
-
*/
|
|
1563
|
-
export declare function updateOrgSettingsDeniedReposDirect(databaseUrl: string, opts: {
|
|
1564
|
-
customerId: string;
|
|
1565
|
-
deniedRepos: OrgSettingsRepoPatternEntry[] | null;
|
|
1566
|
-
}): Promise<void>;
|
|
1567
|
-
/**
|
|
1568
|
-
* DELETE org_settings by customer/org id. Teardown helper.
|
|
1569
|
-
*/
|
|
1570
|
-
export declare function deleteOrgSettingsByCustomerIdDirect(databaseUrl: string, opts: {
|
|
1571
|
-
customerId: string;
|
|
1572
|
-
}): Promise<{
|
|
1573
|
-
deleted: number;
|
|
1574
|
-
}>;
|
|
1575
|
-
/**
|
|
1576
|
-
* READ-ONLY: fetch an execution_runs row by run_id, returning the
|
|
1577
|
-
* security-relevant columns the ci-security e2e asserts on. Throws
|
|
1578
|
-
* when the row is missing.
|
|
1579
|
-
*/
|
|
1580
|
-
export interface ExecutionRunSecurityRow {
|
|
1581
|
-
run_id: string;
|
|
1582
|
-
trust_tier: string | null;
|
|
1583
|
-
lock_file_source: string | null;
|
|
1584
|
-
contributor_username: string | null;
|
|
1585
|
-
status: string;
|
|
1586
|
-
}
|
|
1587
|
-
export declare function getExecutionRunSecurityDirect(databaseUrl: string, opts: {
|
|
1588
|
-
runId: string;
|
|
1589
|
-
}): Promise<ExecutionRunSecurityRow>;
|
|
1590
|
-
/**
|
|
1591
|
-
* READ-ONLY: fetch a held_runs row by id (with the security columns).
|
|
1592
|
-
* Returns null if missing.
|
|
1593
|
-
*/
|
|
1594
|
-
export interface HeldRunSecurityRow {
|
|
1595
|
-
id: string;
|
|
1596
|
-
run_id: string;
|
|
1597
|
-
hold_type: string;
|
|
1598
|
-
queue_type: string;
|
|
1599
|
-
status: string;
|
|
1600
|
-
reason: string | null;
|
|
1601
|
-
expires_at: string | null;
|
|
1602
|
-
approved_by: string | null;
|
|
1603
|
-
resolved_at: string | null;
|
|
1604
|
-
}
|
|
1605
|
-
export declare function getHeldRunByIdDirect(databaseUrl: string, opts: {
|
|
1606
|
-
id: string;
|
|
1607
|
-
}): Promise<HeldRunSecurityRow | null>;
|
|
1608
|
-
/** One recorded approver decision for a held run (`held_run_approvals` row). */
|
|
1609
|
-
export interface HeldRunApprovalRow {
|
|
1610
|
-
id: string;
|
|
1611
|
-
held_run_id: string;
|
|
1612
|
-
approver_user_id: string;
|
|
1613
|
-
decision: string;
|
|
1614
|
-
created_at: Date;
|
|
1615
|
-
}
|
|
1616
|
-
/**
|
|
1617
|
-
* READ-ONLY: list the recorded approver decisions for a held run, newest
|
|
1618
|
-
* first. Approver attribution lives in `held_run_approvals` (one row per
|
|
1619
|
-
* decision), not on the `held_runs` row — used by ci-security e2e to prove
|
|
1620
|
-
* an approval was stamped with the approving user's sub.
|
|
1621
|
-
*/
|
|
1622
|
-
export declare function listHeldRunApprovalsDirect(databaseUrl: string, opts: {
|
|
1623
|
-
heldRunId: string;
|
|
1624
|
-
}): Promise<HeldRunApprovalRow[]>;
|
|
1625
|
-
/**
|
|
1626
|
-
* READ-ONLY: count held_runs rows matching run_id + queue_type.
|
|
1627
|
-
* Used by ci-security e2e to prove no security hold exists for a
|
|
1628
|
-
* trusted contributor PR.
|
|
1629
|
-
*/
|
|
1630
|
-
export declare function countHeldRunsByRunIdDirect(databaseUrl: string, opts: {
|
|
1631
|
-
runId: string;
|
|
1632
|
-
queueType?: string;
|
|
1633
|
-
}): Promise<number>;
|
|
1634
|
-
/**
|
|
1635
|
-
* Wait for Platform-side `execution_runs.status = <status>` where
|
|
1636
|
-
* `created_at > since`. Returns the final status + failure_reason or
|
|
1637
|
-
* null if the timeout elapsed. Used by webhook-pipeline (failed) and
|
|
1638
|
-
* orchestrator-never-reconnects (timed_out_stale).
|
|
1639
|
-
*/
|
|
1640
|
-
export declare function waitForPlatformExecutionRunStatusDirect(databaseUrl: string, opts: {
|
|
1641
|
-
status: string;
|
|
1642
|
-
since: Date;
|
|
1643
|
-
timeoutMs?: number;
|
|
1644
|
-
intervalMs?: number;
|
|
1645
|
-
}): Promise<{
|
|
1646
|
-
status: string;
|
|
1647
|
-
failure_reason: string | null;
|
|
1648
|
-
} | null>;
|
|
1649
|
-
/**
|
|
1650
|
-
* Wait for Platform `event_log` to show at least `minDistinctRouted`
|
|
1651
|
-
* distinct `routed_to` values since a given timestamp. Used by
|
|
1652
|
-
* cluster-round-robin to prove at least 2 orchestrators received
|
|
1653
|
-
* deliveries. Returns the observed count (0 if timed out).
|
|
1654
|
-
*/
|
|
1655
|
-
export declare function waitForPlatformEventLogDistinctRoutedDirect(databaseUrl: string, opts: {
|
|
1656
|
-
since: Date;
|
|
1657
|
-
minDistinctRouted: number;
|
|
1658
|
-
timeoutMs?: number;
|
|
1659
|
-
intervalMs?: number;
|
|
1660
|
-
}): Promise<{
|
|
1661
|
-
distinctRouted: number;
|
|
1662
|
-
}>;
|
|
1663
693
|
/**
|
|
1664
694
|
* Wait for an orchestrator `event_log` row keyed by `delivery_id`.
|
|
1665
695
|
* Returns the full row (the webhook-pipeline e2e asserts many
|
|
@@ -1679,114 +709,5 @@ export interface EventLogRow {
|
|
|
1679
709
|
matched_count: number;
|
|
1680
710
|
run_id: string | null;
|
|
1681
711
|
}
|
|
1682
|
-
export declare function waitForEventLogRowByDeliveryIdDirect(databaseUrl: string, opts: {
|
|
1683
|
-
deliveryId: string;
|
|
1684
|
-
timeoutMs?: number;
|
|
1685
|
-
intervalMs?: number;
|
|
1686
|
-
}): Promise<EventLogRow | null>;
|
|
1687
|
-
/**
|
|
1688
|
-
* Resolve a Platform `webhook_sources.routing_key` for an org.
|
|
1689
|
-
*
|
|
1690
|
-
* - With `routingKeyLikePrefix` only: returns the newest match. Note that
|
|
1691
|
-
* this picks whichever generic source was registered most recently — if
|
|
1692
|
-
* tests have created additional generic sources (e.g. universal-git-forgejo
|
|
1693
|
-
* creating `stg-universal-git-forgejo`), the newest may NOT be the
|
|
1694
|
-
* `stg-generic` default seeded by `pnpm deploy:stg`.
|
|
1695
|
-
* - With `orchDbUrl` + `nameInOrchDb`: looks up the source by name in the
|
|
1696
|
-
* orchestrator's `generic_webhook_sources` table, then verifies the
|
|
1697
|
-
* resulting routing key is registered in Platform's `webhook_sources`.
|
|
1698
|
-
* This is the disambiguating path Bucket-B tests should use when other
|
|
1699
|
-
* generic sources may exist alongside the default.
|
|
1700
|
-
*/
|
|
1701
|
-
export declare function resolvePlatformWebhookSourceRoutingKeyDirect(platformDbUrl: string, opts: {
|
|
1702
|
-
orgId: string;
|
|
1703
|
-
routingKeyLikePrefix: string;
|
|
1704
|
-
orchDbUrl?: string;
|
|
1705
|
-
nameInOrchDb?: string;
|
|
1706
|
-
}): Promise<string | null>;
|
|
1707
|
-
/**
|
|
1708
|
-
* Idempotent seeding of an E2E regular user + org membership + owner
|
|
1709
|
-
* role on the Platform DB. Used by stg-ha-smoke before seeding a user
|
|
1710
|
-
* API key. Requires the org to already have an owner role.
|
|
1711
|
-
*/
|
|
1712
|
-
export declare function ensureOrgOwnerMemberDirect(platformDbUrl: string, opts: {
|
|
1713
|
-
orgId: string;
|
|
1714
|
-
idpSub: string;
|
|
1715
|
-
email: string;
|
|
1716
|
-
displayName: string;
|
|
1717
|
-
}): Promise<{
|
|
1718
|
-
ownerRoleId: string;
|
|
1719
|
-
}>;
|
|
1720
|
-
/**
|
|
1721
|
-
* Cleanup peer_credentials by instance_id LIKE pattern. Used by the
|
|
1722
|
-
* cluster-peer-credentials e2e before/after each test to wipe its
|
|
1723
|
-
* own seeded rows without touching real cluster credentials.
|
|
1724
|
-
*/
|
|
1725
|
-
export declare function deletePeerCredentialsByInstanceIdLikeDirect(databaseUrl: string, opts: {
|
|
1726
|
-
pattern: string;
|
|
1727
|
-
}): Promise<{
|
|
1728
|
-
deleted: number;
|
|
1729
|
-
}>;
|
|
1730
|
-
/**
|
|
1731
|
-
* Insert a peer_credentials row with an explicit expires_at. Used by
|
|
1732
|
-
* the "expired credential is not returned" e2e — the store's save()
|
|
1733
|
-
* always computes a future expiry, so tests that need a pre-expired
|
|
1734
|
-
* row must bypass it.
|
|
1735
|
-
*/
|
|
1736
|
-
export declare function insertPeerCredentialExpiredDirect(databaseUrl: string, opts: {
|
|
1737
|
-
instanceId: string;
|
|
1738
|
-
credentialHash: string;
|
|
1739
|
-
role: string;
|
|
1740
|
-
routingKeys: readonly string[];
|
|
1741
|
-
expiresAt: Date;
|
|
1742
|
-
}): Promise<void>;
|
|
1743
|
-
/**
|
|
1744
|
-
* READ-ONLY: `revoked_at` for a peer_credentials row by hash. Used
|
|
1745
|
-
* by the "save revokes old credential" e2e to assert revocation.
|
|
1746
|
-
* Returns null when the row is missing entirely (distinct from
|
|
1747
|
-
* "present but not revoked").
|
|
1748
|
-
*/
|
|
1749
|
-
export declare function getPeerCredentialRevokedAtDirect(databaseUrl: string, opts: {
|
|
1750
|
-
credentialHash: string;
|
|
1751
|
-
}): Promise<{
|
|
1752
|
-
present: boolean;
|
|
1753
|
-
revokedAt: Date | null;
|
|
1754
|
-
}>;
|
|
1755
|
-
/**
|
|
1756
|
-
* READ-ONLY: list active peer_credentials ids EXCLUDING a
|
|
1757
|
-
* `instance_id LIKE` pattern. Used by revokeAll e2e to snapshot
|
|
1758
|
-
* real cluster credentials it will restore later.
|
|
1759
|
-
*/
|
|
1760
|
-
export declare function listActivePeerCredentialsExcludingDirect(databaseUrl: string, opts: {
|
|
1761
|
-
excludeInstanceIdPattern: string;
|
|
1762
|
-
}): Promise<{
|
|
1763
|
-
ids: string[];
|
|
1764
|
-
}>;
|
|
1765
|
-
/**
|
|
1766
|
-
* Clear revoked_at on a set of peer_credentials ids. Used by revokeAll
|
|
1767
|
-
* e2e to restore real cluster credentials after the destructive test.
|
|
1768
|
-
*/
|
|
1769
|
-
export declare function clearPeerCredentialsRevokedAtByIdsDirect(databaseUrl: string, opts: {
|
|
1770
|
-
ids: readonly string[];
|
|
1771
|
-
}): Promise<{
|
|
1772
|
-
updated: number;
|
|
1773
|
-
}>;
|
|
1774
|
-
/**
|
|
1775
|
-
* READ-ONLY: count currently-active (non-revoked, non-expired)
|
|
1776
|
-
* peer_credentials rows for a given instance_id. Used by the
|
|
1777
|
-
* concurrent-save e2e to assert 1 <= count <= 2.
|
|
1778
|
-
*/
|
|
1779
|
-
export declare function countActivePeerCredentialsByInstanceDirect(databaseUrl: string, opts: {
|
|
1780
|
-
instanceId: string;
|
|
1781
|
-
}): Promise<number>;
|
|
1782
|
-
/**
|
|
1783
|
-
* Terminate every idle backend of the connecting user except our own
|
|
1784
|
-
* connection. Mirrors what a Postgres leader demotion does to idle pooled
|
|
1785
|
-
* connections — used by resilience tests to verify the pg pool error
|
|
1786
|
-
* handlers absorb the termination without a process restart.
|
|
1787
|
-
*
|
|
1788
|
-
* Returns the number of backends terminated.
|
|
1789
|
-
*/
|
|
1790
|
-
export declare function terminateIdleDbBackendsDirect(databaseUrl: string): Promise<number>;
|
|
1791
712
|
export {};
|
|
1792
713
|
//# sourceMappingURL=db-admin.d.ts.map
|