Skip to content

Map framings and codecs through the request's encodings (core#120 B4) - #92

Merged
Kinflou merged 1 commit into
mainfrom
encodings/use-request-mappings
Oct 31, 2026
Merged

Kinflou merged 1 commit into
mainfrom
encodings/use-request-mappings

Conversation

@Kinflou

@Kinflou Kinflou commented Oct 31, 2026

Copy link
Copy Markdown
Member

Step B4 of core#120 for TypeScript.

  • framing_choice and the package codec now read GenerateRequest.encodings. The framing_for / codec_class / default_codec tables are gone.
  • generate_typescript calls comline_codegen::encodings::check first: an unmapped used encoding is an error, never assumed known. MessagePack still hits the support table's refusal first.
  • Imports: a mapped class whose package is @comline/runtime goes in the runtime import, in the same order as before, so the official output is byte-identical. A class from another package gets import { A, B } from "<package>"; after it. A mapping with no package imports nothing (the class is in scope already).
  • lib: each mapped package a file imports from is added to package.json dependencies (its version, or "*"), beside the runtime and std.
  • The TS handshake stays implicit in the runtime's Connection/Client. check still requires comline@1 to be mapped.

Tests

  • a_third_party_framing_and_codec_are_imported_from_their_package keeps runtime/test/generated/acme.ts, a protocol over com.acme.lines@1 and com.acme.cbor@1 mapped onto acme-encodings. typecheck, typecheck:generated and the TypeScript 5.0.4 floor check it against a stub of that package, runtime/test/generated/acme-encodings.ts, mapped through paths.
  • an_unmapped_framing_is_an_error_not_a_fallback and lib_output_depends_on_a_mapped_package.
  • These pass locally: cargo test, xtask --check (std-extra unchanged), npm run typecheck, npm test, typecheck:generated and the 5.0.4 floor.

Pins generation b116831 from ComlineProject/generation#88. Merge after that PR.

framing_choice and the package's codec read GenerateRequest.encodings
instead of a name-to-class table, and generate_typescript refuses an
encoding the package uses with no mapping (encodings::check) instead of
assuming a known framing. A mapped class from @comline/runtime goes in
the runtime import as before, so the official output is unchanged; one
from any other package gets an import of its own.

lib mode adds each mapped package a file imports from to package.json,
beside the runtime and std.

runtime/test/generated/acme.ts is a protocol over a third-party framing
and codec, type-checked (with the TypeScript 5.0 floor too) against a stub
of their package, acme-encodings.ts.

Pins generation b116831 (encodings::resolve/check/official_for).
@Kinflou
Kinflou merged commit 18ee710 into main Oct 31, 2026
10 checks passed
@Kinflou
Kinflou deleted the encodings/use-request-mappings branch October 31, 2026 14:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant