@kana-ai/edgar-ext-linear 0.1.4 → 0.1.5

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.
@@ -11,8 +11,11 @@ export declare const envelope: z.ZodObject<{
11
11
  }, z.core.$strip>;
12
12
  /** One entry of a GraphQL `errors` list as Linear sends it. */
13
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 email } priority creator { id guest email }";
14
+ /**
15
+ * The GraphQL selection of an issue that `issue` parses, with its newest changes, which say who gave it to its assignee.
16
+ * shortcut: 10 changes keep a page of 50 issues far below Linear's query complexity; a card changed more often since it was given to EDGAR names its writer instead.
17
+ */
18
+ export declare const issueFields = "id identifier title description url state { name } labels { nodes { name } } assignee { id displayName email } priority creator { id guest email displayName } history(first: 10) { nodes { createdAt actor { id displayName email } toAssignee { id } } }";
16
19
  /** An issue with the fields a `Card` needs. */
17
20
  export declare const issue: z.ZodObject<{
18
21
  id: z.ZodString;
@@ -38,10 +41,24 @@ export declare const issue: z.ZodObject<{
38
41
  id: z.ZodString;
39
42
  guest: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
40
43
  email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
44
+ displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
45
+ }, z.core.$strip>>>;
46
+ history: z.ZodOptional<z.ZodNullable<z.ZodObject<{
47
+ nodes: z.ZodArray<z.ZodObject<{
48
+ createdAt: z.ZodString;
49
+ actor: z.ZodOptional<z.ZodNullable<z.ZodObject<{
50
+ id: z.ZodString;
51
+ displayName: z.ZodString;
52
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
53
+ }, z.core.$strip>>>;
54
+ toAssignee: z.ZodOptional<z.ZodNullable<z.ZodObject<{
55
+ id: z.ZodString;
56
+ }, z.core.$strip>>>;
57
+ }, z.core.$strip>>;
41
58
  }, z.core.$strip>>>;
42
59
  }, z.core.$strip>;
43
60
  /** The selection of one issue read by its id. Linear answers an archived issue there, and never in a listing. */
44
- export declare const oneIssueFields = "id identifier title description url state { name } labels { nodes { name } } assignee { id displayName email } priority creator { id guest email } archivedAt trashed";
61
+ export declare const oneIssueFields = "id identifier title description url state { name } labels { nodes { name } } assignee { id displayName email } priority creator { id guest email displayName } history(first: 10) { nodes { createdAt actor { id displayName email } toAssignee { id } } } archivedAt trashed";
45
62
  /** One issue read by its id, with the two fields that say it left the board. */
46
63
  export declare const oneIssue: z.ZodObject<{
47
64
  id: z.ZodString;
@@ -67,6 +84,20 @@ export declare const oneIssue: z.ZodObject<{
67
84
  id: z.ZodString;
68
85
  guest: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
69
86
  email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
87
+ displayName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
88
+ }, z.core.$strip>>>;
89
+ history: z.ZodOptional<z.ZodNullable<z.ZodObject<{
90
+ nodes: z.ZodArray<z.ZodObject<{
91
+ createdAt: z.ZodString;
92
+ actor: z.ZodOptional<z.ZodNullable<z.ZodObject<{
93
+ id: z.ZodString;
94
+ displayName: z.ZodString;
95
+ email: z.ZodOptional<z.ZodNullable<z.ZodString>>;
96
+ }, z.core.$strip>>>;
97
+ toAssignee: z.ZodOptional<z.ZodNullable<z.ZodObject<{
98
+ id: z.ZodString;
99
+ }, z.core.$strip>>>;
100
+ }, z.core.$strip>>;
70
101
  }, z.core.$strip>>>;
71
102
  archivedAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
72
103
  trashed: z.ZodOptional<z.ZodNullable<z.ZodBoolean>>;
@@ -9,8 +9,13 @@ export const envelope = z.object({
9
9
  }))
10
10
  .optional(),
11
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 email } priority creator { id guest email }";
12
+ /**
13
+ * The GraphQL selection of an issue that `issue` parses, with its newest changes, which say who gave it to its assignee.
14
+ * shortcut: 10 changes keep a page of 50 issues far below Linear's query complexity; a card changed more often since it was given to EDGAR names its writer instead.
15
+ */
16
+ export const issueFields = "id identifier title description url state { name } labels { nodes { name } } assignee { id displayName email } priority creator { id guest email displayName } history(first: 10) { nodes { createdAt actor { id displayName email } toAssignee { id } } }";
17
+ /** A person as Linear names them in an issue's change. */
18
+ const person = z.object({ id: z.string(), displayName: z.string(), email: z.string().nullish() });
14
19
  /** An issue with the fields a `Card` needs. */
15
20
  export const issue = z.object({
16
21
  id: z.string(),
@@ -25,7 +30,21 @@ export const issue = z.object({
25
30
  .nullish(),
26
31
  priority: z.number().nullish(),
27
32
  creator: z
28
- .object({ id: z.string(), guest: z.boolean().nullish(), email: z.string().nullish() })
33
+ .object({
34
+ id: z.string(),
35
+ guest: z.boolean().nullish(),
36
+ email: z.string().nullish(),
37
+ displayName: z.string().nullish(),
38
+ })
39
+ .nullish(),
40
+ history: z
41
+ .object({
42
+ nodes: z.array(z.object({
43
+ createdAt: z.string(),
44
+ actor: person.nullish(),
45
+ toAssignee: z.object({ id: z.string() }).nullish(),
46
+ })),
47
+ })
29
48
  .nullish(),
30
49
  });
31
50
  /** The selection of one issue read by its id. Linear answers an archived issue there, and never in a listing. */
@@ -64,6 +64,8 @@ export declare const createCardTool: {
64
64
  outside: "outside";
65
65
  team: "team";
66
66
  }>>;
67
+ requested_by: z.ZodExactOptional<z.ZodString>;
68
+ requested_by_id: z.ZodExactOptional<z.ZodString>;
67
69
  }, z.core.$strict>;
68
70
  }, z.core.$strict>;
69
71
  parent: z.ZodExactOptional<z.ZodString>;
@@ -17,6 +17,7 @@ function toCard(settings, value, strict, assignee, own) {
17
17
  const taken = person?.displayName;
18
18
  const takenId = person?.email ?? undefined;
19
19
  const writerId = value.creator?.email ?? undefined;
20
+ const asked = requesterOf(value, own);
20
21
  const priority = priorities[value.priority ?? 0];
21
22
  return done({
22
23
  id: value.identifier,
@@ -32,8 +33,24 @@ function toCard(settings, value, strict, assignee, own) {
32
33
  ...(priority === undefined ? {} : { priority }),
33
34
  trust: trustOf(value.creator?.id ?? "", value.creator, own),
34
35
  ...(writerId === undefined ? {} : { written_by_id: writerId }),
36
+ ...(asked === undefined ? {} : { requested_by: asked.name }),
37
+ ...(asked?.id === undefined ? {} : { requested_by_id: asked.id }),
35
38
  });
36
39
  }
40
+ /** Who asked for the work on an issue: the person, not one of EDGAR's own users in `own`, who last gave it to one of them, else its writer when that is a person; the id is their email. */
41
+ function requesterOf(value, own) {
42
+ const given = (value.history?.nodes ?? [])
43
+ .filter((change) => own.has(change.toAssignee?.id ?? "") && !own.has(change.actor?.id ?? ""))
44
+ .toSorted((a, b) => b.createdAt.localeCompare(a.createdAt))
45
+ .find((change) => change.actor !== null && change.actor !== undefined)?.actor;
46
+ if (given !== null && given !== undefined)
47
+ return { name: given.displayName, id: given.email ?? undefined };
48
+ const writer = value.creator;
49
+ if (writer === null || writer === undefined || own.has(writer.id))
50
+ return undefined;
51
+ const name = writer.displayName ?? undefined;
52
+ return name === undefined ? undefined : { name, id: writer.email ?? undefined };
53
+ }
37
54
  /** The ids of EDGAR's own users: the `viewer` that a read asked with it, and `[extensions.linear] assignee` when the table needs one. */
38
55
  function ownOf(viewer, assignee) {
39
56
  return new Set([viewer.id, assignee].flatMap((id) => id ?? []));
@@ -43,6 +43,8 @@ export declare const tools: {
43
43
  thread: string;
44
44
  };
45
45
  trust?: "outside" | "team";
46
+ requested_by?: string;
47
+ requested_by_id?: string;
46
48
  };
47
49
  };
48
50
  parent?: string;
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "contract": 1,
3
3
  "name": "linear",
4
- "version": "0.1.4",
4
+ "version": "0.1.5",
5
5
  "config_schema": "schemas/config.json",
6
6
  "secrets": [
7
7
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kana-ai/edgar-ext-linear",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "EDGAR extension for Linear: the tracker port, comments, column moves, cards and follow-ups.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -21,8 +21,8 @@
21
21
  ".": "./dist/src/index.js"
22
22
  },
23
23
  "dependencies": {
24
- "@kana-ai/edgar-contracts": "0.1.4",
25
- "@kana-ai/edgar-sdk": "0.1.4",
24
+ "@kana-ai/edgar-contracts": "0.1.5",
25
+ "@kana-ai/edgar-sdk": "0.1.5",
26
26
  "zod": "4.6.7"
27
27
  },
28
28
  "devDependencies": {