@omniq/sdk 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.
Files changed (66) hide show
  1. package/README.md +360 -0
  2. package/dist/__tests__/client.test.d.ts +2 -0
  3. package/dist/__tests__/client.test.d.ts.map +1 -0
  4. package/dist/__tests__/client.test.js +784 -0
  5. package/dist/__tests__/client.test.js.map +1 -0
  6. package/dist/client.d.ts +53 -0
  7. package/dist/client.d.ts.map +1 -0
  8. package/dist/client.js +174 -0
  9. package/dist/client.js.map +1 -0
  10. package/dist/index.d.ts +5 -0
  11. package/dist/index.d.ts.map +1 -0
  12. package/dist/index.js +3 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/resources/ai.d.ts +33 -0
  15. package/dist/resources/ai.d.ts.map +1 -0
  16. package/dist/resources/ai.js +37 -0
  17. package/dist/resources/ai.js.map +1 -0
  18. package/dist/resources/auth.d.ts +16 -0
  19. package/dist/resources/auth.d.ts.map +1 -0
  20. package/dist/resources/auth.js +22 -0
  21. package/dist/resources/auth.js.map +1 -0
  22. package/dist/resources/calendar.d.ts +25 -0
  23. package/dist/resources/calendar.d.ts.map +1 -0
  24. package/dist/resources/calendar.js +38 -0
  25. package/dist/resources/calendar.js.map +1 -0
  26. package/dist/resources/files.d.ts +24 -0
  27. package/dist/resources/files.d.ts.map +1 -0
  28. package/dist/resources/files.js +48 -0
  29. package/dist/resources/files.js.map +1 -0
  30. package/dist/resources/gitlab.d.ts +11 -0
  31. package/dist/resources/gitlab.d.ts.map +1 -0
  32. package/dist/resources/gitlab.js +25 -0
  33. package/dist/resources/gitlab.js.map +1 -0
  34. package/dist/resources/index.d.ts +12 -0
  35. package/dist/resources/index.d.ts.map +1 -0
  36. package/dist/resources/index.js +12 -0
  37. package/dist/resources/index.js.map +1 -0
  38. package/dist/resources/issues.d.ts +17 -0
  39. package/dist/resources/issues.d.ts.map +1 -0
  40. package/dist/resources/issues.js +41 -0
  41. package/dist/resources/issues.js.map +1 -0
  42. package/dist/resources/notifications.d.ts +15 -0
  43. package/dist/resources/notifications.d.ts.map +1 -0
  44. package/dist/resources/notifications.js +18 -0
  45. package/dist/resources/notifications.js.map +1 -0
  46. package/dist/resources/projects.d.ts +15 -0
  47. package/dist/resources/projects.d.ts.map +1 -0
  48. package/dist/resources/projects.js +35 -0
  49. package/dist/resources/projects.js.map +1 -0
  50. package/dist/resources/sprints.d.ts +20 -0
  51. package/dist/resources/sprints.d.ts.map +1 -0
  52. package/dist/resources/sprints.js +40 -0
  53. package/dist/resources/sprints.js.map +1 -0
  54. package/dist/resources/tokens.d.ts +10 -0
  55. package/dist/resources/tokens.d.ts.map +1 -0
  56. package/dist/resources/tokens.js +16 -0
  57. package/dist/resources/tokens.js.map +1 -0
  58. package/dist/resources/wiki.d.ts +23 -0
  59. package/dist/resources/wiki.d.ts.map +1 -0
  60. package/dist/resources/wiki.js +40 -0
  61. package/dist/resources/wiki.js.map +1 -0
  62. package/dist/types.d.ts +478 -0
  63. package/dist/types.d.ts.map +1 -0
  64. package/dist/types.js +3 -0
  65. package/dist/types.js.map +1 -0
  66. package/package.json +38 -0
package/README.md ADDED
@@ -0,0 +1,360 @@
1
+ # @omniq/sdk
2
+
3
+ Typed SDK for the [OMNIQ](https://omniq.pro) Platform API. Zero dependencies — uses native `fetch`.
4
+
5
+ ## Quick Start
6
+
7
+ ```bash
8
+ npm install @omniq/sdk
9
+ # or
10
+ pnpm add @omniq/sdk
11
+ ```
12
+
13
+ ```typescript
14
+ import { OmniqClient } from '@omniq/sdk';
15
+
16
+ const client = new OmniqClient({
17
+ baseUrl: 'https://app.omniq.pro/api/v1',
18
+ token: 'pat_abc123…',
19
+ });
20
+
21
+ const projects = await client.projects.list();
22
+ console.log(projects);
23
+ ```
24
+
25
+ ## Authentication
26
+
27
+ ### Personal Access Token (recommended)
28
+
29
+ Create a PAT in **Settings → Tokens** and pass it to the client.
30
+ Best for scripts, CI pipelines, and MCP servers.
31
+
32
+ ```typescript
33
+ const client = new OmniqClient({
34
+ baseUrl: 'https://app.omniq.pro/api/v1',
35
+ token: process.env.OMNIQ_TOKEN,
36
+ });
37
+ ```
38
+
39
+ ### Cookie (server-side proxy)
40
+
41
+ When proxying through a backend that already holds a session cookie,
42
+ forward the `Cookie` header instead:
43
+
44
+ ```typescript
45
+ const client = new OmniqClient({
46
+ baseUrl: 'https://app.omniq.pro/api/v1',
47
+ cookieHeader: req.headers.cookie,
48
+ });
49
+ ```
50
+
51
+ ### Email / Password
52
+
53
+ Authenticate programmatically and receive a session. The login response
54
+ sets an `httpOnly` cookie — use `cookieHeader` for subsequent calls.
55
+
56
+ ```typescript
57
+ const client = new OmniqClient({
58
+ baseUrl: 'https://app.omniq.pro/api/v1',
59
+ });
60
+
61
+ const { user } = await client.auth.login({
62
+ email: 'user@example.com',
63
+ password: 'secret',
64
+ });
65
+ ```
66
+
67
+ ## Configuration
68
+
69
+ | Option | Type | Default | Description |
70
+ | --- | --- | --- | --- |
71
+ | `baseUrl` | `string` | — | API root URL (required) |
72
+ | `token` | `string` | — | Personal Access Token for Bearer auth |
73
+ | `cookieHeader` | `string` | — | Raw `Cookie` header value for server-side proxy |
74
+ | `maxRetries` | `number` | `3` | Retry count for 5xx / network errors |
75
+
76
+ ## Resources
77
+
78
+ ### Auth — `client.auth`
79
+
80
+ | Method | HTTP | Path | Returns |
81
+ | --- | --- | --- | --- |
82
+ | `login(data)` | `POST` | `/auth/login` | `LoginResponse` |
83
+ | `refresh()` | `POST` | `/auth/refresh` | `{ success: boolean }` |
84
+ | `logout()` | `POST` | `/auth/logout` | `void` |
85
+ | `logoutAll()` | `POST` | `/auth/logout-all` | `void` |
86
+ | `me()` | `GET` | `/auth/me` | `{ user: User }` |
87
+
88
+ ### Projects — `client.projects`
89
+
90
+ | Method | HTTP | Path | Returns |
91
+ | --- | --- | --- | --- |
92
+ | `list()` | `GET` | `/projects` | `Project[]` |
93
+ | `get(id)` | `GET` | `/projects/:id` | `Project` |
94
+ | `create(data)` | `POST` | `/projects` | `Project` |
95
+ | `update(id, data)` | `PATCH` | `/projects/:id` | `Project` |
96
+ | `delete(id)` | `DELETE` | `/projects/:id` | `void` |
97
+ | `listMembers(projectId)` | `GET` | `/projects/:id/members` | `ProjectMember[]` |
98
+ | `addMember(projectId, data)` | `POST` | `/projects/:id/members` | `void` |
99
+ | `removeMember(projectId, userId)` | `DELETE` | `/projects/:id/members/:userId` | `void` |
100
+
101
+ ```typescript
102
+ const project = await client.projects.create({
103
+ name: 'Payments',
104
+ key: 'PAY',
105
+ description: 'Payment processing service',
106
+ });
107
+ ```
108
+
109
+ ### Issues — `client.issues`
110
+
111
+ | Method | HTTP | Path | Returns |
112
+ | --- | --- | --- | --- |
113
+ | `list(params?)` | `GET` | `/issues` | `PaginatedResponse<Issue>` |
114
+ | `listAll(params?)` | `GET` | `/issues` (auto-paginated) | `AsyncGenerator<Issue>` |
115
+ | `get(id)` | `GET` | `/issues/:id` | `Issue` |
116
+ | `create(data)` | `POST` | `/issues` | `Issue` |
117
+ | `update(id, data)` | `PATCH` | `/issues/:id` | `Issue` |
118
+ | `delete(id)` | `DELETE` | `/issues/:id` | `void` |
119
+ | `updateStatus(id, status)` | `POST` | `/issues/:id/status` | `Issue` |
120
+ | `bulkUpdate(data)` | `POST` | `/issues/bulk` | `Issue[]` |
121
+ | `addComment(issueId, data)` | `POST` | `/issues/:id/comments` | `Comment` |
122
+ | `addLink(issueId, data)` | `POST` | `/issues/:id/links` | `IssueLink` |
123
+
124
+ ```typescript
125
+ const issue = await client.issues.create({
126
+ projectId: 'proj_1',
127
+ title: 'Fix login bug',
128
+ priority: 'high',
129
+ type: 'bug',
130
+ });
131
+
132
+ await client.issues.updateStatus(issue.id, 'in_progress');
133
+ ```
134
+
135
+ ### Sprints — `client.sprints`
136
+
137
+ | Method | HTTP | Path | Returns |
138
+ | --- | --- | --- | --- |
139
+ | `list({ projectId })` | `GET` | `/sprints` | `Sprint[]` |
140
+ | `get(id)` | `GET` | `/sprints/:id` | `Sprint` |
141
+ | `create(data)` | `POST` | `/sprints` | `Sprint` |
142
+ | `update(id, data)` | `PATCH` | `/sprints/:id` | `Sprint` |
143
+ | `delete(id)` | `DELETE` | `/sprints/:id` | `void` |
144
+ | `start(id)` | `POST` | `/sprints/:id/start` | `Sprint` |
145
+ | `close(id, transferToSprintId?)` | `POST` | `/sprints/:id/close` | `Sprint` |
146
+ | `burndown(id)` | `GET` | `/sprints/:id/burndown` | `BurndownPoint[]` |
147
+ | `velocity({ projectId })` | `GET` | `/sprints/velocity` | `VelocityData` |
148
+
149
+ ```typescript
150
+ const sprints = await client.sprints.list({ projectId: 'proj_1' });
151
+ const burndown = await client.sprints.burndown(sprints[0].id);
152
+ const velocity = await client.sprints.velocity({ projectId: 'proj_1' });
153
+
154
+ // Close sprint and transfer undone issues
155
+ await client.sprints.close(sprint.id, nextSprint.id);
156
+ ```
157
+
158
+ ### Wiki — `client.wiki`
159
+
160
+ | Method | HTTP | Path | Returns |
161
+ | --- | --- | --- | --- |
162
+ | `listSpaces({ projectId })` | `GET` | `/wiki/spaces` | `WikiSpace[]` |
163
+ | `createSpace(data)` | `POST` | `/wiki/spaces` | `WikiSpace` |
164
+ | `listPages({ spaceId })` | `GET` | `/wiki/pages` | `WikiPage[]` |
165
+ | `createPage(data)` | `POST` | `/wiki/pages` | `WikiPage` |
166
+ | `updatePage(id, data)` | `PATCH` | `/wiki/pages/:id` | `WikiPage` |
167
+ | `pageVersions(id)` | `GET` | `/wiki/pages/:id/versions` | `WikiPageVersion[]` |
168
+ | `restorePage(pageId, versionId)` | `POST` | `/wiki/pages/:id/restore/:versionId` | `WikiPage` |
169
+ | `search({ projectId, q })` | `GET` | `/wiki/search` | `WikiSearchResult[]` |
170
+ | `templates()` | `GET` | `/wiki/templates` | `WikiTemplate[]` |
171
+
172
+ ```typescript
173
+ const results = await client.wiki.search({
174
+ projectId: 'proj_1',
175
+ q: 'onboarding',
176
+ });
177
+ ```
178
+
179
+ ### Calendar — `client.calendar`
180
+
181
+ | Method | HTTP | Path | Returns |
182
+ | --- | --- | --- | --- |
183
+ | `listEvents({ start, end, projectId?, userId? })` | `GET` | `/calendar/events` | `CalendarEvent[]` |
184
+ | `createEvent(data)` | `POST` | `/calendar/events` | `CalendarEvent` |
185
+ | `updateEvent(id, data)` | `PATCH` | `/calendar/events/:id` | `CalendarEvent` |
186
+ | `deleteEvent(id)` | `DELETE` | `/calendar/events/:id` | `void` |
187
+ | `listResources({ start, end, projectId? })` | `GET` | `/calendar/resources` | `CalendarResourceEntity[]` |
188
+ | `exportIcs({ start, end })` | `GET` | `/calendar/export.ics` | `Response` (raw) |
189
+
190
+ ```typescript
191
+ const events = await client.calendar.listEvents({
192
+ start: '2025-06-01',
193
+ end: '2025-06-30',
194
+ projectId: 'proj_1',
195
+ });
196
+
197
+ const icsResponse = await client.calendar.exportIcs({
198
+ start: '2025-06-01',
199
+ end: '2025-06-30',
200
+ });
201
+ const ics = await icsResponse.text();
202
+ ```
203
+
204
+ ### AI — `client.ai`
205
+
206
+ | Method | HTTP | Path | Returns |
207
+ | --- | --- | --- | --- |
208
+ | `chat(data)` | `POST` | `/ai/chat` | `AiChatResponse` |
209
+ | `chatStream(data)` | `POST` | `/ai/chat/stream` | `Response` (raw SSE stream) |
210
+ | `generate(data)` | `POST` | `/ai/generate` | `{ content, tokensUsed }` |
211
+ | `estimate(data)` | `POST` | `/ai/estimate` | `AiEstimateResponse` |
212
+ | `plan(data)` | `POST` | `/ai/plan` | `{ content, tokensUsed }` |
213
+ | `summarize(data)` | `POST` | `/ai/summarize` | `{ content, tokensUsed }` |
214
+ | `insights({ projectId })` | `GET` | `/ai/insights` | `{ content, tokensUsed }` |
215
+
216
+ ```typescript
217
+ const estimate = await client.ai.estimate({
218
+ title: 'Add OAuth2 login',
219
+ description: 'Support Google and GitHub OAuth2 flows',
220
+ });
221
+ console.log(`${estimate.storyPoints} SP (${estimate.confidence}% confidence)`);
222
+
223
+ const reply = await client.ai.chat({
224
+ message: 'Summarize the current sprint progress',
225
+ projectId: 'proj_1',
226
+ });
227
+ console.log(reply.content);
228
+ ```
229
+
230
+ ### Notifications — `client.notifications`
231
+
232
+ | Method | HTTP | Path | Returns |
233
+ | --- | --- | --- | --- |
234
+ | `list({ unreadOnly? }?)` | `GET` | `/notifications` | `{ data: Notification[], unreadCount }` |
235
+ | `markRead(id)` | `POST` | `/notifications/:id/read` | `void` |
236
+ | `markAllRead()` | `POST` | `/notifications/read-all` | `void` |
237
+
238
+ ```typescript
239
+ const { data: notifications, unreadCount } = await client.notifications.list({
240
+ unreadOnly: true,
241
+ });
242
+
243
+ for (const n of notifications) {
244
+ await client.notifications.markRead(n.id);
245
+ }
246
+ ```
247
+
248
+ ### Tokens — `client.tokens`
249
+
250
+ | Method | HTTP | Path | Returns |
251
+ | --- | --- | --- | --- |
252
+ | `list()` | `GET` | `/tokens` | `PersonalAccessToken[]` |
253
+ | `create(data)` | `POST` | `/tokens` | `CreatedToken` |
254
+ | `delete(id)` | `DELETE` | `/tokens/:id` | `void` |
255
+
256
+ ```typescript
257
+ const { token } = await client.tokens.create({
258
+ name: 'CI pipeline',
259
+ scopes: ['issues:read', 'issues:write'],
260
+ expiresAt: '2026-12-31T23:59:59Z',
261
+ });
262
+ // Store `token` securely — it is only shown once.
263
+ ```
264
+
265
+ ### GitLab — `client.gitlab`
266
+
267
+ | Method | HTTP | Path | Returns |
268
+ | --- | --- | --- | --- |
269
+ | `listActivity(projectId)` | `GET` | `/git/events` | `GitLabEvent[]` |
270
+ | `linkCommit(issueId, sha, url?)` | `POST` | `/git/commits/link` | `void` |
271
+
272
+ ```typescript
273
+ const events = await client.gitlab.listActivity('proj_1');
274
+
275
+ await client.gitlab.linkCommit('issue_1', 'abc123def', 'https://gitlab.com/…/commit/abc123def');
276
+ ```
277
+
278
+ ## Pagination
279
+
280
+ Methods returning `PaginatedResponse<T>` include `data`, `total`, `page`, and `limit` fields.
281
+ For convenience, `listAll()` methods return an `AsyncGenerator` that handles page fetching automatically:
282
+
283
+ ```typescript
284
+ for await (const issue of client.issues.listAll({ projectId: 'proj_1' })) {
285
+ console.log(issue.key, issue.title);
286
+ }
287
+
288
+ // With filters
289
+ for await (const issue of client.issues.listAll({
290
+ projectId: 'proj_1',
291
+ status: 'in_progress',
292
+ assigneeId: 'user_1',
293
+ })) {
294
+ process.stdout.write(`${issue.key} `);
295
+ }
296
+ ```
297
+
298
+ The paginator fetches 50 items per page and stops when all items are consumed.
299
+
300
+ ## Error Handling
301
+
302
+ All API errors throw `OmniqApiError` with `status`, `statusText`, and `body` properties:
303
+
304
+ ```typescript
305
+ import { OmniqClient, OmniqApiError } from '@omniq/sdk';
306
+
307
+ try {
308
+ await client.projects.get('nonexistent');
309
+ } catch (error) {
310
+ if (error instanceof OmniqApiError) {
311
+ console.error(error.status); // 404
312
+ console.error(error.statusText); // "Not Found"
313
+ console.error(error.body); // parsed JSON error body
314
+ }
315
+ }
316
+ ```
317
+
318
+ **Automatic retries** — Server errors (5xx) and network failures are retried up to `maxRetries` times
319
+ (default `3`) with exponential backoff (1 s → 2 s → 4 s, capped at 10 s). Client errors (4xx) are
320
+ never retried and throw immediately.
321
+
322
+ ## TypeScript
323
+
324
+ The SDK is fully typed. All entity types, input types, enums, and utility types are exported
325
+ from the package root:
326
+
327
+ ```typescript
328
+ import { OmniqClient } from '@omniq/sdk';
329
+ import type {
330
+ Issue,
331
+ CreateIssueInput,
332
+ IssueStatus,
333
+ IssuePriority,
334
+ StoryPoints,
335
+ PaginatedResponse,
336
+ } from '@omniq/sdk';
337
+
338
+ async function moveToReview(client: OmniqClient, issueId: string): Promise<Issue> {
339
+ return client.issues.updateStatus(issueId, 'review');
340
+ }
341
+ ```
342
+
343
+ <details>
344
+ <summary>All exported types</summary>
345
+
346
+ **Enums / Unions** — `Role`, `IssueStatus`, `IssuePriority`, `IssueType`, `StoryPoints`, `SprintStatus`, `CalendarEventType`, `CalendarEventStatus`, `ContentFormat`, `CommentSource`, `NotificationType`, `EntityType`
347
+
348
+ **Entities** — `User`, `Project`, `Issue`, `Sprint`, `Comment`, `IssueLink`, `WikiSpace`, `WikiPage`, `WikiPageVersion`, `WikiTemplate`, `CalendarEvent`, `CalendarResourceEntity`, `Notification`, `PersonalAccessToken`, `CreatedToken`, `ProjectMember`, `GitLabEvent`, `GitLabCommitLink`
349
+
350
+ **Inputs** — `LoginInput`, `CreateProjectInput`, `AddMemberInput`, `CreateIssueInput`, `UpdateIssueInput`, `BulkUpdateIssueInput`, `CreateCommentInput`, `CreateIssueLinkInput`, `IssueListParams`, `CreateSprintInput`, `UpdateSprintInput`, `CreateWikiSpaceInput`, `CreateWikiPageInput`, `UpdateWikiPageInput`, `CreateCalendarEventInput`, `UpdateCalendarEventInput`, `CreateTokenInput`, `AiChatInput`, `AiGenerateInput`, `AiEstimateInput`
351
+
352
+ **Responses** — `LoginResponse`, `AuthTokens`, `AiChatResponse`, `AiEstimateResponse`, `PaginatedResponse<T>`, `BurndownPoint`, `VelocityEntry`, `VelocityData`, `WikiSearchResult`
353
+
354
+ **Resource classes** — `AuthResource`, `ProjectsResource`, `IssuesResource`, `SprintsResource`, `WikiResource`, `CalendarResource`, `AIResource`, `NotificationsResource`, `TokensResource`, `GitLabResource`
355
+
356
+ </details>
357
+
358
+ ## License
359
+
360
+ MIT
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=client.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/client.test.ts"],"names":[],"mappings":""}