@credal/actions 0.2.48 → 0.2.50
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.js +14 -15
- package/dist/actions/providers/generic/fillTemplateAction.d.ts +7 -0
- package/dist/actions/providers/generic/fillTemplateAction.js +18 -0
- package/dist/actions/providers/generic/genericApiCall.d.ts +3 -0
- package/dist/actions/providers/generic/genericApiCall.js +38 -0
- package/dist/actions/providers/github/searchRepository.js +3 -2
- package/dist/actions/providers/google-oauth/getDriveContentById.d.ts +3 -0
- package/dist/actions/providers/google-oauth/getDriveContentById.js +161 -0
- package/dist/actions/providers/google-oauth/getDriveFileContentById.js +74 -54
- package/dist/actions/providers/google-oauth/searchAndGetDriveContentByKeywords.d.ts +3 -0
- package/dist/actions/providers/google-oauth/searchAndGetDriveContentByKeywords.js +47 -0
- package/dist/actions/providers/google-oauth/searchDriveAndGetContentByKeywords.d.ts +3 -0
- package/dist/actions/providers/google-oauth/searchDriveAndGetContentByKeywords.js +110 -0
- package/dist/actions/providers/google-oauth/searchDriveAndGetContentByQuery.d.ts +3 -0
- package/dist/actions/providers/google-oauth/searchDriveAndGetContentByQuery.js +78 -0
- package/dist/actions/providers/google-oauth/utils/extractContentFromDriveFileId.d.ts +15 -0
- package/dist/actions/providers/google-oauth/utils/extractContentFromDriveFileId.js +129 -0
- package/dist/actions/providers/googlemaps/nearbysearch.d.ts +3 -0
- package/dist/actions/providers/googlemaps/nearbysearch.js +96 -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/snowflake/runSnowflakeQueryWriteResultsToS3.d.ts +3 -0
- package/dist/actions/providers/snowflake/runSnowflakeQueryWriteResultsToS3.js +154 -0
- package/dist/actions/providers/x/scrapeTweetDataWithNitter.d.ts +3 -0
- package/dist/actions/providers/x/scrapeTweetDataWithNitter.js +45 -0
- package/dist/utils/google.d.ts +4 -0
- package/dist/utils/google.js +170 -0
- package/package.json +2 -1
- package/dist/actions/providers/jamf/types.d.ts +0 -8
- package/dist/actions/providers/jamf/types.js +0 -7
@@ -0,0 +1,96 @@
|
|
1
|
+
"use strict";
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
9
|
+
});
|
10
|
+
};
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
13
|
+
};
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
15
|
+
const axios_1 = __importDefault(require("axios"));
|
16
|
+
const types_1 = require("../../autogen/types");
|
17
|
+
const INCLUDED_TYPES = [
|
18
|
+
"monument",
|
19
|
+
"museum",
|
20
|
+
"art_gallery",
|
21
|
+
"sculpture",
|
22
|
+
"cultural_landmark",
|
23
|
+
"historical_place",
|
24
|
+
"performing_arts_theater",
|
25
|
+
"university",
|
26
|
+
"aquarium",
|
27
|
+
"botanical_garden",
|
28
|
+
"comedy_club",
|
29
|
+
"park",
|
30
|
+
"movie_theater",
|
31
|
+
"national_park",
|
32
|
+
"garden",
|
33
|
+
"night_club",
|
34
|
+
"tourist_attraction",
|
35
|
+
"water_park",
|
36
|
+
"zoo",
|
37
|
+
"bar",
|
38
|
+
"restaurant",
|
39
|
+
"food_court",
|
40
|
+
"bakery",
|
41
|
+
"cafe",
|
42
|
+
"coffee_shop",
|
43
|
+
"pub",
|
44
|
+
"wine_bar",
|
45
|
+
"spa",
|
46
|
+
"beach",
|
47
|
+
"market",
|
48
|
+
"shopping_mall",
|
49
|
+
"stadium",
|
50
|
+
];
|
51
|
+
const nearbysearch = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
52
|
+
const url = `https://places.googleapis.com/v1/places:searchNearby`;
|
53
|
+
const fieldMask = [
|
54
|
+
"places.displayName",
|
55
|
+
"places.formattedAddress",
|
56
|
+
"places.priceLevel",
|
57
|
+
"places.rating",
|
58
|
+
"places.primaryTypeDisplayName",
|
59
|
+
"places.editorialSummary",
|
60
|
+
"places.regularOpeningHours",
|
61
|
+
].join(",");
|
62
|
+
const response = yield axios_1.default.post(url, {
|
63
|
+
maxResultCount: 20,
|
64
|
+
includedTypes: INCLUDED_TYPES,
|
65
|
+
locationRestriction: {
|
66
|
+
circle: {
|
67
|
+
center: {
|
68
|
+
latitude: params.latitude,
|
69
|
+
longitude: params.longitude,
|
70
|
+
},
|
71
|
+
radius: 10000,
|
72
|
+
},
|
73
|
+
},
|
74
|
+
}, {
|
75
|
+
headers: {
|
76
|
+
"X-Goog-Api-Key": authParams.apiKey,
|
77
|
+
"X-Goog-FieldMask": fieldMask,
|
78
|
+
"Content-Type": "application/json",
|
79
|
+
},
|
80
|
+
});
|
81
|
+
return types_1.googlemapsNearbysearchOutputSchema.parse({
|
82
|
+
results: response.data.places.map((place) => {
|
83
|
+
var _a, _b;
|
84
|
+
return ({
|
85
|
+
name: place.displayName.text,
|
86
|
+
address: place.formattedAddress,
|
87
|
+
priceLevel: place.priceLevel,
|
88
|
+
rating: place.rating,
|
89
|
+
primaryType: place.primaryTypeDisplayName.text,
|
90
|
+
editorialSummary: ((_a = place.editorialSummary) === null || _a === void 0 ? void 0 : _a.text) || "",
|
91
|
+
openingHours: ((_b = place.regularOpeningHours) === null || _b === void 0 ? void 0 : _b.weekdayDescriptions.join("\n")) || "",
|
92
|
+
});
|
93
|
+
}),
|
94
|
+
});
|
95
|
+
});
|
96
|
+
exports.default = nearbysearch;
|
@@ -0,0 +1,127 @@
|
|
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 getIssueDetails = (_a) => __awaiter(void 0, [_a], void 0, function* ({ params, authParams, }) {
|
11
|
+
var _b;
|
12
|
+
const { authToken } = authParams;
|
13
|
+
const { issueId } = params;
|
14
|
+
if (!authToken) {
|
15
|
+
throw new Error("Valid auth token is required to get Linear issue details");
|
16
|
+
}
|
17
|
+
const query = `
|
18
|
+
query GetIssue($id: String!) {
|
19
|
+
issue(id: $id) {
|
20
|
+
id
|
21
|
+
title
|
22
|
+
description
|
23
|
+
url
|
24
|
+
state {
|
25
|
+
name
|
26
|
+
}
|
27
|
+
assignee {
|
28
|
+
id
|
29
|
+
name
|
30
|
+
}
|
31
|
+
creator {
|
32
|
+
id
|
33
|
+
name
|
34
|
+
}
|
35
|
+
team {
|
36
|
+
id
|
37
|
+
name
|
38
|
+
}
|
39
|
+
project {
|
40
|
+
id
|
41
|
+
name
|
42
|
+
}
|
43
|
+
priority
|
44
|
+
estimate
|
45
|
+
dueDate
|
46
|
+
createdAt
|
47
|
+
updatedAt
|
48
|
+
labels {
|
49
|
+
nodes {
|
50
|
+
name
|
51
|
+
}
|
52
|
+
}
|
53
|
+
comments {
|
54
|
+
nodes {
|
55
|
+
user {
|
56
|
+
name
|
57
|
+
}
|
58
|
+
body
|
59
|
+
}
|
60
|
+
}
|
61
|
+
}
|
62
|
+
}
|
63
|
+
`;
|
64
|
+
try {
|
65
|
+
const response = yield fetch("https://api.linear.app/graphql", {
|
66
|
+
method: "POST",
|
67
|
+
headers: {
|
68
|
+
"Content-Type": "application/json",
|
69
|
+
Authorization: `Bearer ${authToken}`,
|
70
|
+
},
|
71
|
+
body: JSON.stringify({
|
72
|
+
query,
|
73
|
+
variables: { id: issueId },
|
74
|
+
}),
|
75
|
+
});
|
76
|
+
if (!response.ok) {
|
77
|
+
const errorText = yield response.text();
|
78
|
+
throw new Error(`HTTP error: status: ${response.status}, body: ${errorText}`);
|
79
|
+
}
|
80
|
+
const data = yield response.json();
|
81
|
+
if (data.errors) {
|
82
|
+
throw new Error(`GraphQL errors: ${JSON.stringify(data.errors)}`);
|
83
|
+
}
|
84
|
+
if (!((_b = data.data) === null || _b === void 0 ? void 0 : _b.issue)) {
|
85
|
+
return {
|
86
|
+
success: false,
|
87
|
+
error: "Issue not found",
|
88
|
+
};
|
89
|
+
}
|
90
|
+
const { id, title, description, url, state, assignee, creator, team, project, priority, estimate, dueDate, createdAt, updatedAt, labels, comments, } = data.data.issue;
|
91
|
+
return {
|
92
|
+
success: true,
|
93
|
+
issue: {
|
94
|
+
id,
|
95
|
+
title,
|
96
|
+
description: description || undefined,
|
97
|
+
state: (state === null || state === void 0 ? void 0 : state.name) || undefined,
|
98
|
+
assignee: assignee ? { id: assignee.id, name: assignee.name } : undefined,
|
99
|
+
creator: creator ? { id: creator.id, name: creator.name } : undefined,
|
100
|
+
team: team ? { id: team.id, name: team.name } : undefined,
|
101
|
+
project: project ? { id: project.id, name: project.name } : undefined,
|
102
|
+
priority: priority || undefined,
|
103
|
+
estimate: estimate || undefined,
|
104
|
+
dueDate: dueDate || undefined,
|
105
|
+
createdAt: createdAt || undefined,
|
106
|
+
updatedAt: updatedAt || undefined,
|
107
|
+
labels: Array.isArray(labels === null || labels === void 0 ? void 0 : labels.nodes) ? labels.nodes.map(({ name }) => name) : [],
|
108
|
+
url: url || undefined,
|
109
|
+
comments: Array.isArray(comments === null || comments === void 0 ? void 0 : comments.nodes)
|
110
|
+
? comments.nodes.map(({ user, body }) => ({
|
111
|
+
author_name: (user === null || user === void 0 ? void 0 : user.name) || "Unknown",
|
112
|
+
comment: body,
|
113
|
+
}))
|
114
|
+
: [],
|
115
|
+
content: description || undefined,
|
116
|
+
},
|
117
|
+
};
|
118
|
+
}
|
119
|
+
catch (error) {
|
120
|
+
console.error("Error retrieving Linear issue details: ", error);
|
121
|
+
return {
|
122
|
+
success: false,
|
123
|
+
error: error instanceof Error ? error.message : "Unknown error",
|
124
|
+
};
|
125
|
+
}
|
126
|
+
});
|
127
|
+
export default getIssueDetails;
|
@@ -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;
|