@leitwerk-dev/woodpecker 0.2.0 → 0.2.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/README.md +19 -0
- package/dist/binding.d.ts +1 -1
- package/dist/binding.d.ts.map +1 -1
- package/dist/capability.d.ts +4 -1
- package/dist/capability.d.ts.map +1 -1
- package/dist/client.d.ts +31 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/external.d.ts +15 -0
- package/dist/external.d.ts.map +1 -1
- package/dist/index.d.ts +11 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +23 -15
- package/dist/index.js.map +1 -1
- package/dist/provider.d.ts +3 -1
- package/dist/provider.d.ts.map +1 -1
- package/dist/testing.d.ts +44 -3
- package/dist/testing.d.ts.map +1 -1
- package/dist/testing.js +26 -1
- package/dist/testing.js.map +1 -1
- package/dist/tools.d.ts +1 -2
- package/dist/tools.d.ts.map +1 -1
- package/package.json +5 -6
- package/src/binding.ts +1 -1
- package/src/capability.ts +4 -1
- package/src/client.ts +39 -3
- package/src/external.ts +19 -1
- package/src/index.ts +19 -8
- package/src/testing.ts +55 -5
- package/src/tools.ts +2 -10
package/README.md
CHANGED
|
@@ -62,3 +62,22 @@ A newest pending match continues waiting even if an older match is terminal.
|
|
|
62
62
|
An inconclusive scan reports a lookup-window error; inspect repository history
|
|
63
63
|
and adjust the watched pipeline floor before retrying. No match within exhausted
|
|
64
64
|
history is an ordinary wait for a future pipeline.
|
|
65
|
+
|
|
66
|
+
## API support
|
|
67
|
+
|
|
68
|
+
The following exported declarations are `@public`:
|
|
69
|
+
|
|
70
|
+
- `@leitwerk-dev/woodpecker`: `WoodpeckerClient`, `WoodpeckerClientLike`, `WoodpeckerIntegration`, `WoodpeckerPipeline`, `WoodpeckerProjectBinding`, `WoodpeckerRepository`, `default`, `setupWoodpeckerIntegration`.
|
|
71
|
+
- `@leitwerk-dev/woodpecker/testing`: `LocalWoodpeckerAdapter`, `LocalWoodpeckerOptions`, `LocalWoodpeckerRepository`, `LocalWoodpeckerState`.
|
|
72
|
+
|
|
73
|
+
Members have individual classifications; these exports do not make every member
|
|
74
|
+
public. Both `@public` and `@internal` APIs remain usable and fully typed. Source
|
|
75
|
+
annotations are authoritative; see the [SDK compatibility
|
|
76
|
+
policy](../../docs/process-sdk.md#api-compatibility).
|
|
77
|
+
|
|
78
|
+
### External-write replay
|
|
79
|
+
|
|
80
|
+
Pipeline restart uses `ctx.externalWrites.logOnly()` and returns `{ ok: true }`.
|
|
81
|
+
The durable record includes diagnosis metadata and prevents a recorded restart
|
|
82
|
+
from repeating. Lost responses and remote success followed by recording failure
|
|
83
|
+
cannot be recovered. Pipeline status is not evidence that a restart occurred.
|
package/dist/binding.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { resolveRepositoryProjectBinding } from "@leitwerk-dev/process-sdk";
|
|
2
|
-
|
|
2
|
+
/** @internal */
|
|
3
3
|
export declare const resolveWoodpeckerProjectBinding: (ctx: Parameters<typeof resolveRepositoryProjectBinding>[0]) => import("@leitwerk-dev/process-sdk").RepositoryProjectBinding;
|
|
4
4
|
//# sourceMappingURL=binding.d.ts.map
|
package/dist/binding.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAE5E,
|
|
1
|
+
{"version":3,"file":"binding.d.ts","sourceRoot":"","sources":["../src/binding.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC;AAE5E,gBAAgB;AAChB,eAAO,MAAM,+BAA+B,GAC3C,KAAK,UAAU,CAAC,OAAO,+BAA+B,CAAC,CAAC,CAAC,CAAC,iEACO,CAAC"}
|
package/dist/capability.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import type { WoodpeckerClient } from "./client.js";
|
|
2
|
-
/** Public contract shared by HTTP and local adapters. */
|
|
2
|
+
/** Public contract shared by HTTP and local adapters. @public */
|
|
3
3
|
export type WoodpeckerClientLike = Pick<WoodpeckerClient, keyof WoodpeckerClient>;
|
|
4
|
+
/** @public */
|
|
4
5
|
export interface WoodpeckerIntegration {
|
|
6
|
+
/** @public */
|
|
5
7
|
client(profile: string): WoodpeckerClientLike;
|
|
6
8
|
}
|
|
9
|
+
/** @internal */
|
|
7
10
|
export declare const woodpeckerIntegration: import("@leitwerk-dev/process-sdk").CapabilityToken<WoodpeckerIntegration>;
|
|
8
11
|
//# sourceMappingURL=capability.d.ts.map
|
package/dist/capability.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,
|
|
1
|
+
{"version":3,"file":"capability.d.ts","sourceRoot":"","sources":["../src/capability.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACpD,iEAAiE;AACjE,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,gBAAgB,EAAE,MAAM,gBAAgB,CAAC,CAAC;AAElF,cAAc;AACd,MAAM,WAAW,qBAAqB;IACrC,cAAc;IACd,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,oBAAoB,CAAC;CAC9C;AACD,gBAAgB;AAChB,eAAO,MAAM,qBAAqB,4EAEjC,CAAC"}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,36 +1,66 @@
|
|
|
1
1
|
import { IntegrationHttpClient } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @internal */
|
|
2
3
|
export interface WoodpeckerProfile {
|
|
4
|
+
/** @internal */
|
|
3
5
|
baseUrl: string;
|
|
6
|
+
/** @internal */
|
|
4
7
|
token: string;
|
|
5
8
|
}
|
|
9
|
+
/** @public */
|
|
6
10
|
export interface WoodpeckerRepository {
|
|
11
|
+
/** @public */
|
|
7
12
|
id: number;
|
|
13
|
+
/** @public */
|
|
8
14
|
full_name: string;
|
|
9
15
|
}
|
|
16
|
+
/** @public */
|
|
10
17
|
export interface WoodpeckerPipeline {
|
|
18
|
+
/** @internal */
|
|
11
19
|
id: number;
|
|
20
|
+
/** @internal */
|
|
12
21
|
number: number;
|
|
22
|
+
/** @internal */
|
|
13
23
|
status: string;
|
|
24
|
+
/** @internal */
|
|
14
25
|
event: string;
|
|
26
|
+
/** @internal */
|
|
15
27
|
branch: string;
|
|
28
|
+
/** @internal */
|
|
16
29
|
commit: string;
|
|
30
|
+
/** @internal */
|
|
17
31
|
created_at?: number;
|
|
32
|
+
/** @internal */
|
|
18
33
|
workflows?: unknown[];
|
|
19
34
|
}
|
|
35
|
+
/** @internal */
|
|
20
36
|
export declare function parseWoodpeckerProfiles(value: unknown): Map<string, WoodpeckerProfile>;
|
|
37
|
+
/** @public */
|
|
21
38
|
export declare class WoodpeckerClient extends IntegrationHttpClient {
|
|
39
|
+
/** @internal */
|
|
22
40
|
readonly profile: WoodpeckerProfile;
|
|
23
|
-
|
|
41
|
+
/** @internal */
|
|
42
|
+
constructor(
|
|
43
|
+
/** @internal */
|
|
44
|
+
profile: WoodpeckerProfile);
|
|
45
|
+
/** @internal */
|
|
24
46
|
lookupRepository(fullName: string, signal?: AbortSignal): Promise<WoodpeckerRepository>;
|
|
47
|
+
/** @internal */
|
|
25
48
|
listPipelines(repoId: number, signal?: AbortSignal, pagination?: {
|
|
49
|
+
/** @internal */
|
|
26
50
|
page: number;
|
|
51
|
+
/** @internal */
|
|
27
52
|
perPage?: number;
|
|
28
53
|
}): Promise<WoodpeckerPipeline[]>;
|
|
54
|
+
/** @internal */
|
|
29
55
|
getPipeline(repoId: number, number: number, signal?: AbortSignal): Promise<WoodpeckerPipeline>;
|
|
56
|
+
/** @public */
|
|
30
57
|
getStepLogs(repoId: number, number: number, stepId: number, tailLines?: number, maxBytes?: number, signal?: AbortSignal): Promise<{
|
|
58
|
+
/** @public */
|
|
31
59
|
logs: string;
|
|
60
|
+
/** @internal */
|
|
32
61
|
truncated: boolean;
|
|
33
62
|
}>;
|
|
63
|
+
/** @internal */
|
|
34
64
|
restartPipeline(repoId: number, number: number, signal?: AbortSignal): Promise<WoodpeckerPipeline>;
|
|
35
65
|
}
|
|
36
66
|
//# sourceMappingURL=client.d.ts.map
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,MAAM,WAAW,iBAAiB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;CACd;AACD,MAAM,WAAW,oBAAoB;IACpC,EAAE,EAAE,MAAM,CAAC;IACX,SAAS,EAAE,MAAM,CAAC;CAClB;AACD,MAAM,WAAW,kBAAkB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,OAAO,EAAE,CAAC;CACtB;AAwBD,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,GAAG,CAAC,MAAM,EAAE,iBAAiB,CAAC,CActF;AAED,qBAAa,gBAAiB,SAAQ,qBAAqB;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAC;AAGlE,gBAAgB;AAChB,MAAM,WAAW,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AC,kBAAkB,EAAE,CAAC;IAehC,gBAAgB;IAChB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAI9F,cAAc;IACR,WAAW,CAChB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,SAAS,SAAM,EACf,QAAQ,SAAU,EAClB,MAAM,CAAC,EAAE,WAAW;QAyBnB,cAAc;;QAEd,gBAAgB;;;IAKlB,gBAAgB;IAChB,eAAe,CACd,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,WAAW,GAClB,OAAO,CAAC,kBAAkB,CAAC;CAM9B"}
|
package/dist/external.d.ts
CHANGED
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
import type { ExternalActionSource } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @internal */
|
|
2
3
|
export declare const WOODPECKER_PIPELINE_KIND = "@leitwerk-private/woodpecker.pipeline";
|
|
4
|
+
/** @internal */
|
|
3
5
|
export interface WoodpeckerPipelineSourceConfig {
|
|
6
|
+
/** @internal */
|
|
4
7
|
profile: string;
|
|
8
|
+
/** @internal */
|
|
5
9
|
owner: string;
|
|
10
|
+
/** @internal */
|
|
6
11
|
repo: string;
|
|
12
|
+
/** @internal */
|
|
7
13
|
branch: string;
|
|
14
|
+
/** @internal */
|
|
8
15
|
headSha: string;
|
|
16
|
+
/** @internal */
|
|
9
17
|
afterPipelineNumber?: number;
|
|
18
|
+
/** @internal */
|
|
10
19
|
disabled?: boolean;
|
|
20
|
+
/** @internal */
|
|
11
21
|
pollInterval?: string;
|
|
22
|
+
/** @internal */
|
|
12
23
|
statuses?: string[];
|
|
13
24
|
}
|
|
25
|
+
/** @internal */
|
|
14
26
|
export declare const woodpeckerExternal: {
|
|
27
|
+
/** @internal */
|
|
15
28
|
pipeline<TParams, TState>(resolve: (ctx: {
|
|
29
|
+
/** @internal */
|
|
16
30
|
params: TParams;
|
|
31
|
+
/** @internal */
|
|
17
32
|
state: TState;
|
|
18
33
|
}) => WoodpeckerPipelineSourceConfig): ExternalActionSource<TParams, TState>;
|
|
19
34
|
};
|
package/dist/external.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../src/external.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,eAAO,MAAM,wBAAwB,0CAA0C,CAAC;AAChF,MAAM,WAAW,8BAA8B;IAC9C,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AACD,eAAO,MAAM,kBAAkB;
|
|
1
|
+
{"version":3,"file":"external.d.ts","sourceRoot":"","sources":["../src/external.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACtE,gBAAgB;AAChB,eAAO,MAAM,wBAAwB,0CAA0C,CAAC;AAChF,gBAAgB;AAChB,MAAM,WAAW,8BAA8B;IAC9C,gBAAgB;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,gBAAgB;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB;IAChB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,gBAAgB;IAChB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,gBAAgB;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,gBAAgB;IAChB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;CACpB;AACD,gBAAgB;AAChB,eAAO,MAAM,kBAAkB;IAC9B,gBAAgB;aACP,OAAO,EAAE,MAAM,WACd,CAAC,GAAG,EAAE;QACd,gBAAgB;QAChB,MAAM,EAAE,OAAO,CAAC;QAChB,gBAAgB;QAChB,KAAK,EAAE,MAAM,CAAC;KACd,KAAK,8BAA8B,GAClC,oBAAoB,CAAC,OAAO,EAAE,MAAM,CAAC;CAUxC,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { type LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
|
|
2
2
|
import { type WoodpeckerIntegration } from "./capability.js";
|
|
3
|
-
|
|
4
|
-
readonly id: "woodpecker";
|
|
5
|
-
readonly version: "0.1.9";
|
|
6
|
-
};
|
|
3
|
+
/** @public */
|
|
7
4
|
declare const extension: LeitwerkExtensionModule;
|
|
8
|
-
export
|
|
9
|
-
export
|
|
10
|
-
export
|
|
5
|
+
export type { WoodpeckerIntegration } from "./capability.js";
|
|
6
|
+
export { woodpeckerIntegration } from "./capability.js";
|
|
7
|
+
export type { WoodpeckerPipeline } from "./client.js";
|
|
8
|
+
export { WOODPECKER_PIPELINE_KIND, woodpeckerExternal } from "./external.js";
|
|
11
9
|
export default extension;
|
|
12
|
-
/** Register shared tools and polling with an explicit integration. */
|
|
10
|
+
/** Register shared tools and polling with an explicit integration. @public */
|
|
13
11
|
export declare function setupWoodpeckerIntegration(api: Parameters<NonNullable<LeitwerkExtensionModule["setupServer"]>>[0], integration: WoodpeckerIntegration, options?: {
|
|
12
|
+
/** @public */
|
|
14
13
|
now?: () => number;
|
|
15
|
-
}):
|
|
14
|
+
}): {
|
|
15
|
+
/** @public */
|
|
16
|
+
poll(): Promise<import("@leitwerk-dev/watcher-utils").PollResult>;
|
|
17
|
+
} | undefined;
|
|
16
18
|
export * from "./binding.js";
|
|
17
19
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AAC/F,OAAO,EAAE,KAAK,qBAAqB,EAAyB,MAAM,iBAAiB,CAAC;AAYpF,cAAc;AACd,QAAA,MAAM,SAAS,EAAE,uBAahB,CAAC;AAEF,YAAY,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC7E,eAAe,SAAS,CAAC;AAEzB,8EAA8E;AAC9E,wBAAgB,0BAA0B,CACzC,GAAG,EAAE,UAAU,CAAC,WAAW,CAAC,uBAAuB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EACvE,WAAW,EAAE,qBAAqB,EAClC,OAAO,GAAE;IACR,cAAc;IACd,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACd;;;cAON;AAED,cAAc,cAAc,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -46,6 +46,7 @@ function parseWoodpeckerProfiles(value) {
|
|
|
46
46
|
return profiles;
|
|
47
47
|
}
|
|
48
48
|
var WoodpeckerClient = class extends IntegrationHttpClient {
|
|
49
|
+
/** @internal */
|
|
49
50
|
constructor(profile) {
|
|
50
51
|
super("Woodpecker", `${profile.baseUrl}/api`, {
|
|
51
52
|
Authorization: `Bearer ${profile.token}`,
|
|
@@ -54,11 +55,13 @@ var WoodpeckerClient = class extends IntegrationHttpClient {
|
|
|
54
55
|
this.profile = profile;
|
|
55
56
|
}
|
|
56
57
|
profile;
|
|
58
|
+
/** @internal */
|
|
57
59
|
lookupRepository(fullName, signal) {
|
|
58
60
|
return this.request(`/repos/lookup/${encodeURIComponent(fullName)}`, {
|
|
59
61
|
signal
|
|
60
62
|
});
|
|
61
63
|
}
|
|
64
|
+
/** @internal */
|
|
62
65
|
listPipelines(repoId, signal, pagination = { page: 1 }) {
|
|
63
66
|
const { page, perPage = 100 } = pagination;
|
|
64
67
|
if (!Number.isSafeInteger(page) || page < 1 || !Number.isSafeInteger(perPage) || perPage < 1 || perPage > 100)
|
|
@@ -67,9 +70,11 @@ var WoodpeckerClient = class extends IntegrationHttpClient {
|
|
|
67
70
|
signal
|
|
68
71
|
});
|
|
69
72
|
}
|
|
73
|
+
/** @internal */
|
|
70
74
|
getPipeline(repoId, number, signal) {
|
|
71
75
|
return this.request(`/repos/${repoId}/pipelines/${number}`, { signal });
|
|
72
76
|
}
|
|
77
|
+
/** @public */
|
|
73
78
|
async getStepLogs(repoId, number, stepId, tailLines = 400, maxBytes = 262144, signal) {
|
|
74
79
|
const body = await (await this.response(`/repos/${repoId}/logs/${number}/${stepId}`, {
|
|
75
80
|
signal
|
|
@@ -88,8 +93,14 @@ var WoodpeckerClient = class extends IntegrationHttpClient {
|
|
|
88
93
|
} catch {
|
|
89
94
|
}
|
|
90
95
|
const output = boundedLogTail(text.split(/\r?\n/), tailLines, maxBytes);
|
|
91
|
-
return {
|
|
96
|
+
return {
|
|
97
|
+
/** @public */
|
|
98
|
+
logs: output,
|
|
99
|
+
/** @internal */
|
|
100
|
+
truncated: output.length < text.length
|
|
101
|
+
};
|
|
92
102
|
}
|
|
103
|
+
/** @internal */
|
|
93
104
|
restartPipeline(repoId, number, signal) {
|
|
94
105
|
return this.request(`/repos/${repoId}/pipelines/${number}`, {
|
|
95
106
|
method: "POST",
|
|
@@ -108,6 +119,7 @@ import { createPollSchedule, emptyPollResult } from "@leitwerk-dev/watcher-utils
|
|
|
108
119
|
// src/external.ts
|
|
109
120
|
var WOODPECKER_PIPELINE_KIND = "@leitwerk-private/woodpecker.pipeline";
|
|
110
121
|
var woodpeckerExternal = {
|
|
122
|
+
/** @internal */
|
|
111
123
|
pipeline(resolve) {
|
|
112
124
|
return {
|
|
113
125
|
kind: WOODPECKER_PIPELINE_KIND,
|
|
@@ -205,10 +217,6 @@ async function findLatestPipeline(client, repoId, config) {
|
|
|
205
217
|
}
|
|
206
218
|
|
|
207
219
|
// src/tools.ts
|
|
208
|
-
import {
|
|
209
|
-
createWriteIdentity,
|
|
210
|
-
ensureWrite
|
|
211
|
-
} from "@leitwerk-dev/external-writes";
|
|
212
220
|
import {
|
|
213
221
|
numberArg,
|
|
214
222
|
projectParameters,
|
|
@@ -224,7 +232,7 @@ function target(ctx) {
|
|
|
224
232
|
const binding = resolveWoodpeckerProjectBinding(ctx);
|
|
225
233
|
return { fullName: `${binding.owner}/${binding.repo}`, profile: binding.profile };
|
|
226
234
|
}
|
|
227
|
-
function registerWoodpeckerTools(api, integration
|
|
235
|
+
function registerWoodpeckerTools(api, integration) {
|
|
228
236
|
const schema = projectParameters();
|
|
229
237
|
api.tool({
|
|
230
238
|
name: "woodpecker_lookup_repository",
|
|
@@ -272,10 +280,8 @@ function registerWoodpeckerTools(api, integration, writes) {
|
|
|
272
280
|
return client.getPipeline(repo.id, number, ctx.signal);
|
|
273
281
|
const diagnosis = stringArg(args, "diagnosis");
|
|
274
282
|
const logEvidence = stringArg(args, "logEvidence");
|
|
275
|
-
await
|
|
276
|
-
|
|
277
|
-
ctx.process.id,
|
|
278
|
-
createWriteIdentity("woodpecker.restart", ctx.idempotencyKey),
|
|
283
|
+
await ctx.externalWrites.logOnly(
|
|
284
|
+
{ writeType: "woodpecker.restart", dedupKey: ctx.idempotencyKey },
|
|
279
285
|
async () => {
|
|
280
286
|
await client.restartPipeline(repo.id, number, ctx.signal);
|
|
281
287
|
return { repoId: repo.id, number, diagnosis, logEvidence };
|
|
@@ -314,7 +320,12 @@ function registerWoodpeckerTools(api, integration, writes) {
|
|
|
314
320
|
}
|
|
315
321
|
|
|
316
322
|
// src/index.ts
|
|
317
|
-
var manifest = {
|
|
323
|
+
var manifest = {
|
|
324
|
+
/** @internal */
|
|
325
|
+
id: "woodpecker",
|
|
326
|
+
/** @internal */
|
|
327
|
+
version: "0.1.9"
|
|
328
|
+
};
|
|
318
329
|
var extension = {
|
|
319
330
|
manifest,
|
|
320
331
|
setupServer(api, config) {
|
|
@@ -334,15 +345,12 @@ function setupWoodpeckerIntegration(api, integration, options = {}) {
|
|
|
334
345
|
api.provide(woodpeckerIntegration, integration);
|
|
335
346
|
const deps = api.get(coreHostCapabilities.serverSetup);
|
|
336
347
|
if (!deps || Array.isArray(deps)) return;
|
|
337
|
-
registerWoodpeckerTools(api, integration
|
|
348
|
+
registerWoodpeckerTools(api, integration);
|
|
338
349
|
return createWoodpeckerProvider(deps, integration, options);
|
|
339
350
|
}
|
|
340
351
|
export {
|
|
341
352
|
WOODPECKER_PIPELINE_KIND,
|
|
342
|
-
WoodpeckerClient,
|
|
343
353
|
index_default as default,
|
|
344
|
-
manifest,
|
|
345
|
-
parseWoodpeckerProfiles,
|
|
346
354
|
resolveWoodpeckerProjectBinding,
|
|
347
355
|
setupWoodpeckerIntegration,
|
|
348
356
|
woodpeckerExternal,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/capability.ts","../src/client.ts","../src/provider.ts","../src/external.ts","../src/tools.ts","../src/binding.ts"],"sourcesContent":["import type { ExternalWriteLogRepoLike } from \"@leitwerk-dev/external-writes\";\nimport { coreHostCapabilities, type LeitwerkExtensionModule } from \"@leitwerk-dev/process-sdk\";\nimport { type WoodpeckerIntegration, woodpeckerIntegration } from \"./capability.js\";\nimport { parseWoodpeckerProfiles, WoodpeckerClient } from \"./client.js\";\nimport { createWoodpeckerProvider } from \"./provider.js\";\nimport { registerWoodpeckerTools } from \"./tools.js\";\nexport const manifest = { id: \"woodpecker\", version: \"0.1.9\" } as const;\nconst extension: LeitwerkExtensionModule = {\n\tmanifest,\n\tsetupServer(api, config) {\n\t\tconst profiles = parseWoodpeckerProfiles(config);\n\t\tconst integration: WoodpeckerIntegration = {\n\t\t\tclient(profile) {\n\t\t\t\tconst value = profiles.get(profile);\n\t\t\t\tif (!value) throw new Error(`Unknown Woodpecker profile '${profile}'`);\n\t\t\t\treturn new WoodpeckerClient(value);\n\t\t\t},\n\t\t};\n\t\tsetupWoodpeckerIntegration(api, integration);\n\t},\n};\n\nexport * from \"./capability.js\";\nexport * from \"./client.js\";\nexport * from \"./external.js\";\nexport default extension;\n\n/** Register shared tools and polling with an explicit integration. */\nexport function setupWoodpeckerIntegration(\n\tapi: Parameters<NonNullable<LeitwerkExtensionModule[\"setupServer\"]>>[0],\n\tintegration: WoodpeckerIntegration,\n\toptions: { now?: () => number } = {},\n) {\n\tapi.provide(woodpeckerIntegration, integration);\n\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\tif (!deps || Array.isArray(deps)) return;\n\tregisterWoodpeckerTools(api, integration, deps.externalWrites as ExternalWriteLogRepoLike);\n\treturn createWoodpeckerProvider(deps, integration, options);\n}\n\nexport * from \"./binding.js\";\n","import { createCapabilityToken } from \"@leitwerk-dev/process-sdk\";\nimport type { WoodpeckerClient } from \"./client.js\";\n/** Public contract shared by HTTP and local adapters. */\nexport type WoodpeckerClientLike = Pick<WoodpeckerClient, keyof WoodpeckerClient>;\n\nexport interface WoodpeckerIntegration {\n\tclient(profile: string): WoodpeckerClientLike;\n}\nexport const woodpeckerIntegration = createCapabilityToken<WoodpeckerIntegration>(\n\t\"@leitwerk-private/woodpecker.integration\",\n);\n","import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport { IntegrationHttpClient } from \"@leitwerk-dev/process-sdk\";\nimport { boundedLogTail } from \"./logs.js\";\n\nexport interface WoodpeckerProfile {\n\tbaseUrl: string;\n\ttoken: string;\n}\nexport interface WoodpeckerRepository {\n\tid: number;\n\tfull_name: string;\n}\nexport interface WoodpeckerPipeline {\n\tid: number;\n\tnumber: number;\n\tstatus: string;\n\tevent: string;\n\tbranch: string;\n\tcommit: string;\n\tcreated_at?: number;\n\tworkflows?: unknown[];\n}\n\ninterface WoodpeckerLogEntry {\n\tdata?: number[] | string;\n}\n\nfunction decodeLogData(data: WoodpeckerLogEntry[\"data\"]): string {\n\tif (Array.isArray(data)) {\n\t\treturn new TextDecoder(\"utf-8\", { fatal: false }).decode(Uint8Array.from(data));\n\t}\n\tif (typeof data !== \"string\") return \"\";\n\tif (/^[A-Za-z0-9+/]*={0,2}$/.test(data) && data.length % 4 === 0) {\n\t\ttry {\n\t\t\tconst binary = atob(data);\n\t\t\treturn new TextDecoder(\"utf-8\", { fatal: false }).decode(\n\t\t\t\tUint8Array.from(binary, (character) => character.charCodeAt(0)),\n\t\t\t);\n\t\t} catch {\n\t\t\t// Preserve an unexpected plain-text representation instead of hiding logs.\n\t\t}\n\t}\n\treturn data;\n}\n\nexport function parseWoodpeckerProfiles(value: unknown): Map<string, WoodpeckerProfile> {\n\tconst profiles = new Map<string, WoodpeckerProfile>();\n\tfor (const [name, raw] of Object.entries(\n\t\tasUnknownRecord(asUnknownRecord(value)?.profiles) ?? {},\n\t)) {\n\t\tconst config = asUnknownRecord(raw) ?? {};\n\t\tconst baseUrl = typeof config.base_url === \"string\" ? config.base_url.replace(/\\/+$/, \"\") : \"\";\n\t\tconst token = typeof config.token === \"string\" ? config.token.trim() : \"\";\n\t\tif (!/^https:\\/\\//.test(baseUrl))\n\t\t\tthrow new Error(`Woodpecker profile '${name}' requires an HTTPS base_url`);\n\t\tif (!token) throw new Error(`Woodpecker profile '${name}' requires a token`);\n\t\tprofiles.set(name, { baseUrl, token });\n\t}\n\treturn profiles;\n}\n\nexport class WoodpeckerClient extends IntegrationHttpClient {\n\tconstructor(readonly profile: WoodpeckerProfile) {\n\t\tsuper(\"Woodpecker\", `${profile.baseUrl}/api`, {\n\t\t\tAuthorization: `Bearer ${profile.token}`,\n\t\t\tAccept: \"application/json\",\n\t\t});\n\t}\n\n\tlookupRepository(fullName: string, signal?: AbortSignal): Promise<WoodpeckerRepository> {\n\t\treturn this.request(`/repos/lookup/${encodeURIComponent(fullName)}`, {\n\t\t\tsignal,\n\t\t});\n\t}\n\n\tlistPipelines(\n\t\trepoId: number,\n\t\tsignal?: AbortSignal,\n\t\tpagination: { page: number; perPage?: number } = { page: 1 },\n\t): Promise<WoodpeckerPipeline[]> {\n\t\tconst { page, perPage = 100 } = pagination;\n\t\tif (\n\t\t\t!Number.isSafeInteger(page) ||\n\t\t\tpage < 1 ||\n\t\t\t!Number.isSafeInteger(perPage) ||\n\t\t\tperPage < 1 ||\n\t\t\tperPage > 100\n\t\t)\n\t\t\tthrow new Error(\"Invalid Woodpecker pipeline pagination\");\n\t\treturn this.request(`/repos/${repoId}/pipelines?page=${page}&perPage=${perPage}`, {\n\t\t\tsignal,\n\t\t});\n\t}\n\n\tgetPipeline(repoId: number, number: number, signal?: AbortSignal): Promise<WoodpeckerPipeline> {\n\t\treturn this.request(`/repos/${repoId}/pipelines/${number}`, { signal });\n\t}\n\n\tasync getStepLogs(\n\t\trepoId: number,\n\t\tnumber: number,\n\t\tstepId: number,\n\t\ttailLines = 400,\n\t\tmaxBytes = 262_144,\n\t\tsignal?: AbortSignal,\n\t) {\n\t\tconst body = await (\n\t\t\tawait this.response(`/repos/${repoId}/logs/${number}/${stepId}`, {\n\t\t\t\tsignal,\n\t\t\t})\n\t\t).text();\n\t\tlet text = body;\n\t\ttry {\n\t\t\tconst entries = JSON.parse(body) as unknown;\n\t\t\tif (Array.isArray(entries)) {\n\t\t\t\ttext = entries\n\t\t\t\t\t.map((entry) =>\n\t\t\t\t\t\tdecodeLogData(asUnknownRecord(entry)?.data as WoodpeckerLogEntry[\"data\"]).replace(\n\t\t\t\t\t\t\t/\\r?\\n$/,\n\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\\n\");\n\t\t\t}\n\t\t} catch {\n\t\t\t// Older adapters may return text directly; retain it as-is.\n\t\t}\n\t\tconst output = boundedLogTail(text.split(/\\r?\\n/), tailLines, maxBytes);\n\t\treturn { logs: output, truncated: output.length < text.length };\n\t}\n\n\trestartPipeline(\n\t\trepoId: number,\n\t\tnumber: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<WoodpeckerPipeline> {\n\t\treturn this.request(`/repos/${repoId}/pipelines/${number}`, {\n\t\t\tmethod: \"POST\",\n\t\t\tsignal,\n\t\t});\n\t}\n}\n","import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport {\n\ttype CoreServerSetupDeps,\n\tcreateExternalSourcePollReporter,\n} from \"@leitwerk-dev/process-sdk\";\nimport { createPollSchedule, emptyPollResult } from \"@leitwerk-dev/watcher-utils\";\nimport type { WoodpeckerClientLike, WoodpeckerIntegration } from \"./capability.js\";\nimport { WOODPECKER_PIPELINE_KIND, type WoodpeckerPipelineSourceConfig } from \"./external.js\";\n\nfunction parse(value: unknown): WoodpeckerPipelineSourceConfig | null {\n\tconst config = asUnknownRecord(value) ?? {};\n\tif (\n\t\t[\"profile\", \"owner\", \"repo\", \"branch\", \"headSha\"].some(\n\t\t\t(key) => typeof config[key] !== \"string\" || !(config[key] as string).trim(),\n\t\t)\n\t)\n\t\treturn null;\n\treturn {\n\t\tprofile: config.profile as string,\n\t\towner: config.owner as string,\n\t\trepo: config.repo as string,\n\t\tbranch: config.branch as string,\n\t\theadSha: config.headSha as string,\n\t\tafterPipelineNumber:\n\t\t\ttypeof config.afterPipelineNumber === \"number\" ? config.afterPipelineNumber : 0,\n\t\tdisabled: config.disabled === true,\n\t\tpollInterval: typeof config.pollInterval === \"string\" ? config.pollInterval : \"30s\",\n\t\tstatuses: Array.isArray(config.statuses)\n\t\t\t? config.statuses.filter((value): value is string => typeof value === \"string\")\n\t\t\t: undefined,\n\t};\n}\nconst terminal = new Set([\n\t\"success\",\n\t\"failure\",\n\t\"error\",\n\t\"killed\",\n\t\"canceled\",\n\t\"cancelled\",\n\t\"declined\",\n\t\"blocked\",\n]);\nconst supportedEvents = new Set([\"push\", \"pull_request\", \"pull_request_closed\"]);\n\nfunction matchesBranch(event: string, pipelineBranch: string, sourceBranch: string): boolean {\n\t// Woodpecker reports the PR target branch in `branch`. The commit uniquely\n\t// identifies the watched source head, so branch filtering only applies to pushes.\n\treturn event !== \"push\" || pipelineBranch === sourceBranch;\n}\n\nexport function createWoodpeckerProvider(\n\tdeps: CoreServerSetupDeps,\n\tintegration: WoodpeckerIntegration,\n\toptions: { now?: () => number } = {},\n) {\n\tconst due = createPollSchedule(options.now);\n\treturn deps.polling.create({\n\t\tid: \"woodpecker\",\n\t\tpollInterval: () => \"5s\",\n\t\tisEnabled: () => true,\n\t\tdefaultIntervalMs: 5_000,\n\t\tasync pollOnce() {\n\t\t\tconst result = emptyPollResult();\n\t\t\tconst report = createExternalSourcePollReporter(deps.externalSources, result);\n\t\t\tawait report.poll(WOODPECKER_PIPELINE_KIND, async (armed) => {\n\t\t\t\tconst config = parse(armed.resolved);\n\t\t\t\tif (!config) {\n\t\t\t\t\tresult.errors.push(`${armed.id}:invalid_config`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (config.disabled) return;\n\t\t\t\tconst key = `${armed.instanceId}:${armed.id}`;\n\t\t\t\tif (!due(key, config.pollInterval)) return;\n\t\t\t\tconst client = integration.client(config.profile);\n\t\t\t\tconst repo = await client.lookupRepository(`${config.owner}/${config.repo}`);\n\t\t\t\tconst pipeline = await findLatestPipeline(client, repo.id, config);\n\t\t\t\tif (\n\t\t\t\t\t!pipeline ||\n\t\t\t\t\t!terminal.has(pipeline.status) ||\n\t\t\t\t\t(config.statuses && !config.statuses.includes(pipeline.status))\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\tawait report.fire(\n\t\t\t\t\tarmed,\n\t\t\t\t\t{ repositoryId: repo.id, pipeline },\n\t\t\t\t\t`${pipeline.number}:${pipeline.status}`,\n\t\t\t\t);\n\t\t\t});\n\t\t\treturn result;\n\t\t},\n\t});\n}\n\n/** The bounded lookup reports incomplete history instead of waiting silently. */\nexport async function findLatestPipeline(\n\tclient: WoodpeckerClientLike,\n\trepoId: number,\n\tconfig: WoodpeckerPipelineSourceConfig,\n) {\n\tfor (let page = 1; page <= 10; page++) {\n\t\tconst pipelines = (await client.listPipelines(repoId, undefined, { page, perPage: 100 })).sort(\n\t\t\t(a, b) => b.number - a.number,\n\t\t);\n\t\tconst match = pipelines.find(\n\t\t\t(candidate) =>\n\t\t\t\tcandidate.number > (config.afterPipelineNumber ?? 0) &&\n\t\t\t\tcandidate.commit === config.headSha &&\n\t\t\t\tsupportedEvents.has(candidate.event) &&\n\t\t\t\tmatchesBranch(candidate.event, candidate.branch, config.branch),\n\t\t);\n\t\tif (match) return match;\n\t\tif (\n\t\t\tpipelines.length < 100 ||\n\t\t\tpipelines.some((candidate) => candidate.number <= (config.afterPipelineNumber ?? 0))\n\t\t)\n\t\t\treturn null;\n\t}\n\tthrow new Error(\n\t\t\"Woodpecker pipeline lookup window exhausted (1000 pipelines); inspect the repository and update the watched pipeline floor before retrying\",\n\t);\n}\n","import type { ExternalActionSource } from \"@leitwerk-dev/process-sdk\";\nexport const WOODPECKER_PIPELINE_KIND = \"@leitwerk-private/woodpecker.pipeline\";\nexport interface WoodpeckerPipelineSourceConfig {\n\tprofile: string;\n\towner: string;\n\trepo: string;\n\tbranch: string;\n\theadSha: string;\n\tafterPipelineNumber?: number;\n\tdisabled?: boolean;\n\tpollInterval?: string;\n\tstatuses?: string[];\n}\nexport const woodpeckerExternal = {\n\tpipeline<TParams, TState>(\n\t\tresolve: (ctx: { params: TParams; state: TState }) => WoodpeckerPipelineSourceConfig,\n\t): ExternalActionSource<TParams, TState> {\n\t\treturn {\n\t\t\tkind: WOODPECKER_PIPELINE_KIND,\n\t\t\tlabel: \"Woodpecker pipeline completion\",\n\t\t\tdescription: \"Fires when a pipeline matching the current source head completes\",\n\t\t\tconfig: {},\n\t\t\tinputMode: \"none\",\n\t\t\tresolve,\n\t\t};\n\t},\n};\n","import {\n\tcreateWriteIdentity,\n\ttype ExternalWriteLogRepoLike,\n\tensureWrite,\n} from \"@leitwerk-dev/external-writes\";\nimport {\n\ttype IntegrationToolExecutionContext,\n\tnumberArg,\n\tprojectParameters,\n\ttype ServerExtensionAPI,\n\tstringArg,\n} from \"@leitwerk-dev/process-sdk\";\nimport { resolveWoodpeckerProjectBinding } from \"./binding.js\";\nimport type { WoodpeckerIntegration } from \"./capability.js\";\n\nfunction target(ctx: IntegrationToolExecutionContext) {\n\tconst binding = resolveWoodpeckerProjectBinding(ctx);\n\treturn { fullName: `${binding.owner}/${binding.repo}`, profile: binding.profile };\n}\n\nexport function registerWoodpeckerTools(\n\tapi: ServerExtensionAPI,\n\tintegration: WoodpeckerIntegration,\n\twrites: ExternalWriteLogRepoLike,\n) {\n\tconst schema = projectParameters();\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"woodpecker_lookup_repository\",\n\t\tdescription: \"Resolve the current process repository in Woodpecker\",\n\t\tparameters: schema,\n\t\tasync execute(ctx) {\n\t\t\tconst t = target(ctx);\n\t\t\treturn integration.client(t.profile).lookupRepository(t.fullName, ctx.signal);\n\t\t},\n\t});\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"woodpecker_list_pipelines\",\n\t\tdescription: \"List recent Woodpecker pipelines for the current process repository\",\n\t\tparameters: schema,\n\t\tasync execute(ctx) {\n\t\t\tconst t = target(ctx);\n\t\t\tconst client = integration.client(t.profile);\n\t\t\tconst repo = await client.lookupRepository(t.fullName, ctx.signal);\n\t\t\treturn client.listPipelines(repo.id, ctx.signal);\n\t\t},\n\t});\n\tfor (const name of [\"woodpecker_get_pipeline\", \"woodpecker_restart_pipeline\"] as const) {\n\t\tapi.tool<Record<string, unknown>>({\n\t\t\tname,\n\t\t\tdescription: name.endsWith(\"restart_pipeline\")\n\t\t\t\t? \"Restart a diagnosed Woodpecker pipeline\"\n\t\t\t\t: \"Read a Woodpecker pipeline\",\n\t\t\tparameters: projectParameters({\n\t\t\t\tpipelineNumber: { type: \"integer\" },\n\t\t\t\t...(name === \"woodpecker_restart_pipeline\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tdiagnosis: {\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\"Why this is an infrastructure or flaky failure rather than a repository defect\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tlogEvidence: {\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t\tdescription: \"Concrete bounded-log evidence supporting a restart\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t}),\n\t\t\tasync execute(ctx, args) {\n\t\t\t\tconst t = target(ctx);\n\t\t\t\tconst client = integration.client(t.profile);\n\t\t\t\tconst repo = await client.lookupRepository(t.fullName, ctx.signal);\n\t\t\t\tconst number = numberArg(args, \"pipelineNumber\");\n\t\t\t\tif (name === \"woodpecker_get_pipeline\")\n\t\t\t\t\treturn client.getPipeline(repo.id, number, ctx.signal);\n\t\t\t\tconst diagnosis = stringArg(args, \"diagnosis\");\n\t\t\t\tconst logEvidence = stringArg(args, \"logEvidence\");\n\t\t\t\tawait ensureWrite(\n\t\t\t\t\twrites,\n\t\t\t\t\tctx.process.id,\n\t\t\t\t\tcreateWriteIdentity(\"woodpecker.restart\", ctx.idempotencyKey),\n\t\t\t\t\tasync () => {\n\t\t\t\t\t\tawait client.restartPipeline(repo.id, number, ctx.signal);\n\t\t\t\t\t\treturn { repoId: repo.id, number, diagnosis, logEvidence };\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn { ok: true };\n\t\t\t},\n\t\t});\n\t}\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"woodpecker_get_step_logs\",\n\t\tdescription: \"Read bounded logs for a Woodpecker pipeline step\",\n\t\tparameters: projectParameters(\n\t\t\t{\n\t\t\t\tpipelineNumber: { type: \"integer\" },\n\t\t\t\tstepId: { type: \"integer\" },\n\t\t\t\ttailLines: { type: \"integer\" },\n\t\t\t\tmaxBytes: { type: \"integer\" },\n\t\t\t},\n\t\t\t[\"pipelineNumber\", \"stepId\"],\n\t\t),\n\t\tasync execute(ctx, args) {\n\t\t\tconst t = target(ctx);\n\t\t\tconst client = integration.client(t.profile);\n\t\t\tconst repo = await client.lookupRepository(t.fullName, ctx.signal);\n\t\t\treturn client.getStepLogs(\n\t\t\t\trepo.id,\n\t\t\t\tnumberArg(args, \"pipelineNumber\"),\n\t\t\t\tnumberArg(args, \"stepId\"),\n\t\t\t\ttypeof args.tailLines === \"number\" ? args.tailLines : 400,\n\t\t\t\ttypeof args.maxBytes === \"number\" ? args.maxBytes : 262_144,\n\t\t\t\tctx.signal,\n\t\t\t);\n\t\t},\n\t});\n}\n","import { resolveRepositoryProjectBinding } from \"@leitwerk-dev/process-sdk\";\n\nexport type { RepositoryProjectBinding as WoodpeckerProjectBinding } from \"@leitwerk-dev/process-sdk\";\nexport const resolveWoodpeckerProjectBinding = (\n\tctx: Parameters<typeof resolveRepositoryProjectBinding>[0],\n) => resolveRepositoryProjectBinding(ctx, \"woodpecker\", \"forgejo\");\n"],"mappings":";;;;;AACA,SAAS,4BAA0D;;;ACDnE,SAAS,6BAA6B;AAQ/B,IAAM,wBAAwB;AAAA,EACpC;AACD;;;ACVA,SAAS,uBAAuB;AAChC,SAAS,6BAA6B;AA0BtC,SAAS,cAAc,MAA0C;AAChE,MAAI,MAAM,QAAQ,IAAI,GAAG;AACxB,WAAO,IAAI,YAAY,SAAS,EAAE,OAAO,MAAM,CAAC,EAAE,OAAO,W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kC,CAAC,GAClC;AACD,MAAI,QAAQ,uBAAuB,WAAW;AAC9C,QAAM,OAAO,IAAI,IAAI,qBAAqB,WAAW;AACrD,MAAI,CAAC,QAAQ,MAAM,QAAQ,IAAI,EAAG;AAClC,0BAAwB,KAAK,aAAa,KAAK,cAA0C;AACzF,SAAO,yBAAyB,MAAM,aAAa,OAAO;AAC3D;","names":["asUnknownRecord","asUnknownRecord","value"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/capability.ts","../src/client.ts","../src/provider.ts","../src/external.ts","../src/tools.ts","../src/binding.ts"],"sourcesContent":["import { coreHostCapabilities, type LeitwerkExtensionModule } from \"@leitwerk-dev/process-sdk\";\nimport { type WoodpeckerIntegration, woodpeckerIntegration } from \"./capability.js\";\nimport { parseWoodpeckerProfiles, WoodpeckerClient } from \"./client.js\";\nimport { createWoodpeckerProvider } from \"./provider.js\";\nimport { registerWoodpeckerTools } from \"./tools.js\";\n\n/** @internal */\nconst manifest = {\n\t/** @internal */\n\tid: \"woodpecker\",\n\t/** @internal */\n\tversion: \"0.1.9\",\n} as const;\n/** @public */\nconst extension: LeitwerkExtensionModule = {\n\tmanifest,\n\tsetupServer(api, config) {\n\t\tconst profiles = parseWoodpeckerProfiles(config);\n\t\tconst integration: WoodpeckerIntegration = {\n\t\t\tclient(profile) {\n\t\t\t\tconst value = profiles.get(profile);\n\t\t\t\tif (!value) throw new Error(`Unknown Woodpecker profile '${profile}'`);\n\t\t\t\treturn new WoodpeckerClient(value);\n\t\t\t},\n\t\t};\n\t\tsetupWoodpeckerIntegration(api, integration);\n\t},\n};\n\nexport type { WoodpeckerIntegration } from \"./capability.js\";\nexport { woodpeckerIntegration } from \"./capability.js\";\nexport type { WoodpeckerPipeline } from \"./client.js\";\nexport { WOODPECKER_PIPELINE_KIND, woodpeckerExternal } from \"./external.js\";\nexport default extension;\n\n/** Register shared tools and polling with an explicit integration. @public */\nexport function setupWoodpeckerIntegration(\n\tapi: Parameters<NonNullable<LeitwerkExtensionModule[\"setupServer\"]>>[0],\n\tintegration: WoodpeckerIntegration,\n\toptions: {\n\t\t/** @public */\n\t\tnow?: () => number;\n\t} = {},\n) {\n\tapi.provide(woodpeckerIntegration, integration);\n\tconst deps = api.get(coreHostCapabilities.serverSetup);\n\tif (!deps || Array.isArray(deps)) return;\n\tregisterWoodpeckerTools(api, integration);\n\treturn createWoodpeckerProvider(deps, integration, options);\n}\n\nexport * from \"./binding.js\";\n","import { createCapabilityToken } from \"@leitwerk-dev/process-sdk\";\nimport type { WoodpeckerClient } from \"./client.js\";\n/** Public contract shared by HTTP and local adapters. @public */\nexport type WoodpeckerClientLike = Pick<WoodpeckerClient, keyof WoodpeckerClient>;\n\n/** @public */\nexport interface WoodpeckerIntegration {\n\t/** @public */\n\tclient(profile: string): WoodpeckerClientLike;\n}\n/** @internal */\nexport const woodpeckerIntegration = createCapabilityToken<WoodpeckerIntegration>(\n\t\"@leitwerk-private/woodpecker.integration\",\n);\n","import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport { IntegrationHttpClient } from \"@leitwerk-dev/process-sdk\";\nimport { boundedLogTail } from \"./logs.js\";\n\n/** @internal */\nexport interface WoodpeckerProfile {\n\t/** @internal */\n\tbaseUrl: string;\n\t/** @internal */\n\ttoken: string;\n}\n/** @public */\nexport interface WoodpeckerRepository {\n\t/** @public */\n\tid: number;\n\t/** @public */\n\tfull_name: string;\n}\n/** @public */\nexport interface WoodpeckerPipeline {\n\t/** @internal */\n\tid: number;\n\t/** @internal */\n\tnumber: number;\n\t/** @internal */\n\tstatus: string;\n\t/** @internal */\n\tevent: string;\n\t/** @internal */\n\tbranch: string;\n\t/** @internal */\n\tcommit: string;\n\t/** @internal */\n\tcreated_at?: number;\n\t/** @internal */\n\tworkflows?: unknown[];\n}\n\ninterface WoodpeckerLogEntry {\n\tdata?: number[] | string;\n}\n\nfunction decodeLogData(data: WoodpeckerLogEntry[\"data\"]): string {\n\tif (Array.isArray(data)) {\n\t\treturn new TextDecoder(\"utf-8\", { fatal: false }).decode(Uint8Array.from(data));\n\t}\n\tif (typeof data !== \"string\") return \"\";\n\tif (/^[A-Za-z0-9+/]*={0,2}$/.test(data) && data.length % 4 === 0) {\n\t\ttry {\n\t\t\tconst binary = atob(data);\n\t\t\treturn new TextDecoder(\"utf-8\", { fatal: false }).decode(\n\t\t\t\tUint8Array.from(binary, (character) => character.charCodeAt(0)),\n\t\t\t);\n\t\t} catch {\n\t\t\t// Preserve an unexpected plain-text representation instead of hiding logs.\n\t\t}\n\t}\n\treturn data;\n}\n\n/** @internal */\nexport function parseWoodpeckerProfiles(value: unknown): Map<string, WoodpeckerProfile> {\n\tconst profiles = new Map<string, WoodpeckerProfile>();\n\tfor (const [name, raw] of Object.entries(\n\t\tasUnknownRecord(asUnknownRecord(value)?.profiles) ?? {},\n\t)) {\n\t\tconst config = asUnknownRecord(raw) ?? {};\n\t\tconst baseUrl = typeof config.base_url === \"string\" ? config.base_url.replace(/\\/+$/, \"\") : \"\";\n\t\tconst token = typeof config.token === \"string\" ? config.token.trim() : \"\";\n\t\tif (!/^https:\\/\\//.test(baseUrl))\n\t\t\tthrow new Error(`Woodpecker profile '${name}' requires an HTTPS base_url`);\n\t\tif (!token) throw new Error(`Woodpecker profile '${name}' requires a token`);\n\t\tprofiles.set(name, { baseUrl, token });\n\t}\n\treturn profiles;\n}\n\n/** @public */\nexport class WoodpeckerClient extends IntegrationHttpClient {\n\t/** @internal */\n\tconstructor(\n\t\t/** @internal */\n\t\treadonly profile: WoodpeckerProfile,\n\t) {\n\t\tsuper(\"Woodpecker\", `${profile.baseUrl}/api`, {\n\t\t\tAuthorization: `Bearer ${profile.token}`,\n\t\t\tAccept: \"application/json\",\n\t\t});\n\t}\n\n\t/** @internal */\n\tlookupRepository(fullName: string, signal?: AbortSignal): Promise<WoodpeckerRepository> {\n\t\treturn this.request(`/repos/lookup/${encodeURIComponent(fullName)}`, {\n\t\t\tsignal,\n\t\t});\n\t}\n\n\t/** @internal */\n\tlistPipelines(\n\t\trepoId: number,\n\t\tsignal?: AbortSignal,\n\t\tpagination: {\n\t\t\t/** @internal */\n\t\t\tpage: number;\n\t\t\t/** @internal */\n\t\t\tperPage?: number;\n\t\t} = { page: 1 },\n\t): Promise<WoodpeckerPipeline[]> {\n\t\tconst { page, perPage = 100 } = pagination;\n\t\tif (\n\t\t\t!Number.isSafeInteger(page) ||\n\t\t\tpage < 1 ||\n\t\t\t!Number.isSafeInteger(perPage) ||\n\t\t\tperPage < 1 ||\n\t\t\tperPage > 100\n\t\t)\n\t\t\tthrow new Error(\"Invalid Woodpecker pipeline pagination\");\n\t\treturn this.request(`/repos/${repoId}/pipelines?page=${page}&perPage=${perPage}`, {\n\t\t\tsignal,\n\t\t});\n\t}\n\n\t/** @internal */\n\tgetPipeline(repoId: number, number: number, signal?: AbortSignal): Promise<WoodpeckerPipeline> {\n\t\treturn this.request(`/repos/${repoId}/pipelines/${number}`, { signal });\n\t}\n\n\t/** @public */\n\tasync getStepLogs(\n\t\trepoId: number,\n\t\tnumber: number,\n\t\tstepId: number,\n\t\ttailLines = 400,\n\t\tmaxBytes = 262_144,\n\t\tsignal?: AbortSignal,\n\t) {\n\t\tconst body = await (\n\t\t\tawait this.response(`/repos/${repoId}/logs/${number}/${stepId}`, {\n\t\t\t\tsignal,\n\t\t\t})\n\t\t).text();\n\t\tlet text = body;\n\t\ttry {\n\t\t\tconst entries = JSON.parse(body) as unknown;\n\t\t\tif (Array.isArray(entries)) {\n\t\t\t\ttext = entries\n\t\t\t\t\t.map((entry) =>\n\t\t\t\t\t\tdecodeLogData(asUnknownRecord(entry)?.data as WoodpeckerLogEntry[\"data\"]).replace(\n\t\t\t\t\t\t\t/\\r?\\n$/,\n\t\t\t\t\t\t\t\"\",\n\t\t\t\t\t\t),\n\t\t\t\t\t)\n\t\t\t\t\t.join(\"\\n\");\n\t\t\t}\n\t\t} catch {\n\t\t\t// Older adapters may return text directly; retain it as-is.\n\t\t}\n\t\tconst output = boundedLogTail(text.split(/\\r?\\n/), tailLines, maxBytes);\n\t\treturn {\n\t\t\t/** @public */\n\t\t\tlogs: output,\n\t\t\t/** @internal */\n\t\t\ttruncated: output.length < text.length,\n\t\t};\n\t}\n\n\t/** @internal */\n\trestartPipeline(\n\t\trepoId: number,\n\t\tnumber: number,\n\t\tsignal?: AbortSignal,\n\t): Promise<WoodpeckerPipeline> {\n\t\treturn this.request(`/repos/${repoId}/pipelines/${number}`, {\n\t\t\tmethod: \"POST\",\n\t\t\tsignal,\n\t\t});\n\t}\n}\n","import { asUnknownRecord } from \"@leitwerk-dev/domain\";\nimport {\n\ttype CoreServerSetupDeps,\n\tcreateExternalSourcePollReporter,\n} from \"@leitwerk-dev/process-sdk\";\nimport { createPollSchedule, emptyPollResult } from \"@leitwerk-dev/watcher-utils\";\nimport type { WoodpeckerClientLike, WoodpeckerIntegration } from \"./capability.js\";\nimport { WOODPECKER_PIPELINE_KIND, type WoodpeckerPipelineSourceConfig } from \"./external.js\";\n\nfunction parse(value: unknown): WoodpeckerPipelineSourceConfig | null {\n\tconst config = asUnknownRecord(value) ?? {};\n\tif (\n\t\t[\"profile\", \"owner\", \"repo\", \"branch\", \"headSha\"].some(\n\t\t\t(key) => typeof config[key] !== \"string\" || !(config[key] as string).trim(),\n\t\t)\n\t)\n\t\treturn null;\n\treturn {\n\t\tprofile: config.profile as string,\n\t\towner: config.owner as string,\n\t\trepo: config.repo as string,\n\t\tbranch: config.branch as string,\n\t\theadSha: config.headSha as string,\n\t\tafterPipelineNumber:\n\t\t\ttypeof config.afterPipelineNumber === \"number\" ? config.afterPipelineNumber : 0,\n\t\tdisabled: config.disabled === true,\n\t\tpollInterval: typeof config.pollInterval === \"string\" ? config.pollInterval : \"30s\",\n\t\tstatuses: Array.isArray(config.statuses)\n\t\t\t? config.statuses.filter((value): value is string => typeof value === \"string\")\n\t\t\t: undefined,\n\t};\n}\nconst terminal = new Set([\n\t\"success\",\n\t\"failure\",\n\t\"error\",\n\t\"killed\",\n\t\"canceled\",\n\t\"cancelled\",\n\t\"declined\",\n\t\"blocked\",\n]);\nconst supportedEvents = new Set([\"push\", \"pull_request\", \"pull_request_closed\"]);\n\nfunction matchesBranch(event: string, pipelineBranch: string, sourceBranch: string): boolean {\n\t// Woodpecker reports the PR target branch in `branch`. The commit uniquely\n\t// identifies the watched source head, so branch filtering only applies to pushes.\n\treturn event !== \"push\" || pipelineBranch === sourceBranch;\n}\n\nexport function createWoodpeckerProvider(\n\tdeps: CoreServerSetupDeps,\n\tintegration: WoodpeckerIntegration,\n\toptions: { now?: () => number } = {},\n) {\n\tconst due = createPollSchedule(options.now);\n\treturn deps.polling.create({\n\t\tid: \"woodpecker\",\n\t\tpollInterval: () => \"5s\",\n\t\tisEnabled: () => true,\n\t\tdefaultIntervalMs: 5_000,\n\t\tasync pollOnce() {\n\t\t\tconst result = emptyPollResult();\n\t\t\tconst report = createExternalSourcePollReporter(deps.externalSources, result);\n\t\t\tawait report.poll(WOODPECKER_PIPELINE_KIND, async (armed) => {\n\t\t\t\tconst config = parse(armed.resolved);\n\t\t\t\tif (!config) {\n\t\t\t\t\tresult.errors.push(`${armed.id}:invalid_config`);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (config.disabled) return;\n\t\t\t\tconst key = `${armed.instanceId}:${armed.id}`;\n\t\t\t\tif (!due(key, config.pollInterval)) return;\n\t\t\t\tconst client = integration.client(config.profile);\n\t\t\t\tconst repo = await client.lookupRepository(`${config.owner}/${config.repo}`);\n\t\t\t\tconst pipeline = await findLatestPipeline(client, repo.id, config);\n\t\t\t\tif (\n\t\t\t\t\t!pipeline ||\n\t\t\t\t\t!terminal.has(pipeline.status) ||\n\t\t\t\t\t(config.statuses && !config.statuses.includes(pipeline.status))\n\t\t\t\t)\n\t\t\t\t\treturn;\n\t\t\t\tawait report.fire(\n\t\t\t\t\tarmed,\n\t\t\t\t\t{ repositoryId: repo.id, pipeline },\n\t\t\t\t\t`${pipeline.number}:${pipeline.status}`,\n\t\t\t\t);\n\t\t\t});\n\t\t\treturn result;\n\t\t},\n\t});\n}\n\n/** The bounded lookup reports incomplete history instead of waiting silently. */\nexport async function findLatestPipeline(\n\tclient: WoodpeckerClientLike,\n\trepoId: number,\n\tconfig: WoodpeckerPipelineSourceConfig,\n) {\n\tfor (let page = 1; page <= 10; page++) {\n\t\tconst pipelines = (await client.listPipelines(repoId, undefined, { page, perPage: 100 })).sort(\n\t\t\t(a, b) => b.number - a.number,\n\t\t);\n\t\tconst match = pipelines.find(\n\t\t\t(candidate) =>\n\t\t\t\tcandidate.number > (config.afterPipelineNumber ?? 0) &&\n\t\t\t\tcandidate.commit === config.headSha &&\n\t\t\t\tsupportedEvents.has(candidate.event) &&\n\t\t\t\tmatchesBranch(candidate.event, candidate.branch, config.branch),\n\t\t);\n\t\tif (match) return match;\n\t\tif (\n\t\t\tpipelines.length < 100 ||\n\t\t\tpipelines.some((candidate) => candidate.number <= (config.afterPipelineNumber ?? 0))\n\t\t)\n\t\t\treturn null;\n\t}\n\tthrow new Error(\n\t\t\"Woodpecker pipeline lookup window exhausted (1000 pipelines); inspect the repository and update the watched pipeline floor before retrying\",\n\t);\n}\n","import type { ExternalActionSource } from \"@leitwerk-dev/process-sdk\";\n/** @internal */\nexport const WOODPECKER_PIPELINE_KIND = \"@leitwerk-private/woodpecker.pipeline\";\n/** @internal */\nexport interface WoodpeckerPipelineSourceConfig {\n\t/** @internal */\n\tprofile: string;\n\t/** @internal */\n\towner: string;\n\t/** @internal */\n\trepo: string;\n\t/** @internal */\n\tbranch: string;\n\t/** @internal */\n\theadSha: string;\n\t/** @internal */\n\tafterPipelineNumber?: number;\n\t/** @internal */\n\tdisabled?: boolean;\n\t/** @internal */\n\tpollInterval?: string;\n\t/** @internal */\n\tstatuses?: string[];\n}\n/** @internal */\nexport const woodpeckerExternal = {\n\t/** @internal */\n\tpipeline<TParams, TState>(\n\t\tresolve: (ctx: {\n\t\t\t/** @internal */\n\t\t\tparams: TParams;\n\t\t\t/** @internal */\n\t\t\tstate: TState;\n\t\t}) => WoodpeckerPipelineSourceConfig,\n\t): ExternalActionSource<TParams, TState> {\n\t\treturn {\n\t\t\tkind: WOODPECKER_PIPELINE_KIND,\n\t\t\tlabel: \"Woodpecker pipeline completion\",\n\t\t\tdescription: \"Fires when a pipeline matching the current source head completes\",\n\t\t\tconfig: {},\n\t\t\tinputMode: \"none\",\n\t\t\tresolve,\n\t\t};\n\t},\n};\n","import {\n\ttype IntegrationToolExecutionContext,\n\tnumberArg,\n\tprojectParameters,\n\ttype ServerExtensionAPI,\n\tstringArg,\n} from \"@leitwerk-dev/process-sdk\";\nimport { resolveWoodpeckerProjectBinding } from \"./binding.js\";\nimport type { WoodpeckerIntegration } from \"./capability.js\";\n\nfunction target(ctx: IntegrationToolExecutionContext) {\n\tconst binding = resolveWoodpeckerProjectBinding(ctx);\n\treturn { fullName: `${binding.owner}/${binding.repo}`, profile: binding.profile };\n}\n\nexport function registerWoodpeckerTools(\n\tapi: ServerExtensionAPI,\n\tintegration: WoodpeckerIntegration,\n) {\n\tconst schema = projectParameters();\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"woodpecker_lookup_repository\",\n\t\tdescription: \"Resolve the current process repository in Woodpecker\",\n\t\tparameters: schema,\n\t\tasync execute(ctx) {\n\t\t\tconst t = target(ctx);\n\t\t\treturn integration.client(t.profile).lookupRepository(t.fullName, ctx.signal);\n\t\t},\n\t});\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"woodpecker_list_pipelines\",\n\t\tdescription: \"List recent Woodpecker pipelines for the current process repository\",\n\t\tparameters: schema,\n\t\tasync execute(ctx) {\n\t\t\tconst t = target(ctx);\n\t\t\tconst client = integration.client(t.profile);\n\t\t\tconst repo = await client.lookupRepository(t.fullName, ctx.signal);\n\t\t\treturn client.listPipelines(repo.id, ctx.signal);\n\t\t},\n\t});\n\tfor (const name of [\"woodpecker_get_pipeline\", \"woodpecker_restart_pipeline\"] as const) {\n\t\tapi.tool<Record<string, unknown>>({\n\t\t\tname,\n\t\t\tdescription: name.endsWith(\"restart_pipeline\")\n\t\t\t\t? \"Restart a diagnosed Woodpecker pipeline\"\n\t\t\t\t: \"Read a Woodpecker pipeline\",\n\t\t\tparameters: projectParameters({\n\t\t\t\tpipelineNumber: { type: \"integer\" },\n\t\t\t\t...(name === \"woodpecker_restart_pipeline\"\n\t\t\t\t\t? {\n\t\t\t\t\t\t\tdiagnosis: {\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t\tdescription:\n\t\t\t\t\t\t\t\t\t\"Why this is an infrastructure or flaky failure rather than a repository defect\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\tlogEvidence: {\n\t\t\t\t\t\t\t\ttype: \"string\",\n\t\t\t\t\t\t\t\tdescription: \"Concrete bounded-log evidence supporting a restart\",\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t}\n\t\t\t\t\t: {}),\n\t\t\t}),\n\t\t\tasync execute(ctx, args) {\n\t\t\t\tconst t = target(ctx);\n\t\t\t\tconst client = integration.client(t.profile);\n\t\t\t\tconst repo = await client.lookupRepository(t.fullName, ctx.signal);\n\t\t\t\tconst number = numberArg(args, \"pipelineNumber\");\n\t\t\t\tif (name === \"woodpecker_get_pipeline\")\n\t\t\t\t\treturn client.getPipeline(repo.id, number, ctx.signal);\n\t\t\t\tconst diagnosis = stringArg(args, \"diagnosis\");\n\t\t\t\tconst logEvidence = stringArg(args, \"logEvidence\");\n\t\t\t\tawait ctx.externalWrites.logOnly(\n\t\t\t\t\t{ writeType: \"woodpecker.restart\", dedupKey: ctx.idempotencyKey },\n\t\t\t\t\tasync () => {\n\t\t\t\t\t\tawait client.restartPipeline(repo.id, number, ctx.signal);\n\t\t\t\t\t\treturn { repoId: repo.id, number, diagnosis, logEvidence };\n\t\t\t\t\t},\n\t\t\t\t);\n\t\t\t\treturn { ok: true };\n\t\t\t},\n\t\t});\n\t}\n\tapi.tool<Record<string, unknown>>({\n\t\tname: \"woodpecker_get_step_logs\",\n\t\tdescription: \"Read bounded logs for a Woodpecker pipeline step\",\n\t\tparameters: projectParameters(\n\t\t\t{\n\t\t\t\tpipelineNumber: { type: \"integer\" },\n\t\t\t\tstepId: { type: \"integer\" },\n\t\t\t\ttailLines: { type: \"integer\" },\n\t\t\t\tmaxBytes: { type: \"integer\" },\n\t\t\t},\n\t\t\t[\"pipelineNumber\", \"stepId\"],\n\t\t),\n\t\tasync execute(ctx, args) {\n\t\t\tconst t = target(ctx);\n\t\t\tconst client = integration.client(t.profile);\n\t\t\tconst repo = await client.lookupRepository(t.fullName, ctx.signal);\n\t\t\treturn client.getStepLogs(\n\t\t\t\trepo.id,\n\t\t\t\tnumberArg(args, \"pipelineNumber\"),\n\t\t\t\tnumberArg(args, \"stepId\"),\n\t\t\t\ttypeof args.tailLines === \"number\" ? args.tailLines : 400,\n\t\t\t\ttypeof args.maxBytes === \"number\" ? args.maxBytes : 262_144,\n\t\t\t\tctx.signal,\n\t\t\t);\n\t\t},\n\t});\n}\n","import { resolveRepositoryProjectBinding } from \"@leitwerk-dev/process-sdk\";\n\n/** @internal */\nexport const resolveWoodpeckerProjectBinding = (\n\tctx: Parameters<typeof resolveRepositoryProjectBinding>[0],\n) => resolveRepositoryProjectBinding(ctx, \"woodpecker\", \"forgejo\");\n"],"mappings":";;;;;AAAA,SAAS,4BAA0D;;;ACAnE,SAAS,6BAA6B;AAW/B,IAAM,wBAAwB;AAAA,EACpC;AACD;;;ACbA,SAAS,uBAAuB;AAChC,SAAS,6BAA6B;AAyCtC,SAAS,cAAc,MAA0C;AAChE,MAAI,MAAM,QAAQ,IAAI,GAAG;AACxB,WAAO,IAAI,YAAY,SAAS,EAAE,OAAO,MAAM,CAAC,EAAE,OAAO,WAAW,KAAK,IAAI,CAAC;AAAA,EAC/E;AACA,MAAI,OAAO,SAAS,SAAU,QAAO;AACrC,MAAI,yBAAyB,KAAK,IAAI,KAAK,KAAK,SAAS,MAAM,GAAG;AACjE,QAAI;AACH,YAAM,SAAS,KAAK,IAAI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BAAwB,KAAK,WAAW;AACxC,SAAO,yBAAyB,MAAM,aAAa,OAAO;AAC3D;","names":["asUnknownRecord","asUnknownRecord","value"]}
|
package/dist/provider.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ import type { WoodpeckerClientLike, WoodpeckerIntegration } from "./capability.j
|
|
|
3
3
|
import { type WoodpeckerPipelineSourceConfig } from "./external.js";
|
|
4
4
|
export declare function createWoodpeckerProvider(deps: CoreServerSetupDeps, integration: WoodpeckerIntegration, options?: {
|
|
5
5
|
now?: () => number;
|
|
6
|
-
}):
|
|
6
|
+
}): {
|
|
7
|
+
poll(): Promise<import("@leitwerk-dev/watcher-utils").PollResult>;
|
|
8
|
+
};
|
|
7
9
|
/** The bounded lookup reports incomplete history instead of waiting silently. */
|
|
8
10
|
export declare function findLatestPipeline(client: WoodpeckerClientLike, repoId: number, config: WoodpeckerPipelineSourceConfig): Promise<import("./client.js").WoodpeckerPipeline | null>;
|
|
9
11
|
//# sourceMappingURL=provider.d.ts.map
|
package/dist/provider.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,mBAAmB,EAExB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAA4B,KAAK,8BAA8B,EAAE,MAAM,eAAe,CAAC;AA2C9F,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,mBAAmB,EACzB,WAAW,EAAE,qBAAqB,EAClC,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,mBAAmB,EAExB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AACnF,OAAO,EAA4B,KAAK,8BAA8B,EAAE,MAAM,eAAe,CAAC;AA2C9F,wBAAgB,wBAAwB,CACvC,IAAI,EAAE,mBAAmB,EACzB,WAAW,EAAE,qBAAqB,EAClC,OAAO,GAAE;IAAE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAA;CAAO;;EAsCpC;AAED,iFAAiF;AACjF,wBAAsB,kBAAkB,CACvC,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,8BAA8B,4DAuBtC"}
|
package/dist/testing.d.ts
CHANGED
|
@@ -1,55 +1,96 @@
|
|
|
1
1
|
import { LocalProviderStore } from "@leitwerk-dev/test-support/local-git";
|
|
2
2
|
import type { WoodpeckerClientLike } from "./capability.js";
|
|
3
3
|
import type { WoodpeckerPipeline, WoodpeckerRepository } from "./client.js";
|
|
4
|
-
|
|
4
|
+
/** @public */
|
|
5
|
+
interface LocalWoodpeckerRepository {
|
|
6
|
+
/** @public */
|
|
5
7
|
repository: WoodpeckerRepository;
|
|
8
|
+
/** @public */
|
|
6
9
|
pipelines: Array<WoodpeckerPipeline & {
|
|
10
|
+
/** @internal */
|
|
7
11
|
logs: string;
|
|
12
|
+
/** @internal */
|
|
8
13
|
controlKey?: string;
|
|
9
14
|
}>;
|
|
10
15
|
}
|
|
16
|
+
/** @public */
|
|
11
17
|
export interface LocalWoodpeckerState {
|
|
18
|
+
/** @public */
|
|
12
19
|
version: 1;
|
|
20
|
+
/** @public */
|
|
13
21
|
sequence: number;
|
|
22
|
+
/** @public */
|
|
14
23
|
repositories: LocalWoodpeckerRepository[];
|
|
15
24
|
}
|
|
16
|
-
|
|
25
|
+
/** @public */
|
|
26
|
+
interface LocalWoodpeckerOptions {
|
|
27
|
+
/** @public */
|
|
17
28
|
root: string;
|
|
29
|
+
/** @public */
|
|
18
30
|
baseUrl: string;
|
|
31
|
+
/** @public */
|
|
19
32
|
now?: () => number;
|
|
33
|
+
/** @public */
|
|
20
34
|
nextId?: () => number;
|
|
21
35
|
}
|
|
22
|
-
/** Local CI state is independent of the repository's Git host. */
|
|
36
|
+
/** Local CI state is independent of the repository's Git host. @public */
|
|
23
37
|
export declare class LocalWoodpeckerAdapter extends LocalProviderStore<LocalWoodpeckerState, LocalWoodpeckerOptions> {
|
|
38
|
+
/** @public */
|
|
24
39
|
constructor(options: LocalWoodpeckerOptions);
|
|
40
|
+
/** @public */
|
|
25
41
|
seed(fullName: string, id?: number): LocalWoodpeckerRepository;
|
|
42
|
+
/** @public */
|
|
26
43
|
publish(repo: LocalWoodpeckerRepository, input: {
|
|
44
|
+
/** @public */
|
|
27
45
|
branch: string;
|
|
46
|
+
/** @public */
|
|
28
47
|
commit: string;
|
|
48
|
+
/** @public */
|
|
29
49
|
status: string;
|
|
50
|
+
/** @public */
|
|
30
51
|
logs: string;
|
|
52
|
+
/** @internal */
|
|
31
53
|
event?: string;
|
|
54
|
+
/** @internal */
|
|
32
55
|
controlKey?: string;
|
|
33
56
|
}): {
|
|
57
|
+
/** @internal */
|
|
34
58
|
id: number;
|
|
59
|
+
/** @public */
|
|
35
60
|
number: number;
|
|
61
|
+
/** @internal */
|
|
36
62
|
event: string;
|
|
63
|
+
/** @internal */
|
|
37
64
|
created_at: number;
|
|
65
|
+
/** @internal */
|
|
38
66
|
workflows: {
|
|
67
|
+
/** @internal */
|
|
39
68
|
id: number;
|
|
69
|
+
/** @internal */
|
|
40
70
|
name: string;
|
|
71
|
+
/** @internal */
|
|
41
72
|
steps: {
|
|
73
|
+
/** @internal */
|
|
42
74
|
id: number;
|
|
75
|
+
/** @internal */
|
|
43
76
|
name: string;
|
|
77
|
+
/** @internal */
|
|
44
78
|
state: string;
|
|
45
79
|
}[];
|
|
46
80
|
}[];
|
|
81
|
+
/** @public */
|
|
47
82
|
branch: string;
|
|
83
|
+
/** @public */
|
|
48
84
|
commit: string;
|
|
85
|
+
/** @public */
|
|
49
86
|
status: string;
|
|
87
|
+
/** @public */
|
|
50
88
|
logs: string;
|
|
89
|
+
/** @internal */
|
|
51
90
|
controlKey?: string;
|
|
52
91
|
};
|
|
92
|
+
/** @public */
|
|
53
93
|
client(): WoodpeckerClientLike;
|
|
54
94
|
}
|
|
95
|
+
export {};
|
|
55
96
|
//# sourceMappingURL=testing.d.ts.map
|
package/dist/testing.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAG5E,
|
|
1
|
+
{"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,sCAAsC,CAAC;AAC1E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAG5E,cAAc;AACd,UAAU,yBAAyB;IAClC,cAAc;IACd,UAAU,EAAE,oBAAoB,CAAC;IACjC,cAAc;IACd,SAAS,EAAE,KAAK,CACf,kBAAkB,GAAG;QACpB,gBAAgB;QAChB,IAAI,EAAE,MAAM,CAAC;QACb,gBAAgB;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KACpB,CACD,CAAC;CACF;AACD,cAAc;AACd,MAAM,WAAW,oBAAoB;IACpC,cAAc;IACd,OAAO,EAAE,CAAC,CAAC;IACX,cAAc;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,cAAc;IACd,YAAY,EAAE,yBAAyB,EAAE,CAAC;CAC1C;AACD,cAAc;AACd,UAAU,sBAAsB;IAC/B,cAAc;IACd,IAAI,EAAE,MAAM,CAAC;IACb,cAAc;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc;IACd,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,cAAc;IACd,MAAM,CAAC,EAAE,MAAM,MAAM,CAAC;CACtB;AAED,0EAA0E;AAC1E,qBAAa,sBAAuB,SAAQ,kBAAkB,CAC7D,oBAAoB,EACpB,sBAAsB,CACtB;IACA,cAAc;gBACF,OAAO,EAAE,sBAAsB;IAO3C,cAAc;IACd,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM;IASlC,cAAc;IACd,OAAO,CACN,IAAI,EAAE,yBAAyB,EAC/B,KAAK,EAAE;QACN,cAAc;QACd,MAAM,EAAE,MAAM,CAAC;QACf,cAAc;QACd,MAAM,EAAE,MAAM,CAAC;QACf,cAAc;QACd,MAAM,EAAE,MAAM,CAAC;QACf,cAAc;QACd,IAAI,EAAE,MAAM,CAAC;QACb,gBAAgB;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,gBAAgB;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KACpB;QAoBA,gBAAgB;;QAEhB,cAAc;;QAEd,gBAAgB;;QAEhB,gBAAgB;;QAEhB,gBAAgB;;YAGd,gBAAgB;;YAEhB,gBAAgB;;YAEhB,gBAAgB;;gBAGd,gBAAgB;;gBAEhB,gBAAgB;;gBAEhB,gBAAgB;;;;QAtDpB,cAAc;gBACN,MAAM;QACd,cAAc;gBACN,MAAM;QACd,cAAc;gBACN,MAAM;QACd,cAAc;cACR,MAAM;QAGZ,gBAAgB;qBACH,MAAM;;IAsDrB,cAAc;IACd,MAAM,IAAI,oBAAoB;CAsC9B"}
|
package/dist/testing.js
CHANGED
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
// src/testing.ts
|
|
6
6
|
import { LocalProviderStore } from "@leitwerk-dev/test-support/local-git";
|
|
7
7
|
var LocalWoodpeckerAdapter = class extends LocalProviderStore {
|
|
8
|
+
/** @public */
|
|
8
9
|
constructor(options) {
|
|
9
10
|
super(options, "woodpecker.json", {
|
|
10
11
|
version: 1,
|
|
@@ -12,6 +13,7 @@ var LocalWoodpeckerAdapter = class extends LocalProviderStore {
|
|
|
12
13
|
repositories: []
|
|
13
14
|
});
|
|
14
15
|
}
|
|
16
|
+
/** @public */
|
|
15
17
|
seed(fullName, id) {
|
|
16
18
|
const existing = this.state.repositories.find((r) => r.repository.full_name === fullName);
|
|
17
19
|
if (existing) return existing;
|
|
@@ -21,6 +23,7 @@ var LocalWoodpeckerAdapter = class extends LocalProviderStore {
|
|
|
21
23
|
this.save();
|
|
22
24
|
return repo;
|
|
23
25
|
}
|
|
26
|
+
/** @public */
|
|
24
27
|
publish(repo, input) {
|
|
25
28
|
if (![
|
|
26
29
|
"pending",
|
|
@@ -38,18 +41,40 @@ var LocalWoodpeckerAdapter = class extends LocalProviderStore {
|
|
|
38
41
|
const number = this.id();
|
|
39
42
|
const pipeline = {
|
|
40
43
|
...input,
|
|
44
|
+
/** @internal */
|
|
41
45
|
id: number,
|
|
46
|
+
/** @public */
|
|
42
47
|
number,
|
|
48
|
+
/** @internal */
|
|
43
49
|
event: input.event ?? "push",
|
|
50
|
+
/** @internal */
|
|
44
51
|
created_at: Math.floor((this.options.now?.() ?? Date.now()) / 1e3),
|
|
52
|
+
/** @internal */
|
|
45
53
|
workflows: [
|
|
46
|
-
{
|
|
54
|
+
{
|
|
55
|
+
/** @internal */
|
|
56
|
+
id: 1,
|
|
57
|
+
/** @internal */
|
|
58
|
+
name: "local",
|
|
59
|
+
/** @internal */
|
|
60
|
+
steps: [
|
|
61
|
+
{
|
|
62
|
+
/** @internal */
|
|
63
|
+
id: 1,
|
|
64
|
+
/** @internal */
|
|
65
|
+
name: "validation",
|
|
66
|
+
/** @internal */
|
|
67
|
+
state: input.status
|
|
68
|
+
}
|
|
69
|
+
]
|
|
70
|
+
}
|
|
47
71
|
]
|
|
48
72
|
};
|
|
49
73
|
repo.pipelines.push(pipeline);
|
|
50
74
|
this.save();
|
|
51
75
|
return pipeline;
|
|
52
76
|
}
|
|
77
|
+
/** @public */
|
|
53
78
|
client() {
|
|
54
79
|
const repo = (id) => {
|
|
55
80
|
const value = this.state.repositories.find((r) => r.repository.id === id);
|
package/dist/testing.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import { LocalProviderStore } from \"@leitwerk-dev/test-support/local-git\";\nimport type { WoodpeckerClientLike } from \"./capability.js\";\nimport type { WoodpeckerPipeline, WoodpeckerRepository } from \"./client.js\";\nimport { boundedLogTail } from \"./logs.js\";\n\
|
|
1
|
+
{"version":3,"sources":["../src/testing.ts"],"sourcesContent":["import { LocalProviderStore } from \"@leitwerk-dev/test-support/local-git\";\nimport type { WoodpeckerClientLike } from \"./capability.js\";\nimport type { WoodpeckerPipeline, WoodpeckerRepository } from \"./client.js\";\nimport { boundedLogTail } from \"./logs.js\";\n\n/** @public */\ninterface LocalWoodpeckerRepository {\n\t/** @public */\n\trepository: WoodpeckerRepository;\n\t/** @public */\n\tpipelines: Array<\n\t\tWoodpeckerPipeline & {\n\t\t\t/** @internal */\n\t\t\tlogs: string;\n\t\t\t/** @internal */\n\t\t\tcontrolKey?: string;\n\t\t}\n\t>;\n}\n/** @public */\nexport interface LocalWoodpeckerState {\n\t/** @public */\n\tversion: 1;\n\t/** @public */\n\tsequence: number;\n\t/** @public */\n\trepositories: LocalWoodpeckerRepository[];\n}\n/** @public */\ninterface LocalWoodpeckerOptions {\n\t/** @public */\n\troot: string;\n\t/** @public */\n\tbaseUrl: string;\n\t/** @public */\n\tnow?: () => number;\n\t/** @public */\n\tnextId?: () => number;\n}\n\n/** Local CI state is independent of the repository's Git host. @public */\nexport class LocalWoodpeckerAdapter extends LocalProviderStore<\n\tLocalWoodpeckerState,\n\tLocalWoodpeckerOptions\n> {\n\t/** @public */\n\tconstructor(options: LocalWoodpeckerOptions) {\n\t\tsuper(options, \"woodpecker.json\", {\n\t\t\tversion: 1,\n\t\t\tsequence: 0,\n\t\t\trepositories: [],\n\t\t});\n\t}\n\t/** @public */\n\tseed(fullName: string, id?: number) {\n\t\tconst existing = this.state.repositories.find((r) => r.repository.full_name === fullName);\n\t\tif (existing) return existing;\n\t\tconst repo = { repository: { id: id ?? this.id(), full_name: fullName }, pipelines: [] };\n\t\tthis.state.sequence = Math.max(this.state.sequence, repo.repository.id);\n\t\tthis.state.repositories.push(repo);\n\t\tthis.save();\n\t\treturn repo;\n\t}\n\t/** @public */\n\tpublish(\n\t\trepo: LocalWoodpeckerRepository,\n\t\tinput: {\n\t\t\t/** @public */\n\t\t\tbranch: string;\n\t\t\t/** @public */\n\t\t\tcommit: string;\n\t\t\t/** @public */\n\t\t\tstatus: string;\n\t\t\t/** @public */\n\t\t\tlogs: string;\n\t\t\t/** @internal */\n\t\t\tevent?: string;\n\t\t\t/** @internal */\n\t\t\tcontrolKey?: string;\n\t\t},\n\t) {\n\t\tif (\n\t\t\t![\n\t\t\t\t\"pending\",\n\t\t\t\t\"running\",\n\t\t\t\t\"success\",\n\t\t\t\t\"failure\",\n\t\t\t\t\"error\",\n\t\t\t\t\"killed\",\n\t\t\t\t\"canceled\",\n\t\t\t\t\"cancelled\",\n\t\t\t\t\"declined\",\n\t\t\t\t\"blocked\",\n\t\t\t].includes(input.status)\n\t\t)\n\t\t\tthrow new Error(\"Invalid pipeline status\");\n\t\tconst number = this.id();\n\t\tconst pipeline = {\n\t\t\t...input,\n\t\t\t/** @internal */\n\t\t\tid: number,\n\t\t\t/** @public */\n\t\t\tnumber,\n\t\t\t/** @internal */\n\t\t\tevent: input.event ?? \"push\",\n\t\t\t/** @internal */\n\t\t\tcreated_at: Math.floor((this.options.now?.() ?? Date.now()) / 1000),\n\t\t\t/** @internal */\n\t\t\tworkflows: [\n\t\t\t\t{\n\t\t\t\t\t/** @internal */\n\t\t\t\t\tid: 1,\n\t\t\t\t\t/** @internal */\n\t\t\t\t\tname: \"local\",\n\t\t\t\t\t/** @internal */\n\t\t\t\t\tsteps: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\t/** @internal */\n\t\t\t\t\t\t\tid: 1,\n\t\t\t\t\t\t\t/** @internal */\n\t\t\t\t\t\t\tname: \"validation\",\n\t\t\t\t\t\t\t/** @internal */\n\t\t\t\t\t\t\tstate: input.status,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t},\n\t\t\t],\n\t\t};\n\t\trepo.pipelines.push(pipeline);\n\t\tthis.save();\n\t\treturn pipeline;\n\t}\n\t/** @public */\n\tclient(): WoodpeckerClientLike {\n\t\tconst repo = (id: number) => {\n\t\t\tconst value = this.state.repositories.find((r) => r.repository.id === id);\n\t\t\tif (!value) throw new Error(\"Unknown local CI repository\");\n\t\t\treturn value;\n\t\t};\n\t\tconst pipeline = (id: number, number: number) => {\n\t\t\tconst value = repo(id).pipelines.find((p) => p.number === number);\n\t\t\tif (!value) throw new Error(\"Unknown local pipeline\");\n\t\t\treturn value;\n\t\t};\n\t\treturn {\n\t\t\tprofile: { baseUrl: this.options.baseUrl, token: \"\" },\n\t\t\tlookupRepository: async (name) => {\n\t\t\t\tconst value = this.state.repositories.find((r) => r.repository.full_name === name);\n\t\t\t\tif (!value) throw new Error(\"Unknown local CI repository\");\n\t\t\t\treturn structuredClone(value.repository);\n\t\t\t},\n\t\t\tlistPipelines: async (id, _signal, { page = 1, perPage = 100 } = { page: 1 }) =>\n\t\t\t\tstructuredClone(\n\t\t\t\t\t[...repo(id).pipelines]\n\t\t\t\t\t\t.sort((a, b) => b.number - a.number)\n\t\t\t\t\t\t.slice((page - 1) * perPage, page * perPage),\n\t\t\t\t),\n\t\t\tgetPipeline: async (id, number) => structuredClone(pipeline(id, number)),\n\t\t\tgetStepLogs: async (id, number, _step, tail = 400, bytes = 262144) => {\n\t\t\t\tconst original = pipeline(id, number).logs;\n\t\t\t\tconst logs = boundedLogTail(original.split(\"\\n\"), tail, bytes);\n\t\t\t\treturn { logs, truncated: logs !== original };\n\t\t\t},\n\t\t\trestartPipeline: async (id, number) => {\n\t\t\t\tconst value = pipeline(id, number);\n\t\t\t\tvalue.status = \"pending\";\n\t\t\t\tthis.save();\n\t\t\t\treturn structuredClone(value);\n\t\t\t},\n\t\t};\n\t}\n}\n"],"mappings":";;;;;AAAA,SAAS,0BAA0B;AAyC5B,IAAM,yBAAN,cAAqC,mBAG1C;AAAA;AAAA,EAED,YAAY,SAAiC;AAC5C,UAAM,SAAS,mBAAmB;AAAA,MACjC,SAAS;AAAA,MACT,UAAU;AAAA,MACV,cAAc,CAAC;AAAA,IAChB,CAAC;AAAA,EACF;AAAA;AAAA,EAEA,KAAK,UAAkB,IAAa;AACnC,UAAM,WAAW,KAAK,MAAM,aAAa,KAAK,CAAC,MAAM,EAAE,WAAW,cAAc,QAAQ;AACxF,QAAI,SAAU,QAAO;AACrB,UAAM,OAAO,EAAE,YAAY,EAAE,IAAI,MAAM,KAAK,GAAG,GAAG,WAAW,SAAS,GAAG,WAAW,CAAC,EAAE;AACvF,SAAK,MAAM,WAAW,KAAK,IAAI,KAAK,MAAM,UAAU,KAAK,WAAW,EAAE;AACtE,SAAK,MAAM,aAAa,KAAK,IAAI;AACjC,SAAK,KAAK;AACV,WAAO;AAAA,EACR;AAAA;AAAA,EAEA,QACC,MACA,OAcC;AACD,QACC,CAAC;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD,EAAE,SAAS,MAAM,MAAM;AAEvB,YAAM,IAAI,MAAM,yBAAyB;AAC1C,UAAM,SAAS,KAAK,GAAG;AACvB,UAAM,WAAW;AAAA,MAChB,GAAG;AAAA;AAAA,MAEH,IAAI;AAAA;AAAA,MAEJ;AAAA;AAAA,MAEA,OAAO,MAAM,SAAS;AAAA;AAAA,MAEtB,Y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G,MAAM,EAAE,SAAS,EAAE,MAAM,EAClC,OAAO,OAAO,KAAK,SAAS,OAAO,OAAO;AAAA,MAC7C;AAAA,MACD,aAAa,OAAO,IAAI,WAAW,gBAAgB,SAAS,IAAI,MAAM,CAAC;AAAA,MACvE,aAAa,OAAO,IAAI,QAAQ,OAAO,OAAO,KAAK,QAAQ,WAAW;AACrE,cAAM,WAAW,SAAS,IAAI,MAAM,EAAE;AACtC,cAAM,OAAO,eAAe,SAAS,MAAM,IAAI,GAAG,MAAM,KAAK;AAC7D,eAAO,EAAE,MAAM,WAAW,SAAS,SAAS;AAAA,MAC7C;AAAA,MACA,iBAAiB,OAAO,IAAI,WAAW;AACtC,cAAM,QAAQ,SAAS,IAAI,MAAM;AACjC,cAAM,SAAS;AACf,aAAK,KAAK;AACV,eAAO,gBAAgB,KAAK;AAAA,MAC7B;AAAA,IACD;AAAA,EACD;AACD;","names":[]}
|
package/dist/tools.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { type ExternalWriteLogRepoLike } from "@leitwerk-dev/external-writes";
|
|
2
1
|
import { type ServerExtensionAPI } from "@leitwerk-dev/process-sdk";
|
|
3
2
|
import type { WoodpeckerIntegration } from "./capability.js";
|
|
4
|
-
export declare function registerWoodpeckerTools(api: ServerExtensionAPI, integration: WoodpeckerIntegration
|
|
3
|
+
export declare function registerWoodpeckerTools(api: ServerExtensionAPI, integration: WoodpeckerIntegration): void;
|
|
5
4
|
//# sourceMappingURL=tools.d.ts.map
|
package/dist/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,kBAAkB,EAEvB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAO7D,wBAAgB,uBAAuB,CACtC,GAAG,EAAE,kBAAkB,EACvB,WAAW,EAAE,qBAAqB,QA2FlC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leitwerk-dev/woodpecker",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"leitwerk": {
|
|
6
6
|
"extension": {
|
|
@@ -25,11 +25,10 @@
|
|
|
25
25
|
"build": "tsup && tsc -p tsconfig.tsup.json --emitDeclarationOnly"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@leitwerk-dev/domain": "0.2.
|
|
29
|
-
"@leitwerk-dev/
|
|
30
|
-
"@leitwerk-dev/
|
|
31
|
-
"@leitwerk-dev/
|
|
32
|
-
"@leitwerk-dev/test-support": "0.2.0"
|
|
28
|
+
"@leitwerk-dev/domain": "0.2.1",
|
|
29
|
+
"@leitwerk-dev/process-sdk": "0.2.1",
|
|
30
|
+
"@leitwerk-dev/watcher-utils": "0.2.1",
|
|
31
|
+
"@leitwerk-dev/test-support": "0.2.1"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
35
34
|
"tsup": "^8.5.1",
|
package/src/binding.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { resolveRepositoryProjectBinding } from "@leitwerk-dev/process-sdk";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
/** @internal */
|
|
4
4
|
export const resolveWoodpeckerProjectBinding = (
|
|
5
5
|
ctx: Parameters<typeof resolveRepositoryProjectBinding>[0],
|
|
6
6
|
) => resolveRepositoryProjectBinding(ctx, "woodpecker", "forgejo");
|
package/src/capability.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import { createCapabilityToken } from "@leitwerk-dev/process-sdk";
|
|
2
2
|
import type { WoodpeckerClient } from "./client.js";
|
|
3
|
-
/** Public contract shared by HTTP and local adapters. */
|
|
3
|
+
/** Public contract shared by HTTP and local adapters. @public */
|
|
4
4
|
export type WoodpeckerClientLike = Pick<WoodpeckerClient, keyof WoodpeckerClient>;
|
|
5
5
|
|
|
6
|
+
/** @public */
|
|
6
7
|
export interface WoodpeckerIntegration {
|
|
8
|
+
/** @public */
|
|
7
9
|
client(profile: string): WoodpeckerClientLike;
|
|
8
10
|
}
|
|
11
|
+
/** @internal */
|
|
9
12
|
export const woodpeckerIntegration = createCapabilityToken<WoodpeckerIntegration>(
|
|
10
13
|
"@leitwerk-private/woodpecker.integration",
|
|
11
14
|
);
|
package/src/client.ts
CHANGED
|
@@ -2,22 +2,37 @@ import { asUnknownRecord } from "@leitwerk-dev/domain";
|
|
|
2
2
|
import { IntegrationHttpClient } from "@leitwerk-dev/process-sdk";
|
|
3
3
|
import { boundedLogTail } from "./logs.js";
|
|
4
4
|
|
|
5
|
+
/** @internal */
|
|
5
6
|
export interface WoodpeckerProfile {
|
|
7
|
+
/** @internal */
|
|
6
8
|
baseUrl: string;
|
|
9
|
+
/** @internal */
|
|
7
10
|
token: string;
|
|
8
11
|
}
|
|
12
|
+
/** @public */
|
|
9
13
|
export interface WoodpeckerRepository {
|
|
14
|
+
/** @public */
|
|
10
15
|
id: number;
|
|
16
|
+
/** @public */
|
|
11
17
|
full_name: string;
|
|
12
18
|
}
|
|
19
|
+
/** @public */
|
|
13
20
|
export interface WoodpeckerPipeline {
|
|
21
|
+
/** @internal */
|
|
14
22
|
id: number;
|
|
23
|
+
/** @internal */
|
|
15
24
|
number: number;
|
|
25
|
+
/** @internal */
|
|
16
26
|
status: string;
|
|
27
|
+
/** @internal */
|
|
17
28
|
event: string;
|
|
29
|
+
/** @internal */
|
|
18
30
|
branch: string;
|
|
31
|
+
/** @internal */
|
|
19
32
|
commit: string;
|
|
33
|
+
/** @internal */
|
|
20
34
|
created_at?: number;
|
|
35
|
+
/** @internal */
|
|
21
36
|
workflows?: unknown[];
|
|
22
37
|
}
|
|
23
38
|
|
|
@@ -43,6 +58,7 @@ function decodeLogData(data: WoodpeckerLogEntry["data"]): string {
|
|
|
43
58
|
return data;
|
|
44
59
|
}
|
|
45
60
|
|
|
61
|
+
/** @internal */
|
|
46
62
|
export function parseWoodpeckerProfiles(value: unknown): Map<string, WoodpeckerProfile> {
|
|
47
63
|
const profiles = new Map<string, WoodpeckerProfile>();
|
|
48
64
|
for (const [name, raw] of Object.entries(
|
|
@@ -59,24 +75,36 @@ export function parseWoodpeckerProfiles(value: unknown): Map<string, WoodpeckerP
|
|
|
59
75
|
return profiles;
|
|
60
76
|
}
|
|
61
77
|
|
|
78
|
+
/** @public */
|
|
62
79
|
export class WoodpeckerClient extends IntegrationHttpClient {
|
|
63
|
-
|
|
80
|
+
/** @internal */
|
|
81
|
+
constructor(
|
|
82
|
+
/** @internal */
|
|
83
|
+
readonly profile: WoodpeckerProfile,
|
|
84
|
+
) {
|
|
64
85
|
super("Woodpecker", `${profile.baseUrl}/api`, {
|
|
65
86
|
Authorization: `Bearer ${profile.token}`,
|
|
66
87
|
Accept: "application/json",
|
|
67
88
|
});
|
|
68
89
|
}
|
|
69
90
|
|
|
91
|
+
/** @internal */
|
|
70
92
|
lookupRepository(fullName: string, signal?: AbortSignal): Promise<WoodpeckerRepository> {
|
|
71
93
|
return this.request(`/repos/lookup/${encodeURIComponent(fullName)}`, {
|
|
72
94
|
signal,
|
|
73
95
|
});
|
|
74
96
|
}
|
|
75
97
|
|
|
98
|
+
/** @internal */
|
|
76
99
|
listPipelines(
|
|
77
100
|
repoId: number,
|
|
78
101
|
signal?: AbortSignal,
|
|
79
|
-
pagination: {
|
|
102
|
+
pagination: {
|
|
103
|
+
/** @internal */
|
|
104
|
+
page: number;
|
|
105
|
+
/** @internal */
|
|
106
|
+
perPage?: number;
|
|
107
|
+
} = { page: 1 },
|
|
80
108
|
): Promise<WoodpeckerPipeline[]> {
|
|
81
109
|
const { page, perPage = 100 } = pagination;
|
|
82
110
|
if (
|
|
@@ -92,10 +120,12 @@ export class WoodpeckerClient extends IntegrationHttpClient {
|
|
|
92
120
|
});
|
|
93
121
|
}
|
|
94
122
|
|
|
123
|
+
/** @internal */
|
|
95
124
|
getPipeline(repoId: number, number: number, signal?: AbortSignal): Promise<WoodpeckerPipeline> {
|
|
96
125
|
return this.request(`/repos/${repoId}/pipelines/${number}`, { signal });
|
|
97
126
|
}
|
|
98
127
|
|
|
128
|
+
/** @public */
|
|
99
129
|
async getStepLogs(
|
|
100
130
|
repoId: number,
|
|
101
131
|
number: number,
|
|
@@ -126,9 +156,15 @@ export class WoodpeckerClient extends IntegrationHttpClient {
|
|
|
126
156
|
// Older adapters may return text directly; retain it as-is.
|
|
127
157
|
}
|
|
128
158
|
const output = boundedLogTail(text.split(/\r?\n/), tailLines, maxBytes);
|
|
129
|
-
return {
|
|
159
|
+
return {
|
|
160
|
+
/** @public */
|
|
161
|
+
logs: output,
|
|
162
|
+
/** @internal */
|
|
163
|
+
truncated: output.length < text.length,
|
|
164
|
+
};
|
|
130
165
|
}
|
|
131
166
|
|
|
167
|
+
/** @internal */
|
|
132
168
|
restartPipeline(
|
|
133
169
|
repoId: number,
|
|
134
170
|
number: number,
|
package/src/external.ts
CHANGED
|
@@ -1,19 +1,37 @@
|
|
|
1
1
|
import type { ExternalActionSource } from "@leitwerk-dev/process-sdk";
|
|
2
|
+
/** @internal */
|
|
2
3
|
export const WOODPECKER_PIPELINE_KIND = "@leitwerk-private/woodpecker.pipeline";
|
|
4
|
+
/** @internal */
|
|
3
5
|
export interface WoodpeckerPipelineSourceConfig {
|
|
6
|
+
/** @internal */
|
|
4
7
|
profile: string;
|
|
8
|
+
/** @internal */
|
|
5
9
|
owner: string;
|
|
10
|
+
/** @internal */
|
|
6
11
|
repo: string;
|
|
12
|
+
/** @internal */
|
|
7
13
|
branch: string;
|
|
14
|
+
/** @internal */
|
|
8
15
|
headSha: string;
|
|
16
|
+
/** @internal */
|
|
9
17
|
afterPipelineNumber?: number;
|
|
18
|
+
/** @internal */
|
|
10
19
|
disabled?: boolean;
|
|
20
|
+
/** @internal */
|
|
11
21
|
pollInterval?: string;
|
|
22
|
+
/** @internal */
|
|
12
23
|
statuses?: string[];
|
|
13
24
|
}
|
|
25
|
+
/** @internal */
|
|
14
26
|
export const woodpeckerExternal = {
|
|
27
|
+
/** @internal */
|
|
15
28
|
pipeline<TParams, TState>(
|
|
16
|
-
resolve: (ctx: {
|
|
29
|
+
resolve: (ctx: {
|
|
30
|
+
/** @internal */
|
|
31
|
+
params: TParams;
|
|
32
|
+
/** @internal */
|
|
33
|
+
state: TState;
|
|
34
|
+
}) => WoodpeckerPipelineSourceConfig,
|
|
17
35
|
): ExternalActionSource<TParams, TState> {
|
|
18
36
|
return {
|
|
19
37
|
kind: WOODPECKER_PIPELINE_KIND,
|
package/src/index.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
|
-
import type { ExternalWriteLogRepoLike } from "@leitwerk-dev/external-writes";
|
|
2
1
|
import { coreHostCapabilities, type LeitwerkExtensionModule } from "@leitwerk-dev/process-sdk";
|
|
3
2
|
import { type WoodpeckerIntegration, woodpeckerIntegration } from "./capability.js";
|
|
4
3
|
import { parseWoodpeckerProfiles, WoodpeckerClient } from "./client.js";
|
|
5
4
|
import { createWoodpeckerProvider } from "./provider.js";
|
|
6
5
|
import { registerWoodpeckerTools } from "./tools.js";
|
|
7
|
-
|
|
6
|
+
|
|
7
|
+
/** @internal */
|
|
8
|
+
const manifest = {
|
|
9
|
+
/** @internal */
|
|
10
|
+
id: "woodpecker",
|
|
11
|
+
/** @internal */
|
|
12
|
+
version: "0.1.9",
|
|
13
|
+
} as const;
|
|
14
|
+
/** @public */
|
|
8
15
|
const extension: LeitwerkExtensionModule = {
|
|
9
16
|
manifest,
|
|
10
17
|
setupServer(api, config) {
|
|
@@ -20,21 +27,25 @@ const extension: LeitwerkExtensionModule = {
|
|
|
20
27
|
},
|
|
21
28
|
};
|
|
22
29
|
|
|
23
|
-
export
|
|
24
|
-
export
|
|
25
|
-
export
|
|
30
|
+
export type { WoodpeckerIntegration } from "./capability.js";
|
|
31
|
+
export { woodpeckerIntegration } from "./capability.js";
|
|
32
|
+
export type { WoodpeckerPipeline } from "./client.js";
|
|
33
|
+
export { WOODPECKER_PIPELINE_KIND, woodpeckerExternal } from "./external.js";
|
|
26
34
|
export default extension;
|
|
27
35
|
|
|
28
|
-
/** Register shared tools and polling with an explicit integration. */
|
|
36
|
+
/** Register shared tools and polling with an explicit integration. @public */
|
|
29
37
|
export function setupWoodpeckerIntegration(
|
|
30
38
|
api: Parameters<NonNullable<LeitwerkExtensionModule["setupServer"]>>[0],
|
|
31
39
|
integration: WoodpeckerIntegration,
|
|
32
|
-
options: {
|
|
40
|
+
options: {
|
|
41
|
+
/** @public */
|
|
42
|
+
now?: () => number;
|
|
43
|
+
} = {},
|
|
33
44
|
) {
|
|
34
45
|
api.provide(woodpeckerIntegration, integration);
|
|
35
46
|
const deps = api.get(coreHostCapabilities.serverSetup);
|
|
36
47
|
if (!deps || Array.isArray(deps)) return;
|
|
37
|
-
registerWoodpeckerTools(api, integration
|
|
48
|
+
registerWoodpeckerTools(api, integration);
|
|
38
49
|
return createWoodpeckerProvider(deps, integration, options);
|
|
39
50
|
}
|
|
40
51
|
|
package/src/testing.ts
CHANGED
|
@@ -3,27 +3,47 @@ import type { WoodpeckerClientLike } from "./capability.js";
|
|
|
3
3
|
import type { WoodpeckerPipeline, WoodpeckerRepository } from "./client.js";
|
|
4
4
|
import { boundedLogTail } from "./logs.js";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/** @public */
|
|
7
|
+
interface LocalWoodpeckerRepository {
|
|
8
|
+
/** @public */
|
|
7
9
|
repository: WoodpeckerRepository;
|
|
8
|
-
|
|
10
|
+
/** @public */
|
|
11
|
+
pipelines: Array<
|
|
12
|
+
WoodpeckerPipeline & {
|
|
13
|
+
/** @internal */
|
|
14
|
+
logs: string;
|
|
15
|
+
/** @internal */
|
|
16
|
+
controlKey?: string;
|
|
17
|
+
}
|
|
18
|
+
>;
|
|
9
19
|
}
|
|
20
|
+
/** @public */
|
|
10
21
|
export interface LocalWoodpeckerState {
|
|
22
|
+
/** @public */
|
|
11
23
|
version: 1;
|
|
24
|
+
/** @public */
|
|
12
25
|
sequence: number;
|
|
26
|
+
/** @public */
|
|
13
27
|
repositories: LocalWoodpeckerRepository[];
|
|
14
28
|
}
|
|
15
|
-
|
|
29
|
+
/** @public */
|
|
30
|
+
interface LocalWoodpeckerOptions {
|
|
31
|
+
/** @public */
|
|
16
32
|
root: string;
|
|
33
|
+
/** @public */
|
|
17
34
|
baseUrl: string;
|
|
35
|
+
/** @public */
|
|
18
36
|
now?: () => number;
|
|
37
|
+
/** @public */
|
|
19
38
|
nextId?: () => number;
|
|
20
39
|
}
|
|
21
40
|
|
|
22
|
-
/** Local CI state is independent of the repository's Git host. */
|
|
41
|
+
/** Local CI state is independent of the repository's Git host. @public */
|
|
23
42
|
export class LocalWoodpeckerAdapter extends LocalProviderStore<
|
|
24
43
|
LocalWoodpeckerState,
|
|
25
44
|
LocalWoodpeckerOptions
|
|
26
45
|
> {
|
|
46
|
+
/** @public */
|
|
27
47
|
constructor(options: LocalWoodpeckerOptions) {
|
|
28
48
|
super(options, "woodpecker.json", {
|
|
29
49
|
version: 1,
|
|
@@ -31,6 +51,7 @@ export class LocalWoodpeckerAdapter extends LocalProviderStore<
|
|
|
31
51
|
repositories: [],
|
|
32
52
|
});
|
|
33
53
|
}
|
|
54
|
+
/** @public */
|
|
34
55
|
seed(fullName: string, id?: number) {
|
|
35
56
|
const existing = this.state.repositories.find((r) => r.repository.full_name === fullName);
|
|
36
57
|
if (existing) return existing;
|
|
@@ -40,14 +61,21 @@ export class LocalWoodpeckerAdapter extends LocalProviderStore<
|
|
|
40
61
|
this.save();
|
|
41
62
|
return repo;
|
|
42
63
|
}
|
|
64
|
+
/** @public */
|
|
43
65
|
publish(
|
|
44
66
|
repo: LocalWoodpeckerRepository,
|
|
45
67
|
input: {
|
|
68
|
+
/** @public */
|
|
46
69
|
branch: string;
|
|
70
|
+
/** @public */
|
|
47
71
|
commit: string;
|
|
72
|
+
/** @public */
|
|
48
73
|
status: string;
|
|
74
|
+
/** @public */
|
|
49
75
|
logs: string;
|
|
76
|
+
/** @internal */
|
|
50
77
|
event?: string;
|
|
78
|
+
/** @internal */
|
|
51
79
|
controlKey?: string;
|
|
52
80
|
},
|
|
53
81
|
) {
|
|
@@ -69,18 +97,40 @@ export class LocalWoodpeckerAdapter extends LocalProviderStore<
|
|
|
69
97
|
const number = this.id();
|
|
70
98
|
const pipeline = {
|
|
71
99
|
...input,
|
|
100
|
+
/** @internal */
|
|
72
101
|
id: number,
|
|
102
|
+
/** @public */
|
|
73
103
|
number,
|
|
104
|
+
/** @internal */
|
|
74
105
|
event: input.event ?? "push",
|
|
106
|
+
/** @internal */
|
|
75
107
|
created_at: Math.floor((this.options.now?.() ?? Date.now()) / 1000),
|
|
108
|
+
/** @internal */
|
|
76
109
|
workflows: [
|
|
77
|
-
{
|
|
110
|
+
{
|
|
111
|
+
/** @internal */
|
|
112
|
+
id: 1,
|
|
113
|
+
/** @internal */
|
|
114
|
+
name: "local",
|
|
115
|
+
/** @internal */
|
|
116
|
+
steps: [
|
|
117
|
+
{
|
|
118
|
+
/** @internal */
|
|
119
|
+
id: 1,
|
|
120
|
+
/** @internal */
|
|
121
|
+
name: "validation",
|
|
122
|
+
/** @internal */
|
|
123
|
+
state: input.status,
|
|
124
|
+
},
|
|
125
|
+
],
|
|
126
|
+
},
|
|
78
127
|
],
|
|
79
128
|
};
|
|
80
129
|
repo.pipelines.push(pipeline);
|
|
81
130
|
this.save();
|
|
82
131
|
return pipeline;
|
|
83
132
|
}
|
|
133
|
+
/** @public */
|
|
84
134
|
client(): WoodpeckerClientLike {
|
|
85
135
|
const repo = (id: number) => {
|
|
86
136
|
const value = this.state.repositories.find((r) => r.repository.id === id);
|
package/src/tools.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createWriteIdentity,
|
|
3
|
-
type ExternalWriteLogRepoLike,
|
|
4
|
-
ensureWrite,
|
|
5
|
-
} from "@leitwerk-dev/external-writes";
|
|
6
1
|
import {
|
|
7
2
|
type IntegrationToolExecutionContext,
|
|
8
3
|
numberArg,
|
|
@@ -21,7 +16,6 @@ function target(ctx: IntegrationToolExecutionContext) {
|
|
|
21
16
|
export function registerWoodpeckerTools(
|
|
22
17
|
api: ServerExtensionAPI,
|
|
23
18
|
integration: WoodpeckerIntegration,
|
|
24
|
-
writes: ExternalWriteLogRepoLike,
|
|
25
19
|
) {
|
|
26
20
|
const schema = projectParameters();
|
|
27
21
|
api.tool<Record<string, unknown>>({
|
|
@@ -75,10 +69,8 @@ export function registerWoodpeckerTools(
|
|
|
75
69
|
return client.getPipeline(repo.id, number, ctx.signal);
|
|
76
70
|
const diagnosis = stringArg(args, "diagnosis");
|
|
77
71
|
const logEvidence = stringArg(args, "logEvidence");
|
|
78
|
-
await
|
|
79
|
-
|
|
80
|
-
ctx.process.id,
|
|
81
|
-
createWriteIdentity("woodpecker.restart", ctx.idempotencyKey),
|
|
72
|
+
await ctx.externalWrites.logOnly(
|
|
73
|
+
{ writeType: "woodpecker.restart", dedupKey: ctx.idempotencyKey },
|
|
82
74
|
async () => {
|
|
83
75
|
await client.restartPipeline(repo.id, number, ctx.signal);
|
|
84
76
|
return { repoId: repo.id, number, diagnosis, logEvidence };
|