@bdsqqq/lnr-core 1.3.0 → 1.5.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bdsqqq/lnr-core",
3
- "version": "1.3.0",
3
+ "version": "1.5.0",
4
4
  "description": "core business logic for lnr",
5
5
  "type": "module",
6
6
  "private": false,
@@ -0,0 +1,66 @@
1
+ import type { LinearClient } from "@linear/sdk";
2
+
3
+ export interface Attachment {
4
+ id: string;
5
+ url: string;
6
+ title?: string | null;
7
+ subtitle?: string | null;
8
+ createdAt: Date;
9
+ }
10
+
11
+ export interface CreateAttachmentInput {
12
+ issueId: string;
13
+ url: string;
14
+ title: string;
15
+ subtitle?: string;
16
+ }
17
+
18
+ export async function createAttachment(
19
+ client: LinearClient,
20
+ input: CreateAttachmentInput
21
+ ): Promise<Attachment | null> {
22
+ const result = await client.createAttachment(input);
23
+
24
+ if (!result.success) {
25
+ return null;
26
+ }
27
+
28
+ const attachment = await result.attachment;
29
+ if (!attachment) {
30
+ return null;
31
+ }
32
+
33
+ return {
34
+ id: attachment.id,
35
+ url: attachment.url,
36
+ title: attachment.title,
37
+ subtitle: attachment.subtitle,
38
+ createdAt: attachment.createdAt,
39
+ };
40
+ }
41
+
42
+ export async function linkGitHubPR(
43
+ client: LinearClient,
44
+ issueId: string,
45
+ url: string
46
+ ): Promise<boolean> {
47
+ const result = await client.attachmentLinkGitHubPR(issueId, url);
48
+ return result.success;
49
+ }
50
+
51
+ export async function getIssueAttachments(
52
+ client: LinearClient,
53
+ issueId: string
54
+ ): Promise<Attachment[]> {
55
+ const issue = await client.issue(issueId);
56
+ if (!issue) return [];
57
+
58
+ const attachments = await issue.attachments();
59
+ return attachments.nodes.map((a) => ({
60
+ id: a.id,
61
+ url: a.url,
62
+ title: a.title,
63
+ subtitle: a.subtitle,
64
+ createdAt: a.createdAt,
65
+ }));
66
+ }
package/src/index.ts CHANGED
@@ -121,3 +121,7 @@ export {
121
121
 
122
122
  // reactions
123
123
  export { createReaction, deleteReaction } from "./reactions";
124
+
125
+ // attachments
126
+ export type { Attachment, CreateAttachmentInput } from "./attachments";
127
+ export { createAttachment, getIssueAttachments, linkGitHubPR } from "./attachments";
package/src/types.ts CHANGED
@@ -73,6 +73,7 @@ export interface CreateIssueInput {
73
73
  priority?: number;
74
74
  labelIds?: string[];
75
75
  parentId?: string;
76
+ projectId?: string;
76
77
  }
77
78
 
78
79
  export interface UpdateIssueInput {