@dahrk/linear 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +24 -12
- package/dist/batch-source.d.ts +63 -0
- package/dist/batch-source.d.ts.map +1 -0
- package/dist/batch-source.js +149 -0
- package/dist/batch-source.js.map +1 -0
- package/dist/comments.d.ts +36 -0
- package/dist/comments.d.ts.map +1 -0
- package/dist/comments.js +104 -0
- package/dist/comments.js.map +1 -0
- package/dist/documents.d.ts +1 -15
- package/dist/documents.d.ts.map +1 -1
- package/dist/documents.js +37 -27
- package/dist/documents.js.map +1 -1
- package/dist/format-action.d.ts +25 -0
- package/dist/format-action.d.ts.map +1 -0
- package/dist/format-action.js +250 -0
- package/dist/format-action.js.map +1 -0
- package/dist/index.d.ts +119 -15
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +231 -59
- package/dist/index.js.map +1 -1
- package/dist/issue-graph.d.ts +37 -0
- package/dist/issue-graph.d.ts.map +1 -0
- package/dist/issue-graph.js +125 -0
- package/dist/issue-graph.js.map +1 -0
- package/dist/issues.d.ts +27 -2
- package/dist/issues.d.ts.map +1 -1
- package/dist/issues.js +33 -10
- package/dist/issues.js.map +1 -1
- package/dist/labels.d.ts +48 -1
- package/dist/labels.d.ts.map +1 -1
- package/dist/labels.js +72 -24
- package/dist/labels.js.map +1 -1
- package/dist/linear-client.d.ts +51 -0
- package/dist/linear-client.d.ts.map +1 -1
- package/dist/linear-client.js +233 -34
- package/dist/linear-client.js.map +1 -1
- package/dist/oauth.d.ts +52 -12
- package/dist/oauth.d.ts.map +1 -1
- package/dist/oauth.js +91 -34
- package/dist/oauth.js.map +1 -1
- package/dist/recording-client.d.ts +20 -2
- package/dist/recording-client.d.ts.map +1 -1
- package/dist/recording-client.js +39 -1
- package/dist/recording-client.js.map +1 -1
- package/dist/responding-client.d.ts +49 -0
- package/dist/responding-client.d.ts.map +1 -0
- package/dist/responding-client.js +47 -0
- package/dist/responding-client.js.map +1 -0
- package/dist/teams.d.ts +20 -0
- package/dist/teams.d.ts.map +1 -0
- package/dist/teams.js +32 -0
- package/dist/teams.js.map +1 -0
- package/package.json +8 -10
- package/src/batch-source.ts +208 -0
- package/src/comments.ts +126 -0
- package/src/documents.ts +162 -0
- package/src/format-action.ts +279 -0
- package/src/index.ts +617 -0
- package/src/issue-graph.ts +169 -0
- package/src/issues.ts +142 -0
- package/src/labels.ts +254 -0
- package/src/linear-client.ts +448 -0
- package/src/oauth.ts +255 -0
- package/src/recording-client.ts +141 -0
- package/src/responding-client.ts +106 -0
- package/src/teams.ts +44 -0
package/dist/issues.js
CHANGED
|
@@ -13,24 +13,19 @@ export function linearClientAuth(token) {
|
|
|
13
13
|
return token.startsWith("lin_api_") ? { apiKey: token } : { accessToken: token };
|
|
14
14
|
}
|
|
15
15
|
/** The live `TriageApi` backed by a Linear token (personal API key or OAuth access token). Resolves
|
|
16
|
-
* team
|
|
17
|
-
*
|
|
16
|
+
* team by key and optional project by name via server-side `filter` (verified on @linear/sdk 86.0.0,
|
|
17
|
+
* DHK-579: `TeamFilter.key`/`ProjectFilter.name` return exactly the expected node - the earlier
|
|
18
|
+
* paginate-then-match workaround is no longer needed). */
|
|
18
19
|
export function linearTriageApi(token) {
|
|
19
20
|
const client = new LinearClient(linearClientAuth(token));
|
|
20
21
|
return {
|
|
21
22
|
async createIssue(input) {
|
|
22
|
-
const
|
|
23
|
-
while (teams.pageInfo.hasNextPage)
|
|
24
|
-
await teams.fetchNext();
|
|
25
|
-
const team = teams.nodes.find((t) => t.key === input.teamKey);
|
|
23
|
+
const team = (await client.teams({ filter: { key: { eq: input.teamKey } } })).nodes[0];
|
|
26
24
|
if (!team)
|
|
27
25
|
throw new Error(`triage team not found: ${input.teamKey}`);
|
|
28
26
|
let projectId;
|
|
29
27
|
if (input.projectName) {
|
|
30
|
-
|
|
31
|
-
while (projects.pageInfo.hasNextPage)
|
|
32
|
-
await projects.fetchNext();
|
|
33
|
-
projectId = projects.nodes.find((p) => p.name === input.projectName)?.id;
|
|
28
|
+
projectId = (await client.projects({ filter: { name: { eq: input.projectName } } })).nodes[0]?.id;
|
|
34
29
|
}
|
|
35
30
|
const payload = await client.createIssue({
|
|
36
31
|
teamId: team.id,
|
|
@@ -61,4 +56,32 @@ export function linearTriageApi(token) {
|
|
|
61
56
|
},
|
|
62
57
|
};
|
|
63
58
|
}
|
|
59
|
+
/** The live {@link CaptureLinearApi} backed by a tenant connection token (API key or OAuth token). */
|
|
60
|
+
export function linearCaptureApi(token) {
|
|
61
|
+
const client = new LinearClient(linearClientAuth(token));
|
|
62
|
+
return {
|
|
63
|
+
async createIssue(input) {
|
|
64
|
+
const team = (await client.teams({ filter: { key: { eq: input.teamKey } } })).nodes[0];
|
|
65
|
+
if (!team)
|
|
66
|
+
throw new Error(`capture team not found: ${input.teamKey}`);
|
|
67
|
+
let projectId;
|
|
68
|
+
if (input.projectName) {
|
|
69
|
+
projectId = (await client.projects({ filter: { name: { eq: input.projectName } } })).nodes[0]?.id;
|
|
70
|
+
}
|
|
71
|
+
const payload = await client.createIssue({
|
|
72
|
+
teamId: team.id,
|
|
73
|
+
title: input.title,
|
|
74
|
+
description: input.description,
|
|
75
|
+
...(projectId ? { projectId } : {}),
|
|
76
|
+
});
|
|
77
|
+
const issue = await payload.issue;
|
|
78
|
+
return { issueId: issue?.id ?? "", identifier: issue?.identifier ?? "", url: issue?.url ?? "" };
|
|
79
|
+
},
|
|
80
|
+
async updateIssue(input) {
|
|
81
|
+
const payload = await client.updateIssue(input.issueId, { title: input.title, description: input.description });
|
|
82
|
+
const issue = await payload.issue;
|
|
83
|
+
return { issueId: issue?.id ?? input.issueId, identifier: issue?.identifier ?? "", url: issue?.url ?? "" };
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
64
87
|
//# sourceMappingURL=issues.js.map
|
package/dist/issues.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issues.js","sourceR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D,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC;gBACvC,MAAM,EAAE,IAAI,CAAC,EAAE;gBACf,KAAK,EAAE,KAAK,CAAC,KAAK;gBAClB,WAAW,EAAE,KAAK,CAAC,WAAW;gBAC9B,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACpC,CAAC,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC;YAClC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC;QAClG,CAAC;QAED,KAAK,CAAC,WAAW,CAAC,KAAK;YACrB,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC;YAChH,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,KAAK,CAAC;YAClC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,IAAI,KAAK,CAAC,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,UAAU,IAAI,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,IAAI,EAAE,EAAE,CAAC;QAC7G,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/labels.d.ts
CHANGED
|
@@ -47,12 +47,59 @@ export declare function provisionRepoLabels(api: LabelApi, repoNames: Iterable<s
|
|
|
47
47
|
/**
|
|
48
48
|
* Fetch the child names of the issue's **project** `repo` label group (project labels are a separate
|
|
49
49
|
* Linear namespace from issue labels, `Project.labels`). Returns the names of project labels whose
|
|
50
|
-
* parent group is `repo` - e.g. `["
|
|
50
|
+
* parent group is `repo` - e.g. `["dahrk-web"]` - so the hub can bind every issue in that project to
|
|
51
51
|
* a repo via the project-label routing tier. Empty when the issue has no project, no project labels, or
|
|
52
52
|
* no `repo` group. A read against the connection token; data assembly, not control flow, so the result
|
|
53
53
|
* feeds deterministic routing and is snapshotted into the run.
|
|
54
54
|
*/
|
|
55
55
|
export declare function fetchIssueProjectRepoLabels(token: string, issueId: string): Promise<string[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Count an issue's child issues (DHK-412), so the hub's epic guard can decline a parent-of-children.
|
|
58
|
+
* The webhook payload carries an issue's `<parent-issue>` but never a listing of its children, so
|
|
59
|
+
* "has children" must be resolved with a read against the connection token. Returns 0 when the issue
|
|
60
|
+
* has none (or the field is empty). Capped at `first:1` - the guard only needs "any", not an exact
|
|
61
|
+
* total - so it stays a cheap intake read. Data assembly, not control flow: the count feeds the
|
|
62
|
+
* deterministic, no-LLM epic guard.
|
|
63
|
+
*/
|
|
64
|
+
export declare function fetchIssueChildCount(token: string, issueId: string): Promise<number>;
|
|
65
|
+
/** One issue that blocks another and has not settled yet. `identifier` is the human key (e.g.
|
|
66
|
+
* `DHK-777`) the decline note names; `stateName` is the team's own label for the state it sits in,
|
|
67
|
+
* carried for the note only - never matched on (see `fetchOpenBlockers`). */
|
|
68
|
+
export interface OpenBlocker {
|
|
69
|
+
identifier: string;
|
|
70
|
+
stateName: string;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Has a blocker finished, so it no longer blocks?
|
|
74
|
+
*
|
|
75
|
+
* Decided on the workflow state's `type` - Linear's own fixed vocabulary (`backlog`, `unstarted`,
|
|
76
|
+
* `started`, `completed`, `canceled`) - and NEVER on its name. Teams rename states freely: "Done"
|
|
77
|
+
* becomes "Shipped", "Released", "Merged". A name match would stop guarding for every one of those
|
|
78
|
+
* teams with nothing to notice, because the guard would simply never fire again.
|
|
79
|
+
*
|
|
80
|
+
* An absent/unknown type is treated as NOT settled: a blocker we cannot prove is finished is one we
|
|
81
|
+
* must assume is not. Pure, so the rule is pinned by a test rather than by a live Linear read.
|
|
82
|
+
*/
|
|
83
|
+
export declare function isBlockerSettled(stateType: string | undefined): boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The issues blocking `issueId` that are not finished yet, so the hub's blocked guard can decline a
|
|
86
|
+
* run that cannot possibly succeed. The webhook payload carries no relation data at all, so this must
|
|
87
|
+
* be resolved with a read against the connection token, exactly as `fetchIssueChildCount` resolves the
|
|
88
|
+
* epic signal. Returns an empty list when nothing blocks the issue, or when every blocker has settled.
|
|
89
|
+
*
|
|
90
|
+
* The direction matters: `A blocks B` is stored on A, so B reads it through `inverseRelations`. Reading
|
|
91
|
+
* `relations` instead would return what this issue blocks - the opposite question, and one that would
|
|
92
|
+
* silently never guard anything.
|
|
93
|
+
*
|
|
94
|
+
* "Settled" is decided on the state's `type` (`completed` / `canceled`), NEVER on its name. Teams rename
|
|
95
|
+
* workflow states freely - "Done" becomes "Shipped", "Released", "Merged" - and a name match would stop
|
|
96
|
+
* guarding for those teams without any error to notice. The type is Linear's own fixed vocabulary.
|
|
97
|
+
*
|
|
98
|
+
* Capped, like the child-count read: a ticket with more open blockers than the cap is still blocked, and
|
|
99
|
+
* the note naming the first few is enough to act on. Data assembly, not control flow: the list feeds the
|
|
100
|
+
* deterministic, no-LLM blocked guard.
|
|
101
|
+
*/
|
|
102
|
+
export declare function fetchOpenBlockers(token: string, issueId: string): Promise<OpenBlocker[]>;
|
|
56
103
|
/** The live `LabelApi` backed by a Linear bearer token (workspace-scoped labels). */
|
|
57
104
|
export declare function linearLabelApi(token: string): LabelApi;
|
|
58
105
|
/** The live `LabelApi` backed by a Linear bearer token, for **project** labels (a separate namespace
|
package/dist/labels.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../src/labels.ts"],"names":[],"mappings":"AAaA,MAAM,WAAW,QAAQ;IACvB,qDAAqD;IACrD,UAAU,IAAI,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I,GAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAA;CAAO,GAC5B,OAAO,CAAC,MAAM,EAAE,CAAC,CAOnB;AAED;;;;;;;GAOG;AACH,wBAAsB,2BAA2B,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAOnG;AAED;;;;;;;GAOG;AACH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAK1F;AAED;;8EAE8E;AAC9E,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,OAAO,CAEvE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAsB,iBAAiB,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC,CAc9F;AAED,qFAAqF;AACrF,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAsBtD;AAED;;mDAEmD;AACnD,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ,CAsBvD"}
|
package/dist/labels.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Trigger-label auto-provisioning (build spec section 14; plan item 7). A repository declares its
|
|
3
|
-
* workflows as `.
|
|
3
|
+
* workflows as `.dahrk/workflows/*.yaml`, each with a `select.label`; for those labels to be
|
|
4
4
|
* assignable in Linear they must exist in the workspace. Rather than make operators create them by
|
|
5
5
|
* hand, the onboarding path reads the workflow label set and creates any that are missing - once,
|
|
6
6
|
* idempotently - optionally grouped under a single "Dahrk workflow" label group.
|
|
@@ -70,38 +70,86 @@ export async function provisionRepoLabels(api, repoNames, opts = {}) {
|
|
|
70
70
|
describe: (name) => `Dahrk repository selector: ${name}`,
|
|
71
71
|
});
|
|
72
72
|
}
|
|
73
|
-
const GRAPHQL_URL = "https://api.linear.app/graphql";
|
|
74
73
|
/**
|
|
75
74
|
* Fetch the child names of the issue's **project** `repo` label group (project labels are a separate
|
|
76
75
|
* Linear namespace from issue labels, `Project.labels`). Returns the names of project labels whose
|
|
77
|
-
* parent group is `repo` - e.g. `["
|
|
76
|
+
* parent group is `repo` - e.g. `["dahrk-web"]` - so the hub can bind every issue in that project to
|
|
78
77
|
* a repo via the project-label routing tier. Empty when the issue has no project, no project labels, or
|
|
79
78
|
* no `repo` group. A read against the connection token; data assembly, not control flow, so the result
|
|
80
79
|
* feeds deterministic routing and is snapshotted into the run.
|
|
81
80
|
*/
|
|
82
81
|
export async function fetchIssueProjectRepoLabels(token, issueId) {
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
82
|
+
const client = new LinearClient({ accessToken: token });
|
|
83
|
+
const issue = await client.issue(issueId);
|
|
84
|
+
const project = await issue.project;
|
|
85
|
+
if (!project)
|
|
86
|
+
return [];
|
|
87
|
+
const conn = await project.labels({ first: 100, filter: { parent: { name: { eqIgnoreCase: REPO_LABEL_GROUP } } } });
|
|
88
|
+
return conn.nodes.map((n) => n.name.trim());
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Count an issue's child issues (DHK-412), so the hub's epic guard can decline a parent-of-children.
|
|
92
|
+
* The webhook payload carries an issue's `<parent-issue>` but never a listing of its children, so
|
|
93
|
+
* "has children" must be resolved with a read against the connection token. Returns 0 when the issue
|
|
94
|
+
* has none (or the field is empty). Capped at `first:1` - the guard only needs "any", not an exact
|
|
95
|
+
* total - so it stays a cheap intake read. Data assembly, not control flow: the count feeds the
|
|
96
|
+
* deterministic, no-LLM epic guard.
|
|
97
|
+
*/
|
|
98
|
+
export async function fetchIssueChildCount(token, issueId) {
|
|
99
|
+
const client = new LinearClient({ accessToken: token });
|
|
100
|
+
const issue = await client.issue(issueId);
|
|
101
|
+
const conn = await issue.children({ first: 1 });
|
|
102
|
+
return conn.nodes.length;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Has a blocker finished, so it no longer blocks?
|
|
106
|
+
*
|
|
107
|
+
* Decided on the workflow state's `type` - Linear's own fixed vocabulary (`backlog`, `unstarted`,
|
|
108
|
+
* `started`, `completed`, `canceled`) - and NEVER on its name. Teams rename states freely: "Done"
|
|
109
|
+
* becomes "Shipped", "Released", "Merged". A name match would stop guarding for every one of those
|
|
110
|
+
* teams with nothing to notice, because the guard would simply never fire again.
|
|
111
|
+
*
|
|
112
|
+
* An absent/unknown type is treated as NOT settled: a blocker we cannot prove is finished is one we
|
|
113
|
+
* must assume is not. Pure, so the rule is pinned by a test rather than by a live Linear read.
|
|
114
|
+
*/
|
|
115
|
+
export function isBlockerSettled(stateType) {
|
|
116
|
+
return stateType === "completed" || stateType === "canceled";
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The issues blocking `issueId` that are not finished yet, so the hub's blocked guard can decline a
|
|
120
|
+
* run that cannot possibly succeed. The webhook payload carries no relation data at all, so this must
|
|
121
|
+
* be resolved with a read against the connection token, exactly as `fetchIssueChildCount` resolves the
|
|
122
|
+
* epic signal. Returns an empty list when nothing blocks the issue, or when every blocker has settled.
|
|
123
|
+
*
|
|
124
|
+
* The direction matters: `A blocks B` is stored on A, so B reads it through `inverseRelations`. Reading
|
|
125
|
+
* `relations` instead would return what this issue blocks - the opposite question, and one that would
|
|
126
|
+
* silently never guard anything.
|
|
127
|
+
*
|
|
128
|
+
* "Settled" is decided on the state's `type` (`completed` / `canceled`), NEVER on its name. Teams rename
|
|
129
|
+
* workflow states freely - "Done" becomes "Shipped", "Released", "Merged" - and a name match would stop
|
|
130
|
+
* guarding for those teams without any error to notice. The type is Linear's own fixed vocabulary.
|
|
131
|
+
*
|
|
132
|
+
* Capped, like the child-count read: a ticket with more open blockers than the cap is still blocked, and
|
|
133
|
+
* the note naming the first few is enough to act on. Data assembly, not control flow: the list feeds the
|
|
134
|
+
* deterministic, no-LLM blocked guard.
|
|
135
|
+
*/
|
|
136
|
+
export async function fetchOpenBlockers(token, issueId) {
|
|
137
|
+
const client = new LinearClient({ accessToken: token });
|
|
138
|
+
const issue = await client.issue(issueId);
|
|
139
|
+
const conn = await issue.inverseRelations({ first: 25 });
|
|
140
|
+
const open = [];
|
|
141
|
+
for (const relation of conn.nodes) {
|
|
142
|
+
if (relation.type !== "blocks")
|
|
143
|
+
continue;
|
|
144
|
+
const blocker = await relation.issue;
|
|
145
|
+
if (!blocker)
|
|
146
|
+
continue;
|
|
147
|
+
const state = await blocker.state;
|
|
148
|
+
if (isBlockerSettled(state?.type))
|
|
149
|
+
continue;
|
|
150
|
+
open.push({ identifier: blocker.identifier, stateName: state?.name ?? "unknown" });
|
|
103
151
|
}
|
|
104
|
-
return
|
|
152
|
+
return open;
|
|
105
153
|
}
|
|
106
154
|
/** The live `LabelApi` backed by a Linear bearer token (workspace-scoped labels). */
|
|
107
155
|
export function linearLabelApi(token) {
|
package/dist/labels.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"labels.js","sourceRoot":"","sources":["../src/labels.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AA0B3C;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,GAAa,EACb,KAAuB,EACvB,OAAyB,EAAE;IAE3B,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,UAAU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C;gBAChE,GAAG,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACvD,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC5C,CAAC,CAAC;YACH,MAAM,KAAK,GAAG,MAAM,OAAO,CAAC,YAAY,CAAC;YACzC,OAAO,KAAK,EAAE,EAAE,IAAI,EAAE,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/dist/linear-client.d.ts
CHANGED
|
@@ -1,3 +1,54 @@
|
|
|
1
1
|
import type { AgentSessionClient } from "./index.js";
|
|
2
|
+
/** The subset of a Linear workflow state that state-selection needs. Kept structural so the live
|
|
3
|
+
* SDK's `WorkflowState` nodes satisfy it and the pure selectors are unit-testable without the SDK. */
|
|
4
|
+
export interface StateLike {
|
|
5
|
+
id: string;
|
|
6
|
+
name: string;
|
|
7
|
+
position: number;
|
|
8
|
+
type: string;
|
|
9
|
+
}
|
|
10
|
+
/** Find the review-target state the way `moveIssueToReview` does, so `startIssue` can EXCLUDE it.
|
|
11
|
+
* Linear has no "review" state type, so it is matched by name: an explicit configured name
|
|
12
|
+
* (`DAHRK_REVIEW_STATE_NAME`) when set, else the first review-ish name. */
|
|
13
|
+
export declare function findReviewState<T extends StateLike>(states: readonly T[], reviewName?: string): T | undefined;
|
|
14
|
+
/**
|
|
15
|
+
* Pick the team's working ("In Progress") state for a just-started run. A team can have MORE THAN
|
|
16
|
+
* ONE `started`-typed state (e.g. both "In Progress" and "In Review" are typed `started`), so the
|
|
17
|
+
* naive "lowest-position started state" is ambiguous and can wrongly land the ticket in In Review.
|
|
18
|
+
* Prefer an explicit working-name match (`/in progress|doing|started/i`), else the lowest-position
|
|
19
|
+
* `started` state that is NOT the review state. Returns `undefined` when there is no usable working
|
|
20
|
+
* state (so the caller reports a no-op rather than moving the ticket to review).
|
|
21
|
+
*/
|
|
22
|
+
export declare function selectStartState<T extends StateLike>(states: readonly T[], reviewName?: string): T | undefined;
|
|
23
|
+
/** Returns true when `delegateId` should be written on the issue.
|
|
24
|
+
* Skipping when already equal avoids the "assigned to you" notification on every re-run (DHK-263). */
|
|
25
|
+
export declare function shouldSetDelegate(issueDelegateId: string | undefined, viewerId: string): boolean;
|
|
26
|
+
/** A document as the issue-documents lookup sees it. Structural, so `findDocumentByTitle` is unit
|
|
27
|
+
* testable without standing up the SDK. */
|
|
28
|
+
export interface DocumentLike {
|
|
29
|
+
id: string;
|
|
30
|
+
/** Optional so the live SDK's non-null `title` is assignable and a null from the API cannot throw. */
|
|
31
|
+
title?: string;
|
|
32
|
+
url?: string;
|
|
33
|
+
}
|
|
34
|
+
/** The slice of a Linear issue the document lookup needs. */
|
|
35
|
+
export interface IssueDocuments {
|
|
36
|
+
documents(args: {
|
|
37
|
+
first: number;
|
|
38
|
+
}): Promise<{
|
|
39
|
+
nodes: DocumentLike[];
|
|
40
|
+
}>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The document already attached to this issue under `title`, or null when there is none. This is
|
|
44
|
+
* what gives `createDocument` its upsert: Linear keys documents by id only, so a title match on the
|
|
45
|
+
* issue is our stand-in.
|
|
46
|
+
*
|
|
47
|
+
* Titles are compared trimmed and case-insensitively, so a human who lightly re-cases the title does
|
|
48
|
+
* not cause the next run to fork a second copy. The read is bounded and unpaginated at 50, matching
|
|
49
|
+
* `linearDocumentSource.issueDocuments` in `documents.ts`: an issue carrying more than 50 documents
|
|
50
|
+
* silently drops the overflow, which is a deliberate limit rather than a bug.
|
|
51
|
+
*/
|
|
52
|
+
export declare function findDocumentByTitle(issue: IssueDocuments, title: string): Promise<DocumentLike | null>;
|
|
2
53
|
export declare function createLinearClient(token: string): AgentSessionClient;
|
|
3
54
|
//# sourceMappingURL=linear-client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"linear-client.d.ts","sourceRoot":"","sources":["../src/linear-client.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"linear-client.d.ts","sourceRoot":"","sources":["../src/linear-client.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAEV,kBAAkB,EASnB,MAAM,YAAY,CAAC;AA6CpB;uGACuG;AACvG,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;CACd;AAQD;;4EAE4E;AAC5E,wBAAgB,eAAe,CAAC,CAAC,SAAS,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAK7G;AAED;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,CAAC,GAAG,SAAS,CAO9G;AAED;uGACuG;AACvG,wBAAgB,iBAAiB,CAAC,eAAe,EAAE,MAAM,GAAG,SAAS,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEhG;AAED;4CAC4C;AAC5C,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,sGAAsG;IACtG,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,6DAA6D;AAC7D,MAAM,WAAW,cAAc;IAC7B,SAAS,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,YAAY,EAAE,CAAA;KAAE,CAAC,CAAC;CACxE;AAED;;;;;;;;;GASG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,cAAc,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