Skip to content

Create @enonic-types/lib-http-client types package #226

Description

@rymsha

Publish a proper TypeScript types package (@enonic-types/lib-http-client) alongside the JAR so consumers can import type from /lib/http-client without hand-maintaining local ambient declarations.

Motivation

Several downstream apps currently ship their own copies of a http-client.d.ts (e.g. app-features/src/main/resources/types/http-client.d.ts). These copies drift from the actual lib API:

  • connectionTimeout is misspelled as connectTimeout and typed number | string (should be number).
  • readTimeout typed number | string (should be number).
  • Missing options: queryParams, disableHttp2, multipart, followRedirects, certificates, clientCertificate.
  • body in the request typed string only — actually accepts string | ByteSource.
  • Response cookies typed as Record<string, string> — actually an array of cookie objects {name, value, path, domain, expires, secure, httpOnly}.
  • Response headers typed as Record<string, string> — actually values may be string | string[] for repeated headers.
  • Missing response fields: bodyStream.

Every consumer independently re-invents these — and gets them subtly wrong.

Proposal

Add a small types/ directory to this repository:

  • types/index.d.ts — ambient declare module \"/lib/http-client\" covering the single request(params) export, verified against the JS bridge (src/main/resources/lib/http-client.js) and the Java bean (HttpRequestHandler, ResponseMapper).
  • types/package.json@enonic-types/lib-http-client manifest (version substituted at build time, dependency on @enonic-types/core).
  • build.gradle — a small assembleTypes Copy task that materialises build/types/ with the project version substituted; wire jar.dependsOn assembleTypes.
  • .github/workflows/enonic-gradle.yml — add npmPublish: true to the build-and-publish step and the id-token: write / contents: write permissions required by OIDC trusted publishing.

Reference implementation: enonic/lib-mustache#66.

The first publish of a brand-new @enonic-types/lib-http-client will need the npm trusted-publisher / package access configured org-side. Depends on enonic/release-tools#71 (merged).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions