@cesar-richard/git-connector-sdk 1.13.1

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/README.md ADDED
@@ -0,0 +1,45 @@
1
+ # @cesar-richard/git-connector-sdk
2
+
3
+ TypeScript SDK for the [git-connector](https://github.com/cesar-richard-ei/git-connector) v1 API. Read aggregated GitHub/GitLab PR/MR ↔ issue linkage data.
4
+
5
+ The version of this package always matches the version of the git-connector server it targets.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install @cesar-richard/git-connector-sdk
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```ts
16
+ import { createGitConnectorClient } from "@cesar-richard/git-connector-sdk";
17
+
18
+ const client = createGitConnectorClient({
19
+ baseUrl: "https://git-connector.example.com",
20
+ token: process.env.GIT_CONNECTOR_TOKEN!,
21
+ });
22
+
23
+ const { data, error } = await client.GET("/v1/work-items", {
24
+ params: { query: { state: "open", iteration: "current" } },
25
+ });
26
+
27
+ if (error) throw new Error(`API error: ${error}`);
28
+ console.log(`${data.total} open work items in the current iteration`);
29
+ ```
30
+
31
+ ## Auth
32
+
33
+ Get an API token via `POST /admin/api-keys` on your git-connector instance. Tokens have format `gck_*`.
34
+
35
+ ## Endpoints
36
+
37
+ - `GET /v1/work-items` — list aggregated work items with linked PRs/MRs
38
+ - `GET /v1/work-items/{source}/{projectKey}/{number}` — detail
39
+ - `GET /v1/iterations` — list iterations with work-item counts
40
+
41
+ See [`openapi.json`](https://github.com/cesar-richard-ei/git-connector/blob/main/packages/sdk/openapi.json) for the full contract (or consume it directly from non-TS languages).
42
+
43
+ ## License
44
+
45
+ MIT
@@ -0,0 +1,11 @@
1
+ import type { paths } from "./schema";
2
+ export type { paths, components } from "./schema";
3
+ export interface GitConnectorClientOptions {
4
+ /** Base URL of the git-connector server, e.g. `https://git-connector.example.com`. */
5
+ baseUrl: string;
6
+ /** API token issued via `POST /admin/api-keys` (format: `gck_*`). */
7
+ token: string;
8
+ /** Optional custom fetch implementation (default: `globalThis.fetch`). */
9
+ fetch?: typeof fetch;
10
+ }
11
+ export declare function createGitConnectorClient(opts: GitConnectorClientOptions): import("openapi-fetch").Client<paths, `${string}/${string}`>;
package/dist/index.js ADDED
@@ -0,0 +1,15 @@
1
+ import createClient from "openapi-fetch";
2
+ export function createGitConnectorClient(opts) {
3
+ const client = createClient({
4
+ baseUrl: opts.baseUrl.replace(/\/$/, ""),
5
+ fetch: opts.fetch,
6
+ });
7
+ const auth = {
8
+ onRequest({ request }) {
9
+ request.headers.set("Authorization", `Bearer ${opts.token}`);
10
+ return request;
11
+ },
12
+ };
13
+ client.use(auth);
14
+ return client;
15
+ }
@@ -0,0 +1,550 @@
1
+ /**
2
+ * This file was auto-generated by openapi-typescript.
3
+ * Do not make direct changes to the file.
4
+ */
5
+
6
+ export interface paths {
7
+ "/v1/work-items": {
8
+ parameters: {
9
+ query?: never;
10
+ header?: never;
11
+ path?: never;
12
+ cookie?: never;
13
+ };
14
+ get: operations["getV1Work-items"];
15
+ put?: never;
16
+ post?: never;
17
+ delete?: never;
18
+ options?: never;
19
+ head?: never;
20
+ patch?: never;
21
+ trace?: never;
22
+ };
23
+ "/v1/work-items/{source}/{projectKey}/{number}": {
24
+ parameters: {
25
+ query?: never;
26
+ header?: never;
27
+ path?: never;
28
+ cookie?: never;
29
+ };
30
+ get: operations["getV1Work-itemsBySourceByProjectKeyByNumber"];
31
+ put?: never;
32
+ post?: never;
33
+ delete?: never;
34
+ options?: never;
35
+ head?: never;
36
+ patch?: never;
37
+ trace?: never;
38
+ };
39
+ "/v1/iterations": {
40
+ parameters: {
41
+ query?: never;
42
+ header?: never;
43
+ path?: never;
44
+ cookie?: never;
45
+ };
46
+ get: operations["getV1Iterations"];
47
+ put?: never;
48
+ post?: never;
49
+ delete?: never;
50
+ options?: never;
51
+ head?: never;
52
+ patch?: never;
53
+ trace?: never;
54
+ };
55
+ }
56
+ export type webhooks = Record<string, never>;
57
+ export interface components {
58
+ schemas: {
59
+ ActivityIteration: {
60
+ id: string | number;
61
+ title: string;
62
+ startDate: string | null;
63
+ dueDate: string | null;
64
+ state: "upcoming" | "current" | "closed" | "unknown";
65
+ };
66
+ ErrorResponse: {
67
+ error: string;
68
+ };
69
+ IterationWithCount: {
70
+ id: string | number;
71
+ title: string;
72
+ startDate: string | null;
73
+ dueDate: string | null;
74
+ state: "upcoming" | "current" | "closed" | "unknown";
75
+ workItemCount: string | number;
76
+ };
77
+ Label: {
78
+ name: string;
79
+ color: string | null;
80
+ };
81
+ LinkedActivity: {
82
+ id: string;
83
+ type: "pr" | "mr";
84
+ title: string;
85
+ url: string;
86
+ state: "open" | "closed" | "merged" | "draft" | "unknown";
87
+ isDraft: boolean;
88
+ isMerged: boolean;
89
+ hasConflicts: boolean;
90
+ awaitingReview: boolean;
91
+ author: string | null;
92
+ updatedAt: string;
93
+ };
94
+ Provider: "github" | "gitlab";
95
+ WorkItem: {
96
+ id: string;
97
+ source: "github" | "gitlab";
98
+ projectKey: string;
99
+ number: string | number;
100
+ title: string;
101
+ body: string | null;
102
+ url: string;
103
+ state: "open" | "closed" | "unknown";
104
+ createdAt: string;
105
+ updatedAt: string;
106
+ iteration: {
107
+ id: string | number;
108
+ title: string;
109
+ startDate: string | null;
110
+ dueDate: string | null;
111
+ state: "upcoming" | "current" | "closed" | "unknown";
112
+ } | null;
113
+ milestone: string | null;
114
+ assignees: string[];
115
+ labels: {
116
+ name: string;
117
+ color: string | null;
118
+ }[];
119
+ linkedActivities: {
120
+ id: string;
121
+ type: "pr" | "mr";
122
+ title: string;
123
+ url: string;
124
+ state: "open" | "closed" | "merged" | "draft" | "unknown";
125
+ isDraft: boolean;
126
+ isMerged: boolean;
127
+ hasConflicts: boolean;
128
+ awaitingReview: boolean;
129
+ author: string | null;
130
+ updatedAt: string;
131
+ }[];
132
+ };
133
+ WorkItemListResponse: {
134
+ items: {
135
+ id: string;
136
+ source: "github" | "gitlab";
137
+ projectKey: string;
138
+ number: string | number;
139
+ title: string;
140
+ body: string | null;
141
+ url: string;
142
+ state: "open" | "closed" | "unknown";
143
+ createdAt: string;
144
+ updatedAt: string;
145
+ iteration: {
146
+ id: string | number;
147
+ title: string;
148
+ startDate: string | null;
149
+ dueDate: string | null;
150
+ state: "upcoming" | "current" | "closed" | "unknown";
151
+ } | null;
152
+ milestone: string | null;
153
+ assignees: string[];
154
+ labels: {
155
+ name: string;
156
+ color: string | null;
157
+ }[];
158
+ linkedActivities: {
159
+ id: string;
160
+ type: "pr" | "mr";
161
+ title: string;
162
+ url: string;
163
+ state: "open" | "closed" | "merged" | "draft" | "unknown";
164
+ isDraft: boolean;
165
+ isMerged: boolean;
166
+ hasConflicts: boolean;
167
+ awaitingReview: boolean;
168
+ author: string | null;
169
+ updatedAt: string;
170
+ }[];
171
+ }[];
172
+ total: string | number;
173
+ limit: string | number;
174
+ };
175
+ };
176
+ responses: never;
177
+ parameters: never;
178
+ requestBodies: never;
179
+ headers: never;
180
+ pathItems: never;
181
+ }
182
+ export type $defs = Record<string, never>;
183
+ export interface operations {
184
+ "getV1Work-items": {
185
+ parameters: {
186
+ query?: {
187
+ iteration?: string;
188
+ state?: string;
189
+ source?: string;
190
+ projectKey?: string;
191
+ assignee?: string;
192
+ label?: string;
193
+ labelScope?: string;
194
+ search?: string;
195
+ limit?: string;
196
+ };
197
+ header?: never;
198
+ path?: never;
199
+ cookie?: never;
200
+ };
201
+ requestBody?: never;
202
+ responses: {
203
+ 200: {
204
+ headers: {
205
+ [name: string]: unknown;
206
+ };
207
+ content: {
208
+ "application/json": {
209
+ items: {
210
+ id: string;
211
+ source: "github" | "gitlab";
212
+ projectKey: string;
213
+ number: string | number;
214
+ title: string;
215
+ body: string | null;
216
+ url: string;
217
+ state: "open" | "closed" | "unknown";
218
+ createdAt: string;
219
+ updatedAt: string;
220
+ iteration: {
221
+ id: string | number;
222
+ title: string;
223
+ startDate: string | null;
224
+ dueDate: string | null;
225
+ state: "upcoming" | "current" | "closed" | "unknown";
226
+ } | null;
227
+ milestone: string | null;
228
+ assignees: string[];
229
+ labels: {
230
+ name: string;
231
+ color: string | null;
232
+ }[];
233
+ linkedActivities: {
234
+ id: string;
235
+ type: "pr" | "mr";
236
+ title: string;
237
+ url: string;
238
+ state: "open" | "closed" | "merged" | "draft" | "unknown";
239
+ isDraft: boolean;
240
+ isMerged: boolean;
241
+ hasConflicts: boolean;
242
+ awaitingReview: boolean;
243
+ author: string | null;
244
+ updatedAt: string;
245
+ }[];
246
+ }[];
247
+ total: string | number;
248
+ limit: string | number;
249
+ };
250
+ "multipart/form-data": {
251
+ items: {
252
+ id: string;
253
+ source: "github" | "gitlab";
254
+ projectKey: string;
255
+ number: string | number;
256
+ title: string;
257
+ body: string | null;
258
+ url: string;
259
+ state: "open" | "closed" | "unknown";
260
+ createdAt: string;
261
+ updatedAt: string;
262
+ iteration: {
263
+ id: string | number;
264
+ title: string;
265
+ startDate: string | null;
266
+ dueDate: string | null;
267
+ state: "upcoming" | "current" | "closed" | "unknown";
268
+ } | null;
269
+ milestone: string | null;
270
+ assignees: string[];
271
+ labels: {
272
+ name: string;
273
+ color: string | null;
274
+ }[];
275
+ linkedActivities: {
276
+ id: string;
277
+ type: "pr" | "mr";
278
+ title: string;
279
+ url: string;
280
+ state: "open" | "closed" | "merged" | "draft" | "unknown";
281
+ isDraft: boolean;
282
+ isMerged: boolean;
283
+ hasConflicts: boolean;
284
+ awaitingReview: boolean;
285
+ author: string | null;
286
+ updatedAt: string;
287
+ }[];
288
+ }[];
289
+ total: string | number;
290
+ limit: string | number;
291
+ };
292
+ "text/plain": {
293
+ items: {
294
+ id: string;
295
+ source: "github" | "gitlab";
296
+ projectKey: string;
297
+ number: string | number;
298
+ title: string;
299
+ body: string | null;
300
+ url: string;
301
+ state: "open" | "closed" | "unknown";
302
+ createdAt: string;
303
+ updatedAt: string;
304
+ iteration: {
305
+ id: string | number;
306
+ title: string;
307
+ startDate: string | null;
308
+ dueDate: string | null;
309
+ state: "upcoming" | "current" | "closed" | "unknown";
310
+ } | null;
311
+ milestone: string | null;
312
+ assignees: string[];
313
+ labels: {
314
+ name: string;
315
+ color: string | null;
316
+ }[];
317
+ linkedActivities: {
318
+ id: string;
319
+ type: "pr" | "mr";
320
+ title: string;
321
+ url: string;
322
+ state: "open" | "closed" | "merged" | "draft" | "unknown";
323
+ isDraft: boolean;
324
+ isMerged: boolean;
325
+ hasConflicts: boolean;
326
+ awaitingReview: boolean;
327
+ author: string | null;
328
+ updatedAt: string;
329
+ }[];
330
+ }[];
331
+ total: string | number;
332
+ limit: string | number;
333
+ };
334
+ };
335
+ };
336
+ };
337
+ };
338
+ "getV1Work-itemsBySourceByProjectKeyByNumber": {
339
+ parameters: {
340
+ query?: never;
341
+ header?: never;
342
+ path: {
343
+ source: string;
344
+ projectKey: string;
345
+ number: string;
346
+ };
347
+ cookie?: never;
348
+ };
349
+ requestBody?: never;
350
+ responses: {
351
+ 200: {
352
+ headers: {
353
+ [name: string]: unknown;
354
+ };
355
+ content: {
356
+ "application/json": {
357
+ id: string;
358
+ source: "github" | "gitlab";
359
+ projectKey: string;
360
+ number: string | number;
361
+ title: string;
362
+ body: string | null;
363
+ url: string;
364
+ state: "open" | "closed" | "unknown";
365
+ createdAt: string;
366
+ updatedAt: string;
367
+ iteration: {
368
+ id: string | number;
369
+ title: string;
370
+ startDate: string | null;
371
+ dueDate: string | null;
372
+ state: "upcoming" | "current" | "closed" | "unknown";
373
+ } | null;
374
+ milestone: string | null;
375
+ assignees: string[];
376
+ labels: {
377
+ name: string;
378
+ color: string | null;
379
+ }[];
380
+ linkedActivities: {
381
+ id: string;
382
+ type: "pr" | "mr";
383
+ title: string;
384
+ url: string;
385
+ state: "open" | "closed" | "merged" | "draft" | "unknown";
386
+ isDraft: boolean;
387
+ isMerged: boolean;
388
+ hasConflicts: boolean;
389
+ awaitingReview: boolean;
390
+ author: string | null;
391
+ updatedAt: string;
392
+ }[];
393
+ };
394
+ "multipart/form-data": {
395
+ id: string;
396
+ source: "github" | "gitlab";
397
+ projectKey: string;
398
+ number: string | number;
399
+ title: string;
400
+ body: string | null;
401
+ url: string;
402
+ state: "open" | "closed" | "unknown";
403
+ createdAt: string;
404
+ updatedAt: string;
405
+ iteration: {
406
+ id: string | number;
407
+ title: string;
408
+ startDate: string | null;
409
+ dueDate: string | null;
410
+ state: "upcoming" | "current" | "closed" | "unknown";
411
+ } | null;
412
+ milestone: string | null;
413
+ assignees: string[];
414
+ labels: {
415
+ name: string;
416
+ color: string | null;
417
+ }[];
418
+ linkedActivities: {
419
+ id: string;
420
+ type: "pr" | "mr";
421
+ title: string;
422
+ url: string;
423
+ state: "open" | "closed" | "merged" | "draft" | "unknown";
424
+ isDraft: boolean;
425
+ isMerged: boolean;
426
+ hasConflicts: boolean;
427
+ awaitingReview: boolean;
428
+ author: string | null;
429
+ updatedAt: string;
430
+ }[];
431
+ };
432
+ "text/plain": {
433
+ id: string;
434
+ source: "github" | "gitlab";
435
+ projectKey: string;
436
+ number: string | number;
437
+ title: string;
438
+ body: string | null;
439
+ url: string;
440
+ state: "open" | "closed" | "unknown";
441
+ createdAt: string;
442
+ updatedAt: string;
443
+ iteration: {
444
+ id: string | number;
445
+ title: string;
446
+ startDate: string | null;
447
+ dueDate: string | null;
448
+ state: "upcoming" | "current" | "closed" | "unknown";
449
+ } | null;
450
+ milestone: string | null;
451
+ assignees: string[];
452
+ labels: {
453
+ name: string;
454
+ color: string | null;
455
+ }[];
456
+ linkedActivities: {
457
+ id: string;
458
+ type: "pr" | "mr";
459
+ title: string;
460
+ url: string;
461
+ state: "open" | "closed" | "merged" | "draft" | "unknown";
462
+ isDraft: boolean;
463
+ isMerged: boolean;
464
+ hasConflicts: boolean;
465
+ awaitingReview: boolean;
466
+ author: string | null;
467
+ updatedAt: string;
468
+ }[];
469
+ };
470
+ };
471
+ };
472
+ 400: {
473
+ headers: {
474
+ [name: string]: unknown;
475
+ };
476
+ content: {
477
+ "application/json": {
478
+ error: string;
479
+ };
480
+ "multipart/form-data": {
481
+ error: string;
482
+ };
483
+ "text/plain": {
484
+ error: string;
485
+ };
486
+ };
487
+ };
488
+ 404: {
489
+ headers: {
490
+ [name: string]: unknown;
491
+ };
492
+ content: {
493
+ "application/json": {
494
+ error: string;
495
+ };
496
+ "multipart/form-data": {
497
+ error: string;
498
+ };
499
+ "text/plain": {
500
+ error: string;
501
+ };
502
+ };
503
+ };
504
+ };
505
+ };
506
+ getV1Iterations: {
507
+ parameters: {
508
+ query?: {
509
+ state?: string;
510
+ };
511
+ header?: never;
512
+ path?: never;
513
+ cookie?: never;
514
+ };
515
+ requestBody?: never;
516
+ responses: {
517
+ 200: {
518
+ headers: {
519
+ [name: string]: unknown;
520
+ };
521
+ content: {
522
+ "application/json": {
523
+ id: string | number;
524
+ title: string;
525
+ startDate: string | null;
526
+ dueDate: string | null;
527
+ state: "upcoming" | "current" | "closed" | "unknown";
528
+ workItemCount: string | number;
529
+ }[];
530
+ "multipart/form-data": {
531
+ id: string | number;
532
+ title: string;
533
+ startDate: string | null;
534
+ dueDate: string | null;
535
+ state: "upcoming" | "current" | "closed" | "unknown";
536
+ workItemCount: string | number;
537
+ }[];
538
+ "text/plain": {
539
+ id: string | number;
540
+ title: string;
541
+ startDate: string | null;
542
+ dueDate: string | null;
543
+ state: "upcoming" | "current" | "closed" | "unknown";
544
+ workItemCount: string | number;
545
+ }[];
546
+ };
547
+ };
548
+ };
549
+ };
550
+ }
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "@cesar-richard/git-connector-sdk",
3
+ "version": "1.13.1",
4
+ "description": "TypeScript SDK for the git-connector v1 API (work items + iterations aggregated from GitHub/GitLab). Version published on npm tracks server releases.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "https://github.com/cesar-richard-ei/git-connector.git",
9
+ "directory": "packages/sdk"
10
+ },
11
+ "homepage": "https://github.com/cesar-richard-ei/git-connector/tree/main/packages/sdk",
12
+ "type": "module",
13
+ "main": "./dist/index.js",
14
+ "types": "./dist/index.d.ts",
15
+ "exports": {
16
+ ".": {
17
+ "import": "./dist/index.js",
18
+ "types": "./dist/index.d.ts"
19
+ },
20
+ "./schema": {
21
+ "types": "./dist/schema.d.ts"
22
+ }
23
+ },
24
+ "files": [
25
+ "dist",
26
+ "README.md"
27
+ ],
28
+ "publishConfig": {
29
+ "access": "public"
30
+ },
31
+ "scripts": {
32
+ "typecheck": "tsc --noEmit",
33
+ "test": "bun test",
34
+ "build": "tsc -p tsconfig.build.json && cp src/schema.d.ts dist/schema.d.ts"
35
+ },
36
+ "dependencies": {
37
+ "openapi-fetch": "^0.13.0"
38
+ },
39
+ "devDependencies": {
40
+ "openapi-typescript": "^7.4.0"
41
+ }
42
+ }