@knpkv/jira-cli 1.2.0 → 1.2.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/CHANGELOG.md +19 -0
- package/README.md +2 -6
- package/dist/AttachmentService.d.ts.map +1 -1
- package/dist/AttachmentService.js +6 -11
- package/dist/AttachmentService.js.map +1 -1
- package/dist/IssueService.d.ts.map +1 -1
- package/dist/IssueService.js +17 -19
- package/dist/IssueService.js.map +1 -1
- package/dist/JiraAuth.d.ts +1 -1
- package/dist/VersionService.d.ts.map +1 -1
- package/dist/VersionService.js +23 -27
- package/dist/VersionService.js.map +1 -1
- package/dist/commands/layers.d.ts +2 -2
- package/dist/commands/layers.js +1 -1
- package/dist/commands/layers.js.map +1 -1
- package/dist/internal/sync/document.d.ts.map +1 -1
- package/dist/internal/sync/document.js +5 -5
- package/dist/internal/sync/document.js.map +1 -1
- package/dist/internal/sync/fieldValues.d.ts +0 -5
- package/dist/internal/sync/fieldValues.d.ts.map +1 -1
- package/dist/internal/sync/fieldValues.js +9 -4
- package/dist/internal/sync/fieldValues.js.map +1 -1
- package/package.json +9 -9
- package/src/AttachmentService.ts +6 -12
- package/src/IssueService.ts +18 -21
- package/src/VersionService.ts +29 -47
- package/src/commands/layers.ts +1 -1
- package/src/internal/sync/document.ts +5 -7
- package/src/internal/sync/fieldValues.ts +4 -6
- package/test/IssueService.test.ts +55 -39
- package/test/VersionService.test.ts +39 -23
- package/test/integration.test.ts +2 -0
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { describe, expect, it } from "@effect/vitest"
|
|
2
|
-
import { JiraApiClient,
|
|
2
|
+
import { JiraApiClient, make } from "@knpkv/jira-api-client"
|
|
3
3
|
import * as Effect from "effect/Effect"
|
|
4
4
|
import * as Layer from "effect/Layer"
|
|
5
|
-
import
|
|
6
|
-
import
|
|
5
|
+
import * as Redacted from "effect/Redacted"
|
|
6
|
+
import * as HttpClient from "effect/unstable/http/HttpClient"
|
|
7
|
+
import * as HttpClientResponse from "effect/unstable/http/HttpClientResponse"
|
|
7
8
|
import { stripEmails } from "../src/commands/version.js"
|
|
8
9
|
import type { Version } from "../src/VersionService.js"
|
|
9
10
|
import {
|
|
@@ -208,37 +209,45 @@ describe("stripEmails", () => {
|
|
|
208
209
|
// ---------------------------------------------------------------------------
|
|
209
210
|
|
|
210
211
|
const versionsFixture = [
|
|
211
|
-
{
|
|
212
|
+
{
|
|
213
|
+
id: "1",
|
|
214
|
+
name: "1.0.0",
|
|
215
|
+
released: true,
|
|
216
|
+
self: "https://x/version/1",
|
|
217
|
+
contributors: ["account-1", { accountId: "account-2", displayName: "Ada" }]
|
|
218
|
+
},
|
|
212
219
|
{ id: "2", name: "2.0.0", released: false, self: "https://x/version/2" },
|
|
213
220
|
{ id: "3", name: "3.0.0", released: true, self: "https://x/version/3" },
|
|
214
221
|
{ id: "4", name: "4.0.0", released: false, self: "https://x/version/4" }
|
|
215
222
|
]
|
|
216
223
|
|
|
217
224
|
/**
|
|
218
|
-
* Build a JiraApiClient mock whose
|
|
225
|
+
* Build a JiraApiClient mock whose HTTP transport routes by path: the version
|
|
219
226
|
* list endpoint returns the fixture; the JQL search endpoint returns no issues
|
|
220
227
|
* (so the contributor scan resolves to empty without further calls).
|
|
221
228
|
*/
|
|
222
|
-
const makeJiraLayer = () =>
|
|
223
|
-
|
|
229
|
+
const makeJiraLayer = () => {
|
|
230
|
+
const httpClient = HttpClient.make((request) => {
|
|
231
|
+
const body = request.url.includes("/project/PROJ/version")
|
|
232
|
+
? { values: versionsFixture, isLast: true }
|
|
233
|
+
: { issues: [], isLast: true }
|
|
234
|
+
return Effect.succeed(HttpClientResponse.fromWeb(
|
|
235
|
+
request,
|
|
236
|
+
new Response(JSON.stringify(body), { status: 200, headers: { "content-type": "application/json" } })
|
|
237
|
+
))
|
|
238
|
+
})
|
|
239
|
+
const api = make(httpClient, {
|
|
240
|
+
baseUrl: "https://jira.test",
|
|
241
|
+
auth: { type: "basic", email: "test@example.com", apiToken: Redacted.make("token") }
|
|
242
|
+
})
|
|
243
|
+
return Layer.succeed(
|
|
224
244
|
JiraApiClient,
|
|
225
|
-
{
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
path === "/rest/api/3/project/{projectIdOrKey}/version"
|
|
230
|
-
? Promise.resolve({
|
|
231
|
-
data: { values: versionsFixture, isLast: true },
|
|
232
|
-
response: { ok: true, status: 200 }
|
|
233
|
-
})
|
|
234
|
-
: Promise.resolve({
|
|
235
|
-
data: { issues: [], isLast: true },
|
|
236
|
-
response: { ok: true, status: 200 }
|
|
237
|
-
})
|
|
238
|
-
})
|
|
239
|
-
}
|
|
240
|
-
} satisfies JiraApiClientShape
|
|
245
|
+
JiraApiClient.of({
|
|
246
|
+
...api,
|
|
247
|
+
uploadAttachment: () => Effect.die("unused Jira upload mock")
|
|
248
|
+
})
|
|
241
249
|
)
|
|
250
|
+
}
|
|
242
251
|
|
|
243
252
|
describe("listProjectVersions filtering", () => {
|
|
244
253
|
it.effect("returns all versions when neither flag is set", () =>
|
|
@@ -268,4 +277,11 @@ describe("listProjectVersions filtering", () => {
|
|
|
268
277
|
const list = yield* service.listProjectVersions("PROJ", { maxResults: 2 })
|
|
269
278
|
expect(list.map((v) => v.id)).toEqual(["1", "2"])
|
|
270
279
|
}).pipe(Effect.provide(VersionServiceLayer), Effect.provide(makeJiraLayer())))
|
|
280
|
+
|
|
281
|
+
it.effect("preserves Jira Premium contributors decoded from the generated Version schema", () =>
|
|
282
|
+
Effect.gen(function*() {
|
|
283
|
+
const service = yield* VersionService
|
|
284
|
+
const list = yield* service.listProjectVersions("PROJ", { maxResults: 1 })
|
|
285
|
+
expect(list[0]?.contributors.map((person) => person.accountId)).toEqual(["account-1", "account-2"])
|
|
286
|
+
}).pipe(Effect.provide(VersionServiceLayer), Effect.provide(makeJiraLayer())))
|
|
271
287
|
})
|
package/test/integration.test.ts
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
* - JIRA_BASE_URL defaults to https://knpkv.atlassian.net
|
|
11
11
|
* - JIRA_ISSUE_KEY defaults to KAN-1
|
|
12
12
|
*/
|
|
13
|
+
import * as NodeHttpClient from "@effect/platform-node/NodeHttpClient"
|
|
13
14
|
import * as NodeServices from "@effect/platform-node/NodeServices"
|
|
14
15
|
import { describe, expect, it } from "@effect/vitest"
|
|
15
16
|
import { JiraApiClient, JiraApiConfig } from "@knpkv/jira-api-client"
|
|
@@ -101,6 +102,7 @@ const makeIntegrationLayer = (config: IntegrationConfig) => {
|
|
|
101
102
|
Layer.provideMerge(Layer.succeed(SiteUrl, config.baseUrl)),
|
|
102
103
|
Layer.provideMerge(JiraApiClient.layer),
|
|
103
104
|
Layer.provideMerge(configLayer),
|
|
105
|
+
Layer.provideMerge(NodeHttpClient.layerUndici),
|
|
104
106
|
Layer.provideMerge(NodeServices.layer)
|
|
105
107
|
)
|
|
106
108
|
}
|