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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  import type { ForgejoGitIdentity, ForgejoIntegration, ForgejoRepository } from "@leitwerk-dev/forgejo";
2
- import type { GitSshIntegration } from "@leitwerk-dev/git-ssh";
3
- import { type LaunchPreparationCheck, type ProcessLaunchConfig, type ProcessLauncherDefinition } from "@leitwerk-dev/process-sdk";
2
+ import { type GitSshIntegration } from "@leitwerk-dev/git-ssh";
3
+ import type { LaunchPreparationCheck, ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
4
4
  import type { WoodpeckerIntegration } from "@leitwerk-dev/woodpecker";
5
5
  import { type ForgejoRepoChangeParams } from "./params.js";
6
6
  import { type ProfileBindings } from "./profile-bindings.js";
@@ -43,6 +43,13 @@ export declare function createForgejoRepoChangeLauncher(): {
43
43
  /** @internal */
44
44
  resolveGitIdentity: (profile: string) => Promise<ForgejoGitIdentity>;
45
45
  /** @internal */
46
- launcher: ProcessLauncherDefinition<ForgejoRepoChangeParams>;
46
+ launcher: import("@leitwerk-dev/process-sdk").ProcessLauncherDefinition<ForgejoRepoChangeParams> & {
47
+ resolveIssueLaunchConfig(event: {
48
+ profile: string;
49
+ repository: ForgejoRepository;
50
+ issue: Pick<import("@leitwerk-dev/forgejo").ForgejoIssue, "number" | "title" | "body" | "html_url">;
51
+ labels: import("@leitwerk-dev/process-sdk").RepositoryIssueWatcherConfig["labels"];
52
+ }): Promise<ProcessLaunchConfig<ForgejoRepoChangeParams>>;
53
+ };
47
54
  };
48
55
  //# sourceMappingURL=launcher.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACX,kBAAkB,EAClB,kBAAkB,EAClB,iBAAiB,EACjB,MAAM,uBAAuB,CAAC;A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AmB,CAAC,uBAAuB,CAAC,CA6B9C;AAED,gBAAgB;AAChB,MAAM,WAAW,oBAAoB;IACpC,gBAAgB;IAChB,OAAO,EAAE,kBAAkB,CAAC;IAC5B,gBAAgB;IAChB,MAAM,EAAE,iBAAiB,CAAC;IAC1B,gBAAgB;IAChB,UAAU,EAAE,qBAAqB,CAAC;IAClC,gBAAgB;IAChB,eAAe,CAAC,EAAE,eAAe,CAAC;CAClC;AAED,gBAAgB;AAChB,wBAAgB,+BAA+B;IAwE7C,gBAAgB;uBApEkC,oBAAoB,GAAG,IAAI,KAAG,IAAI;IAsEpF,gBAAgB;gCA3DR,OAAO,cACH,mBAAmB,CAAC,uBAAuB,CAAC,KACtD,SAAS,sBAAsB,CAAC,uBAAuB,CAAC,EAAE;IA2D5D,gBAAgB;+BA9CiB,MAAM;IAgDvC,gBAAgB;kCAjCiC,MAAM,KAAG,OAAO,CAAC,kBAAkB,CAAC;IAmCrF,gBAAgB;;;;;;;;;EAGjB"}
package/dist/params.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { type RepositoryChangeLaunchParams } from "@leitwerk-dev/coding/repository-change-launch";
1
+ import { type RepositoryChangeLaunchParams, type RepositoryIssueOriginParams, type RepositoryUiOriginParams } from "@leitwerk-dev/coding/repository-change-launch";
2
2
  /** @public */
3
3
  interface ForgejoRepoChangeCommonParams {
4
4
  /** @internal */
@@ -13,30 +13,10 @@ interface ForgejoRepoChangeCommonParams {
13
13
  repo: string;
14
14
  }
15
15
  /** @public */
16
- export interface ForgejoIssueOriginParams {
17
- /** @internal */
18
- origin: "issue";
19
- /** @internal */
20
- issueNumber: number;
21
- /** @internal */
22
- issueUrl: string;
23
- /** @internal */
24
- triggerLabel: string;
25
- /** @internal */
26
- doneLabel: string;
16
+ export interface ForgejoIssueOriginParams extends RepositoryIssueOriginParams {
27
17
  }
28
18
  /** @public */
29
- export interface ForgejoUiOriginParams {
30
- /** @internal */
31
- origin: "ui";
32
- /** @internal */
33
- issueNumber: null;
34
- /** @internal */
35
- issueUrl: null;
36
- /** @internal */
37
- triggerLabel: null;
38
- /** @internal */
39
- doneLabel: null;
19
+ export interface ForgejoUiOriginParams extends RepositoryUiOriginParams {
40
20
  }
41
21
  /** @public */
42
22
  export type ForgejoRepoChangeParams = RepositoryChangeLaunchParams<ForgejoRepoChangeCommonParams & (ForgejoIssueOriginParams | ForgejoUiOriginParams)>;
@@ -1 +1 @@
1
- {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../src/params.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,4BAA4B,EAEjC,MAAM,+CAA+C,CAAC;AAGvD,cAAc;AACd,UAAU,6BAA6B;IACtC,gBAAgB;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,cAAc;AACd,MAAM,WAAW,wBAAwB;IACxC,gBAAgB;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,gBAAgB;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB;IAChB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,cAAc;AACd,MAAM,WAAW,qBAAqB;IACrC,gBAAgB;IAChB,MAAM,EAAE,IAAI,CAAC;IACb,gBAAgB;IAChB,WAAW,EAAE,IAAI,CAAC;IAClB,gBAAgB;IAChB,QAAQ,EAAE,IAAI,CAAC;IACf,gBAAgB;IAChB,YAAY,EAAE,IAAI,CAAC;IACnB,gBAAgB;IAChB,SAAS,EAAE,IAAI,CAAC;CAChB;AAED,cAAc;AACd,MAAM,MAAM,uBAAuB,GAAG,4BAA4B,CACjE,6BAA6B,GAAG,CAAC,wBAAwB,GAAG,qBAAqB,CAAC,CAClF,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,aAAa,CAC5B,MAAM,EAAE,uBAAuB,GAC7B,MAAM,IAAI,uBAAuB,GAAG,wBAAwB,CAE9D;AAED,gBAAgB;AAChB,eAAO,MAAM,4BAA4B,oEAiDtC,CAAC"}
1
+ {"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../src/params.ts"],"names":[],"mappings":"AAAA,OAAO,EAGN,KAAK,4BAA4B,EACjC,KAAK,2BAA2B,EAChC,KAAK,wBAAwB,EAC7B,MAAM,+CAA+C,CAAC;AAEvD,cAAc;AACd,UAAU,6BAA6B;IACtC,gBAAgB;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,gBAAgB;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB;IAChB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;CACb;AAED,cAAc;AACd,MAAM,WAAW,wBAAyB,SAAQ,2BAA2B;CAAG;AAEhF,cAAc;AACd,MAAM,WAAW,qBAAsB,SAAQ,wBAAwB;CAAG;AAE1E,cAAc;AACd,MAAM,MAAM,uBAAuB,GAAG,4BAA4B,CACjE,6BAA6B,GAAG,CAAC,wBAAwB,GAAG,qBAAqB,CAAC,CAClF,CAAC;AAEF,gBAAgB;AAChB,wBAAgB,aAAa,CAC5B,MAAM,EAAE,uBAAuB,GAC7B,MAAM,IAAI,uBAAuB,GAAG,wBAAwB,CAE9D;AAED,gBAAgB;AAChB,eAAO,MAAM,4BAA4B,oEAWtC,CAAC"}
package/dist/process.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import type { RepositoryChangeState } from "@leitwerk-dev/coding/repository-change-state";
2
- import { type createForgejoRepoChangeLauncher } from "./launcher.js";
2
+ import type { createForgejoRepoChangeLauncher } from "./launcher.js";
3
3
  import { type ForgejoRepoChangeParams } from "./params.js";
4
4
  /** @internal */
5
5
  export declare function createForgejoRepoChangeProcess(launcher: ReturnType<typeof createForgejoRepoChangeLauncher>, docker: boolean): import("@leitwerk-dev/process-sdk").ExtensionProcessDefinition<ForgejoRepoChangeParams, RepositoryChangeState>;
@@ -1 +1 @@
1
- {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAS1F,OAAO,EACN,KAAK,+BAA+B,EAGpC,MAAM,eAAe,CAAC;AACvB,OAAO,EAEN,KAAK,uBAAuB,EAG5B,MAAM,aAAa,CAAC;AA8DrB,gBAAgB;AAChB,wBAAgB,8BAA8B,CAC7C,QAAQ,EAAE,UAAU,CAAC,OAAO,+BAA+B,CAAC,EAC5D,MAAM,EAAE,OAAO,kHA2Sf"}
1
+ {"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../src/process.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AAG1F,OAAO,KAAK,EAAE,+BAA+B,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,EACN,KAAK,uBAAuB,EAG5B,MAAM,aAAa,CAAC;AAwBrB,gBAAgB;AAChB,wBAAgB,8BAA8B,CAC7C,QAAQ,EAAE,UAAU,CAAC,OAAO,+BAA+B,CAAC,EAC5D,MAAM,EAAE,OAAO,kHAmIf"}
@@ -1 +1 @@
1
- {"version":3,"file":"profile-bindings.d.ts","sourceRoot":"","sources":["../src/profile-bindings.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,MAAM,WAAW,cAAc;IAC9B,gBAAgB;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB;IAChB,gBAAgB,EAAE,MAAM,CAAC;CACzB;AACD,gBAAgB;AAChB,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AAajF,gBAAgB;AAChB,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,CA8BlE;AACD,gBAAgB;AAChB,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAIhG"}
1
+ {"version":3,"file":"profile-bindings.d.ts","sourceRoot":"","sources":["../src/profile-bindings.ts"],"names":[],"mappings":"AAEA,qEAAqE;AACrE,MAAM,WAAW,cAAc;IAC9B,gBAAgB;IAChB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB;IAChB,gBAAgB,EAAE,MAAM,CAAC;CACzB;AACD,gBAAgB;AAChB,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;AAEjF,gBAAgB;AAChB,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,eAAe,CAKlE;AACD,gBAAgB;AAChB,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAIhG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leitwerk-dev/forgejo-repo-change",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
5
  "leitwerk": {
6
6
  "extension": {
@@ -20,13 +20,12 @@
20
20
  "build": "tsup && tsc -p tsconfig.tsup.json --emitDeclarationOnly"
21
21
  },
22
22
  "dependencies": {
23
- "@leitwerk-dev/coding": "0.3.0",
24
- "@leitwerk-dev/external-writes": "0.3.0",
25
- "@leitwerk-dev/git-ssh": "0.3.0",
26
- "@leitwerk-dev/process-sdk": "0.3.0",
27
- "@leitwerk-dev/forgejo": "0.3.0",
28
- "@leitwerk-dev/woodpecker": "0.3.0",
29
- "@leitwerk-dev/repository-rebase": "0.3.0"
23
+ "@leitwerk-dev/coding": "0.3.1",
24
+ "@leitwerk-dev/external-writes": "0.3.1",
25
+ "@leitwerk-dev/git-ssh": "0.3.1",
26
+ "@leitwerk-dev/process-sdk": "0.3.1",
27
+ "@leitwerk-dev/forgejo": "0.3.1",
28
+ "@leitwerk-dev/woodpecker": "0.3.1"
30
29
  },
31
30
  "devDependencies": {
32
31
  "tsup": "^8.5.1"
package/src/launcher.ts CHANGED
@@ -1,18 +1,14 @@
1
- import { buildAutoWorkBranchFromSeed } from "@leitwerk-dev/coding/auto-work-branch";
2
- import { trimString } from "@leitwerk-dev/domain";
1
+ import {
2
+ createRepositoryChangeUiLauncher,
3
+ repositoryVisibilityCheck,
4
+ } from "@leitwerk-dev/coding/repository-change-launch";
3
5
  import type {
4
6
  ForgejoGitIdentity,
5
7
  ForgejoIntegration,
6
8
  ForgejoRepository,
7
9
  } from "@leitwerk-dev/forgejo";
8
- import type { GitSshIntegration } from "@leitwerk-dev/git-ssh";
9
- import {
10
- type LauncherValidationError,
11
- type LaunchPreparationCheck,
12
- type ProcessLaunchConfig,
13
- type ProcessLauncherDefinition,
14
- SafeLaunchPreparationError,
15
- } from "@leitwerk-dev/process-sdk";
10
+ import { createGitSshPreparationCheck, type GitSshIntegration } from "@leitwerk-dev/git-ssh";
11
+ import type { LaunchPreparationCheck, ProcessLaunchConfig } from "@leitwerk-dev/process-sdk";
16
12
  import type { WoodpeckerIntegration } from "@leitwerk-dev/woodpecker";
17
13
  import { type ForgejoRepoChangeParams, isIssueOrigin } from "./params.js";
18
14
  import { type ProfileBindings, resolveProfileBinding } from "./profile-bindings.js";
@@ -116,70 +112,22 @@ export function createForgejoRepoChangeLauncher() {
116
112
  return dependencies;
117
113
  }
118
114
 
119
- function sshPreparationCheck(
120
- access: "read" | "write",
121
- params: ForgejoRepoChangeParams,
122
- ): LaunchPreparationCheck<ForgejoRepoChangeParams> {
123
- return {
124
- id: `ssh_${access}`,
125
- label: `Verify SSH ${access} access`,
126
- async run({ signal, logger }) {
127
- signal.throwIfAborted();
128
- const result = await requireDependencies().gitSsh.preflight({
129
- credentialRef: params.sshCredentialRef,
130
- repoLocator: params.repoLocator,
131
- baseBranch: params.baseBranch,
132
- requireWrite: access === "write",
133
- });
134
- signal.throwIfAborted();
135
- if (!result.ok) {
136
- logger.warn(`Git SSH ${result.access} preflight failed: ${result.detail}`);
137
- throw new SafeLaunchPreparationError(
138
- `SSH ${result.access} access failed: ${result.detail}`,
139
- `Authorize Git SSH profile '${params.sshCredentialRef}' for '${params.owner}/${params.repo}' with read/write access, then try again.`,
140
- );
141
- }
142
- },
143
- };
144
- }
145
-
146
115
  /** @internal */
147
116
  function forgejoRepositoryPreparationChecks(
148
117
  _input: unknown,
149
118
  { params }: ProcessLaunchConfig<ForgejoRepoChangeParams>,
150
119
  ): readonly LaunchPreparationCheck<ForgejoRepoChangeParams>[] {
151
120
  return [
152
- {
153
- id: "repository_visibility",
154
- label: "Check repository visibility",
155
- async run({ signal }) {
156
- signal.throwIfAborted();
157
- const repositoryName = `${params.owner}/${params.repo}`;
158
- const visible = (await repositories(params.forgejoProfile)).some(
159
- (candidate) => candidate.full_name === repositoryName,
160
- );
161
- signal.throwIfAborted();
162
- if (!visible) {
163
- throw new SafeLaunchPreparationError(
164
- "Repository is not visible",
165
- "Grant the selected Forgejo profile access to the repository, then try again.",
166
- );
167
- }
168
- },
169
- },
170
- sshPreparationCheck("read", params),
171
- sshPreparationCheck("write", params),
121
+ repositoryVisibilityCheck("Forgejo", async () =>
122
+ (await repositories(params.forgejoProfile)).some(
123
+ (candidate) => candidate.full_name === `${params.owner}/${params.repo}`,
124
+ ),
125
+ ),
126
+ createGitSshPreparationCheck("read", params, () => requireDependencies().gitSsh),
127
+ createGitSshPreparationCheck("write", params, () => requireDependencies().gitSsh),
172
128
  ];
173
129
  }
174
130
 
175
- function validationError(
176
- fieldId: string,
177
- message: string,
178
- code: LauncherValidationError["code"] = "required",
179
- ): LauncherValidationError {
180
- return { code, fieldId, message };
181
- }
182
-
183
131
  /** @internal */
184
132
  function resolveProfiles(profile: string) {
185
133
  const { forgejo, woodpecker, gitSsh, profileBindings = {} } = requireDependencies();
@@ -208,123 +156,19 @@ export function createForgejoRepoChangeLauncher() {
208
156
  return forgejo.client(profile).listRepositories();
209
157
  }
210
158
 
211
- const forgejoRepoChangeUiLauncher: ProcessLauncherDefinition<ForgejoRepoChangeParams> = {
159
+ const forgejoRepoChangeUiLauncher = createRepositoryChangeUiLauncher({
212
160
  id: forgejoRepoChangeUiLauncherId,
213
- label: "Forgejo Repo Change",
214
- description: "Plan, implement, review, and publish a Forgejo change without a source issue",
215
- visibility: "ui",
216
- ui: {
217
- card: {
218
- title: "Forgejo Repo Change",
219
- description: "Start a repository change and publish it as a Forgejo pull request.",
220
- },
221
- launchConfigSchema: {
222
- id: "forgejo_repo_change_form",
223
- title: "Forgejo Repo Change",
224
- fields: [
225
- {
226
- id: "forgejoProfile",
227
- label: "Forgejo profile",
228
- kind: "select",
229
- required: true,
230
- description: "Forgejo profile with server-configured CI and Git SSH access.",
231
- },
232
- {
233
- id: "repository",
234
- label: "Repository",
235
- kind: "select",
236
- required: true,
237
- description: "Repository visible to the selected Forgejo profile.",
238
- },
239
- {
240
- id: "prompt",
241
- label: "Requested change",
242
- kind: "textarea",
243
- required: true,
244
- placeholder: "Describe the change to plan, implement, review, and publish.",
245
- },
246
- ],
247
- submitLabel: "Start change",
248
- },
249
- resolveDefaults() {
250
- return {
251
- forgejoProfile: requireDependencies().forgejo.profiles()[0] ?? "",
252
- repository: "",
253
- prompt: "",
254
- };
255
- },
256
- async resolveOptions(input) {
257
- const { forgejo } = requireDependencies();
258
- const profile = trimString(input.forgejoProfile);
259
- return {
260
- forgejoProfile: forgejo.profiles().map((value) => ({ value, label: value })),
261
- repository: (await repositories(profile)).map((repository) => ({
262
- value: repository.full_name,
263
- label: repository.full_name,
264
- description: repository.html_url,
265
- })),
266
- };
267
- },
268
- preparationChecks: forgejoRepositoryPreparationChecks,
269
- resolveRelaunchInput(previousInput) {
270
- return {
271
- forgejoProfile: trimString(previousInput.forgejoProfile),
272
- repository: trimString(previousInput.repository),
273
- prompt: trimString(previousInput.prompt),
274
- };
275
- },
276
- async resolveLaunchConfig(input) {
277
- const profile = trimString(input.forgejoProfile);
278
- const repositoryName = trimString(input.repository);
279
- const prompt = trimString(input.prompt);
280
- const errors: LauncherValidationError[] = [];
281
- const invalid = (fieldId: string, message: string) => ({
282
- ok: false as const,
283
- errors: [validationError(fieldId, message, "custom_rule")],
284
- });
285
- const { forgejo } = requireDependencies();
286
- if (!profile) errors.push(validationError("forgejoProfile", "Forgejo profile is required"));
287
- else if (!forgejo.profiles().includes(profile))
288
- errors.push(
289
- validationError("forgejoProfile", "Forgejo profile is not available", "custom_rule"),
290
- );
291
- if (!repositoryName) errors.push(validationError("repository", "Repository is required"));
292
- if (!prompt) errors.push(validationError("prompt", "Requested change is required"));
293
- if (errors.length > 0) return { ok: false, errors };
294
-
295
- const repository = (await repositories(profile)).find(
296
- (candidate) => candidate.full_name === repositoryName,
297
- );
298
- if (!repository)
299
- return invalid(
300
- "repository",
301
- "Repository is not available to the selected Forgejo profile",
302
- );
303
-
304
- let binding: ReturnType<typeof resolveProfiles>;
305
- try {
306
- binding = resolveProfiles(profile);
307
- } catch (error) {
308
- return invalid("forgejoProfile", (error as Error).message);
309
- }
310
- const gitIdentity = await resolveForgejoGitIdentity(profile);
311
- const workBranch = buildAutoWorkBranchFromSeed(
312
- prompt,
313
- `${repository.ssh_url}:${repository.default_branch}`,
314
- );
315
- const params = forgejoRepoChangeParams(repository, {
316
- ...binding,
317
- profile,
318
- prompt,
319
- workBranch,
320
- });
321
- return {
322
- ok: true,
323
- launchConfig: forgejoRepoChangeLaunchConfig(params, prompt, gitIdentity),
324
- };
325
- },
326
- },
327
- };
161
+ provider: "Forgejo",
162
+ providerId: "forgejo",
163
+ assertConfigured: requireDependencies,
164
+ profiles: () => requireDependencies().forgejo.profiles(),
165
+ repositories,
166
+ resolveProfiles,
167
+ resolveGitIdentity: resolveForgejoGitIdentity,
168
+ params: forgejoRepoChangeParams,
169
+ launchConfig: forgejoRepoChangeLaunchConfig,
170
+ preparationChecks: forgejoRepositoryPreparationChecks,
171
+ });
328
172
 
329
173
  return {
330
174
  /** @internal */
package/src/params.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  createRepositoryChangeParamsCodec,
3
- normalizeRepositoryChangeParamsInput,
3
+ normalizeRepositoryIssueChangeParams,
4
4
  type RepositoryChangeLaunchParams,
5
- repositoryChangeParamsRecord,
5
+ type RepositoryIssueOriginParams,
6
+ type RepositoryUiOriginParams,
6
7
  } from "@leitwerk-dev/coding/repository-change-launch";
7
- import { trimString } from "@leitwerk-dev/domain";
8
8
 
9
9
  /** @public */
10
10
  interface ForgejoRepoChangeCommonParams {
@@ -21,32 +21,10 @@ interface ForgejoRepoChangeCommonParams {
21
21
  }
22
22
 
23
23
  /** @public */
24
- export interface ForgejoIssueOriginParams {
25
- /** @internal */
26
- origin: "issue";
27
- /** @internal */
28
- issueNumber: number;
29
- /** @internal */
30
- issueUrl: string;
31
- /** @internal */
32
- triggerLabel: string;
33
- /** @internal */
34
- doneLabel: string;
35
- }
24
+ export interface ForgejoIssueOriginParams extends RepositoryIssueOriginParams {}
36
25
 
37
26
  /** @public */
38
- export interface ForgejoUiOriginParams {
39
- /** @internal */
40
- origin: "ui";
41
- /** @internal */
42
- issueNumber: null;
43
- /** @internal */
44
- issueUrl: null;
45
- /** @internal */
46
- triggerLabel: null;
47
- /** @internal */
48
- doneLabel: null;
49
- }
27
+ export interface ForgejoUiOriginParams extends RepositoryUiOriginParams {}
50
28
 
51
29
  /** @public */
52
30
  export type ForgejoRepoChangeParams = RepositoryChangeLaunchParams<
@@ -64,50 +42,12 @@ export function isIssueOrigin(
64
42
  export const forgejoRepoChangeParamsCodec =
65
43
  createRepositoryChangeParamsCodec<ForgejoRepoChangeParams>({
66
44
  normalize(value) {
67
- const shared = normalizeRepositoryChangeParamsInput(value, "Forgejo Repo Change");
68
- const record = repositoryChangeParamsRecord(value, "Forgejo Repo Change");
69
- const text = (name: string) => {
70
- const value = trimString(record[name]);
71
- if (!value) throw new Error(`Forgejo Repo Change requires ${name}`);
72
- return value;
73
- };
74
-
75
- const common = {
76
- ...shared,
77
- forgejoProfile: text("forgejoProfile"),
78
- woodpeckerProfile: text("woodpeckerProfile"),
79
- sshCredentialRef: text("sshCredentialRef"),
80
- owner: text("owner"),
81
- repo: text("repo"),
82
- };
83
- const origin = trimString(record.origin);
84
- if (origin === "ui") {
85
- return {
86
- ...common,
87
- origin: "ui" as const,
88
- issueNumber: null,
89
- issueUrl: null,
90
- triggerLabel: null,
91
- doneLabel: null,
92
- };
93
- }
94
- if (origin && origin !== "issue") {
95
- throw new Error("Forgejo Repo Change requires a valid origin");
96
- }
97
-
98
- if (
99
- typeof record.issueNumber !== "number" ||
100
- !Number.isInteger(record.issueNumber) ||
101
- record.issueNumber <= 0
102
- )
103
- throw new Error("Forgejo Repo Change requires issueNumber");
104
- return {
105
- ...common,
106
- origin: "issue" as const,
107
- issueNumber: record.issueNumber,
108
- issueUrl: text("issueUrl"),
109
- triggerLabel: text("triggerLabel"),
110
- doneLabel: text("doneLabel"),
111
- };
45
+ return normalizeRepositoryIssueChangeParams(value, "Forgejo Repo Change", [
46
+ "forgejoProfile",
47
+ "woodpeckerProfile",
48
+ "sshCredentialRef",
49
+ "owner",
50
+ "repo",
51
+ ]);
112
52
  },
113
53
  });