@cat-factory/worker 0.6.0 → 0.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/LICENSE +21 -21
  2. package/dist/infrastructure/container.d.ts.map +1 -1
  3. package/dist/infrastructure/container.js +36 -2
  4. package/dist/infrastructure/container.js.map +1 -1
  5. package/dist/infrastructure/repositories/D1BootstrapJobRepository.js +4 -4
  6. package/dist/infrastructure/repositories/D1ModelDefaultsRepository.js +1 -1
  7. package/dist/infrastructure/repositories/D1PipelineScheduleRepository.js +25 -25
  8. package/dist/infrastructure/repositories/D1RepoProjectionRepository.js +6 -6
  9. package/dist/infrastructure/repositories/D1ServiceRepository.js +1 -1
  10. package/dist/infrastructure/repositories/D1TrackerSettingsRepository.d.ts.map +1 -1
  11. package/dist/infrastructure/repositories/D1TrackerSettingsRepository.js +12 -6
  12. package/dist/infrastructure/repositories/D1TrackerSettingsRepository.js.map +1 -1
  13. package/dist/infrastructure/repositories/D1WorkspaceMountRepository.js +8 -8
  14. package/migrations/0005_issue_tracker_writeback.sql +11 -0
  15. package/package.json +18 -13
  16. package/dist/infrastructure/ai/CloudflareModelProvider.d.ts +0 -23
  17. package/dist/infrastructure/ai/CloudflareModelProvider.d.ts.map +0 -1
  18. package/dist/infrastructure/ai/CloudflareModelProvider.js +0 -62
  19. package/dist/infrastructure/ai/CloudflareModelProvider.js.map +0 -1
  20. package/dist/infrastructure/ai/ContainerRepoScanner.d.ts +0 -39
  21. package/dist/infrastructure/ai/ContainerRepoScanner.d.ts.map +0 -1
  22. package/dist/infrastructure/ai/ContainerRepoScanner.js +0 -115
  23. package/dist/infrastructure/ai/ContainerRepoScanner.js.map +0 -1
  24. package/dist/infrastructure/documents/ConfluenceProvider.d.ts +0 -29
  25. package/dist/infrastructure/documents/ConfluenceProvider.d.ts.map +0 -1
  26. package/dist/infrastructure/documents/ConfluenceProvider.js +0 -179
  27. package/dist/infrastructure/documents/ConfluenceProvider.js.map +0 -1
  28. package/dist/infrastructure/documents/GitHubDocsProvider.d.ts +0 -42
  29. package/dist/infrastructure/documents/GitHubDocsProvider.d.ts.map +0 -1
  30. package/dist/infrastructure/documents/GitHubDocsProvider.js +0 -85
  31. package/dist/infrastructure/documents/GitHubDocsProvider.js.map +0 -1
  32. package/dist/infrastructure/documents/NotionProvider.d.ts +0 -32
  33. package/dist/infrastructure/documents/NotionProvider.d.ts.map +0 -1
  34. package/dist/infrastructure/documents/NotionProvider.js +0 -220
  35. package/dist/infrastructure/documents/NotionProvider.js.map +0 -1
  36. package/dist/infrastructure/environments/HttpEnvironmentProvider.d.ts +0 -27
  37. package/dist/infrastructure/environments/HttpEnvironmentProvider.d.ts.map +0 -1
  38. package/dist/infrastructure/environments/HttpEnvironmentProvider.js +0 -314
  39. package/dist/infrastructure/environments/HttpEnvironmentProvider.js.map +0 -1
  40. package/dist/infrastructure/events/InAppNotificationChannel.d.ts +0 -19
  41. package/dist/infrastructure/events/InAppNotificationChannel.d.ts.map +0 -1
  42. package/dist/infrastructure/events/InAppNotificationChannel.js +0 -22
  43. package/dist/infrastructure/events/InAppNotificationChannel.js.map +0 -1
  44. package/dist/infrastructure/repositories/D1RepoBlueprintRepository.d.ts +0 -20
  45. package/dist/infrastructure/repositories/D1RepoBlueprintRepository.d.ts.map +0 -1
  46. package/dist/infrastructure/repositories/D1RepoBlueprintRepository.js +0 -64
  47. package/dist/infrastructure/repositories/D1RepoBlueprintRepository.js.map +0 -1
  48. package/dist/infrastructure/tasks/GitHubIssuesProvider.d.ts +0 -50
  49. package/dist/infrastructure/tasks/GitHubIssuesProvider.d.ts.map +0 -1
  50. package/dist/infrastructure/tasks/GitHubIssuesProvider.js +0 -91
  51. package/dist/infrastructure/tasks/GitHubIssuesProvider.js.map +0 -1
  52. package/dist/infrastructure/tasks/JiraProvider.d.ts +0 -29
  53. package/dist/infrastructure/tasks/JiraProvider.d.ts.map +0 -1
  54. package/dist/infrastructure/tasks/JiraProvider.js +0 -109
  55. package/dist/infrastructure/tasks/JiraProvider.js.map +0 -1
@@ -1,20 +0,0 @@
1
- import type { RepoBlueprintRecord, RepoBlueprintRepository } from '@cat-factory/kernel';
2
- import type { D1Database } from '@cloudflare/workers-types';
3
- /**
4
- * D1-backed store of repository blueprints (migration 0011). One row per
5
- * (workspace, repo): `upsert` replaces the existing blueprint in place, keyed by
6
- * the unique `(workspace_id, repo_owner, repo_name)` index, so the row is always
7
- * the single current decomposition. The tree is persisted whole as JSON.
8
- */
9
- export declare class D1RepoBlueprintRepository implements RepoBlueprintRepository {
10
- private readonly db;
11
- constructor({ db }: {
12
- db: D1Database;
13
- });
14
- upsert(record: RepoBlueprintRecord): Promise<void>;
15
- get(workspaceId: string, id: string): Promise<RepoBlueprintRecord | null>;
16
- getByRepo(workspaceId: string, repoOwner: string, repoName: string): Promise<RepoBlueprintRecord | null>;
17
- listByWorkspace(workspaceId: string): Promise<RepoBlueprintRecord[]>;
18
- delete(workspaceId: string, id: string): Promise<void>;
19
- }
20
- //# sourceMappingURL=D1RepoBlueprintRepository.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"D1RepoBlueprintRepository.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1RepoBlueprintRepository.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAEV,mBAAmB,EACnB,uBAAuB,EACxB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAA;AA0B3D;;;;;GAKG;AACH,qBAAa,yBAA0B,YAAW,uBAAuB;IACvE,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAY;IAE/B,YAAY,EAAE,EAAE,EAAE,EAAE;QAAE,EAAE,EAAE,UAAU,CAAA;KAAE,EAErC;IAEK,MAAM,CAAC,MAAM,EAAE,mBAAmB,GAAG,OAAO,CAAC,IAAI,CAAC,CAsBvD;IAEK,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAM9E;IAEK,SAAS,CACb,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAQrC;IAEK,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,EAAE,CAAC,CAMzE;IAEK,MAAM,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAK3D;CACF"}
@@ -1,64 +0,0 @@
1
- function rowToRecord(row) {
2
- return {
3
- id: row.id,
4
- workspaceId: row.workspace_id,
5
- repoOwner: row.repo_owner,
6
- repoName: row.repo_name,
7
- source: row.source,
8
- service: JSON.parse(row.service_json),
9
- createdAt: row.created_at,
10
- updatedAt: row.updated_at,
11
- };
12
- }
13
- /**
14
- * D1-backed store of repository blueprints (migration 0011). One row per
15
- * (workspace, repo): `upsert` replaces the existing blueprint in place, keyed by
16
- * the unique `(workspace_id, repo_owner, repo_name)` index, so the row is always
17
- * the single current decomposition. The tree is persisted whole as JSON.
18
- */
19
- export class D1RepoBlueprintRepository {
20
- db;
21
- constructor({ db }) {
22
- this.db = db;
23
- }
24
- async upsert(record) {
25
- await this.db
26
- .prepare(`INSERT INTO repo_blueprints
27
- (id, workspace_id, repo_owner, repo_name, source, service_json, created_at, updated_at)
28
- VALUES (?, ?, ?, ?, ?, ?, ?, ?)
29
- ON CONFLICT (workspace_id, repo_owner, repo_name) DO UPDATE SET
30
- source = excluded.source,
31
- service_json = excluded.service_json,
32
- updated_at = excluded.updated_at`)
33
- .bind(record.id, record.workspaceId, record.repoOwner, record.repoName, record.source, JSON.stringify(record.service), record.createdAt, record.updatedAt)
34
- .run();
35
- }
36
- async get(workspaceId, id) {
37
- const row = await this.db
38
- .prepare('SELECT * FROM repo_blueprints WHERE workspace_id = ? AND id = ?')
39
- .bind(workspaceId, id)
40
- .first();
41
- return row ? rowToRecord(row) : null;
42
- }
43
- async getByRepo(workspaceId, repoOwner, repoName) {
44
- const row = await this.db
45
- .prepare('SELECT * FROM repo_blueprints WHERE workspace_id = ? AND repo_owner = ? AND repo_name = ?')
46
- .bind(workspaceId, repoOwner, repoName)
47
- .first();
48
- return row ? rowToRecord(row) : null;
49
- }
50
- async listByWorkspace(workspaceId) {
51
- const { results } = await this.db
52
- .prepare('SELECT * FROM repo_blueprints WHERE workspace_id = ? ORDER BY updated_at DESC')
53
- .bind(workspaceId)
54
- .all();
55
- return (results ?? []).map(rowToRecord);
56
- }
57
- async delete(workspaceId, id) {
58
- await this.db
59
- .prepare('DELETE FROM repo_blueprints WHERE workspace_id = ? AND id = ?')
60
- .bind(workspaceId, id)
61
- .run();
62
- }
63
- }
64
- //# sourceMappingURL=D1RepoBlueprintRepository.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"D1RepoBlueprintRepository.js","sourceRoot":"","sources":["../../../src/infrastructure/repositories/D1RepoBlueprintRepository.ts"],"names":[],"mappings":"AAkBA,SAAS,WAAW,CAAC,GAAqB;IACxC,OAAO;QACL,EAAE,EAAE,GAAG,CAAC,EAAE;QACV,WAAW,EAAE,GAAG,CAAC,YAAY;QAC7B,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,QAAQ,EAAE,GAAG,CAAC,SAAS;QACvB,MAAM,EAAE,GAAG,CAAC,MAAuC;QACnD,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAqB;QACzD,SAAS,EAAE,GAAG,CAAC,UAAU;QACzB,SAAS,EAAE,GAAG,CAAC,UAAU;KAC1B,CAAA;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,OAAO,yBAAyB;IACnB,EAAE,CAAY;IAE/B,YAAY,EAAE,EAAE,EAAsB;QACpC,IAAI,CAAC,EAAE,GAAG,EAAE,CAAA;IACd,CAAC;IAED,KAAK,CAAC,MAAM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AAC,CAAA;IACzC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,WAAmB,EAAE,EAAU;QAC1C,MAAM,IAAI,CAAC,EAAE;aACV,OAAO,CAAC,+DAA+D,CAAC;aACxE,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;aACrB,GAAG,EAAE,CAAA;IACV,CAAC;CACF"}
@@ -1,50 +0,0 @@
1
- import { type GitHubClient, type GitHubInstallationRepository, type TaskContent, type TaskCredentials, type TaskSearchResult, type TaskSourceProvider, type NormalizedTaskConnection } from '@cat-factory/kernel';
2
- export interface GitHubIssuesProviderDependencies {
3
- githubClient: GitHubClient;
4
- /** Resolves which installation owns a given repo owner (by account login). */
5
- installations: GitHubInstallationRepository;
6
- }
7
- export declare class GitHubIssuesProvider implements TaskSourceProvider {
8
- private readonly deps;
9
- readonly kind: 'github';
10
- readonly descriptor: {
11
- source: "github" | "jira";
12
- label: string;
13
- icon: string;
14
- credentialFields: {
15
- key: string;
16
- label: string;
17
- help?: string | undefined;
18
- placeholder?: string | undefined;
19
- secret?: boolean | undefined;
20
- }[];
21
- refLabel: string;
22
- refPlaceholder: string;
23
- searchable?: boolean | undefined;
24
- };
25
- constructor(deps: GitHubIssuesProviderDependencies);
26
- /**
27
- * GitHub issues piggyback on the installed GitHub App, so there is nothing to
28
- * validate or persist — the connection is a marker. Any supplied fields are
29
- * ignored (the connect form has none).
30
- */
31
- normalizeConnection(_input: TaskCredentials): NormalizedTaskConnection;
32
- parseRef(input: string): string | null;
33
- fetchTask(_credentials: TaskCredentials, externalId: string): Promise<TaskContent>;
34
- /**
35
- * Search issues visible to *this workspace's* GitHub App installation. The
36
- * installation token only sees its own account's repos, so scoping to the
37
- * workspace's installation keeps results from leaking across tenants — a
38
- * deployment may host many installations, but a workspace owns exactly one.
39
- * Credentials are unused (the App authenticates), matching `fetchTask`.
40
- */
41
- search(_credentials: TaskCredentials, query: string, workspaceId: string): Promise<TaskSearchResult[]>;
42
- /**
43
- * Find the GitHub App installation whose account owns `owner`. The
44
- * installation token for that account is what can read the repo's issues,
45
- * regardless of which workspace triggered the import (one account → one
46
- * installation, shared across that account's workspaces).
47
- */
48
- private resolveInstallationId;
49
- }
50
- //# sourceMappingURL=GitHubIssuesProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GitHubIssuesProvider.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/tasks/GitHubIssuesProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,4BAA4B,EACjC,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC9B,MAAM,qBAAqB,CAAA;AAW5B,MAAM,WAAW,gCAAgC;IAC/C,YAAY,EAAE,YAAY,CAAA;IAC1B,8EAA8E;IAC9E,aAAa,EAAE,4BAA4B,CAAA;CAC5C;AAED,qBAAa,oBAAqB,YAAW,kBAAkB;IAIjD,OAAO,CAAC,QAAQ,CAAC,IAAI;IAHjC,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAS;IACjC,QAAQ,CAAC,UAAU;;;;;;;;;;;;;;MAA2B;IAE9C,YAA6B,IAAI,EAAE,gCAAgC,EAAI;IAEvE;;;;OAIG;IACH,mBAAmB,CAAC,MAAM,EAAE,eAAe,GAAG,wBAAwB,CAErE;IAED,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAErC;IAEK,SAAS,CAAC,YAAY,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA0BvF;IAED;;;;;;OAMG;IACG,MAAM,CACV,YAAY,EAAE,eAAe,EAC7B,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,gBAAgB,EAAE,CAAC,CAsB7B;IAED;;;;;OAKG;YACW,qBAAqB;CAUpC"}
@@ -1,91 +0,0 @@
1
- import { ConflictError, ValidationError, } from '@cat-factory/kernel';
2
- import { GITHUB_ISSUES_DESCRIPTOR, githubIssuesLogic } from '@cat-factory/integrations';
3
- export class GitHubIssuesProvider {
4
- deps;
5
- kind = 'github';
6
- descriptor = GITHUB_ISSUES_DESCRIPTOR;
7
- constructor(deps) {
8
- this.deps = deps;
9
- }
10
- /**
11
- * GitHub issues piggyback on the installed GitHub App, so there is nothing to
12
- * validate or persist — the connection is a marker. Any supplied fields are
13
- * ignored (the connect form has none).
14
- */
15
- normalizeConnection(_input) {
16
- return { credentials: {}, label: 'GitHub' };
17
- }
18
- parseRef(input) {
19
- return githubIssuesLogic.parseGitHubIssueRef(input);
20
- }
21
- async fetchTask(_credentials, externalId) {
22
- const id = githubIssuesLogic.parseGitHubIssueExternalId(externalId);
23
- if (!id) {
24
- throw new ValidationError(`"${externalId}" is not a valid GitHub issue reference`);
25
- }
26
- const installationId = await this.resolveInstallationId(id.owner);
27
- const detail = await this.deps.githubClient.getIssue(installationId, { owner: id.owner, repo: id.repo }, id.number);
28
- return {
29
- externalId,
30
- url: detail.url || githubIssuesLogic.githubIssueUrl(id),
31
- title: detail.title,
32
- // GitHub issues have no workflow status or type beyond open/closed; surface
33
- // the state as the status and a constant type so the structured prompt
34
- // rendering stays uniform across sources.
35
- status: detail.state,
36
- type: 'Issue',
37
- assignee: detail.assignee,
38
- priority: null,
39
- labels: detail.labels,
40
- description: detail.body,
41
- comments: detail.comments,
42
- };
43
- }
44
- /**
45
- * Search issues visible to *this workspace's* GitHub App installation. The
46
- * installation token only sees its own account's repos, so scoping to the
47
- * workspace's installation keeps results from leaking across tenants — a
48
- * deployment may host many installations, but a workspace owns exactly one.
49
- * Credentials are unused (the App authenticates), matching `fetchTask`.
50
- */
51
- async search(_credentials, query, workspaceId) {
52
- const installation = await this.deps.installations.getByWorkspace(workspaceId);
53
- if (!installation)
54
- return [];
55
- const hits = await this.deps.githubClient
56
- .searchIssues(installation.installationId, query, 20)
57
- .catch(() => []);
58
- const out = [];
59
- const seen = new Set();
60
- for (const hit of hits) {
61
- const externalId = githubIssuesLogic.githubIssueExternalId(hit);
62
- if (seen.has(externalId))
63
- continue;
64
- seen.add(externalId);
65
- out.push({
66
- source: 'github',
67
- externalId,
68
- title: hit.title,
69
- url: hit.url,
70
- status: hit.state,
71
- excerpt: '',
72
- });
73
- }
74
- return out.slice(0, 20);
75
- }
76
- /**
77
- * Find the GitHub App installation whose account owns `owner`. The
78
- * installation token for that account is what can read the repo's issues,
79
- * regardless of which workspace triggered the import (one account → one
80
- * installation, shared across that account's workspaces).
81
- */
82
- async resolveInstallationId(owner) {
83
- const active = await this.deps.installations.listActive();
84
- const match = active.find((i) => i.accountLogin.toLowerCase() === owner.toLowerCase());
85
- if (!match) {
86
- throw new ConflictError(`No GitHub App installation found for "${owner}". Install the GitHub App on that account to link its issues.`);
87
- }
88
- return match.installationId;
89
- }
90
- }
91
- //# sourceMappingURL=GitHubIssuesProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"GitHubIssuesProvider.js","sourceRoot":"","sources":["../../../src/infrastructure/tasks/GitHubIssuesProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,eAAe,GAQhB,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,wBAAwB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAA;AAgBvF,MAAM,OAAO,oBAAoB;IAIF,IAAI;IAHxB,IAAI,GAAG,QAAiB,CAAA;IACxB,UAAU,GAAG,wBAAwB,CAAA;IAE9C,YAA6B,IAAsC;oBAAtC,IAAI;IAAqC,CAAC;IAEvE;;;;OAIG;IACH,mBAAmB,CAAC,MAAuB;QACzC,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;IAC7C,CAAC;IAED,QAAQ,CAAC,KAAa;QACpB,OAAO,iBAAiB,CAAC,mBAAmB,CAAC,KAAK,CAAC,CAAA;IACrD,CAAC;IAED,KAAK,CAAC,SAAS,CAAC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askCredentials, type TaskSearchResult, type TaskSourceProvider, type NormalizedTaskConnection } from '@cat-factory/kernel';
2
- /** Carries the HTTP status so callers can surface a meaningful error. */
3
- export declare class JiraApiError extends Error {
4
- readonly status: number;
5
- constructor(status: number, message: string);
6
- }
7
- export declare class JiraProvider implements TaskSourceProvider {
8
- readonly kind: 'jira';
9
- readonly descriptor: {
10
- source: "github" | "jira";
11
- label: string;
12
- icon: string;
13
- credentialFields: {
14
- key: string;
15
- label: string;
16
- help?: string | undefined;
17
- placeholder?: string | undefined;
18
- secret?: boolean | undefined;
19
- }[];
20
- refLabel: string;
21
- refPlaceholder: string;
22
- searchable?: boolean | undefined;
23
- };
24
- normalizeConnection(input: TaskCredentials): NormalizedTaskConnection;
25
- parseRef(input: string): string | null;
26
- fetchTask(credentials: TaskCredentials, externalId: string): Promise<TaskContent>;
27
- search(credentials: TaskCredentials, query: string): Promise<TaskSearchResult[]>;
28
- }
29
- //# sourceMappingURL=JiraProvider.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JiraProvider.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/tasks/JiraProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,wBAAwB,EAC9B,MAAM,qBAAqB,CAAA;AAa5B,yEAAyE;AACzE,qBAAa,YAAa,SAAQ,KAAK;IAEnC,QAAQ,CAAC,MAAM,EAAE,MAAM;IADzB,YACW,MAAM,EAAE,MAAM,EACvB,OAAO,EAAE,MAAM,EAIhB;CACF;AAsBD,qBAAa,YAAa,YAAW,kBAAkB;IACrD,QAAQ,CAAC,IAAI,EAAG,MAAM,CAAS;IAC/B,QAAQ,CAAC,UAAU;;;;;;;;;;;;;;MAAkB;IAErC,mBAAmB,CAAC,KAAK,EAAE,eAAe,GAAG,wBAAwB,CAepE;IAED,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAErC;IAEK,SAAS,CAAC,WAAW,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,CA4CtF;IAEK,MAAM,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA6BrF;CACF"}
@@ -1,109 +0,0 @@
1
- import { ValidationError, atlassianLogic, } from '@cat-factory/kernel';
2
- import { JIRA_DESCRIPTOR, jiraLogic } from '@cat-factory/integrations';
3
- // JiraProvider: the task-source provider for Jira Cloud. It authenticates with
4
- // HTTP Basic (account email + API token, the same scheme as Confluence), fetches
5
- // an issue via the REST v3 API, and maps it onto the structured TaskContent —
6
- // converting the ADF description and comment bodies to the Markdown the generic
7
- // excerpt/prompt logic consumes. All Jira-specific *pure* logic (ref parsing, ADF
8
- // conversion) lives in `@cat-factory/integrations` so it is unit-testable; this class is
9
- // the thin `fetch` shell around it. No SDK — fetch + `btoa` suffice.
10
- const USER_AGENT = 'cat-factory';
11
- /** Carries the HTTP status so callers can surface a meaningful error. */
12
- export class JiraApiError extends Error {
13
- status;
14
- constructor(status, message) {
15
- super(message);
16
- this.status = status;
17
- this.name = 'JiraApiError';
18
- }
19
- }
20
- export class JiraProvider {
21
- kind = 'jira';
22
- descriptor = JIRA_DESCRIPTOR;
23
- normalizeConnection(input) {
24
- const baseUrlRaw = input.baseUrl?.trim();
25
- const accountEmail = input.accountEmail?.trim();
26
- const apiToken = input.apiToken?.trim();
27
- if (!baseUrlRaw || !accountEmail || !apiToken) {
28
- throw new ValidationError('Jira requires a site URL, account email and API token');
29
- }
30
- const baseUrl = atlassianLogic.normalizeAtlassianBaseUrl(baseUrlRaw);
31
- // Guard against SSRF: the stored base URL is later fetched with the
32
- // workspace's credentials, so it must be a public https host.
33
- atlassianLogic.assertSafeAtlassianBaseUrl(baseUrl);
34
- return {
35
- credentials: { baseUrl, accountEmail, apiToken },
36
- label: baseUrl,
37
- };
38
- }
39
- parseRef(input) {
40
- return jiraLogic.parseJiraRef(input);
41
- }
42
- async fetchTask(credentials, externalId) {
43
- const base = credentials.baseUrl.replace(/\/+$/, '');
44
- const fields = 'summary,description,status,issuetype,assignee,priority,labels,comment';
45
- const url = `${base}/rest/api/3/issue/${encodeURIComponent(externalId)}?fields=${fields}`;
46
- const auth = btoa(`${credentials.accountEmail}:${credentials.apiToken}`);
47
- const res = await fetch(url, {
48
- method: 'GET',
49
- headers: {
50
- authorization: `Basic ${auth}`,
51
- accept: 'application/json',
52
- 'user-agent': USER_AGENT,
53
- },
54
- });
55
- if (!res.ok) {
56
- const text = await res.text().catch(() => '');
57
- throw new JiraApiError(res.status, `Jira GET ${url} → ${res.status}: ${text.slice(0, 300)}`);
58
- }
59
- const json = (await res.json().catch(() => null));
60
- if (!json || !json.key || !json.fields) {
61
- throw new JiraApiError(502, `Jira returned an unexpected body for issue ${externalId}`);
62
- }
63
- const f = json.fields;
64
- const comments = (f.comment?.comments ?? []).map((c) => ({
65
- author: c.author?.displayName ?? '',
66
- createdAt: c.created ?? '',
67
- body: jiraLogic.adfToMarkdown(c.body),
68
- }));
69
- return {
70
- externalId: json.key,
71
- url: `${base}/browse/${json.key}`,
72
- title: f.summary ?? '(untitled)',
73
- status: f.status?.name ?? '',
74
- type: f.issuetype?.name ?? '',
75
- assignee: f.assignee?.displayName ?? null,
76
- priority: f.priority?.name ?? null,
77
- labels: Array.isArray(f.labels) ? f.labels : [],
78
- description: jiraLogic.adfToMarkdown(f.description),
79
- comments,
80
- };
81
- }
82
- async search(credentials, query) {
83
- const base = credentials.baseUrl.replace(/\/+$/, '');
84
- // Re-validate the stored base before fetching with the workspace's credentials
85
- // (defense-in-depth against a base that became unsafe since connect time).
86
- atlassianLogic.assertSafeAtlassianBaseUrl(base);
87
- const jql = encodeURIComponent(jiraLogic.buildJiraSearchJql(query));
88
- // `/rest/api/3/search/jql` is the current enhanced-search endpoint; the legacy
89
- // GET `/rest/api/3/search` was removed by Atlassian (May 2025). The `issues[]`
90
- // response shape is unchanged, so `parseJiraSearchResults` still applies.
91
- const url = `${base}/rest/api/3/search/jql?jql=${jql}&fields=summary,status&maxResults=20`;
92
- const auth = btoa(`${credentials.accountEmail}:${credentials.apiToken}`);
93
- const res = await fetch(url, {
94
- method: 'GET',
95
- headers: {
96
- authorization: `Basic ${auth}`,
97
- accept: 'application/json',
98
- 'user-agent': USER_AGENT,
99
- },
100
- });
101
- if (!res.ok) {
102
- const text = await res.text().catch(() => '');
103
- throw new JiraApiError(res.status, `Jira search ${url} → ${res.status}: ${text.slice(0, 300)}`);
104
- }
105
- const json = await res.json().catch(() => null);
106
- return jiraLogic.parseJiraSearchResults(json, base);
107
- }
108
- }
109
- //# sourceMappingURL=JiraProvider.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"JiraProvider.js","sourceRoot":"","sources":["../../../src/infrastructure/tasks/JiraProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,cAAc,GAOf,MAAM,qBAAqB,CAAA;AAC5B,OAAO,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAA;AAEtE,+EAA+E;AAC/E,iFAAiF;AACjF,8EAA8E;AAC9E,gFAAgF;AAChF,kFAAkF;AAClF,yFAAyF;AACzF,qEAAqE;AAErE,MAAM,UAAU,GAAG,aAAa,CAAA;AAEhC,yEAAyE;AACzE,MAAM,OAAO,YAAa,SAAQ,KAAK;IAE1B,MAAM;IADjB,YACW,MAAc,EACvB,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAA;sBAHL,MAAM;QAIf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAA;IAC5B,CAAC;CACF;AAsBD,MAAM,OAAO,YAAY;IACd,IAAI,GAAG,MAAe,CAAA;IACtB,UAAU,GAAG,eAAe,CAAA;IAErC,mBAAmB,CAAC,KAAsB;QACxC,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,EAAE,IAAI,EAAE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