@felixgeelhaar/jira-sdk 0.2.0 → 1.0.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 (46) hide show
  1. package/README.md +214 -374
  2. package/dist/auth/index.cjs +400 -0
  3. package/dist/auth/index.cjs.map +1 -0
  4. package/dist/auth/index.d.cts +192 -0
  5. package/dist/auth/index.d.ts +192 -0
  6. package/dist/auth/index.js +386 -0
  7. package/dist/auth/index.js.map +1 -0
  8. package/dist/errors/index.cjs +272 -0
  9. package/dist/errors/index.cjs.map +1 -0
  10. package/dist/errors/index.d.cts +203 -0
  11. package/dist/errors/index.d.ts +203 -0
  12. package/dist/errors/index.js +254 -0
  13. package/dist/errors/index.js.map +1 -0
  14. package/dist/http-client-BSzRYQZa.d.cts +317 -0
  15. package/dist/http-client-erRvYNs-.d.ts +317 -0
  16. package/dist/index.cjs +9582 -13466
  17. package/dist/index.cjs.map +1 -1
  18. package/dist/index.d.cts +1242 -76
  19. package/dist/index.d.ts +1242 -76
  20. package/dist/index.js +9166 -13318
  21. package/dist/index.js.map +1 -1
  22. package/dist/schemas/index.cjs +2481 -13092
  23. package/dist/schemas/index.cjs.map +1 -1
  24. package/dist/schemas/index.d.cts +335 -207
  25. package/dist/schemas/index.d.ts +335 -207
  26. package/dist/schemas/index.js +2138 -13047
  27. package/dist/schemas/index.js.map +1 -1
  28. package/dist/services/index.cjs +6375 -13323
  29. package/dist/services/index.cjs.map +1 -1
  30. package/dist/services/index.d.cts +3852 -299
  31. package/dist/services/index.d.ts +3852 -299
  32. package/dist/services/index.js +6350 -13321
  33. package/dist/services/index.js.map +1 -1
  34. package/dist/transport/index.cjs +1016 -0
  35. package/dist/transport/index.cjs.map +1 -0
  36. package/dist/transport/index.d.cts +372 -0
  37. package/dist/transport/index.d.ts +372 -0
  38. package/dist/transport/index.js +997 -0
  39. package/dist/transport/index.js.map +1 -0
  40. package/dist/types-E6djPHpW.d.cts +95 -0
  41. package/dist/types-E6djPHpW.d.ts +95 -0
  42. package/dist/webhook-Bn8gme6Y.d.cts +6959 -0
  43. package/dist/webhook-Bn8gme6Y.d.ts +6959 -0
  44. package/package.json +73 -27
  45. package/dist/project-BtUx-eSv.d.cts +0 -1480
  46. package/dist/project-BtUx-eSv.d.ts +0 -1480
@@ -0,0 +1,317 @@
1
+ import { A as AuthProvider } from './types-E6djPHpW.cjs';
2
+
3
+ /**
4
+ * Logging abstraction for the SDK.
5
+ * Provides a simple interface that can be implemented by any logging library.
6
+ */
7
+ /** Log levels supported by the SDK */
8
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error';
9
+ /** Structured log fields */
10
+ type LogFields = Record<string, unknown>;
11
+ /**
12
+ * Logger interface that SDK consumers can implement.
13
+ * Compatible with most logging libraries.
14
+ */
15
+ interface Logger {
16
+ /** Log debug messages (verbose, for development) */
17
+ debug(message: string, fields?: LogFields): void;
18
+ /** Log informational messages (normal operations) */
19
+ info(message: string, fields?: LogFields): void;
20
+ /** Log warning messages (potential issues) */
21
+ warn(message: string, fields?: LogFields): void;
22
+ /** Log error messages (failures) */
23
+ error(message: string, fields?: LogFields): void;
24
+ /** Create a child logger with additional context */
25
+ child?(fields: LogFields): Logger;
26
+ }
27
+ /**
28
+ * Check if a value implements the Logger interface
29
+ */
30
+ declare function isLogger(value: unknown): value is Logger;
31
+
32
+ /**
33
+ * HTTP request method
34
+ */
35
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
36
+ /**
37
+ * A value that may appear in a query string.
38
+ *
39
+ * Arrays are serialized as repeated keys (`id=1&id=2`), which is what Jira
40
+ * expects for parameters it documents as "ampersand-separated". Parameters it
41
+ * documents as "comma-separated" should be joined by the caller into a single
42
+ * string instead.
43
+ */
44
+ type QueryParamValue = string | number | boolean | string[] | number[];
45
+ /**
46
+ * HTTP request configuration
47
+ */
48
+ interface HttpRequest {
49
+ /**
50
+ * Request URL (can be relative to base URL)
51
+ */
52
+ url: string;
53
+ /**
54
+ * HTTP method
55
+ */
56
+ method: HttpMethod;
57
+ /**
58
+ * Request headers
59
+ */
60
+ headers?: Record<string, string> | undefined;
61
+ /**
62
+ * Request body (will be JSON stringified if object)
63
+ */
64
+ body?: unknown;
65
+ /**
66
+ * Query parameters
67
+ */
68
+ params?: Record<string, QueryParamValue | undefined> | undefined;
69
+ /**
70
+ * Request timeout in milliseconds
71
+ */
72
+ timeout?: number | undefined;
73
+ /**
74
+ * AbortSignal for request cancellation
75
+ */
76
+ signal?: AbortSignal | undefined;
77
+ /**
78
+ * Custom metadata passed through middleware
79
+ */
80
+ metadata?: Record<string, unknown> | undefined;
81
+ }
82
+ /**
83
+ * HTTP response
84
+ */
85
+ interface HttpResponse<T = unknown> {
86
+ /**
87
+ * Response status code
88
+ */
89
+ status: number;
90
+ /**
91
+ * Response status text
92
+ */
93
+ statusText: string;
94
+ /**
95
+ * Response headers
96
+ */
97
+ headers: Headers;
98
+ /**
99
+ * Parsed response body
100
+ */
101
+ data: T;
102
+ /**
103
+ * Original request
104
+ */
105
+ request: HttpRequest;
106
+ /**
107
+ * Response time in milliseconds
108
+ */
109
+ responseTime: number;
110
+ }
111
+ /**
112
+ * Middleware context passed through the chain
113
+ */
114
+ interface MiddlewareContext {
115
+ /**
116
+ * Current request
117
+ */
118
+ request: HttpRequest;
119
+ /**
120
+ * Auth provider (if configured)
121
+ */
122
+ auth?: AuthProvider | undefined;
123
+ /**
124
+ * Logger instance
125
+ */
126
+ logger: Logger;
127
+ /**
128
+ * Retry count (incremented by retry middleware)
129
+ */
130
+ retryCount: number;
131
+ /**
132
+ * Custom context data
133
+ */
134
+ [key: string]: unknown;
135
+ }
136
+ /**
137
+ * Next function to call the next middleware or the actual request
138
+ */
139
+ type MiddlewareNext = (context: MiddlewareContext) => Promise<HttpResponse>;
140
+ /**
141
+ * Middleware function type
142
+ */
143
+ type Middleware = (context: MiddlewareContext, next: MiddlewareNext) => Promise<HttpResponse>;
144
+ /**
145
+ * HTTP client configuration
146
+ */
147
+ interface HttpClientConfig {
148
+ /**
149
+ * Base URL for all requests
150
+ */
151
+ baseUrl: string;
152
+ /**
153
+ * Authentication provider
154
+ */
155
+ auth?: AuthProvider;
156
+ /**
157
+ * Logger instance
158
+ */
159
+ logger?: Logger;
160
+ /**
161
+ * Default request timeout in milliseconds
162
+ */
163
+ timeout?: number;
164
+ /**
165
+ * Default headers for all requests
166
+ */
167
+ defaultHeaders?: Record<string, string>;
168
+ /**
169
+ * Middleware chain
170
+ */
171
+ middleware?: Middleware[];
172
+ /**
173
+ * Custom fetch implementation (for testing or alternative runtimes)
174
+ */
175
+ fetch?: typeof fetch;
176
+ /**
177
+ * Allow insecure HTTP connections (not recommended for production)
178
+ *
179
+ * By default, HTTP URLs will throw an error in production and warn in development.
180
+ * Set to true to disable this security check (useful for testing or internal APIs).
181
+ *
182
+ * @default false
183
+ */
184
+ allowInsecureHttp?: boolean;
185
+ }
186
+ /**
187
+ * Request options for individual requests
188
+ */
189
+ interface RequestOptions {
190
+ /**
191
+ * Request timeout override
192
+ */
193
+ timeout?: number | undefined;
194
+ /**
195
+ * AbortSignal for cancellation
196
+ */
197
+ signal?: AbortSignal | undefined;
198
+ /**
199
+ * Additional headers for this request
200
+ */
201
+ headers?: Record<string, string> | undefined;
202
+ /**
203
+ * Query-string parameters for this request.
204
+ *
205
+ * Available on every verb, not just GET — Jira attaches query parameters to
206
+ * POST, PUT and DELETE endpoints too (`expand`, `notifyUsers`,
207
+ * `replaceWith`, and so on).
208
+ */
209
+ params?: Record<string, QueryParamValue | undefined> | undefined;
210
+ /**
211
+ * Custom metadata passed to middleware
212
+ */
213
+ metadata?: Record<string, unknown> | undefined;
214
+ /**
215
+ * Skip authentication for this request
216
+ */
217
+ skipAuth?: boolean | undefined;
218
+ }
219
+
220
+ /**
221
+ * HTTP client for making API requests
222
+ *
223
+ * Features:
224
+ * - Middleware support for request/response processing
225
+ * - Automatic authentication header injection
226
+ * - Request timeout handling
227
+ * - AbortSignal support for cancellation
228
+ * - Automatic JSON serialization/deserialization
229
+ * - Error classification (API errors, network errors, etc.)
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * const client = new HttpClient({
234
+ * baseUrl: 'https://your-domain.atlassian.net',
235
+ * auth: new ApiTokenAuth({ email: '...', apiToken: '...' }),
236
+ * middleware: [loggingMiddleware, retryMiddleware],
237
+ * });
238
+ *
239
+ * const response = await client.get('/rest/api/3/myself');
240
+ * ```
241
+ */
242
+ declare class HttpClient {
243
+ private readonly baseUrl;
244
+ private readonly auth;
245
+ private readonly logger;
246
+ private readonly timeout;
247
+ private readonly defaultHeaders;
248
+ private readonly middleware;
249
+ private readonly fetchFn;
250
+ private middlewareChain;
251
+ constructor(config: HttpClientConfig);
252
+ /**
253
+ * Make a GET request
254
+ */
255
+ get<T = unknown>(path: string, params?: Record<string, QueryParamValue | undefined>, options?: RequestOptions): Promise<HttpResponse<T>>;
256
+ /**
257
+ * Make a POST request
258
+ */
259
+ post<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<HttpResponse<T>>;
260
+ /**
261
+ * Make a PUT request
262
+ */
263
+ put<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<HttpResponse<T>>;
264
+ /**
265
+ * Make a PATCH request
266
+ */
267
+ patch<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<HttpResponse<T>>;
268
+ /**
269
+ * Make a DELETE request
270
+ */
271
+ delete<T = unknown>(path: string, options?: RequestOptions): Promise<HttpResponse<T>>;
272
+ /**
273
+ * Make a request with full control over the configuration
274
+ */
275
+ request<T = unknown>(requestConfig: Omit<HttpRequest, 'method'> & {
276
+ method?: HttpMethod;
277
+ } & RequestOptions): Promise<HttpResponse<T>>;
278
+ /**
279
+ * Build the middleware chain with the final request handler
280
+ */
281
+ private buildMiddlewareChain;
282
+ /**
283
+ * Execute the actual HTTP request
284
+ */
285
+ private executeRequest;
286
+ /**
287
+ * Handle error responses and throw appropriate errors
288
+ */
289
+ private handleErrorResponse;
290
+ /**
291
+ * Parse Retry-After header
292
+ */
293
+ private parseRetryAfter;
294
+ /**
295
+ * Combine multiple AbortSignals
296
+ */
297
+ private combineSignals;
298
+ /**
299
+ * Add middleware to the chain
300
+ * Note: This rebuilds the middleware chain for the new configuration
301
+ */
302
+ use(middleware: Middleware): this;
303
+ /**
304
+ * Get the base URL
305
+ */
306
+ getBaseUrl(): string;
307
+ /**
308
+ * Get the auth provider
309
+ */
310
+ getAuth(): AuthProvider | undefined;
311
+ }
312
+ /**
313
+ * Factory function to create HTTP client
314
+ */
315
+ declare function createHttpClient(config: HttpClientConfig): HttpClient;
316
+
317
+ export { HttpClient as H, type Logger as L, type Middleware as M, type QueryParamValue as Q, type RequestOptions as R, type LogFields as a, type LogLevel as b, type HttpClientConfig as c, type HttpMethod as d, type HttpRequest as e, type HttpResponse as f, type MiddlewareContext as g, type MiddlewareNext as h, createHttpClient as i, isLogger as j };
@@ -0,0 +1,317 @@
1
+ import { A as AuthProvider } from './types-E6djPHpW.js';
2
+
3
+ /**
4
+ * Logging abstraction for the SDK.
5
+ * Provides a simple interface that can be implemented by any logging library.
6
+ */
7
+ /** Log levels supported by the SDK */
8
+ type LogLevel = 'debug' | 'info' | 'warn' | 'error';
9
+ /** Structured log fields */
10
+ type LogFields = Record<string, unknown>;
11
+ /**
12
+ * Logger interface that SDK consumers can implement.
13
+ * Compatible with most logging libraries.
14
+ */
15
+ interface Logger {
16
+ /** Log debug messages (verbose, for development) */
17
+ debug(message: string, fields?: LogFields): void;
18
+ /** Log informational messages (normal operations) */
19
+ info(message: string, fields?: LogFields): void;
20
+ /** Log warning messages (potential issues) */
21
+ warn(message: string, fields?: LogFields): void;
22
+ /** Log error messages (failures) */
23
+ error(message: string, fields?: LogFields): void;
24
+ /** Create a child logger with additional context */
25
+ child?(fields: LogFields): Logger;
26
+ }
27
+ /**
28
+ * Check if a value implements the Logger interface
29
+ */
30
+ declare function isLogger(value: unknown): value is Logger;
31
+
32
+ /**
33
+ * HTTP request method
34
+ */
35
+ type HttpMethod = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | 'OPTIONS';
36
+ /**
37
+ * A value that may appear in a query string.
38
+ *
39
+ * Arrays are serialized as repeated keys (`id=1&id=2`), which is what Jira
40
+ * expects for parameters it documents as "ampersand-separated". Parameters it
41
+ * documents as "comma-separated" should be joined by the caller into a single
42
+ * string instead.
43
+ */
44
+ type QueryParamValue = string | number | boolean | string[] | number[];
45
+ /**
46
+ * HTTP request configuration
47
+ */
48
+ interface HttpRequest {
49
+ /**
50
+ * Request URL (can be relative to base URL)
51
+ */
52
+ url: string;
53
+ /**
54
+ * HTTP method
55
+ */
56
+ method: HttpMethod;
57
+ /**
58
+ * Request headers
59
+ */
60
+ headers?: Record<string, string> | undefined;
61
+ /**
62
+ * Request body (will be JSON stringified if object)
63
+ */
64
+ body?: unknown;
65
+ /**
66
+ * Query parameters
67
+ */
68
+ params?: Record<string, QueryParamValue | undefined> | undefined;
69
+ /**
70
+ * Request timeout in milliseconds
71
+ */
72
+ timeout?: number | undefined;
73
+ /**
74
+ * AbortSignal for request cancellation
75
+ */
76
+ signal?: AbortSignal | undefined;
77
+ /**
78
+ * Custom metadata passed through middleware
79
+ */
80
+ metadata?: Record<string, unknown> | undefined;
81
+ }
82
+ /**
83
+ * HTTP response
84
+ */
85
+ interface HttpResponse<T = unknown> {
86
+ /**
87
+ * Response status code
88
+ */
89
+ status: number;
90
+ /**
91
+ * Response status text
92
+ */
93
+ statusText: string;
94
+ /**
95
+ * Response headers
96
+ */
97
+ headers: Headers;
98
+ /**
99
+ * Parsed response body
100
+ */
101
+ data: T;
102
+ /**
103
+ * Original request
104
+ */
105
+ request: HttpRequest;
106
+ /**
107
+ * Response time in milliseconds
108
+ */
109
+ responseTime: number;
110
+ }
111
+ /**
112
+ * Middleware context passed through the chain
113
+ */
114
+ interface MiddlewareContext {
115
+ /**
116
+ * Current request
117
+ */
118
+ request: HttpRequest;
119
+ /**
120
+ * Auth provider (if configured)
121
+ */
122
+ auth?: AuthProvider | undefined;
123
+ /**
124
+ * Logger instance
125
+ */
126
+ logger: Logger;
127
+ /**
128
+ * Retry count (incremented by retry middleware)
129
+ */
130
+ retryCount: number;
131
+ /**
132
+ * Custom context data
133
+ */
134
+ [key: string]: unknown;
135
+ }
136
+ /**
137
+ * Next function to call the next middleware or the actual request
138
+ */
139
+ type MiddlewareNext = (context: MiddlewareContext) => Promise<HttpResponse>;
140
+ /**
141
+ * Middleware function type
142
+ */
143
+ type Middleware = (context: MiddlewareContext, next: MiddlewareNext) => Promise<HttpResponse>;
144
+ /**
145
+ * HTTP client configuration
146
+ */
147
+ interface HttpClientConfig {
148
+ /**
149
+ * Base URL for all requests
150
+ */
151
+ baseUrl: string;
152
+ /**
153
+ * Authentication provider
154
+ */
155
+ auth?: AuthProvider;
156
+ /**
157
+ * Logger instance
158
+ */
159
+ logger?: Logger;
160
+ /**
161
+ * Default request timeout in milliseconds
162
+ */
163
+ timeout?: number;
164
+ /**
165
+ * Default headers for all requests
166
+ */
167
+ defaultHeaders?: Record<string, string>;
168
+ /**
169
+ * Middleware chain
170
+ */
171
+ middleware?: Middleware[];
172
+ /**
173
+ * Custom fetch implementation (for testing or alternative runtimes)
174
+ */
175
+ fetch?: typeof fetch;
176
+ /**
177
+ * Allow insecure HTTP connections (not recommended for production)
178
+ *
179
+ * By default, HTTP URLs will throw an error in production and warn in development.
180
+ * Set to true to disable this security check (useful for testing or internal APIs).
181
+ *
182
+ * @default false
183
+ */
184
+ allowInsecureHttp?: boolean;
185
+ }
186
+ /**
187
+ * Request options for individual requests
188
+ */
189
+ interface RequestOptions {
190
+ /**
191
+ * Request timeout override
192
+ */
193
+ timeout?: number | undefined;
194
+ /**
195
+ * AbortSignal for cancellation
196
+ */
197
+ signal?: AbortSignal | undefined;
198
+ /**
199
+ * Additional headers for this request
200
+ */
201
+ headers?: Record<string, string> | undefined;
202
+ /**
203
+ * Query-string parameters for this request.
204
+ *
205
+ * Available on every verb, not just GET — Jira attaches query parameters to
206
+ * POST, PUT and DELETE endpoints too (`expand`, `notifyUsers`,
207
+ * `replaceWith`, and so on).
208
+ */
209
+ params?: Record<string, QueryParamValue | undefined> | undefined;
210
+ /**
211
+ * Custom metadata passed to middleware
212
+ */
213
+ metadata?: Record<string, unknown> | undefined;
214
+ /**
215
+ * Skip authentication for this request
216
+ */
217
+ skipAuth?: boolean | undefined;
218
+ }
219
+
220
+ /**
221
+ * HTTP client for making API requests
222
+ *
223
+ * Features:
224
+ * - Middleware support for request/response processing
225
+ * - Automatic authentication header injection
226
+ * - Request timeout handling
227
+ * - AbortSignal support for cancellation
228
+ * - Automatic JSON serialization/deserialization
229
+ * - Error classification (API errors, network errors, etc.)
230
+ *
231
+ * @example
232
+ * ```typescript
233
+ * const client = new HttpClient({
234
+ * baseUrl: 'https://your-domain.atlassian.net',
235
+ * auth: new ApiTokenAuth({ email: '...', apiToken: '...' }),
236
+ * middleware: [loggingMiddleware, retryMiddleware],
237
+ * });
238
+ *
239
+ * const response = await client.get('/rest/api/3/myself');
240
+ * ```
241
+ */
242
+ declare class HttpClient {
243
+ private readonly baseUrl;
244
+ private readonly auth;
245
+ private readonly logger;
246
+ private readonly timeout;
247
+ private readonly defaultHeaders;
248
+ private readonly middleware;
249
+ private readonly fetchFn;
250
+ private middlewareChain;
251
+ constructor(config: HttpClientConfig);
252
+ /**
253
+ * Make a GET request
254
+ */
255
+ get<T = unknown>(path: string, params?: Record<string, QueryParamValue | undefined>, options?: RequestOptions): Promise<HttpResponse<T>>;
256
+ /**
257
+ * Make a POST request
258
+ */
259
+ post<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<HttpResponse<T>>;
260
+ /**
261
+ * Make a PUT request
262
+ */
263
+ put<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<HttpResponse<T>>;
264
+ /**
265
+ * Make a PATCH request
266
+ */
267
+ patch<T = unknown>(path: string, body?: unknown, options?: RequestOptions): Promise<HttpResponse<T>>;
268
+ /**
269
+ * Make a DELETE request
270
+ */
271
+ delete<T = unknown>(path: string, options?: RequestOptions): Promise<HttpResponse<T>>;
272
+ /**
273
+ * Make a request with full control over the configuration
274
+ */
275
+ request<T = unknown>(requestConfig: Omit<HttpRequest, 'method'> & {
276
+ method?: HttpMethod;
277
+ } & RequestOptions): Promise<HttpResponse<T>>;
278
+ /**
279
+ * Build the middleware chain with the final request handler
280
+ */
281
+ private buildMiddlewareChain;
282
+ /**
283
+ * Execute the actual HTTP request
284
+ */
285
+ private executeRequest;
286
+ /**
287
+ * Handle error responses and throw appropriate errors
288
+ */
289
+ private handleErrorResponse;
290
+ /**
291
+ * Parse Retry-After header
292
+ */
293
+ private parseRetryAfter;
294
+ /**
295
+ * Combine multiple AbortSignals
296
+ */
297
+ private combineSignals;
298
+ /**
299
+ * Add middleware to the chain
300
+ * Note: This rebuilds the middleware chain for the new configuration
301
+ */
302
+ use(middleware: Middleware): this;
303
+ /**
304
+ * Get the base URL
305
+ */
306
+ getBaseUrl(): string;
307
+ /**
308
+ * Get the auth provider
309
+ */
310
+ getAuth(): AuthProvider | undefined;
311
+ }
312
+ /**
313
+ * Factory function to create HTTP client
314
+ */
315
+ declare function createHttpClient(config: HttpClientConfig): HttpClient;
316
+
317
+ export { HttpClient as H, type Logger as L, type Middleware as M, type QueryParamValue as Q, type RequestOptions as R, type LogFields as a, type LogLevel as b, type HttpClientConfig as c, type HttpMethod as d, type HttpRequest as e, type HttpResponse as f, type MiddlewareContext as g, type MiddlewareNext as h, createHttpClient as i, isLogger as j };