Skip to content

v6.2.0

Choose a tag to compare

@github-actions github-actions released this 24 Aug 12:34
· 68 commits to master since this release

Avatars moved bytes in both directions and the specification described both as JSON, so neither direction worked. Reading an image threw before the response reached the caller; uploading one had no way to send an image at all. Both are fixed here, along with two column endpoints broken by the same reading of the same specification.

Bug Fixes

  • getAvatarImageByID, getAvatarImageByType and getAvatarImageByOwner return the image. All three were generated with StreamingResponseBodySchema — the specification's StreamingResponseBody, an object with no properties — so a response arriving as image/png or image/svg+xml was reported as SchemaMismatchError: Expected a JSON response to validate against the schema. There was no input for which they could succeed. They now return a Blob. Fixes #434.

    A Blob rather than the bytes alone, because the content type cannot be worked out from the request: the same avatar URL answers with SVG for a system avatar and PNG for an uploaded one, and format is optional. image.type is the content type, await image.arrayBuffer() the bytes, and new Response(image) passes it straight to a browser. In v5 this was AvatarWithDetails — { avatar, contentType }; the two fields are now one value.

    Attachment downloads are unchanged. getAttachmentContent and getAttachmentThumbnail still return the bytes, because an attachment already carries its mimeType and filename in its metadata.

  • storeAvatar, createProjectAvatar and createIssueTypeAvatar accept an image. Their request body was generated as Record<string, any> — an object of arbitrary keys — because Atlassian declares it under a wildcard media type with an empty schema. It is now a Blob:

    await jira.avatars.storeAvatar({
      type: 'project',
      entityId: project.id,
      size: 48,
      body: new Blob([bytes], { type: 'image/png' }),
    });

    The Blob carries the content type the endpoint reads the image by; fetch takes the header from it, so nothing is passed alongside it and nothing can contradict it. The three calls also send X-Atlassian-Token: no-check, which Jira requires — without it the upload is refused outright, with it and no content type the image is rejected as an unsupported format. Both were verified against a live site.

  • setUserColumns and setIssueNavigatorDefaultColumns take the columns. Both declare a ColumnRequestBody reference under a wildcard media type and nowhere else; only application/json was read, so the reference was missed and the body degraded to the same shapeless object. They now take columns: string[], like setColumns on a filter already did:

    await jira.users.setUserColumns({ columns: ['summary', 'status'] });

Types

  • Those three methods are typed Promise<Blob>, where they were Promise<StreamingResponseBody>. Nothing that compiled against the old type can have been working — the call threw before returning — so the compiler pointing at these lines is the first honest signal about them. StreamingResponseBody itself is still exported; nothing else referenced it.

  • BlobSchema is exported from jira.js/core, beside BufferSchema. It marks an endpoint whose response is bytes with a content type worth keeping; the client reads such a response with response.blob() rather than parsing it as JSON.

  • The three upload bodies are typed Blob, where they were Record<string, any>. No call could have worked: the endpoints refuse a request without the XSRF header, which the old shape had no way to send.

  • setUserColumns and setIssueNavigatorDefaultColumns take columns: string[] in place of body. Unlike the avatar uploads, these two had a working form — { body: { columns: [...] } } reached Jira intact — so a call written that way needs the one-line change. { body: [...] }, the other reading the old type invited, was answered with 400.

  • The agile models point at their nested shapes instead of repeating them. A board's admins.users was written out in full in each of the models that carried a board, and the same held for changelog histories, column statuses and issue fields across twenty-one others. They now reference UserSchema, GroupSchema, BoardLocationSchema, RelationSchema, ChangelogSchema and the rest, each of which was exported already and describes the identical shape, field for field and constraint for constraint. Nothing validates differently, no description was lost, and every type is structurally what it was — a nested shape simply reports itself by name in an editor now, and the generated agile sources are a thousand lines shorter.

  • toggleFeatures takes a described body. It was typed Record<string, any> — an object of arbitrary keys — because the shape was declared inline and had no name to point at; the operation's own boardId collides with the body's, so its fields cannot be spread the way rankIssues spreads its own. The body is now FeatureToggleRequest: { boardId?, enabling?, feature? }. A call already passing those three fields is unchanged.

  • The agile model GetQuickFilter is deprecated in favour of QuickFilter. The two were the same six optional fields under two names, because the response was declared inline rather than by reference; it now resolves to the named schema, and getQuickFilter is typed Promise<QuickFilter>. The old name is still exported, still assignable and still the same type — an alias marked @deprecated, which an editor strikes through and which goes at the next major version. Nothing has to change today. The request parameter type of that name is untouched.

  • Four orderBy parameters list the fields they sort by. getPrecomputations, getPrecomputationsByID, getTrashedFieldsPaginated and searchWorkflows were typed string while their own documentation named the fields — functionKey, used, created, updated for the precomputations, and so on. Fifteen other orderBy parameters carry the list in the specification and were generated from it all along; these four carried it only in prose. They are now typed the same way, sort prefixes included:

    await jira.jqlFunctionsApps.getPrecomputationsByID({ precomputationIDs: [...], orderBy: '-created' });

    As everywhere else, the type stays open — 'created' | '-created' | '+created' | ... | (string & {}) — so an editor suggests the documented fields and any other string still compiles.

  • Five more agile models are deprecated in favour of the components they were copies of. createBoard and getBoard answer with Board, getAllBoards with PageBoard, getBoardByFilterId with PageBoardFilter, and getAllQuickFilters with PageQuickFilter. Each of those responses is declared inline in the specification, field for field the component sitting beside it, so the generator had nothing to name it after but the operation — and the component it duplicated went unused: no agile model referenced Board at all, while six of them wrote a board out in full. The retired names are still exported as @deprecated aliases of the new ones, assignable in both directions, and go at the next major version. Nothing has to change today.

    A board reports its type properly now, as a side effect worth naming. Board.type is 'scrum' | 'kanban' | 'simple' | (string & {}); every copy of it was a plain string, and since each of these methods returned a copy, the narrowing reached none of them. getBoard() and the boards inside getAllBoards().values carry it now.

  • A page of things is typed Page<T>. Atlassian restates the pagination envelope once per item type — PageBoard, PageUser, PagedArticle, ninety-odd of them across the three APIs, identical but for what sits in values — and each generated a model of its own. So a page of boards and a page of users were two unrelated shapes with the same seven fields, and nothing said they were the same idea. Each API now has one Page<T>, and the endpoints answering with a page are typed with it:

    const boards: Page<Board> = await agile.board.getAllBoards();
    const comments: Page<Comment> = await jira.issueComments.getCommentsByIds({ ids: [10000, 10001] });

    Three generics, not one: the envelopes genuinely differ. Cloud's carries nextPage and self, Agile's does not, and Service Desk's is _expands/_links/isLastPage/limit/size/start — giving Agile cloud's would document two fields Jira Software never sends. Each is exported from its own entry point, all three under the name Page.

    Nothing is removed and nothing changes shape: the 82 retired names — 62 in cloud, 17 in Service Desk, 3 in Agile — remain exported as @deprecated aliases of the generic (type PageBoard = Page<Board>), assignable in both directions, going at the next major version. The schemas keep their own names, since PageBoardSchema is the only handle on the runtime schema. Every page type was compared against the one it replaces, in both directions, before this shipped.

    Only exact matches folded. A page that differs by a field, a description or a format — the cursor-based pages, PageOfChangelogs, PageOfComments, PageOfWorklogs, PagedLink — generates exactly as it did.

    The browser bundle drops from 481 kB to 471 kB, and the generated sources by a thousand lines: 82 copies of an envelope became three.

  • A page's own fields are no longer optional. isLast, maxResults, startAt, total and values were all typed T | undefined, so reading a page meant reaching past a ?? [] and a ?? 0 that never fire:

    const page = await jira.projects.searchProjects();
    
    for (const project of page.values) { /* was: page.values ?? [] */ }

    Atlassian marks the whole envelope optional, and that is what the generator had to go on. Measured against a live site instead, those five came back on all 32 page responses across 23 platform endpoints and the agile board listings. The two that genuinely are conditional stay optional: self is absent from five of those endpoints, and nextPage appears only while a next page exists.

    Service Desk's pages are untouched — all seven of their fields stay optional. They cannot be reached from the test site, which holds no Service Management licence, and the only real captures to be found show _expands present on one endpoint and absent on its neighbour. Guessing from Atlassian's examples is what this change is getting away from.

    Reading a page is only ever safer for the change. Constructing one is not: a Page<T> written by hand — a fixture, a mock, a stub returned from a wrapper — now has to carry all five fields, and PageBoardSchema.parse() over such an object fails where it used to pass.

  • Eleven cloud models lose the name of the serializer that made them. Page2ComponentJsonSchema read like an implementation detail because it was one: the 2 is the version of Atlassian's own Java class, and Json and Jackson1 name the serializer that produced it. Neither describes anything a caller can act on — PageBean2X and PageBeanX carry the same seven fields, and no page is declared in both forms.

    was is
    Page2ComponentJson PageComponent
    Page2FieldAssociationSchemeFieldSearchResult PageFieldAssociationSchemeFieldSearchResult
    Page2FieldAssociationSchemeProjectSearchResult PageFieldAssociationSchemeProjectSearchResult
    Page2GetFieldAssociationSchemeResponse PageGetFieldAssociationSchemeResponse
    Page2GetProjectsWithFieldSchemesResponse PageGetProjectsWithFieldSchemesResponse
    Page2ProjectField PageProjectField
    ComponentJson Component
    CustomFieldDefinitionJson CustomFieldDefinition
    LinkIssueRequestJson LinkIssueRequest
    NotificationSchemeAndProjectMappingJson NotificationSchemeAndProjectMapping
    JiraLabelPropertiesInputJackson1 JiraLabelProperties

    Every retired name is still exported, as a @deprecated alias of its replacement — both the schema and the type — assignable in both directions and going at the next major version. Nothing has to change today. Page2JqlFunctionPrecomputation had been renamed by hand some releases ago, which is what suggested the rest were an oversight rather than a decision.

    Two names keep their Json on purpose. ResolutionJson would collide with the Resolution that describes a different shape, and TaskProgressJsonNode is one of four models that differ only in their result field — it wants the treatment the pages just had, not a new name. JsonNode, JsonType and JsonContextVariable are named after JSON for a reason and are untouched.

  • createCustomField lists the field types it accepts. type was string while its own documentation named all twenty-one built-in types, and searcherKey beside it had been an enum all along — the difference being that Atlassian put that one's values in the specification and this one's only in prose:

    await jira.issueFields.createCustomField({
      name: 'Story points',
      type: 'com.atlassian.jira.plugin.system.customfieldtypes:float',
    });

    The type stays open, which here is not a formality: a site carries plugin and Forge field types — com.atlassian.jpo:jpo-custom-field-parent, com.pyxis.greenhopper.jira:gh-sprint — that no list of Atlassian's will ever name, and every one of them still compiles.

    Two of the twenty-one are in the list only because the description was read twice. Atlassian's own bullets leave the value of multicheckboxes and multigrouppicker empty and give multiselect and multiuserpicker their neighbours' values, so reading the stated values alone drops two real types — one of which, multiuserpicker, a live site answers with.

General

  • A parameter type built on a model is written as one call. 139 of them read z.object({}).extend(BoardCreateSchema.shape) — an empty object, then everything merged onto it. They are z.object(BoardCreateSchema.shape) now. The schema is the same object either way, and nothing about the types changes; it is the generated sources that were harder to read than the thing they describe.
  • The writes are covered live now. All three uploads store an image against the test site and delete it again, the filter, account and site-wide column endpoints are set and restored, and the avatar just uploaded is read back through getAvatarImageByID — the two halves proving each other. None of this had a single test before, which is how a body typed as an object survived a major release.
  • The live test for these endpoints was passing without testing anything. It looked for avatarId= in a project's avatarUrls, which give the path form and carry no such parameter, so the match failed, the test returned on its second line, and every assertion below it — including the one a SchemaMismatchError would have failed — was unreachable. That is why this shipped. The test now takes its avatar id from getAllSystemAvatars, asserted non-empty by the test above it, and has no branch that can turn it off; the two remaining image endpoints are covered as well.