@leitwerk-dev/forgejo-repo-change 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,8 +1,11 @@
1
- /** Server-owned, non-secret wiring for future launches. */
1
+ /** Server-owned, non-secret wiring for future launches. @internal */
2
2
  export interface ProfileBinding {
3
+ /** @internal */
3
4
  woodpeckerProfile: string;
5
+ /** @internal */
4
6
  sshCredentialRef: string;
5
7
  }
8
+ /** @internal */
6
9
  export type ProfileBindings = Readonly<Record<string, Readonly<ProfileBinding>>>;
7
10
 
8
11
  function record(value: unknown, label: string): Record<string, unknown> {
@@ -16,6 +19,7 @@ function field(value: unknown, fallback: string, label: string): string {
16
19
  throw new Error(`${label} must be a non-empty string`);
17
20
  return value.trim();
18
21
  }
22
+ /** @internal */
19
23
  export function parseProfileBindings(raw: unknown): ProfileBindings {
20
24
  const config = raw === undefined ? {} : record(raw, "forgejo-repo-change configuration");
21
25
  if (config.profile_bindings === undefined) return Object.freeze({});
@@ -47,6 +51,7 @@ export function parseProfileBindings(raw: unknown): ProfileBindings {
47
51
  });
48
52
  return Object.freeze(Object.fromEntries(entries));
49
53
  }
54
+ /** @internal */
50
55
  export function resolveProfileBinding(bindings: ProfileBindings, profile: string): ProfileBinding {
51
56
  return Object.hasOwn(bindings, profile)
52
57
  ? { ...bindings[profile] }
@@ -0,0 +1,14 @@
1
+ import { forgejoRepoChangeProcess as process } from "./testing/default-process.js";
2
+
3
+ export function deliveryTurn() {
4
+ const turn = process.turns.get("deliver_change")?.definition;
5
+ if (turn?.kind !== "automatic") throw new Error("Missing delivery turn");
6
+ return turn;
7
+ }
8
+
9
+ export function routingState(
10
+ forgejoRepoChange: Record<string, unknown>,
11
+ extensionState: Record<string, unknown> = {},
12
+ ) {
13
+ return process.stateCodec.parse({ extensionState: { ...extensionState, forgejoRepoChange } });
14
+ }