@knpkv/jira-api-client 0.3.1 → 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 (38) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/README.md +88 -65
  3. package/dist/JiraApiClient.d.ts +20 -86
  4. package/dist/JiraApiClient.d.ts.map +1 -1
  5. package/dist/JiraApiClient.js +26 -76
  6. package/dist/JiraApiClient.js.map +1 -1
  7. package/dist/generated/JiraApi.d.ts +103971 -0
  8. package/dist/generated/JiraApi.d.ts.map +1 -0
  9. package/dist/generated/JiraApi.js +7608 -0
  10. package/dist/generated/JiraApi.js.map +1 -0
  11. package/dist/index.d.ts +3 -12
  12. package/dist/index.d.ts.map +1 -1
  13. package/dist/index.js +3 -11
  14. package/dist/index.js.map +1 -1
  15. package/package.json +13 -16
  16. package/scripts/regenerate.ts +209 -202
  17. package/scripts/tsconfig.json +13 -0
  18. package/src/JiraApiClient.ts +74 -105
  19. package/src/generated/JiraApi.ts +19596 -0
  20. package/src/index.ts +3 -14
  21. package/test/JiraApiClient.test.ts +155 -137
  22. package/.specs/VERSION_V3 +0 -1
  23. package/.specs/jira-v3-1001.0.0-SNAPSHOT-05f20e18d9bde3de68f911b4915970482f536d4e.json +0 -56275
  24. package/.specs/jira-v3-1001.0.0-SNAPSHOT-d7cd03e966bb408ad32ffe870114289c528f56fd.json +0 -56129
  25. package/.specs/jira-v3-1001.0.0-SNAPSHOT-ea9913a8c4412d2bfb1911480b023a04544e19d8.json +0 -55618
  26. package/dist/OpenApiFetchClient.d.ts +0 -55
  27. package/dist/OpenApiFetchClient.d.ts.map +0 -1
  28. package/dist/OpenApiFetchClient.js +0 -63
  29. package/dist/OpenApiFetchClient.js.map +0 -1
  30. package/dist/generated/v3/index.d.ts +0 -7
  31. package/dist/generated/v3/index.d.ts.map +0 -1
  32. package/dist/generated/v3/index.js +0 -2
  33. package/dist/generated/v3/index.js.map +0 -1
  34. package/dist/generated/v3/schema.d.ts +0 -64454
  35. package/src/OpenApiFetchClient.ts +0 -92
  36. package/src/generated/v3/index.ts +0 -6
  37. package/src/generated/v3/schema.d.ts +0 -64454
  38. package/tsconfig.tsbuildinfo +0 -1
@@ -1,92 +0,0 @@
1
- /**
2
- * Generic Effect wrapper for openapi-fetch clients.
3
- *
4
- * Exposes a type-safe `Client<Paths>` and a `toEffect` helper that wraps
5
- * any `Promise<FetchResponse>` in Effect with error mapping.
6
- *
7
- * @example
8
- * ```typescript
9
- * const page = yield* toEffect(client.GET("/pages/{id}", {
10
- * params: { path: { id: 123 } }
11
- * }))
12
- * ```
13
- *
14
- * @module
15
- */
16
- import * as Data from "effect/Data"
17
- import * as Effect from "effect/Effect"
18
- import createClient, { type Client, type FetchResponse } from "openapi-fetch"
19
- import type { MediaType } from "openapi-typescript-helpers"
20
-
21
- /**
22
- * Error from openapi-fetch operations.
23
- *
24
- * @category Errors
25
- */
26
- export class FetchClientError extends Data.TaggedError("FetchClientError")<{
27
- readonly error: unknown
28
- readonly status: number
29
- readonly message: string
30
- }> {}
31
-
32
- /** Extract success `data` from a FetchResponse discriminated union. */
33
- export type SuccessData<T> = T extends { data: infer D; error?: undefined } ? D
34
- : T extends { data?: infer D } ? NonNullable<D>
35
- : never
36
-
37
- /**
38
- * Wrap an openapi-fetch `Promise<FetchResponse>` in Effect.
39
- *
40
- * Extracts `data` on success, maps errors to `FetchClientError`.
41
- * Fully type-safe — path/body constraints come from the `Client<Paths>` call site.
42
- *
43
- * @example
44
- * ```typescript
45
- * const page = yield* toEffect(client.GET("/pages/{id}", { params: { path: { id: 123 } } }))
46
- * ```
47
- *
48
- * @category Utilities
49
- */
50
- // eslint-disable-next-line @typescript-eslint/no-explicit-any -- matches FetchResponse generic constraint
51
- export const toEffect = <T extends Record<string | number, any>, O, M extends MediaType>(
52
- promise: Promise<FetchResponse<T, O, M>>
53
- ): Effect.Effect<SuccessData<FetchResponse<T, O, M>>, FetchClientError> =>
54
- Effect.tryPromise({
55
- try: () =>
56
- promise.then(({ data, error, response }) => {
57
- if (error !== undefined || !response.ok) {
58
- throw { error, status: response.status }
59
- }
60
- return data as SuccessData<FetchResponse<T, O, M>>
61
- }),
62
- catch: (e) =>
63
- new FetchClientError({
64
- error: (e as Record<string, unknown>).error ?? e,
65
- status: ((e as Record<string, unknown>).status as number | undefined) ?? 0,
66
- message: typeof (e as Record<string, unknown>).error === "string"
67
- ? (e as Record<string, unknown>).error as string
68
- : JSON.stringify((e as Record<string, unknown>).error ?? e)
69
- })
70
- })
71
-
72
- /**
73
- * openapi-fetch client paired with the `toEffect` helper.
74
- *
75
- * @category Client
76
- */
77
- export interface OpenApiFetchClient<Paths extends {}> {
78
- /** Type-safe openapi-fetch client. Use with `toEffect()` to get Effect. */
79
- readonly client: Client<Paths, "application/json">
80
- }
81
-
82
- /**
83
- * Create an openapi-fetch client with auth headers pre-configured.
84
- *
85
- * @category Constructors
86
- */
87
- export const makeOpenApiFetchClient = <Paths extends {}>(
88
- baseUrl: string,
89
- headers: Record<string, string>
90
- ): OpenApiFetchClient<Paths> => ({
91
- client: createClient<Paths, "application/json">({ baseUrl, headers })
92
- })
@@ -1,6 +0,0 @@
1
- /**
2
- * Generated Jira Cloud REST API v3 types.
3
- *
4
- * @module
5
- */
6
- export type { components, operations, paths } from "./schema.js"