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).
Publish a proper TypeScript types package (
@enonic-types/lib-http-client) alongside the JAR so consumers canimport typefrom/lib/http-clientwithout 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:connectionTimeoutis misspelled asconnectTimeoutand typednumber | string(should benumber).readTimeouttypednumber | string(should benumber).queryParams,disableHttp2,multipart,followRedirects,certificates,clientCertificate.bodyin the request typedstringonly — actually acceptsstring | ByteSource.cookiestyped asRecord<string, string>— actually an array of cookie objects{name, value, path, domain, expires, secure, httpOnly}.headerstyped asRecord<string, string>— actually values may bestring | string[]for repeated headers.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— ambientdeclare module \"/lib/http-client\"covering the singlerequest(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-clientmanifest (version substituted at build time, dependency on@enonic-types/core).build.gradle— a smallassembleTypesCopy task that materialisesbuild/types/with the project version substituted; wirejar.dependsOn assembleTypes..github/workflows/enonic-gradle.yml— addnpmPublish: trueto thebuild-and-publishstep and theid-token: write/contents: writepermissions required by OIDC trusted publishing.Reference implementation: enonic/lib-mustache#66.
The first publish of a brand-new
@enonic-types/lib-http-clientwill need the npm trusted-publisher / package access configured org-side. Depends on enonic/release-tools#71 (merged).