sunsama-api 0.1.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/LICENSE +21 -0
- package/README.md +215 -0
- package/dist/cjs/client/index.js +347 -0
- package/dist/cjs/client/index.js.map +1 -0
- package/dist/cjs/errors/index.js +110 -0
- package/dist/cjs/errors/index.js.map +1 -0
- package/dist/cjs/index.js +21 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/queries/fragments/index.js +9 -0
- package/dist/cjs/queries/fragments/index.js.map +1 -0
- package/dist/cjs/queries/fragments/stream.js +74 -0
- package/dist/cjs/queries/fragments/stream.js.map +1 -0
- package/dist/cjs/queries/fragments/task.js +500 -0
- package/dist/cjs/queries/fragments/task.js.map +1 -0
- package/dist/cjs/queries/index.js +11 -0
- package/dist/cjs/queries/index.js.map +1 -0
- package/dist/cjs/queries/streams.js +19 -0
- package/dist/cjs/queries/streams.js.map +1 -0
- package/dist/cjs/queries/tasks.js +41 -0
- package/dist/cjs/queries/tasks.js.map +1 -0
- package/dist/cjs/queries/user.js +472 -0
- package/dist/cjs/queries/user.js.map +1 -0
- package/dist/cjs/types/api.js +9 -0
- package/dist/cjs/types/api.js.map +1 -0
- package/dist/cjs/types/client.js +6 -0
- package/dist/cjs/types/client.js.map +1 -0
- package/dist/cjs/types/common.js +6 -0
- package/dist/cjs/types/common.js.map +1 -0
- package/dist/cjs/types/index.js +8 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/utils/index.js +63 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/esm/client/index.js +348 -0
- package/dist/esm/client/index.js.map +1 -0
- package/dist/esm/errors/index.js +105 -0
- package/dist/esm/errors/index.js.map +1 -0
- package/dist/esm/index.js +16 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/queries/fragments/index.js +6 -0
- package/dist/esm/queries/fragments/index.js.map +1 -0
- package/dist/esm/queries/fragments/stream.js +71 -0
- package/dist/esm/queries/fragments/stream.js.map +1 -0
- package/dist/esm/queries/fragments/task.js +497 -0
- package/dist/esm/queries/fragments/task.js.map +1 -0
- package/dist/esm/queries/index.js +8 -0
- package/dist/esm/queries/index.js.map +1 -0
- package/dist/esm/queries/streams.js +16 -0
- package/dist/esm/queries/streams.js.map +1 -0
- package/dist/esm/queries/tasks.js +38 -0
- package/dist/esm/queries/tasks.js.map +1 -0
- package/dist/esm/queries/user.js +469 -0
- package/dist/esm/queries/user.js.map +1 -0
- package/dist/esm/types/api.js +8 -0
- package/dist/esm/types/api.js.map +1 -0
- package/dist/esm/types/client.js +5 -0
- package/dist/esm/types/client.js.map +1 -0
- package/dist/esm/types/common.js +5 -0
- package/dist/esm/types/common.js.map +1 -0
- package/dist/esm/types/index.js +7 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/utils/index.js +57 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/types/client/index.d.ts +109 -0
- package/dist/types/client/index.d.ts.map +1 -0
- package/dist/types/errors/index.d.ts +67 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +14 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/queries/fragments/index.d.ts +6 -0
- package/dist/types/queries/fragments/index.d.ts.map +1 -0
- package/dist/types/queries/fragments/stream.d.ts +5 -0
- package/dist/types/queries/fragments/stream.d.ts.map +1 -0
- package/dist/types/queries/fragments/task.d.ts +8 -0
- package/dist/types/queries/fragments/task.d.ts.map +1 -0
- package/dist/types/queries/index.d.ts +8 -0
- package/dist/types/queries/index.d.ts.map +1 -0
- package/dist/types/queries/streams.d.ts +5 -0
- package/dist/types/queries/streams.d.ts.map +1 -0
- package/dist/types/queries/tasks.d.ts +6 -0
- package/dist/types/queries/tasks.d.ts.map +1 -0
- package/dist/types/queries/user.d.ts +5 -0
- package/dist/types/queries/user.d.ts.map +1 -0
- package/dist/types/types/api.d.ts +838 -0
- package/dist/types/types/api.d.ts.map +1 -0
- package/dist/types/types/client.d.ts +30 -0
- package/dist/types/types/client.d.ts.map +1 -0
- package/dist/types/types/common.d.ts +58 -0
- package/dist/types/types/common.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +9 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +35 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/package.json +90 -0
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Sunsama API client
|
|
3
|
+
*
|
|
4
|
+
* Provides a type-safe interface to interact with all Sunsama API endpoints.
|
|
5
|
+
*/
|
|
6
|
+
import { print } from 'graphql';
|
|
7
|
+
import { Cookie, CookieJar } from 'tough-cookie';
|
|
8
|
+
import { SunsamaAuthError } from '../errors';
|
|
9
|
+
import { GET_STREAMS_BY_GROUP_ID_QUERY, GET_TASKS_BACKLOG_QUERY, GET_TASKS_BY_DAY_QUERY, GET_USER_QUERY, } from '../queries';
|
|
10
|
+
/**
|
|
11
|
+
* Main Sunsama API client class
|
|
12
|
+
*
|
|
13
|
+
* Provides a type-safe interface to interact with all Sunsama API endpoints.
|
|
14
|
+
*/
|
|
15
|
+
export class SunsamaClient {
|
|
16
|
+
static BASE_URL = 'https://api.sunsama.com';
|
|
17
|
+
config;
|
|
18
|
+
cookieJar;
|
|
19
|
+
userId;
|
|
20
|
+
groupId;
|
|
21
|
+
timezone;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new Sunsama client instance
|
|
24
|
+
*
|
|
25
|
+
* @param config - Client configuration options (optional)
|
|
26
|
+
*/
|
|
27
|
+
constructor(config = {}) {
|
|
28
|
+
this.config = config;
|
|
29
|
+
this.cookieJar = new CookieJar();
|
|
30
|
+
// If a session token is provided, set it as a cookie
|
|
31
|
+
if (config.sessionToken) {
|
|
32
|
+
this.setSessionTokenAsCookie(config.sessionToken);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Gets the current client configuration
|
|
37
|
+
*/
|
|
38
|
+
getConfig() {
|
|
39
|
+
return { ...this.config };
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Checks if the client is authenticated
|
|
43
|
+
*
|
|
44
|
+
* @returns True if cookies are present in the jar
|
|
45
|
+
*/
|
|
46
|
+
async isAuthenticated() {
|
|
47
|
+
const cookies = await this.cookieJar.getCookies(SunsamaClient.BASE_URL);
|
|
48
|
+
return cookies.some(cookie => cookie.key === 'sunsamaSession');
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Authenticates with email and password
|
|
52
|
+
*
|
|
53
|
+
* @param email - User email address
|
|
54
|
+
* @param password - User password
|
|
55
|
+
* @throws SunsamaAuthError if login fails
|
|
56
|
+
*/
|
|
57
|
+
async login(email, password) {
|
|
58
|
+
// Prepare form data
|
|
59
|
+
const formData = new URLSearchParams();
|
|
60
|
+
formData.append('email', email);
|
|
61
|
+
formData.append('password', password);
|
|
62
|
+
try {
|
|
63
|
+
// For login, we need to handle redirects manually to capture the session cookie
|
|
64
|
+
const loginUrl = `${SunsamaClient.BASE_URL}/account/login/email`;
|
|
65
|
+
// Get cookies from jar for this URL
|
|
66
|
+
const cookies = await this.cookieJar.getCookies(loginUrl);
|
|
67
|
+
const headers = {
|
|
68
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
69
|
+
Origin: 'https://app.sunsama.com',
|
|
70
|
+
};
|
|
71
|
+
if (cookies.length > 0) {
|
|
72
|
+
headers['Cookie'] = cookies.map(cookie => cookie.cookieString()).join('; ');
|
|
73
|
+
}
|
|
74
|
+
const response = await fetch(loginUrl, {
|
|
75
|
+
method: 'POST',
|
|
76
|
+
headers,
|
|
77
|
+
body: formData.toString(),
|
|
78
|
+
redirect: 'manual', // Don't follow redirects automatically
|
|
79
|
+
});
|
|
80
|
+
// For login, we expect a 302 redirect on success
|
|
81
|
+
if (response.status !== 302) {
|
|
82
|
+
const responseText = await response.text();
|
|
83
|
+
throw new SunsamaAuthError(`Login failed: ${response.status} ${response.statusText}. Response: ${responseText}`);
|
|
84
|
+
}
|
|
85
|
+
// Extract and store cookies from response
|
|
86
|
+
const setCookieHeader = response.headers.get('set-cookie');
|
|
87
|
+
if (!setCookieHeader) {
|
|
88
|
+
// Debug: print all response headers
|
|
89
|
+
const allHeaders = {};
|
|
90
|
+
response.headers.forEach((value, key) => {
|
|
91
|
+
allHeaders[key] = value;
|
|
92
|
+
});
|
|
93
|
+
throw new SunsamaAuthError(`No session cookie received from login. Response headers: ${JSON.stringify(allHeaders, null, 2)}`);
|
|
94
|
+
}
|
|
95
|
+
// Store the cookie in the jar
|
|
96
|
+
try {
|
|
97
|
+
const loginUrl = `${SunsamaClient.BASE_URL}/account/login/email`;
|
|
98
|
+
await this.cookieJar.setCookie(setCookieHeader, loginUrl);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
throw new SunsamaAuthError(`Failed to store session cookie: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
if (error instanceof SunsamaAuthError) {
|
|
106
|
+
throw error;
|
|
107
|
+
}
|
|
108
|
+
throw new SunsamaAuthError(`Login request failed: ${error instanceof Error ? error.message : 'Unknown error'}`);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Clears all cookies from the jar and cached user data
|
|
113
|
+
*/
|
|
114
|
+
logout() {
|
|
115
|
+
this.cookieJar.removeAllCookiesSync();
|
|
116
|
+
this.userId = undefined;
|
|
117
|
+
this.groupId = undefined;
|
|
118
|
+
this.timezone = undefined;
|
|
119
|
+
}
|
|
120
|
+
/**
|
|
121
|
+
* Makes an authenticated request to the Sunsama API
|
|
122
|
+
*
|
|
123
|
+
* @param path - The API endpoint path (e.g., '/tasks')
|
|
124
|
+
* @param options - Request options
|
|
125
|
+
* @returns The response from the API
|
|
126
|
+
* @internal
|
|
127
|
+
*/
|
|
128
|
+
async request(path, options) {
|
|
129
|
+
const url = `${SunsamaClient.BASE_URL}${path}`;
|
|
130
|
+
// Build headers
|
|
131
|
+
const headers = {
|
|
132
|
+
Origin: 'https://app.sunsama.com',
|
|
133
|
+
...options.headers,
|
|
134
|
+
};
|
|
135
|
+
// Get cookies from jar for this URL
|
|
136
|
+
const cookies = await this.cookieJar.getCookies(url);
|
|
137
|
+
if (cookies.length > 0) {
|
|
138
|
+
headers['Cookie'] = cookies.map(cookie => cookie.cookieString()).join('; ');
|
|
139
|
+
}
|
|
140
|
+
// Build query string if params provided
|
|
141
|
+
let fullUrl = url;
|
|
142
|
+
if (options.params) {
|
|
143
|
+
const params = new URLSearchParams();
|
|
144
|
+
Object.entries(options.params).forEach(([key, value]) => {
|
|
145
|
+
params.append(key, String(value));
|
|
146
|
+
});
|
|
147
|
+
fullUrl = `${url}?${params.toString()}`;
|
|
148
|
+
}
|
|
149
|
+
// Process request body
|
|
150
|
+
let body;
|
|
151
|
+
if (options.body instanceof URLSearchParams) {
|
|
152
|
+
body = options.body.toString();
|
|
153
|
+
}
|
|
154
|
+
else if (options.body) {
|
|
155
|
+
body = JSON.stringify(options.body);
|
|
156
|
+
}
|
|
157
|
+
// Make the request
|
|
158
|
+
return await fetch(fullUrl, {
|
|
159
|
+
method: options.method,
|
|
160
|
+
headers,
|
|
161
|
+
body,
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Makes a GraphQL request to the Sunsama API
|
|
166
|
+
*
|
|
167
|
+
* @param request - The GraphQL request
|
|
168
|
+
* @returns The GraphQL response
|
|
169
|
+
* @internal
|
|
170
|
+
*/
|
|
171
|
+
async graphqlRequest(request) {
|
|
172
|
+
// Convert DocumentNode to string if needed
|
|
173
|
+
const queryString = typeof request.query === 'string' ? request.query : print(request.query);
|
|
174
|
+
const requestBody = {
|
|
175
|
+
...request,
|
|
176
|
+
query: queryString,
|
|
177
|
+
};
|
|
178
|
+
const response = await this.request('/graphql', {
|
|
179
|
+
method: 'POST',
|
|
180
|
+
headers: {
|
|
181
|
+
'Content-Type': 'application/json',
|
|
182
|
+
Accept: 'application/json',
|
|
183
|
+
...(request.operationName && { 'x-gql-operation-name': request.operationName }),
|
|
184
|
+
},
|
|
185
|
+
body: requestBody,
|
|
186
|
+
});
|
|
187
|
+
if (!response.ok) {
|
|
188
|
+
const responseText = await response.text();
|
|
189
|
+
throw new SunsamaAuthError(`GraphQL request failed: ${response.status} ${response.statusText}. Response: ${responseText}`);
|
|
190
|
+
}
|
|
191
|
+
const result = (await response.json());
|
|
192
|
+
if (result.errors && result.errors.length > 0) {
|
|
193
|
+
throw new SunsamaAuthError(`GraphQL errors: ${result.errors.map(e => e.message).join(', ')}`);
|
|
194
|
+
}
|
|
195
|
+
return result;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Gets the current user information
|
|
199
|
+
*
|
|
200
|
+
* @returns The current user data
|
|
201
|
+
* @throws SunsamaAuthError if not authenticated or request fails
|
|
202
|
+
*/
|
|
203
|
+
async getUser() {
|
|
204
|
+
const request = {
|
|
205
|
+
operationName: 'getUser',
|
|
206
|
+
variables: {},
|
|
207
|
+
query: GET_USER_QUERY,
|
|
208
|
+
};
|
|
209
|
+
const response = await this.graphqlRequest(request);
|
|
210
|
+
if (!response.data) {
|
|
211
|
+
throw new SunsamaAuthError('No user data received');
|
|
212
|
+
}
|
|
213
|
+
const user = response.data.currentUser;
|
|
214
|
+
// Cache user ID, group ID, and timezone for future requests
|
|
215
|
+
this.userId = user._id;
|
|
216
|
+
this.groupId = user.primaryGroup?.groupId;
|
|
217
|
+
this.timezone = user.profile.timezone;
|
|
218
|
+
return user;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Gets tasks for a specific day
|
|
222
|
+
*
|
|
223
|
+
* @param day - ISO date string (e.g., "2025-05-31")
|
|
224
|
+
* @param timezone - Timezone string (e.g., "America/New_York", defaults to user's timezone)
|
|
225
|
+
* @returns Array of tasks for the specified day
|
|
226
|
+
* @throws SunsamaAuthError if not authenticated or request fails
|
|
227
|
+
*/
|
|
228
|
+
async getTasksByDay(day, timezone) {
|
|
229
|
+
// Use cached values if available, otherwise fetch user data
|
|
230
|
+
if (!this.userId || !this.groupId) {
|
|
231
|
+
await this.getUser();
|
|
232
|
+
}
|
|
233
|
+
const userTimezone = timezone || this.timezone || 'UTC';
|
|
234
|
+
if (!this.groupId) {
|
|
235
|
+
throw new SunsamaAuthError('Unable to determine group ID from user data. User primaryGroup is required.');
|
|
236
|
+
}
|
|
237
|
+
const variables = {
|
|
238
|
+
day,
|
|
239
|
+
timezone: userTimezone,
|
|
240
|
+
userId: this.userId,
|
|
241
|
+
groupId: this.groupId,
|
|
242
|
+
};
|
|
243
|
+
const request = {
|
|
244
|
+
operationName: 'getTasksByDay',
|
|
245
|
+
variables: { input: variables },
|
|
246
|
+
query: GET_TASKS_BY_DAY_QUERY,
|
|
247
|
+
};
|
|
248
|
+
const response = await this.graphqlRequest(request);
|
|
249
|
+
if (!response.data) {
|
|
250
|
+
throw new SunsamaAuthError('No task data received');
|
|
251
|
+
}
|
|
252
|
+
return response.data.tasksByDayV2;
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Gets tasks from the backlog
|
|
256
|
+
*
|
|
257
|
+
* @returns Array of backlog tasks
|
|
258
|
+
* @throws SunsamaAuthError if not authenticated or request fails
|
|
259
|
+
*/
|
|
260
|
+
async getTasksBacklog() {
|
|
261
|
+
// Use cached values if available, otherwise fetch user data
|
|
262
|
+
if (!this.userId || !this.groupId) {
|
|
263
|
+
await this.getUser();
|
|
264
|
+
}
|
|
265
|
+
if (!this.groupId) {
|
|
266
|
+
throw new SunsamaAuthError('Unable to determine group ID from user data. User primaryGroup is required.');
|
|
267
|
+
}
|
|
268
|
+
const variables = {
|
|
269
|
+
userId: this.userId,
|
|
270
|
+
groupId: this.groupId,
|
|
271
|
+
};
|
|
272
|
+
const request = {
|
|
273
|
+
operationName: 'getTasksBacklog',
|
|
274
|
+
variables,
|
|
275
|
+
query: GET_TASKS_BACKLOG_QUERY,
|
|
276
|
+
};
|
|
277
|
+
const response = await this.graphqlRequest(request);
|
|
278
|
+
if (!response.data) {
|
|
279
|
+
throw new SunsamaAuthError('No backlog data received');
|
|
280
|
+
}
|
|
281
|
+
return response.data.tasksBacklog;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Gets streams for the user's group
|
|
285
|
+
*
|
|
286
|
+
* @returns Array of streams for the user's group
|
|
287
|
+
* @throws SunsamaAuthError if not authenticated or request fails
|
|
288
|
+
*/
|
|
289
|
+
async getStreamsByGroupId() {
|
|
290
|
+
// Use cached values if available, otherwise fetch user data
|
|
291
|
+
if (!this.groupId) {
|
|
292
|
+
await this.getUser();
|
|
293
|
+
}
|
|
294
|
+
if (!this.groupId) {
|
|
295
|
+
throw new SunsamaAuthError('Unable to determine group ID from user data. User primaryGroup is required.');
|
|
296
|
+
}
|
|
297
|
+
const request = {
|
|
298
|
+
operationName: 'getStreamsByGroupId',
|
|
299
|
+
variables: { groupId: this.groupId },
|
|
300
|
+
query: GET_STREAMS_BY_GROUP_ID_QUERY,
|
|
301
|
+
};
|
|
302
|
+
const response = await this.graphqlRequest(request);
|
|
303
|
+
if (!response.data) {
|
|
304
|
+
throw new SunsamaAuthError('No stream data received');
|
|
305
|
+
}
|
|
306
|
+
return response.data.streamsByGroupId;
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Gets the user's timezone
|
|
310
|
+
*
|
|
311
|
+
* @returns The user's timezone string (e.g., "America/New_York")
|
|
312
|
+
* @throws SunsamaAuthError if not authenticated or request fails
|
|
313
|
+
*/
|
|
314
|
+
async getUserTimezone() {
|
|
315
|
+
// Use cached timezone if available, otherwise fetch user data
|
|
316
|
+
if (!this.timezone) {
|
|
317
|
+
await this.getUser();
|
|
318
|
+
}
|
|
319
|
+
if (!this.timezone) {
|
|
320
|
+
throw new SunsamaAuthError('Unable to determine timezone from user data. User profile.timezone is required.');
|
|
321
|
+
}
|
|
322
|
+
return this.timezone;
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Sets a session token as a cookie in the jar
|
|
326
|
+
*
|
|
327
|
+
* @param token - The session token to set
|
|
328
|
+
* @internal
|
|
329
|
+
*/
|
|
330
|
+
setSessionTokenAsCookie(token) {
|
|
331
|
+
try {
|
|
332
|
+
const cookie = new Cookie({
|
|
333
|
+
key: 'sunsamaSession',
|
|
334
|
+
value: token,
|
|
335
|
+
domain: 'api.sunsama.com',
|
|
336
|
+
path: '/',
|
|
337
|
+
httpOnly: true,
|
|
338
|
+
secure: true,
|
|
339
|
+
});
|
|
340
|
+
this.cookieJar.setCookieSync(cookie, SunsamaClient.BASE_URL);
|
|
341
|
+
}
|
|
342
|
+
catch (error) {
|
|
343
|
+
// Silently fail if cookie cannot be set
|
|
344
|
+
// Note: Error intentionally ignored to avoid breaking authentication flow
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAC7C,OAAO,EACL,6BAA6B,EAC7B,uBAAuB,EACvB,sBAAsB,EACtB,cAAc,GACf,MAAM,YAAY,CAAC;AAiBpB;;;;GAIG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,CAAU,QAAQ,GAAG,yBAAyB,CAAC;IAE5C,MAAM,CAAsB;IAC5B,SAAS,CAAY;IAC9B,MAAM,CAAU;IAChB,OAAO,CAAU;IACjB,QAAQ,CAAU;IAE1B;;;;OAIG;IACH,YAAY,SAA8B,EAAE;QAC1C,IAAI,CAAC,MAAM,GA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AAO,CACR,CAAC;QAEF,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnB,MAAM,IAAI,gBAAgB,CAAC,yBAAyB,CAAC,CAAC;QACxD,CAAC;QAED,OAAO,QAAQ,CAAC,IAAI,CAAC,gBAAgB,CAAC;IACxC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,eAAe;QACnB,8DAA8D;QAC9D,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACvB,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACnB,MAAM,IAAI,gBAAgB,CACxB,iFAAiF,CAClF,CAAC;QACJ,CAAC;QAED,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;;OAKG;IACK,uBAAuB,CAAC,KAAa;QAC3C,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,IAAI,MAAM,CAAC;gBACxB,GAAG,EAAE,gBAAgB;gBACrB,KAAK,EAAE,KAAK;gBACZ,MAAM,EAAE,iBAAiB;gBACzB,IAAI,EAAE,GAAG;gBACT,QAAQ,EAAE,IAAI;gBACd,MAAM,EAAE,IAAI;aACb,CAAC,CAAC;YAEH,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;QAC/D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,wCAAwC;YACxC,0EAA0E;QAC5E,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error classes for the Sunsama API wrapper
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Base error class for all Sunsama-related errors
|
|
6
|
+
*/
|
|
7
|
+
export class SunsamaError extends Error {
|
|
8
|
+
code;
|
|
9
|
+
cause;
|
|
10
|
+
constructor(message, code, cause) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.code = code;
|
|
13
|
+
this.cause = cause;
|
|
14
|
+
this.name = 'SunsamaError';
|
|
15
|
+
// Maintains proper stack trace for where our error was thrown (only available on V8)
|
|
16
|
+
if (Error.captureStackTrace) {
|
|
17
|
+
Error.captureStackTrace(this, SunsamaError);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Error thrown when API requests fail
|
|
23
|
+
*/
|
|
24
|
+
export class SunsamaApiError extends SunsamaError {
|
|
25
|
+
status;
|
|
26
|
+
response;
|
|
27
|
+
constructor(message, status, response, code) {
|
|
28
|
+
super(message, code);
|
|
29
|
+
this.status = status;
|
|
30
|
+
this.response = response;
|
|
31
|
+
this.name = 'SunsamaApiError';
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Check if this is a client error (4xx status code)
|
|
35
|
+
*/
|
|
36
|
+
isClientError() {
|
|
37
|
+
return this.status >= 400 && this.status < 500;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Check if this is a server error (5xx status code)
|
|
41
|
+
*/
|
|
42
|
+
isServerError() {
|
|
43
|
+
return this.status >= 500;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Check if this is a rate limit error
|
|
47
|
+
*/
|
|
48
|
+
isRateLimitError() {
|
|
49
|
+
return this.status === 429;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Check if this is an authentication error
|
|
53
|
+
*/
|
|
54
|
+
isAuthError() {
|
|
55
|
+
return this.status === 401 || this.status === 403;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Error thrown when client configuration is invalid
|
|
60
|
+
*/
|
|
61
|
+
export class SunsamaConfigError extends SunsamaError {
|
|
62
|
+
constructor(message, code) {
|
|
63
|
+
super(message, code);
|
|
64
|
+
this.name = 'SunsamaConfigError';
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Error thrown when authentication fails
|
|
69
|
+
*/
|
|
70
|
+
export class SunsamaAuthError extends SunsamaError {
|
|
71
|
+
constructor(message, code, cause) {
|
|
72
|
+
super(message, code, cause);
|
|
73
|
+
this.name = 'SunsamaAuthError';
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Error thrown when request validation fails
|
|
78
|
+
*/
|
|
79
|
+
export class SunsamaValidationError extends SunsamaError {
|
|
80
|
+
field;
|
|
81
|
+
constructor(message, field, code) {
|
|
82
|
+
super(message, code);
|
|
83
|
+
this.field = field;
|
|
84
|
+
this.name = 'SunsamaValidationError';
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Error thrown when network requests fail
|
|
89
|
+
*/
|
|
90
|
+
export class SunsamaNetworkError extends SunsamaError {
|
|
91
|
+
constructor(message, cause) {
|
|
92
|
+
super(message, 'NETWORK_ERROR', cause);
|
|
93
|
+
this.name = 'SunsamaNetworkError';
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Error thrown when requests timeout
|
|
98
|
+
*/
|
|
99
|
+
export class SunsamaTimeoutError extends SunsamaNetworkError {
|
|
100
|
+
constructor(timeout) {
|
|
101
|
+
super(`Request timed out after ${timeout}ms`);
|
|
102
|
+
this.name = 'SunsamaTimeoutError';
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/errors/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;GAEG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IAGnB;IACA;IAHlB,YACE,OAAe,EACC,IAAa,EACb,KAAa;QAE7B,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAS;QACb,UAAK,GAAL,KAAK,CAAQ;QAG7B,IAA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IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;IACjC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,sBAAuB,SAAQ,YAAY;IAGpC;IAFlB,YACE,OAAe,EACC,KAAc,EAC9B,IAAa;QAEb,KAAK,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QAHL,UAAK,GAAL,KAAK,CAAS;QAI9B,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,YAAY;IACnD,YAAY,OAAe,EAAE,KAAa;QACxC,KAAK,CAAC,OAAO,EAAE,eAAe,EAAE,KAAK,CAAC,CAAC;QACvC,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,mBAAoB,SAAQ,mBAAmB;IAC1D,YAAY,OAAe;QACzB,KAAK,CAAC,2BAA2B,OAAO,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sunsama API TypeScript Wrapper
|
|
3
|
+
*
|
|
4
|
+
* A comprehensive TypeScript wrapper for the Sunsama API, providing type-safe access
|
|
5
|
+
* to daily planning and task management functionality.
|
|
6
|
+
*
|
|
7
|
+
* @author Your Name
|
|
8
|
+
* @version 0.1.0
|
|
9
|
+
*/
|
|
10
|
+
// Main client export
|
|
11
|
+
export { SunsamaClient } from './client/index.js';
|
|
12
|
+
// Error exports
|
|
13
|
+
export * from './errors/index.js';
|
|
14
|
+
// Utility exports (if needed)
|
|
15
|
+
export * from './utils/index.js';
|
|
16
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,qBAAqB;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAKlD,gBAAgB;AAChB,cAAc,mBAAmB,CAAC;AAElC,8BAA8B;AAC9B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/queries/fragments/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,WAAW,CAAC;AAC1B,cAAc,aAAa,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stream-related GraphQL fragments
|
|
3
|
+
*/
|
|
4
|
+
import { gql } from 'graphql-tag';
|
|
5
|
+
export const STREAM_FRAGMENT = gql `
|
|
6
|
+
fragment StreamData on Stream {
|
|
7
|
+
_id
|
|
8
|
+
groupId
|
|
9
|
+
createdAt
|
|
10
|
+
createdBy
|
|
11
|
+
streamName
|
|
12
|
+
category
|
|
13
|
+
categoryStreamId
|
|
14
|
+
personal
|
|
15
|
+
description
|
|
16
|
+
status
|
|
17
|
+
lastModified
|
|
18
|
+
slackChannelId
|
|
19
|
+
slackAccountId
|
|
20
|
+
standup {
|
|
21
|
+
channel
|
|
22
|
+
rule {
|
|
23
|
+
isoDays
|
|
24
|
+
hour
|
|
25
|
+
minute
|
|
26
|
+
__typename
|
|
27
|
+
}
|
|
28
|
+
nextStandupDate
|
|
29
|
+
lastStandupDate
|
|
30
|
+
timezone
|
|
31
|
+
__typename
|
|
32
|
+
}
|
|
33
|
+
editTrail {
|
|
34
|
+
userId
|
|
35
|
+
editDate
|
|
36
|
+
__typename
|
|
37
|
+
}
|
|
38
|
+
color
|
|
39
|
+
memberIds
|
|
40
|
+
private
|
|
41
|
+
projectIntegrations {
|
|
42
|
+
integration
|
|
43
|
+
projectId
|
|
44
|
+
accountId
|
|
45
|
+
userId
|
|
46
|
+
__typename
|
|
47
|
+
}
|
|
48
|
+
schedules {
|
|
49
|
+
userId
|
|
50
|
+
timeSpans {
|
|
51
|
+
id
|
|
52
|
+
dayIndex
|
|
53
|
+
start {
|
|
54
|
+
hour
|
|
55
|
+
minute
|
|
56
|
+
__typename
|
|
57
|
+
}
|
|
58
|
+
end {
|
|
59
|
+
hour
|
|
60
|
+
minute
|
|
61
|
+
__typename
|
|
62
|
+
}
|
|
63
|
+
__typename
|
|
64
|
+
}
|
|
65
|
+
__typename
|
|
66
|
+
}
|
|
67
|
+
deleted
|
|
68
|
+
__typename
|
|
69
|
+
}
|
|
70
|
+
`;
|
|
71
|
+
//# sourceMappingURL=stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stream.js","sourceRoot":"","sources":["../../../../src/queries/fragments/stream.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,MAAM,CAAC,MAAM,eAAe,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiEjC,CAAC"}
|