@hasna/connectors 0.3.16 → 0.4.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/bin/index.js +71 -1
- package/bin/mcp.js +71 -1
- package/bin/serve.js +70 -0
- package/connectors/connect-asana/.env.example +11 -0
- package/connectors/connect-asana/CLAUDE.md +128 -0
- package/connectors/connect-asana/README.md +193 -0
- package/connectors/connect-asana/package.json +52 -0
- package/connectors/connect-asana/src/api/client.ts +119 -0
- package/connectors/connect-asana/src/api/index.ts +319 -0
- package/connectors/connect-asana/src/cli/index.ts +731 -0
- package/connectors/connect-asana/src/index.ts +19 -0
- package/connectors/connect-asana/src/types/index.ts +270 -0
- package/connectors/connect-asana/src/utils/config.ts +171 -0
- package/connectors/connect-asana/src/utils/output.ts +119 -0
- package/connectors/connect-asana/tsconfig.json +16 -0
- package/connectors/connect-clickup/.env.example +11 -0
- package/connectors/connect-clickup/CLAUDE.md +128 -0
- package/connectors/connect-clickup/README.md +193 -0
- package/connectors/connect-clickup/package.json +52 -0
- package/connectors/connect-clickup/src/api/client.ts +116 -0
- package/connectors/connect-clickup/src/api/index.ts +400 -0
- package/connectors/connect-clickup/src/cli/index.ts +625 -0
- package/connectors/connect-clickup/src/index.ts +19 -0
- package/connectors/connect-clickup/src/types/index.ts +591 -0
- package/connectors/connect-clickup/src/utils/config.ts +157 -0
- package/connectors/connect-clickup/src/utils/output.ts +119 -0
- package/connectors/connect-clickup/tsconfig.json +16 -0
- package/connectors/connect-confluence/.env.example +11 -0
- package/connectors/connect-confluence/CLAUDE.md +272 -0
- package/connectors/connect-confluence/README.md +193 -0
- package/connectors/connect-confluence/package.json +53 -0
- package/connectors/connect-confluence/scripts/release.ts +179 -0
- package/connectors/connect-confluence/src/api/client.ts +213 -0
- package/connectors/connect-confluence/src/api/example.ts +48 -0
- package/connectors/connect-confluence/src/api/index.ts +51 -0
- package/connectors/connect-confluence/src/cli/index.ts +254 -0
- package/connectors/connect-confluence/src/index.ts +103 -0
- package/connectors/connect-confluence/src/types/index.ts +237 -0
- package/connectors/connect-confluence/src/utils/auth.ts +274 -0
- package/connectors/connect-confluence/src/utils/bulk.ts +212 -0
- package/connectors/connect-confluence/src/utils/config.ts +326 -0
- package/connectors/connect-confluence/src/utils/output.ts +175 -0
- package/connectors/connect-confluence/src/utils/settings.ts +114 -0
- package/connectors/connect-confluence/src/utils/storage.ts +198 -0
- package/connectors/connect-confluence/tsconfig.json +16 -0
- package/connectors/connect-jira/.env.example +11 -0
- package/connectors/connect-jira/CLAUDE.md +128 -0
- package/connectors/connect-jira/README.md +193 -0
- package/connectors/connect-jira/package.json +53 -0
- package/connectors/connect-jira/src/api/client.ts +131 -0
- package/connectors/connect-jira/src/api/index.ts +266 -0
- package/connectors/connect-jira/src/cli/index.ts +653 -0
- package/connectors/connect-jira/src/index.ts +23 -0
- package/connectors/connect-jira/src/types/index.ts +448 -0
- package/connectors/connect-jira/src/utils/config.ts +179 -0
- package/connectors/connect-jira/src/utils/output.ts +119 -0
- package/connectors/connect-jira/tsconfig.json +16 -0
- package/connectors/connect-linear/CLAUDE.md +88 -0
- package/connectors/connect-linear/README.md +201 -0
- package/connectors/connect-linear/package.json +45 -0
- package/connectors/connect-linear/src/api/client.ts +62 -0
- package/connectors/connect-linear/src/api/index.ts +46 -0
- package/connectors/connect-linear/src/api/issues.ts +247 -0
- package/connectors/connect-linear/src/api/projects.ts +179 -0
- package/connectors/connect-linear/src/api/teams.ts +125 -0
- package/connectors/connect-linear/src/api/users.ts +112 -0
- package/connectors/connect-linear/src/cli/index.ts +560 -0
- package/connectors/connect-linear/src/index.ts +27 -0
- package/connectors/connect-linear/src/types/index.ts +275 -0
- package/connectors/connect-linear/src/utils/config.ts +249 -0
- package/connectors/connect-linear/src/utils/output.ts +119 -0
- package/connectors/connect-linear/tsconfig.json +16 -0
- package/connectors/connect-slack/.env.example +7 -0
- package/connectors/connect-slack/CLAUDE.md +69 -0
- package/connectors/connect-slack/README.md +150 -0
- package/connectors/connect-slack/package.json +44 -0
- package/connectors/connect-slack/src/api/channels.ts +112 -0
- package/connectors/connect-slack/src/api/client.ts +97 -0
- package/connectors/connect-slack/src/api/index.ts +42 -0
- package/connectors/connect-slack/src/api/messages.ts +127 -0
- package/connectors/connect-slack/src/api/users.ts +110 -0
- package/connectors/connect-slack/src/cli/index.ts +494 -0
- package/connectors/connect-slack/src/index.ts +21 -0
- package/connectors/connect-slack/src/types/index.ts +263 -0
- package/connectors/connect-slack/src/utils/config.ts +297 -0
- package/connectors/connect-slack/src/utils/output.ts +119 -0
- package/connectors/connect-slack/tsconfig.json +16 -0
- package/connectors/connect-telegram/.env.example +2 -0
- package/connectors/connect-telegram/package.json +49 -0
- package/connectors/connect-todoist/.env.example +11 -0
- package/connectors/connect-todoist/CLAUDE.md +104 -0
- package/connectors/connect-todoist/README.md +193 -0
- package/connectors/connect-todoist/package.json +52 -0
- package/connectors/connect-todoist/src/api/client.ts +117 -0
- package/connectors/connect-todoist/src/api/index.ts +188 -0
- package/connectors/connect-todoist/src/cli/index.ts +990 -0
- package/connectors/connect-todoist/src/index.ts +21 -0
- package/connectors/connect-todoist/src/types/index.ts +240 -0
- package/connectors/connect-todoist/src/utils/config.ts +157 -0
- package/connectors/connect-todoist/src/utils/output.ts +119 -0
- package/connectors/connect-todoist/tsconfig.json +16 -0
- package/connectors/connect-trello/.env.example +11 -0
- package/connectors/connect-trello/CLAUDE.md +128 -0
- package/connectors/connect-trello/README.md +193 -0
- package/connectors/connect-trello/package.json +53 -0
- package/connectors/connect-trello/src/api/client.ts +128 -0
- package/connectors/connect-trello/src/api/index.ts +278 -0
- package/connectors/connect-trello/src/cli/index.ts +737 -0
- package/connectors/connect-trello/src/index.ts +21 -0
- package/connectors/connect-trello/src/types/index.ts +314 -0
- package/connectors/connect-trello/src/utils/config.ts +182 -0
- package/connectors/connect-trello/src/utils/output.ts +119 -0
- package/connectors/connect-trello/tsconfig.json +16 -0
- package/connectors/connect-whatsapp/.env.example +11 -0
- package/connectors/connect-whatsapp/CLAUDE.md +113 -0
- package/connectors/connect-whatsapp/README.md +193 -0
- package/connectors/connect-whatsapp/package.json +53 -0
- package/connectors/connect-whatsapp/src/api/client.ts +133 -0
- package/connectors/connect-whatsapp/src/api/index.ts +365 -0
- package/connectors/connect-whatsapp/src/cli/index.ts +686 -0
- package/connectors/connect-whatsapp/src/index.ts +25 -0
- package/connectors/connect-whatsapp/src/types/index.ts +502 -0
- package/connectors/connect-whatsapp/src/utils/config.ts +179 -0
- package/connectors/connect-whatsapp/src/utils/output.ts +119 -0
- package/connectors/connect-whatsapp/tsconfig.json +16 -0
- package/dist/index.js +70 -0
- package/package.json +1 -1
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Asana Connector
|
|
2
|
+
// TypeScript wrapper for Asana projects, tasks, workspaces, and teams API
|
|
3
|
+
|
|
4
|
+
export { Asana } from './api';
|
|
5
|
+
export * from './types';
|
|
6
|
+
export { AsanaClient } from './api';
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
getAccessToken,
|
|
10
|
+
setAccessToken,
|
|
11
|
+
getCurrentProfile,
|
|
12
|
+
setCurrentProfile,
|
|
13
|
+
listProfiles,
|
|
14
|
+
createProfile,
|
|
15
|
+
deleteProfile,
|
|
16
|
+
loadProfile,
|
|
17
|
+
saveProfile,
|
|
18
|
+
clearConfig,
|
|
19
|
+
} from './utils/config';
|
|
@@ -0,0 +1,270 @@
|
|
|
1
|
+
// Asana Connector Types
|
|
2
|
+
// Projects, tasks, workspaces, and teams management
|
|
3
|
+
|
|
4
|
+
// ============================================
|
|
5
|
+
// Configuration
|
|
6
|
+
// ============================================
|
|
7
|
+
|
|
8
|
+
export interface AsanaConfig {
|
|
9
|
+
accessToken: string;
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// ============================================
|
|
14
|
+
// Common Types
|
|
15
|
+
// ============================================
|
|
16
|
+
|
|
17
|
+
export type OutputFormat = 'json' | 'pretty';
|
|
18
|
+
|
|
19
|
+
export interface AsanaResponse<T> {
|
|
20
|
+
data: T;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface AsanaListResponse<T> {
|
|
24
|
+
data: T[];
|
|
25
|
+
next_page?: {
|
|
26
|
+
offset: string;
|
|
27
|
+
path: string;
|
|
28
|
+
uri: string;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// ============================================
|
|
33
|
+
// Workspace Types
|
|
34
|
+
// ============================================
|
|
35
|
+
|
|
36
|
+
export interface Workspace {
|
|
37
|
+
gid: string;
|
|
38
|
+
name: string;
|
|
39
|
+
resource_type: 'workspace';
|
|
40
|
+
is_organization?: boolean;
|
|
41
|
+
email_domains?: string[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// ============================================
|
|
45
|
+
// User Types
|
|
46
|
+
// ============================================
|
|
47
|
+
|
|
48
|
+
export interface User {
|
|
49
|
+
gid: string;
|
|
50
|
+
name: string;
|
|
51
|
+
resource_type: 'user';
|
|
52
|
+
email?: string;
|
|
53
|
+
photo?: {
|
|
54
|
+
image_21x21?: string;
|
|
55
|
+
image_27x27?: string;
|
|
56
|
+
image_36x36?: string;
|
|
57
|
+
image_60x60?: string;
|
|
58
|
+
image_128x128?: string;
|
|
59
|
+
};
|
|
60
|
+
workspaces?: Workspace[];
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// ============================================
|
|
64
|
+
// Team Types
|
|
65
|
+
// ============================================
|
|
66
|
+
|
|
67
|
+
export interface Team {
|
|
68
|
+
gid: string;
|
|
69
|
+
name: string;
|
|
70
|
+
resource_type: 'team';
|
|
71
|
+
description?: string;
|
|
72
|
+
html_description?: string;
|
|
73
|
+
organization?: Workspace;
|
|
74
|
+
visibility?: 'secret' | 'request_to_join' | 'public';
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ============================================
|
|
78
|
+
// Project Types
|
|
79
|
+
// ============================================
|
|
80
|
+
|
|
81
|
+
export interface Project {
|
|
82
|
+
gid: string;
|
|
83
|
+
name: string;
|
|
84
|
+
resource_type: 'project';
|
|
85
|
+
archived?: boolean;
|
|
86
|
+
color?: string;
|
|
87
|
+
created_at?: string;
|
|
88
|
+
current_status?: ProjectStatus;
|
|
89
|
+
current_status_update?: StatusUpdate;
|
|
90
|
+
due_date?: string;
|
|
91
|
+
due_on?: string;
|
|
92
|
+
html_notes?: string;
|
|
93
|
+
notes?: string;
|
|
94
|
+
owner?: User;
|
|
95
|
+
public?: boolean;
|
|
96
|
+
start_on?: string;
|
|
97
|
+
team?: Team;
|
|
98
|
+
workspace?: Workspace;
|
|
99
|
+
completed?: boolean;
|
|
100
|
+
completed_at?: string;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface ProjectStatus {
|
|
104
|
+
gid: string;
|
|
105
|
+
color: 'green' | 'yellow' | 'red' | 'blue';
|
|
106
|
+
text: string;
|
|
107
|
+
author?: User;
|
|
108
|
+
created_at?: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface StatusUpdate {
|
|
112
|
+
gid: string;
|
|
113
|
+
resource_type: 'status_update';
|
|
114
|
+
title?: string;
|
|
115
|
+
text?: string;
|
|
116
|
+
status_type?: string;
|
|
117
|
+
created_at?: string;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface CreateProjectInput {
|
|
121
|
+
name: string;
|
|
122
|
+
workspace?: string;
|
|
123
|
+
team?: string;
|
|
124
|
+
notes?: string;
|
|
125
|
+
color?: string;
|
|
126
|
+
due_on?: string;
|
|
127
|
+
start_on?: string;
|
|
128
|
+
public?: boolean;
|
|
129
|
+
archived?: boolean;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
// ============================================
|
|
133
|
+
// Section Types
|
|
134
|
+
// ============================================
|
|
135
|
+
|
|
136
|
+
export interface Section {
|
|
137
|
+
gid: string;
|
|
138
|
+
name: string;
|
|
139
|
+
resource_type: 'section';
|
|
140
|
+
created_at?: string;
|
|
141
|
+
project?: Project;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export interface CreateSectionInput {
|
|
145
|
+
name: string;
|
|
146
|
+
insert_before?: string;
|
|
147
|
+
insert_after?: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
// ============================================
|
|
151
|
+
// Task Types
|
|
152
|
+
// ============================================
|
|
153
|
+
|
|
154
|
+
export interface Task {
|
|
155
|
+
gid: string;
|
|
156
|
+
name: string;
|
|
157
|
+
resource_type: 'task';
|
|
158
|
+
approval_status?: 'pending' | 'approved' | 'rejected' | 'changes_requested';
|
|
159
|
+
assignee?: User;
|
|
160
|
+
assignee_status?: 'inbox' | 'today' | 'upcoming' | 'later';
|
|
161
|
+
completed?: boolean;
|
|
162
|
+
completed_at?: string;
|
|
163
|
+
created_at?: string;
|
|
164
|
+
due_at?: string;
|
|
165
|
+
due_on?: string;
|
|
166
|
+
html_notes?: string;
|
|
167
|
+
notes?: string;
|
|
168
|
+
num_subtasks?: number;
|
|
169
|
+
parent?: Task;
|
|
170
|
+
projects?: Project[];
|
|
171
|
+
start_at?: string;
|
|
172
|
+
start_on?: string;
|
|
173
|
+
tags?: Tag[];
|
|
174
|
+
workspace?: Workspace;
|
|
175
|
+
memberships?: { project: Project; section: Section }[];
|
|
176
|
+
followers?: User[];
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
export interface CreateTaskInput {
|
|
180
|
+
name: string;
|
|
181
|
+
workspace?: string;
|
|
182
|
+
projects?: string[];
|
|
183
|
+
assignee?: string;
|
|
184
|
+
notes?: string;
|
|
185
|
+
html_notes?: string;
|
|
186
|
+
due_on?: string;
|
|
187
|
+
due_at?: string;
|
|
188
|
+
start_on?: string;
|
|
189
|
+
start_at?: string;
|
|
190
|
+
completed?: boolean;
|
|
191
|
+
parent?: string;
|
|
192
|
+
tags?: string[];
|
|
193
|
+
followers?: string[];
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// ============================================
|
|
197
|
+
// Tag Types
|
|
198
|
+
// ============================================
|
|
199
|
+
|
|
200
|
+
export interface Tag {
|
|
201
|
+
gid: string;
|
|
202
|
+
name: string;
|
|
203
|
+
resource_type: 'tag';
|
|
204
|
+
color?: string;
|
|
205
|
+
workspace?: Workspace;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export interface CreateTagInput {
|
|
209
|
+
name: string;
|
|
210
|
+
workspace: string;
|
|
211
|
+
color?: string;
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
// ============================================
|
|
215
|
+
// Story Types (Comments)
|
|
216
|
+
// ============================================
|
|
217
|
+
|
|
218
|
+
export interface Story {
|
|
219
|
+
gid: string;
|
|
220
|
+
resource_type: 'story';
|
|
221
|
+
created_at?: string;
|
|
222
|
+
created_by?: User;
|
|
223
|
+
text?: string;
|
|
224
|
+
html_text?: string;
|
|
225
|
+
type?: 'comment' | 'system';
|
|
226
|
+
is_pinned?: boolean;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
export interface CreateStoryInput {
|
|
230
|
+
text: string;
|
|
231
|
+
html_text?: string;
|
|
232
|
+
is_pinned?: boolean;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// ============================================
|
|
236
|
+
// Attachment Types
|
|
237
|
+
// ============================================
|
|
238
|
+
|
|
239
|
+
export interface Attachment {
|
|
240
|
+
gid: string;
|
|
241
|
+
name: string;
|
|
242
|
+
resource_type: 'attachment';
|
|
243
|
+
created_at?: string;
|
|
244
|
+
download_url?: string;
|
|
245
|
+
host?: 'asana' | 'dropbox' | 'gdrive' | 'onedrive' | 'box' | 'vimeo' | 'external';
|
|
246
|
+
parent?: Task;
|
|
247
|
+
view_url?: string;
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
// ============================================
|
|
251
|
+
// API Error Types
|
|
252
|
+
// ============================================
|
|
253
|
+
|
|
254
|
+
export interface AsanaErrorDetail {
|
|
255
|
+
message: string;
|
|
256
|
+
help?: string;
|
|
257
|
+
phrase?: string;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
export class AsanaApiError extends Error {
|
|
261
|
+
public readonly statusCode: number;
|
|
262
|
+
public readonly errors?: AsanaErrorDetail[];
|
|
263
|
+
|
|
264
|
+
constructor(message: string, statusCode: number, errors?: AsanaErrorDetail[]) {
|
|
265
|
+
super(message);
|
|
266
|
+
this.name = 'AsanaApiError';
|
|
267
|
+
this.statusCode = statusCode;
|
|
268
|
+
this.errors = errors;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync, readdirSync, rmSync } from 'fs';
|
|
2
|
+
import { homedir } from 'os';
|
|
3
|
+
import { join } from 'path';
|
|
4
|
+
|
|
5
|
+
const CONNECTOR_NAME = 'connect-asana';
|
|
6
|
+
const DEFAULT_PROFILE = 'default';
|
|
7
|
+
|
|
8
|
+
export interface ProfileConfig {
|
|
9
|
+
accessToken?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Store for --profile flag override (set by CLI before commands run)
|
|
13
|
+
let profileOverride: string | undefined;
|
|
14
|
+
|
|
15
|
+
// Config directory: ~/.connect/{connector-name}/
|
|
16
|
+
const CONFIG_DIR = join(homedir(), '.connect', CONNECTOR_NAME);
|
|
17
|
+
const PROFILES_DIR = join(CONFIG_DIR, 'profiles');
|
|
18
|
+
const CURRENT_PROFILE_FILE = join(CONFIG_DIR, 'current_profile');
|
|
19
|
+
|
|
20
|
+
// ============================================
|
|
21
|
+
// Profile Management
|
|
22
|
+
// ============================================
|
|
23
|
+
|
|
24
|
+
export function setProfileOverride(profile: string | undefined): void {
|
|
25
|
+
profileOverride = profile;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function ensureConfigDir(): void {
|
|
29
|
+
if (!existsSync(CONFIG_DIR)) {
|
|
30
|
+
mkdirSync(CONFIG_DIR, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
if (!existsSync(PROFILES_DIR)) {
|
|
33
|
+
mkdirSync(PROFILES_DIR, { recursive: true });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function getProfilePath(profile: string): string {
|
|
38
|
+
return join(PROFILES_DIR, `${profile}.json`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getCurrentProfile(): string {
|
|
42
|
+
if (profileOverride) {
|
|
43
|
+
return profileOverride;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
ensureConfigDir();
|
|
47
|
+
|
|
48
|
+
if (existsSync(CURRENT_PROFILE_FILE)) {
|
|
49
|
+
try {
|
|
50
|
+
const profile = readFileSync(CURRENT_PROFILE_FILE, 'utf-8').trim();
|
|
51
|
+
if (profile && profileExists(profile)) {
|
|
52
|
+
return profile;
|
|
53
|
+
}
|
|
54
|
+
} catch {
|
|
55
|
+
// Fall through to default
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return DEFAULT_PROFILE;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export function setCurrentProfile(profile: string): void {
|
|
63
|
+
ensureConfigDir();
|
|
64
|
+
|
|
65
|
+
if (!profileExists(profile) && profile !== DEFAULT_PROFILE) {
|
|
66
|
+
throw new Error(`Profile "${profile}" does not exist`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
writeFileSync(CURRENT_PROFILE_FILE, profile);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function profileExists(profile: string): boolean {
|
|
73
|
+
return existsSync(getProfilePath(profile));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export function listProfiles(): string[] {
|
|
77
|
+
ensureConfigDir();
|
|
78
|
+
|
|
79
|
+
if (!existsSync(PROFILES_DIR)) {
|
|
80
|
+
return [];
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return readdirSync(PROFILES_DIR)
|
|
84
|
+
.filter(f => f.endsWith('.json'))
|
|
85
|
+
.map(f => f.replace('.json', ''))
|
|
86
|
+
.sort();
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function createProfile(profile: string, config: ProfileConfig = {}): boolean {
|
|
90
|
+
ensureConfigDir();
|
|
91
|
+
|
|
92
|
+
if (profileExists(profile)) {
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
if (!/^[a-zA-Z0-9_-]+$/.test(profile)) {
|
|
97
|
+
throw new Error('Profile name can only contain letters, numbers, hyphens, and underscores');
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
writeFileSync(getProfilePath(profile), JSON.stringify(config, null, 2));
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function deleteProfile(profile: string): boolean {
|
|
105
|
+
if (profile === DEFAULT_PROFILE) {
|
|
106
|
+
return false;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
if (!profileExists(profile)) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (getCurrentProfile() === profile) {
|
|
114
|
+
setCurrentProfile(DEFAULT_PROFILE);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
rmSync(getProfilePath(profile));
|
|
118
|
+
return true;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export function loadProfile(profile?: string): ProfileConfig {
|
|
122
|
+
ensureConfigDir();
|
|
123
|
+
const profileName = profile || getCurrentProfile();
|
|
124
|
+
const profilePath = getProfilePath(profileName);
|
|
125
|
+
|
|
126
|
+
if (!existsSync(profilePath)) {
|
|
127
|
+
return {};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
try {
|
|
131
|
+
return JSON.parse(readFileSync(profilePath, 'utf-8'));
|
|
132
|
+
} catch {
|
|
133
|
+
return {};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function saveProfile(config: ProfileConfig, profile?: string): void {
|
|
138
|
+
ensureConfigDir();
|
|
139
|
+
const profileName = profile || getCurrentProfile();
|
|
140
|
+
writeFileSync(getProfilePath(profileName), JSON.stringify(config, null, 2));
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// ============================================
|
|
144
|
+
// Access Token Management
|
|
145
|
+
// ============================================
|
|
146
|
+
|
|
147
|
+
export function getAccessToken(): string | undefined {
|
|
148
|
+
return process.env.ASANA_ACCESS_TOKEN || loadProfile().accessToken;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function setAccessToken(accessToken: string): void {
|
|
152
|
+
const config = loadProfile();
|
|
153
|
+
config.accessToken = accessToken;
|
|
154
|
+
saveProfile(config);
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
// ============================================
|
|
158
|
+
// Utility Functions
|
|
159
|
+
// ============================================
|
|
160
|
+
|
|
161
|
+
export function clearConfig(): void {
|
|
162
|
+
saveProfile({});
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function getConfigDir(): string {
|
|
166
|
+
return CONFIG_DIR;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export function getActiveProfileName(): string {
|
|
170
|
+
return getCurrentProfile();
|
|
171
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import chalk from 'chalk';
|
|
2
|
+
|
|
3
|
+
export type OutputFormat = 'json' | 'table' | 'pretty';
|
|
4
|
+
|
|
5
|
+
export function formatOutput(data: unknown, format: OutputFormat = 'pretty'): string {
|
|
6
|
+
switch (format) {
|
|
7
|
+
case 'json':
|
|
8
|
+
return JSON.stringify(data, null, 2);
|
|
9
|
+
case 'table':
|
|
10
|
+
return formatAsTable(data);
|
|
11
|
+
case 'pretty':
|
|
12
|
+
default:
|
|
13
|
+
return formatPretty(data);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function formatAsTable(data: unknown): string {
|
|
18
|
+
if (!Array.isArray(data)) {
|
|
19
|
+
data = [data];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const items = data as Record<string, unknown>[];
|
|
23
|
+
if (items.length === 0) {
|
|
24
|
+
return 'No data';
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const firstItem = items[0];
|
|
28
|
+
if (!firstItem || typeof firstItem !== 'object') {
|
|
29
|
+
return 'No data';
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const keys = Object.keys(firstItem);
|
|
33
|
+
const colWidths = keys.map(key => {
|
|
34
|
+
const maxValue = Math.max(
|
|
35
|
+
key.length,
|
|
36
|
+
...items.map(item => String(item[key] ?? '').length)
|
|
37
|
+
);
|
|
38
|
+
return Math.min(maxValue, 40);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const header = keys.map((key, i) => key.padEnd(colWidths[i] ?? 10)).join(' | ');
|
|
42
|
+
const separator = colWidths.map(w => '-'.repeat(w)).join('-+-');
|
|
43
|
+
|
|
44
|
+
const rows = items.map(item =>
|
|
45
|
+
keys.map((key, i) => {
|
|
46
|
+
const value = String(item[key] ?? '');
|
|
47
|
+
const width = colWidths[i] ?? 10;
|
|
48
|
+
return value.length > width
|
|
49
|
+
? value.substring(0, width - 3) + '...'
|
|
50
|
+
: value.padEnd(width);
|
|
51
|
+
}).join(' | ')
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
return [header, separator, ...rows].join('\n');
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
function formatPretty(data: unknown): string {
|
|
58
|
+
if (Array.isArray(data)) {
|
|
59
|
+
return data.map((item, i) => `${chalk.cyan(`[${i + 1}]`)} ${formatPrettyItem(item)}`).join('\n\n');
|
|
60
|
+
}
|
|
61
|
+
return formatPrettyItem(data);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function formatPrettyItem(item: unknown, indent = 0): string {
|
|
65
|
+
if (item === null || item === undefined) {
|
|
66
|
+
return chalk.gray('null');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
if (typeof item !== 'object') {
|
|
70
|
+
return String(item);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const spaces = ' '.repeat(indent);
|
|
74
|
+
const entries = Object.entries(item as Record<string, unknown>);
|
|
75
|
+
|
|
76
|
+
return entries
|
|
77
|
+
.map(([key, value]) => {
|
|
78
|
+
if (Array.isArray(value)) {
|
|
79
|
+
if (value.length === 0) {
|
|
80
|
+
return `${spaces}${chalk.blue(key)}: ${chalk.gray('[]')}`;
|
|
81
|
+
}
|
|
82
|
+
if (typeof value[0] === 'object') {
|
|
83
|
+
return `${spaces}${chalk.blue(key)}:\n${value.map(v => formatPrettyItem(v, indent + 1)).join('\n')}`;
|
|
84
|
+
}
|
|
85
|
+
return `${spaces}${chalk.blue(key)}: ${value.join(', ')}`;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (typeof value === 'object' && value !== null) {
|
|
89
|
+
return `${spaces}${chalk.blue(key)}:\n${formatPrettyItem(value, indent + 1)}`;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return `${spaces}${chalk.blue(key)}: ${chalk.white(String(value))}`;
|
|
93
|
+
})
|
|
94
|
+
.join('\n');
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export function success(message: string): void {
|
|
98
|
+
console.log(chalk.green('✓'), message);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function error(message: string): void {
|
|
102
|
+
console.error(chalk.red('✗'), message);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function warn(message: string): void {
|
|
106
|
+
console.warn(chalk.yellow('⚠'), message);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function info(message: string): void {
|
|
110
|
+
console.log(chalk.blue('ℹ'), message);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export function heading(message: string): void {
|
|
114
|
+
console.log(chalk.bold.cyan(`\n${message}\n`));
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export function print(data: unknown, format: OutputFormat = 'pretty'): void {
|
|
118
|
+
console.log(formatOutput(data, format));
|
|
119
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ESNext",
|
|
4
|
+
"module": "ESNext",
|
|
5
|
+
"moduleResolution": "bundler",
|
|
6
|
+
"esModuleInterop": true,
|
|
7
|
+
"strict": true,
|
|
8
|
+
"skipLibCheck": true,
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"outDir": "./dist",
|
|
11
|
+
"rootDir": "./src",
|
|
12
|
+
"types": ["bun-types"]
|
|
13
|
+
},
|
|
14
|
+
"include": ["src/**/*"],
|
|
15
|
+
"exclude": ["node_modules", "dist", "bin"]
|
|
16
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# API Credentials
|
|
2
|
+
# TODO: Update variable names and instructions for your API
|
|
3
|
+
# Example: PERPLEXITY_API_KEY, OPENAI_API_KEY, etc.
|
|
4
|
+
|
|
5
|
+
CONNECTOR_API_KEY=your-api-key-here
|
|
6
|
+
|
|
7
|
+
# Optional: API secret (if your API requires it)
|
|
8
|
+
# CONNECTOR_API_SECRET=your-api-secret-here
|
|
9
|
+
|
|
10
|
+
# Optional: Custom base URL (if needed)
|
|
11
|
+
# CONNECTOR_BASE_URL=https://api.example.com
|