@credal/actions 0.2.47 → 0.2.49
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/dist/actions/actionMapper.js +39 -1
- package/dist/actions/autogen/templates.d.ts +6 -0
- package/dist/actions/autogen/templates.js +640 -0
- package/dist/actions/autogen/types.d.ts +803 -1
- package/dist/actions/autogen/types.js +222 -0
- package/dist/actions/groups.js +11 -1
- package/dist/actions/providers/confluence/updatePage.d.ts +3 -0
- package/dist/actions/providers/confluence/updatePage.js +47 -0
- package/dist/actions/providers/credal/callCopilot.d.ts +3 -0
- package/dist/actions/providers/credal/callCopilot.js +36 -0
- package/dist/actions/providers/github/searchRepository.js +3 -2
- package/dist/actions/providers/gitlab/searchGroup.js +11 -5
- package/dist/actions/providers/jamf/types.d.ts +8 -0
- package/dist/actions/providers/jamf/types.js +7 -0
- package/dist/actions/providers/linear/getIssueDetails.d.ts +3 -0
- package/dist/actions/providers/linear/getIssueDetails.js +127 -0
- package/dist/actions/providers/linear/getIssues.d.ts +3 -0
- package/dist/actions/providers/linear/getIssues.js +160 -0
- package/dist/actions/providers/linear/getProjectDetails.d.ts +3 -0
- package/dist/actions/providers/linear/getProjectDetails.js +129 -0
- package/dist/actions/providers/linear/getProjects.d.ts +3 -0
- package/dist/actions/providers/linear/getProjects.js +96 -0
- package/dist/actions/providers/linear/getTeamDetails.d.ts +3 -0
- package/dist/actions/providers/linear/getTeamDetails.js +84 -0
- package/dist/actions/providers/linear/getTeams.d.ts +3 -0
- package/dist/actions/providers/linear/getTeams.js +68 -0
- package/dist/actions/providers/math/index.d.ts +1 -0
- package/dist/actions/providers/math/index.js +37 -0
- package/dist/actions/providers/slack/index.d.ts +1 -0
- package/dist/actions/providers/slack/index.js +37 -0
- package/dist/actions/providers/slack/listConversations.d.ts +3 -0
- package/dist/actions/providers/slack/listConversations.js +41 -0
- package/package.json +1 -1
- package/dist/actions/providers/github/fetchFile.d.ts +0 -3
- package/dist/actions/providers/github/fetchFile.js +0 -131
- package/dist/actions/providers/github/getContents.d.ts +0 -3
- package/dist/actions/providers/github/getContents.js +0 -41
@@ -0,0 +1,160 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
const getIssues = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
11
|
+
var _b;
|
12
|
+
const { authToken } = authParams;
|
13
|
+
const { query, maxResults } = params;
|
14
|
+
if (!authToken) {
|
15
|
+
throw new Error("Valid auth token is required to get Linear issues");
|
16
|
+
}
|
17
|
+
const PAGE_SIZE = 50; // Linear's max per page
|
18
|
+
const max = typeof maxResults === "number" && maxResults > 0 ? maxResults : 500;
|
19
|
+
let fetched = 0;
|
20
|
+
let afterCursor = null;
|
21
|
+
const allIssues = [];
|
22
|
+
try {
|
23
|
+
while (fetched < max) {
|
24
|
+
const graphqlQuery = `
|
25
|
+
query GetIssues($query: String, $first: Int, $after: String) {
|
26
|
+
issues(
|
27
|
+
filter: { or: [
|
28
|
+
{ title: { contains: $query } },
|
29
|
+
{ description: { contains: $query } }
|
30
|
+
] },
|
31
|
+
first: $first,
|
32
|
+
after: $after
|
33
|
+
) {
|
34
|
+
nodes {
|
35
|
+
id
|
36
|
+
title
|
37
|
+
url
|
38
|
+
dueDate
|
39
|
+
state {
|
40
|
+
name
|
41
|
+
}
|
42
|
+
assignee {
|
43
|
+
id
|
44
|
+
name
|
45
|
+
}
|
46
|
+
project {
|
47
|
+
id
|
48
|
+
name
|
49
|
+
}
|
50
|
+
team {
|
51
|
+
id
|
52
|
+
name
|
53
|
+
}
|
54
|
+
labels {
|
55
|
+
nodes {
|
56
|
+
name
|
57
|
+
}
|
58
|
+
}
|
59
|
+
comments {
|
60
|
+
nodes {
|
61
|
+
user {
|
62
|
+
name
|
63
|
+
}
|
64
|
+
body
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
pageInfo {
|
69
|
+
endCursor
|
70
|
+
hasNextPage
|
71
|
+
}
|
72
|
+
}
|
73
|
+
}
|
74
|
+
`;
|
75
|
+
const variables = {
|
76
|
+
query: query || null,
|
77
|
+
first: Math.min(PAGE_SIZE, max - fetched),
|
78
|
+
after: afterCursor,
|
79
|
+
};
|
80
|
+
const response = yield fetch("https://api.linear.app/graphql", {
|
81
|
+
method: "POST",
|
82
|
+
headers: {
|
83
|
+
"Content-Type": "application/json",
|
84
|
+
Authorization: `Bearer ${authToken}`,
|
85
|
+
},
|
86
|
+
body: JSON.stringify({
|
87
|
+
query: graphqlQuery,
|
88
|
+
variables,
|
89
|
+
}),
|
90
|
+
});
|
91
|
+
if (!response.ok) {
|
92
|
+
const errorText = yield response.text();
|
93
|
+
throw new Error(`HTTP error: status: ${response.status}, body: ${errorText}`);
|
94
|
+
}
|
95
|
+
const data = yield response.json();
|
96
|
+
if (data.errors) {
|
97
|
+
throw new Error(`GraphQL errors: ${JSON.stringify(data.errors)}`);
|
98
|
+
}
|
99
|
+
const issuesData = (_b = data.data) === null || _b === void 0 ? void 0 : _b.issues;
|
100
|
+
if (!issuesData) {
|
101
|
+
break;
|
102
|
+
}
|
103
|
+
const { nodes, pageInfo } = issuesData;
|
104
|
+
if (Array.isArray(nodes) && nodes.length > 0) {
|
105
|
+
const processedIssues = nodes.map((issue) => {
|
106
|
+
const { id, title, url, dueDate, state, assignee, project, team, labels, comments } = issue;
|
107
|
+
return {
|
108
|
+
id,
|
109
|
+
title,
|
110
|
+
labels: Array.isArray(labels === null || labels === void 0 ? void 0 : labels.nodes) ? labels.nodes.map(({ name }) => name) : [],
|
111
|
+
state: (state === null || state === void 0 ? void 0 : state.name) || "",
|
112
|
+
assignee: assignee ? { id: assignee.id, name: assignee.name } : null,
|
113
|
+
due_date: dueDate,
|
114
|
+
project: project ? { id: project.id, name: project.name } : null,
|
115
|
+
team: team ? { id: team.id, name: team.name } : null,
|
116
|
+
url,
|
117
|
+
comments: Array.isArray(comments === null || comments === void 0 ? void 0 : comments.nodes)
|
118
|
+
? comments.nodes.map(({ user, body }) => ({
|
119
|
+
author_name: (user === null || user === void 0 ? void 0 : user.name) || "Unknown",
|
120
|
+
comment: body,
|
121
|
+
}))
|
122
|
+
: [],
|
123
|
+
};
|
124
|
+
});
|
125
|
+
allIssues.push(...processedIssues);
|
126
|
+
fetched = allIssues.length;
|
127
|
+
}
|
128
|
+
if (!(pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.hasNextPage) || !(pageInfo === null || pageInfo === void 0 ? void 0 : pageInfo.endCursor) || allIssues.length >= max) {
|
129
|
+
break;
|
130
|
+
}
|
131
|
+
afterCursor = pageInfo.endCursor;
|
132
|
+
}
|
133
|
+
return {
|
134
|
+
success: true,
|
135
|
+
issues: allIssues.slice(0, max).map(issue => {
|
136
|
+
const { id, title, labels, state, assignee, due_date, project, team, url, comments } = issue;
|
137
|
+
return {
|
138
|
+
id,
|
139
|
+
title,
|
140
|
+
labels,
|
141
|
+
state,
|
142
|
+
assignee: assignee || undefined,
|
143
|
+
due_date: due_date || undefined,
|
144
|
+
project: project || undefined,
|
145
|
+
team: team || undefined,
|
146
|
+
url,
|
147
|
+
comments,
|
148
|
+
};
|
149
|
+
}),
|
150
|
+
};
|
151
|
+
}
|
152
|
+
catch (error) {
|
153
|
+
console.error("Error retrieving Linear issues: ", error);
|
154
|
+
return {
|
155
|
+
success: false,
|
156
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
157
|
+
};
|
158
|
+
}
|
159
|
+
});
|
160
|
+
export default getIssues;
|
@@ -0,0 +1,129 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
const getProjectDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
11
|
+
var _b;
|
12
|
+
const { authToken } = authParams;
|
13
|
+
const { projectId } = params;
|
14
|
+
if (!authToken) {
|
15
|
+
throw new Error("Valid auth token is required to get Linear project details");
|
16
|
+
}
|
17
|
+
const query = `
|
18
|
+
query GetProject($id: String!) {
|
19
|
+
project(id: $id) {
|
20
|
+
id
|
21
|
+
name
|
22
|
+
description
|
23
|
+
state
|
24
|
+
progress
|
25
|
+
targetDate
|
26
|
+
createdAt
|
27
|
+
updatedAt
|
28
|
+
url
|
29
|
+
lead {
|
30
|
+
id
|
31
|
+
name
|
32
|
+
}
|
33
|
+
teams {
|
34
|
+
nodes {
|
35
|
+
id
|
36
|
+
name
|
37
|
+
}
|
38
|
+
}
|
39
|
+
issues {
|
40
|
+
nodes {
|
41
|
+
id
|
42
|
+
title
|
43
|
+
url
|
44
|
+
}
|
45
|
+
}
|
46
|
+
projectUpdates {
|
47
|
+
nodes {
|
48
|
+
id
|
49
|
+
body
|
50
|
+
user {
|
51
|
+
name
|
52
|
+
}
|
53
|
+
createdAt
|
54
|
+
}
|
55
|
+
}
|
56
|
+
}
|
57
|
+
}
|
58
|
+
`;
|
59
|
+
try {
|
60
|
+
const response = yield fetch("https://api.linear.app/graphql", {
|
61
|
+
method: "POST",
|
62
|
+
headers: {
|
63
|
+
"Content-Type": "application/json",
|
64
|
+
Authorization: `Bearer ${authToken}`,
|
65
|
+
},
|
66
|
+
body: JSON.stringify({
|
67
|
+
query,
|
68
|
+
variables: { id: projectId },
|
69
|
+
}),
|
70
|
+
});
|
71
|
+
if (!response.ok) {
|
72
|
+
const errorText = yield response.text();
|
73
|
+
throw new Error(`HTTP error: status: ${response.status}, body: ${errorText}`);
|
74
|
+
}
|
75
|
+
const data = yield response.json();
|
76
|
+
if (data.errors) {
|
77
|
+
throw new Error(`GraphQL errors: ${JSON.stringify(data.errors)}`);
|
78
|
+
}
|
79
|
+
if (!((_b = data.data) === null || _b === void 0 ? void 0 : _b.project)) {
|
80
|
+
return {
|
81
|
+
success: false,
|
82
|
+
error: "Project not found",
|
83
|
+
};
|
84
|
+
}
|
85
|
+
const { id, name, description, state, progress, targetDate, createdAt, updatedAt, url, lead, teams, issues, projectUpdates, } = data.data.project;
|
86
|
+
return {
|
87
|
+
success: true,
|
88
|
+
project: {
|
89
|
+
id,
|
90
|
+
name,
|
91
|
+
description: description || undefined,
|
92
|
+
state: state || undefined,
|
93
|
+
progress,
|
94
|
+
targetDate: targetDate || undefined,
|
95
|
+
createdAt: createdAt || undefined,
|
96
|
+
updatedAt: updatedAt || undefined,
|
97
|
+
lead: lead ? { id: lead.id, name: lead.name } : undefined,
|
98
|
+
team: Array.isArray(teams === null || teams === void 0 ? void 0 : teams.nodes) && teams.nodes.length > 0
|
99
|
+
? { id: teams.nodes[0].id, name: teams.nodes[0].name }
|
100
|
+
: undefined,
|
101
|
+
issues: Array.isArray(issues === null || issues === void 0 ? void 0 : issues.nodes)
|
102
|
+
? issues.nodes.map(({ id, title, url }) => ({
|
103
|
+
id,
|
104
|
+
name: title,
|
105
|
+
url,
|
106
|
+
}))
|
107
|
+
: [],
|
108
|
+
url: url || undefined,
|
109
|
+
updates: Array.isArray(projectUpdates === null || projectUpdates === void 0 ? void 0 : projectUpdates.nodes)
|
110
|
+
? projectUpdates.nodes.map(({ id, body, user, createdAt }) => ({
|
111
|
+
id,
|
112
|
+
content: body,
|
113
|
+
author_name: (user === null || user === void 0 ? void 0 : user.name) || "Unknown",
|
114
|
+
created_at: createdAt,
|
115
|
+
}))
|
116
|
+
: [],
|
117
|
+
content: description || undefined,
|
118
|
+
},
|
119
|
+
};
|
120
|
+
}
|
121
|
+
catch (error) {
|
122
|
+
console.error("Error retrieving Linear project details: ", error);
|
123
|
+
return {
|
124
|
+
success: false,
|
125
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
126
|
+
};
|
127
|
+
}
|
128
|
+
});
|
129
|
+
export default getProjectDetails;
|
@@ -0,0 +1,96 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
const getProjects = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams, }) {
|
11
|
+
var _b;
|
12
|
+
const { authToken } = authParams;
|
13
|
+
if (!authToken) {
|
14
|
+
throw new Error("Valid auth token is required to get Linear projects");
|
15
|
+
}
|
16
|
+
const query = `
|
17
|
+
query GetProjects {
|
18
|
+
projects {
|
19
|
+
nodes {
|
20
|
+
id
|
21
|
+
name
|
22
|
+
description
|
23
|
+
state
|
24
|
+
progress
|
25
|
+
url
|
26
|
+
creator {
|
27
|
+
id
|
28
|
+
name
|
29
|
+
}
|
30
|
+
lead {
|
31
|
+
id
|
32
|
+
name
|
33
|
+
}
|
34
|
+
labels {
|
35
|
+
nodes {
|
36
|
+
name
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}
|
41
|
+
}
|
42
|
+
`;
|
43
|
+
try {
|
44
|
+
const response = yield fetch("https://api.linear.app/graphql", {
|
45
|
+
method: "POST",
|
46
|
+
headers: {
|
47
|
+
"Content-Type": "application/json",
|
48
|
+
Authorization: `Bearer ${authToken}`,
|
49
|
+
},
|
50
|
+
body: JSON.stringify({
|
51
|
+
query,
|
52
|
+
}),
|
53
|
+
});
|
54
|
+
if (!response.ok) {
|
55
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
56
|
+
}
|
57
|
+
const data = yield response.json();
|
58
|
+
if (data.errors) {
|
59
|
+
throw new Error(`GraphQL errors: ${JSON.stringify(data.errors)}`);
|
60
|
+
}
|
61
|
+
if (!((_b = data.data) === null || _b === void 0 ? void 0 : _b.projects)) {
|
62
|
+
return {
|
63
|
+
success: false,
|
64
|
+
error: "No projects found",
|
65
|
+
};
|
66
|
+
}
|
67
|
+
const { nodes } = data.data.projects;
|
68
|
+
const projects = Array.isArray(nodes) ? nodes : [];
|
69
|
+
return {
|
70
|
+
success: true,
|
71
|
+
projects: projects.map((project) => {
|
72
|
+
const { id, name, description, state, progress, url, creator, lead, labels } = project;
|
73
|
+
return {
|
74
|
+
id,
|
75
|
+
name,
|
76
|
+
status: state,
|
77
|
+
labels: Array.isArray(labels === null || labels === void 0 ? void 0 : labels.nodes) ? labels.nodes.map(({ name }) => name) : [],
|
78
|
+
content: description || undefined,
|
79
|
+
description: description || undefined,
|
80
|
+
creator: creator ? { id: creator.id, name: creator.name } : undefined,
|
81
|
+
lead: lead ? { id: lead.id, name: lead.name } : undefined,
|
82
|
+
progress,
|
83
|
+
url,
|
84
|
+
};
|
85
|
+
}),
|
86
|
+
};
|
87
|
+
}
|
88
|
+
catch (error) {
|
89
|
+
console.error("Error retrieving Linear projects: ", error);
|
90
|
+
return {
|
91
|
+
success: false,
|
92
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
93
|
+
};
|
94
|
+
}
|
95
|
+
});
|
96
|
+
export default getProjects;
|
@@ -0,0 +1,84 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
const getTeamDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
11
|
+
var _b;
|
12
|
+
const { authToken } = authParams;
|
13
|
+
const { teamId } = params;
|
14
|
+
if (!authToken) {
|
15
|
+
throw new Error("Valid auth token is required to get Linear team details");
|
16
|
+
}
|
17
|
+
const query = `
|
18
|
+
query GetTeam($id: String!) {
|
19
|
+
team(id: $id) {
|
20
|
+
id
|
21
|
+
name
|
22
|
+
key
|
23
|
+
members {
|
24
|
+
nodes {
|
25
|
+
id
|
26
|
+
name
|
27
|
+
email
|
28
|
+
}
|
29
|
+
}
|
30
|
+
}
|
31
|
+
}
|
32
|
+
`;
|
33
|
+
try {
|
34
|
+
const response = yield fetch("https://api.linear.app/graphql", {
|
35
|
+
method: "POST",
|
36
|
+
headers: {
|
37
|
+
"Content-Type": "application/json",
|
38
|
+
Authorization: `Bearer ${authToken}`,
|
39
|
+
},
|
40
|
+
body: JSON.stringify({
|
41
|
+
query,
|
42
|
+
variables: { id: teamId },
|
43
|
+
}),
|
44
|
+
});
|
45
|
+
if (!response.ok) {
|
46
|
+
const errorText = yield response.text();
|
47
|
+
throw new Error(`HTTP error, status: ${response.status} body: ${errorText}`);
|
48
|
+
}
|
49
|
+
const data = yield response.json();
|
50
|
+
if (data.errors) {
|
51
|
+
throw new Error(`GraphQL errors: ${JSON.stringify(data.errors)}`);
|
52
|
+
}
|
53
|
+
if (!((_b = data.data) === null || _b === void 0 ? void 0 : _b.team)) {
|
54
|
+
return {
|
55
|
+
success: false,
|
56
|
+
error: "Team not found",
|
57
|
+
};
|
58
|
+
}
|
59
|
+
const { id, name, key, members } = data.data.team;
|
60
|
+
return {
|
61
|
+
success: true,
|
62
|
+
team: {
|
63
|
+
id,
|
64
|
+
name,
|
65
|
+
identifier: key,
|
66
|
+
members: Array.isArray(members === null || members === void 0 ? void 0 : members.nodes)
|
67
|
+
? members.nodes.map(({ id, name, email }) => ({
|
68
|
+
id,
|
69
|
+
name,
|
70
|
+
email,
|
71
|
+
}))
|
72
|
+
: [],
|
73
|
+
},
|
74
|
+
};
|
75
|
+
}
|
76
|
+
catch (error) {
|
77
|
+
console.error("Error retrieving Linear team details: ", error);
|
78
|
+
return {
|
79
|
+
success: false,
|
80
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
81
|
+
};
|
82
|
+
}
|
83
|
+
});
|
84
|
+
export default getTeamDetails;
|
@@ -0,0 +1,68 @@
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
8
|
+
});
|
9
|
+
};
|
10
|
+
const getTeams = (_a) => __awaiter(void 0, [_a], void 0, function* ({ authParams, }) {
|
11
|
+
var _b;
|
12
|
+
const { authToken } = authParams;
|
13
|
+
if (!authToken) {
|
14
|
+
throw new Error("Valid auth token is required to get Linear teams");
|
15
|
+
}
|
16
|
+
const query = `
|
17
|
+
query GetTeams {
|
18
|
+
teams {
|
19
|
+
nodes {
|
20
|
+
id
|
21
|
+
name
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
`;
|
26
|
+
try {
|
27
|
+
const response = yield fetch("https://api.linear.app/graphql", {
|
28
|
+
method: "POST",
|
29
|
+
headers: {
|
30
|
+
"Content-Type": "application/json",
|
31
|
+
Authorization: `Bearer ${authToken}`,
|
32
|
+
},
|
33
|
+
body: JSON.stringify({
|
34
|
+
query,
|
35
|
+
}),
|
36
|
+
});
|
37
|
+
if (!response.ok) {
|
38
|
+
throw new Error(`HTTP error! status: ${response.status}`);
|
39
|
+
}
|
40
|
+
const data = yield response.json();
|
41
|
+
if (data.errors) {
|
42
|
+
throw new Error(`GraphQL errors: ${JSON.stringify(data.errors)}`);
|
43
|
+
}
|
44
|
+
if (!((_b = data.data) === null || _b === void 0 ? void 0 : _b.teams)) {
|
45
|
+
return {
|
46
|
+
success: false,
|
47
|
+
error: "No teams found",
|
48
|
+
};
|
49
|
+
}
|
50
|
+
const { nodes } = data.data.teams;
|
51
|
+
const teams = Array.isArray(nodes) ? nodes : [];
|
52
|
+
return {
|
53
|
+
success: true,
|
54
|
+
teams: teams.map((team) => ({
|
55
|
+
id: team.id,
|
56
|
+
name: team.name,
|
57
|
+
})),
|
58
|
+
};
|
59
|
+
}
|
60
|
+
catch (error) {
|
61
|
+
console.error("Error retrieving Linear teams: ", error);
|
62
|
+
return {
|
63
|
+
success: false,
|
64
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
65
|
+
};
|
66
|
+
}
|
67
|
+
});
|
68
|
+
export default getTeams;
|
@@ -0,0 +1 @@
|
|
1
|
+
export * as add from "./add";
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
36
|
+
exports.add = void 0;
|
37
|
+
exports.add = __importStar(require("./add"));
|
@@ -0,0 +1 @@
|
|
1
|
+
export * as listConversations from "./listConversations";
|
@@ -0,0 +1,37 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
3
|
+
if (k2 === undefined) k2 = k;
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
7
|
+
}
|
8
|
+
Object.defineProperty(o, k2, desc);
|
9
|
+
}) : (function(o, m, k, k2) {
|
10
|
+
if (k2 === undefined) k2 = k;
|
11
|
+
o[k2] = m[k];
|
12
|
+
}));
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
15
|
+
}) : function(o, v) {
|
16
|
+
o["default"] = v;
|
17
|
+
});
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
19
|
+
var ownKeys = function(o) {
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
21
|
+
var ar = [];
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
23
|
+
return ar;
|
24
|
+
};
|
25
|
+
return ownKeys(o);
|
26
|
+
};
|
27
|
+
return function (mod) {
|
28
|
+
if (mod && mod.__esModule) return mod;
|
29
|
+
var result = {};
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
31
|
+
__setModuleDefault(result, mod);
|
32
|
+
return result;
|
33
|
+
};
|
34
|
+
})();
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
36
|
+
exports.listConversations = void 0;
|
37
|
+
exports.listConversations = __importStar(require("./listConversations"));
|