language
language copied to clipboard
Better support for modules in java
The Java implementation does not yet support some module specific logic, such as converting a set of module files to a full model and back.
For reference, the main code that handles modules are:
- Go:
- https://github.com/openfga/language/blob/main/pkg/go/transformer/module-to-model.go
- https://github.com/openfga/language/blob/main/pkg/go/transformer/mod-to-json.go
- test runners:
- https://github.com/openfga/language/blob/main/pkg/go/transformer/mod-to-json_test.go
- https://github.com/openfga/language/blob/main/pkg/go/transformer/module-to-model_test.go
- JS:
- https://github.com/openfga/language/blob/main/pkg/js/util/model_utils.ts#L10-L23 (given a model with modules, give me the list of modules)
- Tests for it: https://github.com/openfga/language/blob/main/pkg/js/util/model_utils.test.ts#L6-L69
- https://github.com/openfga/language/tree/main/pkg/js/transformer/modules
- test runners: https://github.com/openfga/language/tree/main/pkg/js/tests/modules
The tests are shared across all packages, and only the test runner needs to be implemented. Test data specific to modules
- https://github.com/openfga/language/blob/main/tests/data/fga-mod-transformer-cases.yaml
- https://github.com/openfga/language/tree/main/tests/data/transformer-module
For those interested, there is an early discovery branch @ewanharris started a long while back that you can take inspiration from: https://github.com/openfga/language/commits/feat/java-modular-transform/
I'm starting to work on this improvement. The linked branch is very outdated, I'm binging that up to speed first.