Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
4cecf83
feat(compiler): Add JavaScript/TypeScript IDL code generation for gRPC
miantalha45 Feb 23, 2026
42c840c
Fix linting issues
miantalha45 Feb 23, 2026
1cf6e76
chore: remove incorrect JavaScript codegen files
miantalha45 Feb 23, 2026
7d92cb2
feat(compiler): add TypeScript/JavaScript code generation
miantalha45 Feb 23, 2026
6dc214d
Pushing remaining changes
miantalha45 Feb 24, 2026
918f762
Fix linting issues
miantalha45 Feb 24, 2026
4fe3d0b
docs: improve TypeScript generator docstring
miantalha45 Feb 25, 2026
92cd483
fix(compiler): address Copilot code review comments on TypeScript gen…
miantalha45 Feb 25, 2026
361b2b6
Fix code generation for JS/TS
miantalha45 Feb 26, 2026
362eb44
Merge branch 'main' into generate-messageTypes-from-IDL
miantalha45 Feb 26, 2026
b33168b
Fix failing checks
miantalha45 Feb 26, 2026
8833cb1
Fix linting issues
miantalha45 Feb 26, 2026
3488282
Fix linting issue
miantalha45 Feb 26, 2026
469b122
chore(typescript): remove package-lock.json from tracking and add .gi…
miantalha45 Feb 28, 2026
a7f9b4e
Merge branch 'main' into generate-messageTypes-from-IDL
miantalha45 Feb 28, 2026
7fc0e87
ci(javascript): add TypeScript IDL tests to javascript_xlang CI job
miantalha45 Feb 28, 2026
61539b6
chore: apply formatter fixes (prettier, ruff)
miantalha45 Feb 28, 2026
eaf01c8
fix(typescript): align run_typescript_tests.sh with other language ID…
miantalha45 Feb 28, 2026
749889b
chore: trigger CI recheck
miantalha45 Feb 28, 2026
3abc1de
Addressing all comments from reviewer
miantalha45 Mar 1, 2026
75c679b
Fix failing checks
miantalha45 Mar 1, 2026
6d9a656
chore: trigger PR reprocessing
miantalha45 Mar 1, 2026
b2bfd69
fix(docs): fix mismatched code fence in generated-code.md
miantalha45 Mar 1, 2026
a4570bd
chore: trigger PR reprocessing
miantalha45 Mar 1, 2026
0368926
Rename TS to JS
miantalha45 Mar 1, 2026
7d4ba20
style: wrap long line in test_javascript_codegen.py
miantalha45 Mar 1, 2026
4472a21
Fix all changes told in comments
miantalha45 Mar 7, 2026
cd6d54d
Merge branch 'main' into generate-messageTypes-from-IDL
chaokunyang Mar 18, 2026
449eaee
One failing tests fixed
miantalha45 Mar 18, 2026
c235ec6
Add new renamed imports
miantalha45 Mar 18, 2026
11bbea6
Fix failing tests
miantalha45 Mar 23, 2026
41859bc
Merge branch 'main' into generate-messageTypes-from-IDL
miantalha45 Mar 23, 2026
82e1212
Merge branch 'main' into generate-messageTypes-from-IDL
miantalha45 Mar 23, 2026
3bda7c4
Fix failing xlang tests
miantalha45 Mar 28, 2026
e9d5066
Merge branch 'main' into generate-messageTypes-from-IDL
miantalha45 Mar 28, 2026
8099090
Updated tests for compatible format
miantalha45 Apr 1, 2026
421cec7
Fix failing CI checks
miantalha45 Apr 1, 2026
e5c0f42
Merge branch 'main' into generate-messageTypes-from-IDL
miantalha45 Apr 1, 2026
f611010
Fix xlang tests
miantalha45 Apr 1, 2026
25753ab
Revert "Fix xlang tests"
miantalha45 Apr 2, 2026
419ad85
Fix naming conventions for JS
miantalha45 Apr 2, 2026
2316a5e
Fix js compiler test naming conventions
miantalha45 Apr 2, 2026
19f7785
Fix naming conventions for nested structs/enums
miantalha45 Apr 3, 2026
e78140d
Fix formatting
miantalha45 Apr 3, 2026
3fa17e9
PascalCase for class names in JS
miantalha45 Apr 3, 2026
1681189
Fix failing test
miantalha45 Apr 4, 2026
66cb436
fix failing idl tests
miantalha45 Apr 5, 2026
2c6d901
trigger CI
miantalha45 Apr 5, 2026
dfa843b
Merge branch 'main' into generate-messageTypes-from-IDL
miantalha45 Apr 5, 2026
d4fdff3
Fix copilot suggestions
miantalha45 Apr 6, 2026
bec6ee6
Merge branch 'main' into generate-messageTypes-from-IDL
miantalha45 Apr 6, 2026
7fc4c64
Merge branch 'main' into generate-messageTypes-from-IDL
miantalha45 Apr 7, 2026
d839521
Add union support in JS generator
miantalha45 Apr 7, 2026
23ea5cc
Fix code style
miantalha45 Apr 7, 2026
4d22f45
fix the comments
miantalha45 Apr 7, 2026
f121c6b
fix comments
miantalha45 Apr 8, 2026
64e4c6a
Some enhancements
miantalha45 Apr 8, 2026
14526d6
some fixes
miantalha45 Apr 8, 2026
990671a
trigger CI
miantalha45 Apr 8, 2026
0dcb2f8
address AI Review
miantalha45 Apr 9, 2026
7157506
Merge branch 'main' into generate-messageTypes-from-IDL
miantalha45 Apr 9, 2026
b1699b6
trigger CI
miantalha45 Apr 9, 2026
6558a01
trigger CI
miantalha45 Apr 9, 2026
a5477b1
Fix offset issue from collection.ts file
miantalha45 Apr 9, 2026
6f10ab9
fixes
miantalha45 Apr 11, 2026
f36f49a
Merge branch 'main' into generate-messageTypes-from-IDL
miantalha45 Apr 11, 2026
36164aa
Fix failing CI
miantalha45 Apr 13, 2026
0b996a3
Merge branch 'main' into generate-messageTypes-from-IDL
miantalha45 Apr 13, 2026
28ca89a
Fix code style
miantalha45 Apr 13, 2026
24481f9
Change refTracking to ref
miantalha45 Apr 13, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ jobs:
run: |
cd javascript
npm install
npm run build
- name: Run JavaScript Xlang Test
env:
FORY_JAVASCRIPT_JAVA_CI: "1"
Expand All @@ -502,6 +503,8 @@ jobs:
mvn -T16 --no-transfer-progress clean install -DskipTests -Dmaven.javadoc.skip=true -Dmaven.source.skip=true
cd fory-core
mvn --no-transfer-progress test -Dtest=org.apache.fory.xlang.JavaScriptXlangTest -DforkCount=0
- name: Run JavaScript IDL Tests
run: ./integration_tests/idl_tests/run_javascript_tests.sh

rust:
name: Rust CI
Expand Down
58 changes: 39 additions & 19 deletions compiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The FDL compiler generates cross-language serialization code from schema definit

## Features

- **Multi-language code generation**: Java, Python, Go, Rust, C++, C#
- **Multi-language code generation**: Java, Python, Go, Rust, C++, C#, JavaScript, and Swift
- **Rich type system**: Primitives, enums, messages, lists, maps
- **Cross-language serialization**: Generated code works seamlessly with Apache Fory
- **Type ID and namespace support**: Both numeric IDs and name-based type registration
Expand Down Expand Up @@ -64,16 +64,16 @@ message Cat [id=103] {
foryc schema.fdl --output ./generated

# Generate for specific languages
foryc schema.fdl --lang java,python,csharp --output ./generated
foryc schema.fdl --lang java,python,csharp,javascript --output ./generated

# Override package name
foryc schema.fdl --package myapp.models --output ./generated

# Language-specific output directories (protoc-style)
foryc schema.fdl --java_out=./src/main/java --python_out=./python/src --csharp_out=./csharp/src/Generated
foryc schema.fdl --java_out=./src/main/java --python_out=./python/src --csharp_out=./csharp/src/Generated --javascript_out=./javascript

# Combine with other options
foryc schema.fdl --java_out=./gen --go_out=./gen/go --csharp_out=./gen/csharp -I ./proto
foryc schema.fdl --java_out=./gen --go_out=./gen/go --csharp_out=./gen/csharp --javascript_out=./gen/js -I ./proto
```

### 3. Use Generated Code
Expand Down Expand Up @@ -185,19 +185,19 @@ message Config { ... } // Registered as "package.Config"

### Primitive Types

| FDL Type | Java | Python | Go | Rust | C++ | C# |
| ----------- | ----------- | ------------------- | ----------- | ----------------------- | ---------------------- | ---------------- |
| `bool` | `boolean` | `bool` | `bool` | `bool` | `bool` | `bool` |
| `int8` | `byte` | `pyfory.int8` | `int8` | `i8` | `int8_t` | `sbyte` |
| `int16` | `short` | `pyfory.int16` | `int16` | `i16` | `int16_t` | `short` |
| `int32` | `int` | `pyfory.int32` | `int32` | `i32` | `int32_t` | `int` |
| `int64` | `long` | `pyfory.int64` | `int64` | `i64` | `int64_t` | `long` |
| `float32` | `float` | `pyfory.float32` | `float32` | `f32` | `float` | `float` |
| `float64` | `double` | `pyfory.float64` | `float64` | `f64` | `double` | `double` |
| `string` | `String` | `str` | `string` | `String` | `std::string` | `string` |
| `bytes` | `byte[]` | `bytes` | `[]byte` | `Vec<u8>` | `std::vector<uint8_t>` | `byte[]` |
| `date` | `LocalDate` | `datetime.date` | `time.Time` | `chrono::NaiveDate` | `fory::Date` | `DateOnly` |
| `timestamp` | `Instant` | `datetime.datetime` | `time.Time` | `chrono::NaiveDateTime` | `fory::Timestamp` | `DateTimeOffset` |
| FDL Type | Java | Python | Go | Rust | C++ | C# | JavaScript |
| ----------- | ----------- | ------------------- | ----------- | ----------------------- | ---------------------- | ---------------- | ------------------ |
| `bool` | `boolean` | `bool` | `bool` | `bool` | `bool` | `bool` | `boolean` |
| `int8` | `byte` | `pyfory.int8` | `int8` | `i8` | `int8_t` | `sbyte` | `number` |
| `int16` | `short` | `pyfory.int16` | `int16` | `i16` | `int16_t` | `short` | `number` |
| `int32` | `int` | `pyfory.int32` | `int32` | `i32` | `int32_t` | `int` | `number` |
| `int64` | `long` | `pyfory.int64` | `int64` | `i64` | `int64_t` | `long` | `bigint \| number` |
| `float32` | `float` | `pyfory.float32` | `float32` | `f32` | `float` | `float` | `number` |
| `float64` | `double` | `pyfory.float64` | `float64` | `f64` | `double` | `double` | `number` |
| `string` | `String` | `str` | `string` | `String` | `std::string` | `string` | `string` |
| `bytes` | `byte[]` | `bytes` | `[]byte` | `Vec<u8>` | `std::vector<uint8_t>` | `byte[]` | `Uint8Array` |
| `date` | `LocalDate` | `datetime.date` | `time.Time` | `chrono::NaiveDate` | `fory::Date` | `DateOnly` | `Date` |
| `timestamp` | `Instant` | `datetime.datetime` | `time.Time` | `chrono::NaiveDateTime` | `fory::Timestamp` | `DateTimeOffset` | `Date` |

### Collection Types

Expand Down Expand Up @@ -285,7 +285,8 @@ fory_compiler/
├── go.py # Go struct generator
├── rust.py # Rust struct generator
├── cpp.py # C++ struct generator
└── csharp.py # C# class generator
├── csharp.py # C# class generator
└── javascript.py # JavaScript interface generator
```

### FDL Frontend
Expand Down Expand Up @@ -422,6 +423,25 @@ cd integration_tests/idl_tests
./run_csharp_tests.sh
```

### JavaScript

Generates interfaces with:

- `export interface` declarations for messages
- `export enum` declarations for enums
- Discriminated unions with case enums
- Registration helper function

```javascript
export interface Cat {
friend?: Dog | null;
name?: string | null;
tags: string[];
scores: Map<string, number>;
lives: number;
}
```

## CLI Reference

```
Expand All @@ -431,7 +451,7 @@ Arguments:
FILES FDL files to compile

Options:
--lang TEXT Target languages (java,python,cpp,rust,go,csharp or "all")
--lang TEXT Target languages (java,python,cpp,rust,go,csharp,javascript or "all")
Default: all
--output, -o PATH Output directory
Default: ./generated
Expand Down
11 changes: 10 additions & 1 deletion compiler/fory_compiler/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ def parse_args(args: Optional[List[str]] = None) -> argparse.Namespace:
"--lang",
type=str,
default="all",
help="Comma-separated list of target languages (java,python,cpp,rust,go,csharp,swift). Default: all",
help="Comma-separated list of target languages (java,python,cpp,rust,go,csharp,javascript,swift). Default: all",
)

parser.add_argument(
Expand Down Expand Up @@ -343,6 +343,14 @@ def parse_args(args: Optional[List[str]] = None) -> argparse.Namespace:
help="Generate C# code in DST_DIR",
)

parser.add_argument(
"--javascript_out",
type=Path,
default=None,
metavar="DST_DIR",
help="Generate JavaScript code in DST_DIR",
)

parser.add_argument(
"--swift_out",
type=Path,
Expand Down Expand Up @@ -650,6 +658,7 @@ def cmd_compile(args: argparse.Namespace) -> int:
"go": args.go_out,
"rust": args.rust_out,
"csharp": args.csharp_out,
"javascript": args.javascript_out,
"swift": args.swift_out,
}

Expand Down
3 changes: 3 additions & 0 deletions compiler/fory_compiler/generators/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from fory_compiler.generators.rust import RustGenerator
from fory_compiler.generators.go import GoGenerator
from fory_compiler.generators.csharp import CSharpGenerator
from fory_compiler.generators.javascript import JavaScriptGenerator
from fory_compiler.generators.swift import SwiftGenerator

GENERATORS = {
Expand All @@ -33,6 +34,7 @@
"rust": RustGenerator,
"go": GoGenerator,
"csharp": CSharpGenerator,
"javascript": JavaScriptGenerator,
"swift": SwiftGenerator,
Comment on lines 24 to 38
Copy link

Copilot AI Apr 9, 2026

Choose a reason for hiding this comment

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

PR description references a new compiler/fory_compiler/generators/typescript.py and a TypeScriptGenerator, but the implementation added in this PR is compiler/fory_compiler/generators/javascript.py with JavaScriptGenerator registered under the javascript language. Please update the PR description (or naming) to match the actual generator/module names to avoid confusion for reviewers and users.

Copilot uses AI. Check for mistakes.
}

Expand All @@ -44,6 +46,7 @@
"RustGenerator",
"GoGenerator",
"CSharpGenerator",
"JavaScriptGenerator",
"SwiftGenerator",
"GENERATORS",
]
Loading
Loading