@kana-ai/edgar-ext-linear 0.0.0-stage → 0.1.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/LICENSE +202 -0
- package/README.md +198 -2
- package/dist/src/api/client.d.ts +21 -0
- package/dist/src/api/client.js +53 -0
- package/dist/src/api/failures.d.ts +11 -0
- package/dist/src/api/failures.js +37 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +19 -0
- package/dist/src/schemas/config.d.ts +25 -0
- package/dist/src/schemas/config.js +37 -0
- package/dist/src/schemas/linear.d.ts +116 -0
- package/dist/src/schemas/linear.js +57 -0
- package/dist/src/schemas/tools.d.ts +169 -0
- package/dist/src/schemas/tools.js +147 -0
- package/dist/src/tracker/assignee.d.ts +15 -0
- package/dist/src/tracker/assignee.js +58 -0
- package/dist/src/tracker/cards.d.ts +33 -0
- package/dist/src/tracker/cards.js +372 -0
- package/dist/src/tracker/comments.d.ts +11 -0
- package/dist/src/tracker/comments.js +62 -0
- package/dist/src/tracker/description.d.ts +19 -0
- package/dist/src/tracker/description.js +55 -0
- package/dist/src/tracker/hand-back.d.ts +8 -0
- package/dist/src/tracker/hand-back.js +94 -0
- package/dist/src/tracker/port.d.ts +2 -0
- package/dist/src/tracker/port.js +46 -0
- package/dist/src/tracker/states.d.ts +21 -0
- package/dist/src/tracker/states.js +82 -0
- package/dist/src/tracker/tools.d.ts +142 -0
- package/dist/src/tracker/tools.js +130 -0
- package/dist/src/tracker/transitions.d.ts +13 -0
- package/dist/src/tracker/transitions.js +94 -0
- package/edgar-extension.json +208 -0
- package/package.json +41 -3
- package/schemas/assign.in.json +15 -0
- package/schemas/assign.out.json +14 -0
- package/schemas/batch_cards.in.json +27 -0
- package/schemas/batch_cards.out.json +37 -0
- package/schemas/close.in.json +14 -0
- package/schemas/close.out.json +10 -0
- package/schemas/comment.in.json +19 -0
- package/schemas/comment.out.json +10 -0
- package/schemas/config.json +94 -0
- package/schemas/count_sighting.in.json +17 -0
- package/schemas/count_sighting.out.json +10 -0
- package/schemas/create_card.in.json +108 -0
- package/schemas/create_card.out.json +13 -0
- package/schemas/find_assignee.in.json +15 -0
- package/schemas/find_assignee.out.json +10 -0
- package/schemas/find_cards.in.json +18 -0
- package/schemas/find_cards.out.json +33 -0
- package/schemas/find_description.in.json +15 -0
- package/schemas/find_description.out.json +10 -0
- package/schemas/hand_back.in.json +11 -0
- package/schemas/hand_back.out.json +18 -0
- package/schemas/move.in.json +15 -0
- package/schemas/move.out.json +10 -0
- package/schemas/release_follow_ups.in.json +15 -0
- package/schemas/release_follow_ups.out.json +13 -0
- package/schemas/restore_assignee.in.json +20 -0
- package/schemas/restore_assignee.out.json +10 -0
- package/schemas/restore_description.in.json +20 -0
- package/schemas/restore_description.out.json +10 -0
- package/schemas/update_description.in.json +15 -0
- package/schemas/update_description.out.json +14 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
const column = z.string().min(1);
|
|
3
|
+
/** The extension's `[extensions.linear]` table: the team key, the optional card scope, the Linear column of each engine state, the columns where a card assigned to `assignee` counts as intake, and the switch that keeps every card of another assignee out. */
|
|
4
|
+
export const config = z
|
|
5
|
+
.strictObject({
|
|
6
|
+
team: z.string().min(1),
|
|
7
|
+
project: z.string().min(1).optional(),
|
|
8
|
+
title_prefix: z.string().min(1).optional(),
|
|
9
|
+
labels: z.array(z.string().min(1)).optional(),
|
|
10
|
+
columns: z.strictObject({
|
|
11
|
+
intake: column,
|
|
12
|
+
ready: column,
|
|
13
|
+
working: column,
|
|
14
|
+
in_review: column,
|
|
15
|
+
waiting_on_person: column,
|
|
16
|
+
in_testing: column,
|
|
17
|
+
done: column,
|
|
18
|
+
cancelled: column,
|
|
19
|
+
}),
|
|
20
|
+
assignee: z
|
|
21
|
+
.string()
|
|
22
|
+
.min(1)
|
|
23
|
+
.optional()
|
|
24
|
+
.describe("the Linear user, by id or email, or `me` for the user of LINEAR_TOKEN, which is the default: the user whose cards in `assigned` count as intake, and the one user of `assignee_only`"),
|
|
25
|
+
assignee_only: z
|
|
26
|
+
.boolean()
|
|
27
|
+
.default(false)
|
|
28
|
+
.describe("true: a card is in scope only while it is assigned to `assignee`, in every column, and EDGAR assigns each card it files to that user"),
|
|
29
|
+
assigned: z
|
|
30
|
+
.array(column)
|
|
31
|
+
.default([])
|
|
32
|
+
.describe("the Linear columns where a card assigned to `assignee` counts as intake"),
|
|
33
|
+
})
|
|
34
|
+
.refine((table) => !table.assigned.some((name) => Object.values(table.columns).includes(name)), {
|
|
35
|
+
message: "a column of `assigned` is a column of `columns` already",
|
|
36
|
+
path: ["assigned"],
|
|
37
|
+
});
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** A GraphQL answer: `data`, and the `errors` list as Linear sends it. */
|
|
3
|
+
export declare const envelope: z.ZodObject<{
|
|
4
|
+
data: z.ZodOptional<z.ZodUnknown>;
|
|
5
|
+
errors: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
6
|
+
message: z.ZodOptional<z.ZodString>;
|
|
7
|
+
extensions: z.ZodOptional<z.ZodObject<{
|
|
8
|
+
code: z.ZodOptional<z.ZodString>;
|
|
9
|
+
}, z.core.$strip>>;
|
|
10
|
+
}, z.core.$strip>>>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
/** One entry of a GraphQL `errors` list as Linear sends it. */
|
|
13
|
+
export type GraphqlError = NonNullable<z.infer<typeof envelope>["errors"]>[number];
|
|
14
|
+
/** The GraphQL selection of an issue that `issue` parses. */
|
|
15
|
+
export declare const issueFields = "id identifier title description url state { name } labels { nodes { name } } assignee { id displayName }";
|
|
16
|
+
/** An issue with the fields a `Card` needs. */
|
|
17
|
+
export declare const issue: z.ZodObject<{
|
|
18
|
+
id: z.ZodString;
|
|
19
|
+
identifier: z.ZodString;
|
|
20
|
+
title: z.ZodString;
|
|
21
|
+
description: z.ZodNullable<z.ZodString>;
|
|
22
|
+
url: z.ZodString;
|
|
23
|
+
state: z.ZodObject<{
|
|
24
|
+
name: z.ZodString;
|
|
25
|
+
}, z.core.$strip>;
|
|
26
|
+
labels: z.ZodObject<{
|
|
27
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
28
|
+
name: z.ZodString;
|
|
29
|
+
}, z.core.$strip>>;
|
|
30
|
+
}, z.core.$strip>;
|
|
31
|
+
assignee: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
32
|
+
id: z.ZodString;
|
|
33
|
+
displayName: z.ZodString;
|
|
34
|
+
}, z.core.$strip>>>;
|
|
35
|
+
}, z.core.$strip>;
|
|
36
|
+
/** The selection of one issue read by its id. Linear answers an archived issue there, and never in a listing. */
|
|
37
|
+
export declare const oneIssueFields = "id identifier title description url state { name } labels { nodes { name } } assignee { id displayName } archivedAt trashed";
|
|
38
|
+
/** One issue read by its id, with the two fields that say it left the board. */
|
|
39
|
+
export declare const oneIssue: z.ZodObject<{
|
|
40
|
+
id: z.ZodString;
|
|
41
|
+
identifier: z.ZodString;
|
|
42
|
+
title: z.ZodString;
|
|
43
|
+
description: z.ZodNullable<z.ZodString>;
|
|
44
|
+
url: z.ZodString;
|
|
45
|
+
state: z.ZodObject<{
|
|
46
|
+
name: z.ZodString;
|
|
47
|
+
}, z.core.$strip>;
|
|
48
|
+
labels: z.ZodObject<{
|
|
49
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
50
|
+
name: z.ZodString;
|
|
51
|
+
}, z.core.$strip>>;
|
|
52
|
+
}, z.core.$strip>;
|
|
53
|
+
assignee: z.ZodOptional<z.ZodNullable<z.ZodObject<{
|
|
54
|
+
id: z.ZodString;
|
|
55
|
+
displayName: z.ZodString;
|
|
56
|
+
}, z.core.$strip>>>;
|
|
57
|
+
archivedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
|
|
58
|
+
trashed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
|
|
59
|
+
}, z.core.$strip>;
|
|
60
|
+
/** A connection of nodes that carry an id and a name, as team states and labels. */
|
|
61
|
+
export declare const idNames: z.ZodObject<{
|
|
62
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
63
|
+
id: z.ZodString;
|
|
64
|
+
name: z.ZodString;
|
|
65
|
+
}, z.core.$strip>>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
/** The identifier and URL of a created or found issue. */
|
|
68
|
+
export declare const created: z.ZodObject<{
|
|
69
|
+
identifier: z.ZodString;
|
|
70
|
+
url: z.ZodString;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
/** An open card that holds a fingerprint, with the description its block is in. */
|
|
73
|
+
export declare const heldIssue: z.ZodObject<{
|
|
74
|
+
identifier: z.ZodString;
|
|
75
|
+
url: z.ZodString;
|
|
76
|
+
id: z.ZodString;
|
|
77
|
+
description: z.ZodNullable<z.ZodString>;
|
|
78
|
+
}, z.core.$strip>;
|
|
79
|
+
/** A comment with its author, a person or a bot. */
|
|
80
|
+
export declare const comment: z.ZodObject<{
|
|
81
|
+
id: z.ZodString;
|
|
82
|
+
body: z.ZodString;
|
|
83
|
+
createdAt: z.ZodString;
|
|
84
|
+
user: z.ZodNullable<z.ZodObject<{
|
|
85
|
+
id: z.ZodString;
|
|
86
|
+
}, z.core.$strip>>;
|
|
87
|
+
botActor: z.ZodNullable<z.ZodObject<{
|
|
88
|
+
id: z.ZodNullable<z.ZodString>;
|
|
89
|
+
}, z.core.$strip>>;
|
|
90
|
+
}, z.core.$strip>;
|
|
91
|
+
/** An attachment of an issue. */
|
|
92
|
+
export declare const attachment: z.ZodObject<{
|
|
93
|
+
id: z.ZodString;
|
|
94
|
+
title: z.ZodString;
|
|
95
|
+
url: z.ZodString;
|
|
96
|
+
}, z.core.$strip>;
|
|
97
|
+
/** The user a token signs in as, from `viewer`. */
|
|
98
|
+
export declare const viewerId: z.ZodObject<{
|
|
99
|
+
viewer: z.ZodObject<{
|
|
100
|
+
id: z.ZodString;
|
|
101
|
+
}, z.core.$strip>;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
/** The users a `users` filter matches. */
|
|
104
|
+
export declare const userIds: z.ZodObject<{
|
|
105
|
+
users: z.ZodObject<{
|
|
106
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
107
|
+
id: z.ZodString;
|
|
108
|
+
}, z.core.$strip>>;
|
|
109
|
+
}, z.core.$strip>;
|
|
110
|
+
}, z.core.$strip>;
|
|
111
|
+
/** The user read by an id; `null` when the workspace has no such user. */
|
|
112
|
+
export declare const userById: z.ZodObject<{
|
|
113
|
+
user: z.ZodNullable<z.ZodObject<{
|
|
114
|
+
id: z.ZodString;
|
|
115
|
+
}, z.core.$strip>>;
|
|
116
|
+
}, z.core.$strip>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** A GraphQL answer: `data`, and the `errors` list as Linear sends it. */
|
|
3
|
+
export const envelope = z.object({
|
|
4
|
+
data: z.unknown().optional(),
|
|
5
|
+
errors: z
|
|
6
|
+
.array(z.object({
|
|
7
|
+
message: z.string().optional(),
|
|
8
|
+
extensions: z.object({ code: z.string().optional() }).optional(),
|
|
9
|
+
}))
|
|
10
|
+
.optional(),
|
|
11
|
+
});
|
|
12
|
+
/** The GraphQL selection of an issue that `issue` parses. */
|
|
13
|
+
export const issueFields = "id identifier title description url state { name } labels { nodes { name } } assignee { id displayName }";
|
|
14
|
+
/** An issue with the fields a `Card` needs. */
|
|
15
|
+
export const issue = z.object({
|
|
16
|
+
id: z.string(),
|
|
17
|
+
identifier: z.string(),
|
|
18
|
+
title: z.string(),
|
|
19
|
+
description: z.string().nullable(),
|
|
20
|
+
url: z.string(),
|
|
21
|
+
state: z.object({ name: z.string() }),
|
|
22
|
+
labels: z.object({ nodes: z.array(z.object({ name: z.string() })) }),
|
|
23
|
+
assignee: z.object({ id: z.string(), displayName: z.string() }).nullish(),
|
|
24
|
+
});
|
|
25
|
+
/** The selection of one issue read by its id. Linear answers an archived issue there, and never in a listing. */
|
|
26
|
+
export const oneIssueFields = `${issueFields} archivedAt trashed`;
|
|
27
|
+
/** One issue read by its id, with the two fields that say it left the board. */
|
|
28
|
+
export const oneIssue = issue.extend({
|
|
29
|
+
archivedAt: z.string().nullish(),
|
|
30
|
+
trashed: z.boolean().nullish(),
|
|
31
|
+
});
|
|
32
|
+
/** A connection of nodes that carry an id and a name, as team states and labels. */
|
|
33
|
+
export const idNames = z.object({
|
|
34
|
+
nodes: z.array(z.object({ id: z.string(), name: z.string() })),
|
|
35
|
+
});
|
|
36
|
+
/** The identifier and URL of a created or found issue. */
|
|
37
|
+
export const created = z.object({ identifier: z.string(), url: z.string() });
|
|
38
|
+
/** An open card that holds a fingerprint, with the description its block is in. */
|
|
39
|
+
export const heldIssue = created.extend({ id: z.string(), description: z.string().nullable() });
|
|
40
|
+
/** A comment with its author, a person or a bot. */
|
|
41
|
+
export const comment = z.object({
|
|
42
|
+
id: z.string(),
|
|
43
|
+
body: z.string(),
|
|
44
|
+
createdAt: z.string(),
|
|
45
|
+
user: z.object({ id: z.string() }).nullable(),
|
|
46
|
+
botActor: z.object({ id: z.string().nullable() }).nullable(),
|
|
47
|
+
});
|
|
48
|
+
/** An attachment of an issue. */
|
|
49
|
+
export const attachment = z.object({ id: z.string(), title: z.string(), url: z.string() });
|
|
50
|
+
/** The user a token signs in as, from `viewer`. */
|
|
51
|
+
export const viewerId = z.object({ viewer: z.object({ id: z.string() }) });
|
|
52
|
+
/** The users a `users` filter matches. */
|
|
53
|
+
export const userIds = z.object({
|
|
54
|
+
users: z.object({ nodes: z.array(z.object({ id: z.string() })) }),
|
|
55
|
+
});
|
|
56
|
+
/** The user read by an id; `null` when the workspace has no such user. */
|
|
57
|
+
export const userById = z.object({ user: z.object({ id: z.string() }).nullable() });
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
/** The input and output of `comment`. */
|
|
3
|
+
export declare const commentTool: {
|
|
4
|
+
input: z.ZodObject<{
|
|
5
|
+
card: z.ZodString;
|
|
6
|
+
text: z.ZodString;
|
|
7
|
+
link: z.ZodExactOptional<z.ZodString>;
|
|
8
|
+
}, z.core.$strip>;
|
|
9
|
+
output: z.ZodObject<{
|
|
10
|
+
id: z.ZodString;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
};
|
|
13
|
+
/** The input and output of `move`. */
|
|
14
|
+
export declare const moveTool: {
|
|
15
|
+
input: z.ZodObject<{
|
|
16
|
+
card: z.ZodString;
|
|
17
|
+
column: z.ZodString;
|
|
18
|
+
}, z.core.$strip>;
|
|
19
|
+
output: z.ZodObject<{
|
|
20
|
+
column: z.ZodString;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
};
|
|
23
|
+
/** The input and output of `close`. */
|
|
24
|
+
export declare const closeTool: {
|
|
25
|
+
input: z.ZodObject<{
|
|
26
|
+
card: z.ZodString;
|
|
27
|
+
reason: z.ZodString;
|
|
28
|
+
}, z.core.$strip>;
|
|
29
|
+
output: z.ZodObject<{
|
|
30
|
+
state: z.ZodString;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
};
|
|
33
|
+
/** The input and output of `create_card`. */
|
|
34
|
+
export declare const createCardTool: {
|
|
35
|
+
input: z.ZodObject<{
|
|
36
|
+
spec: z.ZodObject<{
|
|
37
|
+
title: z.ZodString;
|
|
38
|
+
description: z.ZodString;
|
|
39
|
+
column: z.ZodExactOptional<z.ZodString>;
|
|
40
|
+
labels: z.ZodExactOptional<z.ZodArray<z.ZodString>>;
|
|
41
|
+
block: z.ZodObject<{
|
|
42
|
+
kind: z.ZodEnum<{
|
|
43
|
+
defect: "defect";
|
|
44
|
+
investigation: "investigation";
|
|
45
|
+
question: "question";
|
|
46
|
+
request: "request";
|
|
47
|
+
}>;
|
|
48
|
+
service: z.ZodExactOptional<z.ZodString>;
|
|
49
|
+
environment: z.ZodExactOptional<z.ZodString>;
|
|
50
|
+
fingerprint: z.ZodExactOptional<z.ZodString>;
|
|
51
|
+
first_seen: z.ZodExactOptional<z.ZodISODateTime>;
|
|
52
|
+
last_seen: z.ZodExactOptional<z.ZodISODateTime>;
|
|
53
|
+
occurrences: z.ZodExactOptional<z.ZodNumber>;
|
|
54
|
+
severity: z.ZodExactOptional<z.ZodString>;
|
|
55
|
+
window: z.ZodExactOptional<z.ZodString>;
|
|
56
|
+
waits_for: z.ZodExactOptional<z.ZodString>;
|
|
57
|
+
decided: z.ZodExactOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
58
|
+
origin: z.ZodExactOptional<z.ZodObject<{
|
|
59
|
+
extension: z.ZodString;
|
|
60
|
+
channel: z.ZodString;
|
|
61
|
+
thread: z.ZodString;
|
|
62
|
+
}, z.core.$strict>>;
|
|
63
|
+
}, z.core.$strict>;
|
|
64
|
+
}, z.core.$strict>;
|
|
65
|
+
parent: z.ZodExactOptional<z.ZodString>;
|
|
66
|
+
}, z.core.$strip>;
|
|
67
|
+
output: z.ZodObject<{
|
|
68
|
+
id: z.ZodString;
|
|
69
|
+
url: z.ZodString;
|
|
70
|
+
}, z.core.$strip>;
|
|
71
|
+
};
|
|
72
|
+
/** The input and output of `release_follow_ups`. */
|
|
73
|
+
export declare const releaseFollowUpsTool: {
|
|
74
|
+
input: z.ZodObject<{
|
|
75
|
+
card: z.ZodString;
|
|
76
|
+
pull_request: z.ZodString;
|
|
77
|
+
}, z.core.$strip>;
|
|
78
|
+
output: z.ZodObject<{
|
|
79
|
+
released: z.ZodArray<z.ZodString>;
|
|
80
|
+
}, z.core.$strip>;
|
|
81
|
+
};
|
|
82
|
+
/** The input and output of `update_description` and of its lookup, `find_description`. */
|
|
83
|
+
export declare const descriptionTool: {
|
|
84
|
+
input: z.ZodObject<{
|
|
85
|
+
card: z.ZodString;
|
|
86
|
+
description: z.ZodString;
|
|
87
|
+
}, z.core.$strip>;
|
|
88
|
+
output: z.ZodObject<{
|
|
89
|
+
id: z.ZodString;
|
|
90
|
+
previous: z.ZodOptional<z.ZodString>;
|
|
91
|
+
}, z.core.$strip>;
|
|
92
|
+
};
|
|
93
|
+
/** The input and output of `assign` and of its lookup, `find_assignee`. */
|
|
94
|
+
export declare const assignTool: {
|
|
95
|
+
input: z.ZodObject<{
|
|
96
|
+
card: z.ZodString;
|
|
97
|
+
user: z.ZodString;
|
|
98
|
+
}, z.core.$strip>;
|
|
99
|
+
output: z.ZodObject<{
|
|
100
|
+
id: z.ZodString;
|
|
101
|
+
previous: z.ZodOptional<z.ZodString>;
|
|
102
|
+
}, z.core.$strip>;
|
|
103
|
+
};
|
|
104
|
+
/** The input and output of `restore_description` and of `restore_assignee`, which the engine calls with the undone call's output. */
|
|
105
|
+
export declare const restoreTool: {
|
|
106
|
+
input: z.ZodObject<{
|
|
107
|
+
stage_output: z.ZodObject<{
|
|
108
|
+
id: z.ZodString;
|
|
109
|
+
previous: z.ZodOptional<z.ZodString>;
|
|
110
|
+
}, z.core.$strip>;
|
|
111
|
+
}, z.core.$strip>;
|
|
112
|
+
output: z.ZodObject<{
|
|
113
|
+
id: z.ZodString;
|
|
114
|
+
}, z.core.$strip>;
|
|
115
|
+
};
|
|
116
|
+
/** The input and output of `find_cards`. */
|
|
117
|
+
export declare const findCardsTool: {
|
|
118
|
+
input: z.ZodObject<{
|
|
119
|
+
text: z.ZodString;
|
|
120
|
+
except: z.ZodExactOptional<z.ZodString>;
|
|
121
|
+
}, z.core.$strip>;
|
|
122
|
+
output: z.ZodObject<{
|
|
123
|
+
cards: z.ZodArray<z.ZodObject<{
|
|
124
|
+
id: z.ZodString;
|
|
125
|
+
title: z.ZodString;
|
|
126
|
+
url: z.ZodString;
|
|
127
|
+
state: z.ZodString;
|
|
128
|
+
created_at: z.ZodString;
|
|
129
|
+
}, z.core.$strip>>;
|
|
130
|
+
}, z.core.$strip>;
|
|
131
|
+
};
|
|
132
|
+
/** The input and output of `batch_cards`. */
|
|
133
|
+
export declare const batchCardsTool: {
|
|
134
|
+
input: z.ZodObject<{
|
|
135
|
+
batch: z.ZodString;
|
|
136
|
+
except: z.ZodString;
|
|
137
|
+
only: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
138
|
+
}, z.core.$strip>;
|
|
139
|
+
output: z.ZodObject<{
|
|
140
|
+
cards: z.ZodArray<z.ZodObject<{
|
|
141
|
+
id: z.ZodString;
|
|
142
|
+
title: z.ZodString;
|
|
143
|
+
url: z.ZodString;
|
|
144
|
+
description: z.ZodString;
|
|
145
|
+
}, z.core.$strip>>;
|
|
146
|
+
skipped: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
147
|
+
}, z.core.$strip>;
|
|
148
|
+
};
|
|
149
|
+
/** The input and output of `count_sighting`. */
|
|
150
|
+
export declare const countSightingTool: {
|
|
151
|
+
input: z.ZodObject<{
|
|
152
|
+
card: z.ZodString;
|
|
153
|
+
seen_at: z.ZodExactOptional<z.ZodISODateTime>;
|
|
154
|
+
}, z.core.$strip>;
|
|
155
|
+
output: z.ZodObject<{
|
|
156
|
+
id: z.ZodString;
|
|
157
|
+
}, z.core.$strip>;
|
|
158
|
+
};
|
|
159
|
+
/** The input and output of `hand_back`. */
|
|
160
|
+
export declare const handBackTool: {
|
|
161
|
+
input: z.ZodObject<{
|
|
162
|
+
card: z.ZodString;
|
|
163
|
+
}, z.core.$strip>;
|
|
164
|
+
output: z.ZodObject<{
|
|
165
|
+
id: z.ZodString;
|
|
166
|
+
to: z.ZodString;
|
|
167
|
+
previous: z.ZodString;
|
|
168
|
+
}, z.core.$strip>;
|
|
169
|
+
};
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { cardSpec } from "@kana-ai/edgar-contracts/card";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
/** The input and output of `comment`. */
|
|
4
|
+
export const commentTool = {
|
|
5
|
+
input: z.object({
|
|
6
|
+
card: z.string().min(1),
|
|
7
|
+
text: z.string().min(1),
|
|
8
|
+
link: z.string().min(1).exactOptional(),
|
|
9
|
+
}),
|
|
10
|
+
output: z.object({ id: z.string() }),
|
|
11
|
+
};
|
|
12
|
+
/** The input and output of `move`. */
|
|
13
|
+
export const moveTool = {
|
|
14
|
+
input: z.object({ card: z.string().min(1), column: z.string().min(1) }),
|
|
15
|
+
output: z.object({ column: z.string() }),
|
|
16
|
+
};
|
|
17
|
+
/** The input and output of `close`. */
|
|
18
|
+
export const closeTool = {
|
|
19
|
+
input: z.object({ card: z.string().min(1), reason: z.string() }),
|
|
20
|
+
output: z.object({ state: z.string() }),
|
|
21
|
+
};
|
|
22
|
+
/** The input and output of `create_card`. */
|
|
23
|
+
export const createCardTool = {
|
|
24
|
+
input: z.object({ spec: cardSpec, parent: z.string().min(1).exactOptional() }),
|
|
25
|
+
output: z.object({ id: z.string(), url: z.string() }),
|
|
26
|
+
};
|
|
27
|
+
/** The input and output of `release_follow_ups`. */
|
|
28
|
+
export const releaseFollowUpsTool = {
|
|
29
|
+
input: z.object({ card: z.string().min(1), pull_request: z.string().min(1) }),
|
|
30
|
+
output: z.object({ released: z.array(z.string()) }),
|
|
31
|
+
};
|
|
32
|
+
/** The input and output of `update_description` and of its lookup, `find_description`. */
|
|
33
|
+
export const descriptionTool = {
|
|
34
|
+
input: z.object({
|
|
35
|
+
card: z.string().min(1),
|
|
36
|
+
description: z.string().describe("the new description; the card's edgar:v0 block is kept"),
|
|
37
|
+
}),
|
|
38
|
+
output: z.object({
|
|
39
|
+
id: z.string(),
|
|
40
|
+
previous: z
|
|
41
|
+
.string()
|
|
42
|
+
.optional()
|
|
43
|
+
.describe("the description before the write, which restore_description puts back; none when the card already read so"),
|
|
44
|
+
}),
|
|
45
|
+
};
|
|
46
|
+
/** The input and output of `assign` and of its lookup, `find_assignee`. */
|
|
47
|
+
export const assignTool = {
|
|
48
|
+
input: z.object({
|
|
49
|
+
card: z.string().min(1),
|
|
50
|
+
user: z
|
|
51
|
+
.string()
|
|
52
|
+
.describe("the Linear user by email or id, `me` for the user of LINEAR_TOKEN, or an empty text for nobody"),
|
|
53
|
+
}),
|
|
54
|
+
output: z.object({
|
|
55
|
+
id: z.string(),
|
|
56
|
+
previous: z
|
|
57
|
+
.string()
|
|
58
|
+
.optional()
|
|
59
|
+
.describe("the id of the user the card was assigned to before the write, or an empty text for nobody, which restore_assignee sets back; none when the card already had that assignee"),
|
|
60
|
+
}),
|
|
61
|
+
};
|
|
62
|
+
/** The input and output of `restore_description` and of `restore_assignee`, which the engine calls with the undone call's output. */
|
|
63
|
+
export const restoreTool = {
|
|
64
|
+
input: z.object({
|
|
65
|
+
stage_output: z.object({ id: z.string().min(1), previous: z.string().optional() }),
|
|
66
|
+
}),
|
|
67
|
+
output: z.object({ id: z.string() }),
|
|
68
|
+
};
|
|
69
|
+
/** The input and output of `find_cards`. */
|
|
70
|
+
export const findCardsTool = {
|
|
71
|
+
input: z.object({
|
|
72
|
+
text: z
|
|
73
|
+
.string()
|
|
74
|
+
.min(1)
|
|
75
|
+
.max(1024)
|
|
76
|
+
.describe("words of the fault, such as the error message, the endpoint or the service"),
|
|
77
|
+
except: z
|
|
78
|
+
.string()
|
|
79
|
+
.min(1)
|
|
80
|
+
.exactOptional()
|
|
81
|
+
.describe("the card you work on; it and each card made after it are left out"),
|
|
82
|
+
}),
|
|
83
|
+
output: z.object({
|
|
84
|
+
cards: z
|
|
85
|
+
.array(z.object({
|
|
86
|
+
id: z.string(),
|
|
87
|
+
title: z.string(),
|
|
88
|
+
url: z.string(),
|
|
89
|
+
state: z.string().describe("the engine state of the card, or its column name"),
|
|
90
|
+
created_at: z.string(),
|
|
91
|
+
}))
|
|
92
|
+
.max(10),
|
|
93
|
+
}),
|
|
94
|
+
};
|
|
95
|
+
/** The input and output of `batch_cards`. */
|
|
96
|
+
export const batchCardsTool = {
|
|
97
|
+
input: z.object({
|
|
98
|
+
batch: z
|
|
99
|
+
.string()
|
|
100
|
+
.min(1)
|
|
101
|
+
.max(256)
|
|
102
|
+
.describe("the `decided.batch` of the card you work on, such as its repository"),
|
|
103
|
+
except: z.string().min(1).describe("the card you work on; it is left out"),
|
|
104
|
+
only: z
|
|
105
|
+
.array(z.string().min(1))
|
|
106
|
+
.max(20)
|
|
107
|
+
.optional()
|
|
108
|
+
.describe("only these card ids, each kept only while it is an open card of the batch"),
|
|
109
|
+
}),
|
|
110
|
+
output: z.object({
|
|
111
|
+
cards: z
|
|
112
|
+
.array(z.object({
|
|
113
|
+
id: z.string(),
|
|
114
|
+
title: z.string(),
|
|
115
|
+
url: z.string(),
|
|
116
|
+
description: z.string(),
|
|
117
|
+
}))
|
|
118
|
+
.max(20),
|
|
119
|
+
skipped: z
|
|
120
|
+
.array(z.string())
|
|
121
|
+
.max(20)
|
|
122
|
+
.optional()
|
|
123
|
+
.describe("the ids of `only` that are not open cards of the batch; absent when none is"),
|
|
124
|
+
}),
|
|
125
|
+
};
|
|
126
|
+
/** The input and output of `count_sighting`. */
|
|
127
|
+
export const countSightingTool = {
|
|
128
|
+
input: z.object({
|
|
129
|
+
card: z.string().min(1),
|
|
130
|
+
seen_at: z.iso
|
|
131
|
+
.datetime({ offset: true })
|
|
132
|
+
.exactOptional()
|
|
133
|
+
.describe("when the fault was seen again; a retry with the same time counts nothing"),
|
|
134
|
+
}),
|
|
135
|
+
output: z.object({ id: z.string() }),
|
|
136
|
+
};
|
|
137
|
+
/** The input and output of `hand_back`. */
|
|
138
|
+
export const handBackTool = {
|
|
139
|
+
input: z.object({ card: z.string().min(1) }),
|
|
140
|
+
output: z.object({
|
|
141
|
+
id: z.string(),
|
|
142
|
+
to: z.string().describe("the display name of the person the card is now assigned to"),
|
|
143
|
+
previous: z
|
|
144
|
+
.string()
|
|
145
|
+
.describe("the id of the user the card was assigned to before, or an empty text for nobody"),
|
|
146
|
+
}),
|
|
147
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Outcome } from "@kana-ai/edgar-sdk";
|
|
2
|
+
import { type LinearCtx } from "#api/client";
|
|
3
|
+
/** Assigns a card to `user`, or to nobody for an empty `user`, and answers the id of the assignee it replaced, `""` for nobody. A card that already has that assignee is not written again and gets no `previous`: this call cannot know what a lost earlier call replaced, so its undo writes nothing. */
|
|
4
|
+
export declare function assign(ctx: LinearCtx, card: string, user: string): Promise<Outcome<{
|
|
5
|
+
id: string;
|
|
6
|
+
previous?: string;
|
|
7
|
+
}>>;
|
|
8
|
+
/** Sets the card's assignee back to `previous`, the user id that `assign` answered, or to nobody for `""`. With no `previous` the undone call wrote nothing, so this writes nothing. */
|
|
9
|
+
export declare function restoreAssignee(ctx: LinearCtx, card: string, previous: string | undefined): Promise<Outcome<{
|
|
10
|
+
id: string;
|
|
11
|
+
}>>;
|
|
12
|
+
/** `done` when the card already has the assignee that `assign` sets for `user`, else `skipped`: the lookup of a call that did not end. Its answer has no `previous`, so a later undo of a call it settled writes nothing. */
|
|
13
|
+
export declare function findAssignee(ctx: LinearCtx, card: string, user: string): Promise<Outcome<{
|
|
14
|
+
id: string;
|
|
15
|
+
}>>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { done, err, ok, permanentFailure, skipped, } from "@kana-ai/edgar-sdk";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
import { linear } from "#api/client";
|
|
4
|
+
import { issueId } from "#tracker/cards";
|
|
5
|
+
import { userId } from "#tracker/states";
|
|
6
|
+
import { update } from "#tracker/transitions";
|
|
7
|
+
/** The issue behind a card with the id of its assignee, and the assignee that an assign to `user` writes; `null` is nobody. A card or a user that Linear does not have is `not_found`. */
|
|
8
|
+
async function planned(ctx, card, user) {
|
|
9
|
+
const read = await linear(ctx, "query Assignee($id: String!) { issue(id: $id) { id assignee { id } } }", { id: card }, z.object({
|
|
10
|
+
issue: z
|
|
11
|
+
.object({ id: z.string(), assignee: z.object({ id: z.string() }).nullish() })
|
|
12
|
+
.nullable(),
|
|
13
|
+
}));
|
|
14
|
+
if (!read.ok)
|
|
15
|
+
return err(read.error);
|
|
16
|
+
const issue = read.value.issue;
|
|
17
|
+
if (issue === null)
|
|
18
|
+
return err(permanentFailure("not_found", `linear: no card ${card}`));
|
|
19
|
+
const current = issue.assignee?.id ?? null;
|
|
20
|
+
if (user === "")
|
|
21
|
+
return ok({ id: issue.id, current, next: null });
|
|
22
|
+
const found = await userId(ctx, user);
|
|
23
|
+
if (!found.ok)
|
|
24
|
+
return err(found.error);
|
|
25
|
+
return found.value === undefined
|
|
26
|
+
? err(permanentFailure("not_found", `linear: no user ${user}`))
|
|
27
|
+
: ok({ id: issue.id, current, next: found.value });
|
|
28
|
+
}
|
|
29
|
+
/** Assigns a card to `user`, or to nobody for an empty `user`, and answers the id of the assignee it replaced, `""` for nobody. A card that already has that assignee is not written again and gets no `previous`: this call cannot know what a lost earlier call replaced, so its undo writes nothing. */
|
|
30
|
+
export async function assign(ctx, card, user) {
|
|
31
|
+
const plan = await planned(ctx, card, user);
|
|
32
|
+
if (!plan.ok)
|
|
33
|
+
return plan.error;
|
|
34
|
+
const { id, current, next } = plan.value;
|
|
35
|
+
if (current === next)
|
|
36
|
+
return done({ id: card });
|
|
37
|
+
const written = await update(ctx, id, { assigneeId: next });
|
|
38
|
+
return written.ok ? done({ id: card, previous: current ?? "" }) : written.error;
|
|
39
|
+
}
|
|
40
|
+
/** Sets the card's assignee back to `previous`, the user id that `assign` answered, or to nobody for `""`. With no `previous` the undone call wrote nothing, so this writes nothing. */
|
|
41
|
+
export async function restoreAssignee(ctx, card, previous) {
|
|
42
|
+
if (previous === undefined)
|
|
43
|
+
return done({ id: card });
|
|
44
|
+
const target = await issueId(ctx, card);
|
|
45
|
+
if (!target.ok)
|
|
46
|
+
return target.error;
|
|
47
|
+
const written = await update(ctx, target.value, {
|
|
48
|
+
assigneeId: previous === "" ? null : previous,
|
|
49
|
+
});
|
|
50
|
+
return written.ok ? done({ id: card }) : written.error;
|
|
51
|
+
}
|
|
52
|
+
/** `done` when the card already has the assignee that `assign` sets for `user`, else `skipped`: the lookup of a call that did not end. Its answer has no `previous`, so a later undo of a call it settled writes nothing. */
|
|
53
|
+
export async function findAssignee(ctx, card, user) {
|
|
54
|
+
const plan = await planned(ctx, card, user);
|
|
55
|
+
if (!plan.ok)
|
|
56
|
+
return plan.error;
|
|
57
|
+
return plan.value.current === plan.value.next ? done({ id: card }) : skipped();
|
|
58
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { Card, CardSpec } from "@kana-ai/edgar-contracts/rpc";
|
|
2
|
+
import { type Failure, type Outcome, type Result } from "@kana-ai/edgar-sdk";
|
|
3
|
+
import { z } from "zod";
|
|
4
|
+
import { type LinearCtx } from "#api/client";
|
|
5
|
+
import type { batchCardsTool, findCardsTool } from "#schemas/tools";
|
|
6
|
+
/** The Linear id of the card `card`, or `not_found`. */
|
|
7
|
+
export declare function issueId(ctx: LinearCtx, card: string): Promise<Result<string, Failure>>;
|
|
8
|
+
/** The ids of the labels named `names`, the first match per name; a missing name is `invalid`. */
|
|
9
|
+
export declare function labelIds(ctx: LinearCtx, names: readonly string[]): Promise<Result<string[], Failure>>;
|
|
10
|
+
/** One page of the cards in the engine states `columns` and in the table's scope, with the cursor of the next and the requests left; a name that is not an engine state is `invalid`. `intake` also takes each card assigned to `assignee` in a column of `assigned`. With `assignee_only`, Linear answers only the cards assigned to `assignee` or labelled `edgar:waiting`. */
|
|
11
|
+
export declare function listCards(ctx: LinearCtx, input: {
|
|
12
|
+
readonly columns: readonly string[];
|
|
13
|
+
readonly cursor: string | null;
|
|
14
|
+
}): Promise<Outcome<{
|
|
15
|
+
cards: Card[];
|
|
16
|
+
next: string | null;
|
|
17
|
+
budget_remaining: number;
|
|
18
|
+
}>>;
|
|
19
|
+
/** The card `id`; a missing, archived or trashed card is `not_found` and a bad block `invalid`. With `assignee_only`, a card that is not assigned to `assignee` and not labelled `edgar:waiting` is `not_found` too, so the engine reads it as a card that left the board. */
|
|
20
|
+
export declare function readCard(ctx: LinearCtx, id: string): Promise<Outcome<Card>>;
|
|
21
|
+
/** At most 10 open cards of the table's team and scope that Linear's search matches with `text`, the best match first; with `assignee_only`, only EDGAR's cards and those handed back. With `except`, that card and each card made after it are left out, so two cards never point at each other; a missing `except` is `not_found`. */
|
|
22
|
+
export declare function findCards(ctx: LinearCtx, text: string, except?: string): Promise<Outcome<z.infer<typeof findCardsTool.output>>>;
|
|
23
|
+
/** At most 20 open cards of the table's team and scope whose block names `batch` in `decided.batch`, with `except` left out; with `assignee_only`, only EDGAR's cards and those handed back. A card whose block does not read is left out. */
|
|
24
|
+
export declare function batchCards(ctx: LinearCtx, batch: string, except: string, ids?: readonly string[]): Promise<Outcome<z.infer<typeof batchCardsTool.output>>>;
|
|
25
|
+
/** Counts one more sighting, at `seen` or now, of the fault that the card `card` holds, for a fault that a run found again without filing a card. */
|
|
26
|
+
export declare function countSightingOn(ctx: LinearCtx, card: string, seen: string | undefined): Promise<Outcome<{
|
|
27
|
+
id: string;
|
|
28
|
+
}>>;
|
|
29
|
+
/** Files a card inside the table's scope, or returns the open card that already holds the block's fingerprint. With `assignee_only`, the new card is assigned to `assignee`, so it is in scope from its first sweep. Calls with one fingerprint run one at a time in this process, so the second finds the card the first filed. */
|
|
30
|
+
export declare function createCard(ctx: LinearCtx, spec: CardSpec, parent?: string): Promise<Outcome<{
|
|
31
|
+
id: string;
|
|
32
|
+
url: string;
|
|
33
|
+
}>>;
|