Skip to content

feat(schemas): shared schema types - #35

Merged
BenPinet merged 13 commits into
nextfrom
fix/shared_types
Nov 20, 2026
Merged

BenPinet merged 13 commits into
nextfrom
fix/shared_types

Conversation

@JulienChampagnol

@JulienChampagnol JulienChampagnol commented Nov 19, 2026 •

Copy link
Copy Markdown
Member

Summary

One source of truth for the types used by the route schemas of the microservices.

  • Data types for TypeScript: generate_data_types.py also writes data_types.json (the values of each Literal type) and data_types.d.ts.
  • Shared schema types: each package defines the types it is the lowest to use in src/<package>/schema_types.json, generated as dataclasses (schema_types.py) and interfaces (schema_types.d.ts).
    • The generator reads the schema_types.json of the package and of its @geode/* dependencies; a type defined twice is an error.
    • A type can extends another one (ColorRGBA extends ColorRGB).
    • Non object types get aliases (DataId = str, export type DataId = string), and the generated code names them: id: DataId instead of id: str.
    • This package only defines DataId and GeodeId (its database uses them). Back defines CRS, the model components, and with Viewer ViewerId, AttributeName, Filename and Point3D; Viewer defines the colors and styles. Packages not depending on each other may define the same type, with the same definition.
  • Route schemas only name the shared types: a field is just {"title": "ColorRGBA"}.
    • The generator expands it in every generated file (combined *_schemas.json, Python and TypeScript types), which import the shared type instead of declaring their own.
    • It writes src/<package>/schema_definitions.json for the runtime.
  • Runtime: load_schema and get_schemas_dict expand the shared types from that file, so fastjsonschema still validates the full schemas.
  • Database: Data.id is a DataId and Data.geode_id a GeodeId.
  • The npm package now ships generate_schema_types.js and schema_types.py, needed by the generator in the other repos.

Test plan

  • ruff, mypy, oxfmt and oxlint clean
  • New tests for the runtime expansion (tests/test_schemas.py)
  • Back (172), Viewer (310) and Vease-Modeling-Back (30) tests pass with the regenerated schemas; the generated Python, TypeScript and combined JSON are identical to before the stubbing

🤖 Generated with Claude Code

JulienChampagnol and others added 4 commits November 19, 2026 15:14
generate_data_types.py writes the values of each Literal type of data_types.py
(data_types.json) and their TypeScript unions (data_types.d.ts).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each package defines the schema types it is the lowest to use in its
schema_types.json, generated as dataclasses and TypeScript interfaces.
A type can extend another one (ColorRGBA extends ColorRGB).
Only DataId, GeodeId, ViewerId, AttributeName, Filename and Point3D are used by
both OpenGeodeWeb-Back and OpenGeodeWeb-Viewer, so they are defined here.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A field titled after a shared type (e.g. {"title": "ColorRGBA"}) is expanded in the
generated files, and the generated code imports the shared type instead of
declaring its own.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
load_schema and get_schemas_dict expand them from the schema_definitions.json
generated in the package.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JulienChampagnol and others added 8 commits November 19, 2026 15:52
DataId, GeodeId, ViewerId, AttributeName and Filename are now importable types
(e.g. DataId = str, export type DataId = string).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ColorRGB and ColorRGBA are defined by OpenGeodeWeb-Viewer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A field titled after an alias (e.g. {"title": "DataId"}) is typed with it
(id: DataId) instead of its own type (id: str). A route module declaring a class
named like an alias (the Visibility params) imports it as VisibilityType.
The generated modules importing shared types keep them as runtime imports.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
In the generated TypeScript, a field described on one line is followed by its
description (points: ColorMapPoints; // Flat array of [value, r, g, b, ...])
instead of a block comment above it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ViewerId, AttributeName, Filename and Point3D are defined by OpenGeodeWeb-Back and
OpenGeodeWeb-Viewer. Packages not depending on each other may define the same
type: a package seeing both requires the same definition. A package may only
define aliases.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
BlockIds = list[ViewerId] instead of list[int], each alias declared after the
ones it uses.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… package

The CI installs the dependencies of a package in its node_modules, but removes
their "0.0.0" versions from its package.json: the generator did not see them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A response that is a shared type (the {x, y, z} of get_point_position is a
Point3D) was replaced by it, but the Schemas tree still named it: it is now an
alias of the shared type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
from sqlalchemy import String, select
from sqlalchemy.orm import Mapped, mapped_column

from opengeodeweb_microservice.schema_types import DataId, GeodeId # noqa: TC001

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is # noqa: TC001 ?

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.

3 participants