Skip to content

Improve generated types: discriminated unions, schema flattening, spec overrides - #4

Merged
javrrr merged 4 commits into
mainfrom
fix/empty-abstract-input-bases
Mar 26, 2026
Merged

Improve generated types: discriminated unions, schema flattening, spec overrides#4
javrrr merged 4 commits into
mainfrom
fix/empty-abstract-input-bases

Conversation

@javrrr

@javrrr javrrr commented Mar 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • Discriminated unions for connector inputs (DataStreamConnectorInput, ConnectionCreateInput, ConnectionUpdateInput) — generated from a config validated against the spec's oneOf entries. Checking connectorType now narrows connectorDetails to the correct config type.
  • Schema flattening — 332 allOf schemas are pre-resolved into flat object types at generation time, so IntelliSense hovers and error messages show readable property lists instead of A & B & C intersection chains.
  • Schema overrides (SCHEMA_OVERRIDES) — structured config to patch spec bugs: relaxes incorrectly required fields (mappings, sourceFields, orgUnitIdentifierFieldName, recordModifiedFieldName) and fixes dataLakeObjectInfo array-only type to accept single objects.
  • Simplify<T> utility type for complex intersections.
  • Escape hatches — service methods accept the strict discriminated union OR the raw generated type, so unknown/future connector types aren't blocked.
  • scripts/README.md — documents the full generation pipeline, flattening, overrides, and discriminated union config.

Test plan

  • npm run generate — validates all configs against the spec, no errors or warnings
  • npm run typecheck — clean compile including scripts/type-tests.ts assertions
  • npm test — 211 tests pass
  • npm run build && npm pack — tarball builds with .d.ts files included
  • Verified in consuming repo: flat type hovers, discriminated union narrowing, spec override fields optional

javrrr added 4 commits March 26, 2026 02:21
Normalize selected empty allOf input base schemas from Record<string, never> to {} so intersection child configs are constructible, and add compile-time type tests plus spec hash pinning to keep generation deterministic.

Made-with: Cursor
Add a DataStreamCreateInput override so create() accepts either a single DLO object or an array, matching observed runtime API behavior while keeping generated schema types intact.

Made-with: Cursor
- Discriminated unions for connector inputs (DataStreamConnectorInput,
  ConnectionCreateInput, ConnectionUpdateInput) generated from a config
  validated against the spec's oneOf entries.
- Flatten 332 allOf schemas into plain object types for readable
  IntelliSense hovers and error messages.
- Structured SCHEMA_OVERRIDES to patch spec bugs: relax incorrectly
  required fields (mappings, sourceFields, orgUnitIdentifierFieldName,
  recordModifiedFieldName) and fix dataLakeObjectInfo array-only type.
- Add Simplify<T> utility type for complex intersections.
- Service methods accept strict discriminated unions with raw type
  escape hatches for unknown connector types.
- Add scripts/README.md documenting the generation pipeline.
@javrrr
javrrr merged commit 42530ea into main Mar 26, 2026
1 check passed
@javrrr
javrrr deleted the fix/empty-abstract-input-bases branch March 26, 2026 03:35
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