Commit Graph

120 Commits

Author SHA1 Message Date
Piotr Siuszko
f7314a3438 Update docs 2025-07-10 20:16:11 +02:00
Piotr Siuszko
dd20a3bd34 Remove ReflectJsonSchema, functionality is provided by CustomInternalSchemaData 2025-07-10 19:23:10 +02:00
Piotr Siuszko
f404446756 Introduce fields: title, rust_fields_info, replace pattern_properties
with pattern and property_names
2025-07-10 17:17:22 +02:00
Piotr Siuszko
cc0bd1b481 Update TypeReferencePath 2025-07-10 10:58:48 +02:00
Piotr Siuszko
f2dd14c8aa Simplify encoding of the def ids 2025-07-09 19:21:16 +02:00
Piotr Siuszko
2800e77ef9 Allow providing CustomInternalSchemaData instead of only adding data for
forcing as array.
2025-07-09 19:14:49 +02:00
Piotr Siuszko
5ad2351c2a Make one_of field in top schema optional, disabled by default. 2025-07-09 16:59:48 +02:00
MevLyshkin
ebe6e04407
Merge branch 'main' into proper-json-schema 2025-07-09 09:37:48 +02:00
François Mockers
1cbd67f96a
formatting fix in bevy_remote cargo.toml (#20033)
# Objective

- bevy_log is not "others". it's part of Bevy

## Solution

- Move it
- Also use the same format as other Bevy dependency (path first) as I
use it in some regexes to run tests on the repo
2025-07-08 17:02:02 +00:00
Piotr Siuszko
2b2fbdce28 Remove eprint 2025-07-08 18:14:30 +02:00
Piotr Siuszko
f5cb1c78b0 export schema now stores possible values to serialize in top 'one_of' field, support for Unit like structs serialization" 2025-07-08 17:45:37 +02:00
Piotr Siuszko
e07b19510c TypeReferenceId RFC 3986 support improvements 2025-07-07 19:45:32 +02:00
Piotr Siuszko
bc52a1ad5a Fix compilation, add more glam types 2025-07-07 18:10:07 +02:00
Piotr Siuszko
67d5857ec0 Update Cargo.toml 2025-07-07 17:37:19 +02:00
Piotr Siuszko
7eb31ac648 Register more glam types as arrays 2025-07-07 17:37:19 +02:00
Piotr Siuszko
bbe9798846 Remove some of the feature specific types, simplify the code 2025-07-07 17:14:53 +02:00
Piotr Siuszko
06c4a96c0d Ref type means no schema type 2025-07-06 22:39:57 +02:00
Piotr Siuszko
84bcdb9651 More logic in trait, start removing old code 2025-07-06 22:34:15 +02:00
Piotr Siuszko
b6d55b5b2c Move more logic into trait for TypeRegistry, better defs id generation 2025-07-06 18:48:12 +02:00
Piotr Siuszko
64807b0d38 Reworked building type dependencies list 2025-07-06 11:30:34 +02:00
Piotr Siuszko
0ff3201c3c Missing definitions handling 2025-07-05 13:15:06 +02:00
Piotr Siuszko
23ca435e73 Cleanup, support for Cow<str> 2025-07-05 12:05:33 +02:00
Piotr Siuszko
a58f697363 Add helper trait for registering schema types 2025-07-05 11:43:27 +02:00
Piotr Siuszko
daf03b5b3a Restore a as a f32 field, add separate unsigned field in test struct 2025-07-05 09:46:01 +02:00
Piotr Siuszko
4b8d0064ef Fixes for NonZero types, store typepath for primitive types 2025-07-05 09:07:40 +02:00
Piotr Siuszko
0b375625e0 Basic support for NonZero types with not field 2025-07-05 08:22:40 +02:00
Piotr Siuszko
492ad8be31 Remove id field 2025-07-05 07:53:22 +02:00
Piotr Siuszko
714d56e1ed Use oneOf for Option types, use jsonschema for testing schemas 2025-07-04 17:24:59 +02:00
MevLyshkin
efec7d192f
Merge branch 'main' into proper-json-schema 2025-07-04 09:32:07 +02:00
Piotr Siuszko
15125a3de5 Docs fix 2025-07-04 09:31:26 +02:00
Joe Buehler
d16d216083
Add support for returning all Component and values to query method in the Bevy Remote Protocol (#19857)
# Objective

We should have an API with filtering to allow BRP clients to retrieve
all relevant data from the world state. Currently working on adding
examples - but reviews are appreciated! Still semi-WIP while I get my
head around bevy’s reflection and implementation :)

## Solution

This change adds support to query all entities in the world, and returns
all of their Reflected Components with corresponding values. For custom
`Components` it's important to still implement `Reflect` so that this
endpoint returns these. This will be useful for the
`bevy_entity_inspector` so that we can easily get the current world
state. We have modified the existing query API
so that clients can now pass in an empty `components[]` on the JSON
request.

## Testing

Updated example to showcase how to use the new endpoint to get all data:
```rust
/// Create a query_all request to send to the remote Bevy app.
/// This request will return all entities in the app, their components, and their
/// component values.
fn run_query_all_components_and_entities(url: String) -> Result<(), anyhow::Error> {
    let query_all_req = BrpRequest {
        jsonrpc: String::from("2.0"),
        method: String::from(BRP_QUERY_METHOD),
        id: Some(serde_json::to_value(1)?),
        params: None,
    };
    println!("query_all req: {:#?}", query_all_req);
    let query_all_res = ureq::post(&url)
        .send_json(query_all_req)?
        .body_mut()
        .read_json::<serde_json::Value>()?;
    println!("{query_all_res:#}");
    Ok(())
}
```

---

## Showcase
In the `client.rs` example, we can clearly see (assuming the `server.rs`
is running) a query hit for all entities and components:
```text
query_all req: BrpRequest {
    jsonrpc: "2.0",
    method: "bevy/query",
    id: Some(
        Number(1),
    ),
    params: Some(
        Object {
            "data": Object {
                "components": Array [],
                "has": Array [],
                "option": Array [],
            },
            "filter": Object {
                "with": Array [],
                "without": Array [],
            },
            "strict": Bool(false),
        },
    ),
}
```

And in the massive response:
```text
.....
{
      "components": {
        "bevy_window::monitor::Monitor": {
          "name": "\\\\.\\DISPLAY1",
          "physical_height": 1080,
          "physical_position": [
            -1920,
            0
          ],
          "physical_width": 1920,
          "refresh_rate_millihertz": 240000,
          "scale_factor": 1.25,
          "video_modes": [
            {
              "bit_depth": 32,
              "physical_size": [
                1920,
                1080
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                1680,
                1050
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                1600,
                900
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                1440,
                900
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                1400,
                1050
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                1366,
                768
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                1360,
                768
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                1280,
                1024
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                1280,
                960
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                1280,
                800
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                1280,
                768
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                1280,
                720
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                1280,
                600
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                1152,
                864
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                1024,
                768
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                800,
                600
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                640,
                480
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                640,
                400
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                512,
                384
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                400,
                300
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                320,
                240
              ],
              "refresh_rate_millihertz": 240000
            },
            {
              "bit_depth": 32,
              "physical_size": [
                320,
                200
              ],
              "refresh_rate_millihertz": 240000
            }
          ]
        }
      },
      "entity": 4294967267
    },
....
```

What's also really cool about this and `bevy_reflect` is that we also
get custom components returned as well (see below for `"server::Cube":
1.0` as the custom reflected struct specified in `server.rs`:

```text
{
      "components": {
        "bevy_render::primitives::Aabb": {
          "center": [
            0.0,
            0.0,
            0.0
          ],
          "half_extents": [
            0.5,
            0.5,
            0.5
          ]
        },
        "bevy_render::view::visibility::InheritedVisibility": true,
        "bevy_render::view::visibility::ViewVisibility": true,
        "bevy_render::view::visibility::Visibility": "Inherited",
        "bevy_transform::components::global_transform::GlobalTransform": [
          1.0,
          0.0,
          0.0,
          0.0,
          1.0,
          0.0,
          0.0,
          0.0,
          1.0,
          0.0,
          2.4572744369506836,
          0.0
        ],
        "bevy_transform::components::transform::Transform": {
          "rotation": [
            0.0,
            0.0,
            0.0,
            1.0
          ],
          "scale": [
            1.0,
            1.0,
            1.0
          ],
          "translation": [
            0.0,
            2.4572744369506836,
            0.0
          ]
        },
        "bevy_transform::components::transform::TransformTreeChanged": null,
        "server::Cube": 1.0
      },
```

---------

Co-authored-by: Jan Hohenheim <jan@hohenheim.ch>
2025-07-03 18:51:32 +00:00
Piotr Siuszko
59cb4b6dc7 Format fix 2025-07-03 17:13:50 +02:00
Piotr Siuszko
9ed0787d41 schema IDs using URN format, further improvements, tests for export
endpoint
2025-07-03 17:08:51 +02:00
MevLyshkin
16c7db42aa
Merge branch 'main' into proper-json-schema 2025-07-03 11:41:33 +02:00
Piotr Siuszko
cd1b933333 Cleanup 2025-07-03 11:41:10 +02:00
Piotr Siuszko
d83f82f045 Schema definitions generate better 2025-07-03 11:40:27 +02:00
Piotr Siuszko
5ea21b4705 Start populating schema definitons field 2025-07-03 09:46:10 +02:00
Piotr Siuszko
27366c9f4f Cleanup and refactor 2025-07-01 21:57:10 +02:00
charlotte 🌸
92e65d5eb1
Upgrade to Rust 1.88 (#19825) 2025-06-26 19:38:19 +00:00
MevLyshkin
a67cccc107
Update crates/bevy_remote/src/lib.rs
Good call

Co-authored-by: Sébastien Job <sebastien.job@gmail.com>
2025-06-24 21:36:59 +02:00
Piotr Siuszko
8cea898f9c values bound fix 2025-06-23 18:22:02 +02:00
Piotr Siuszko
e9ee9462dd Rename reflect_types to reflect_type_data, update field doc 2025-06-23 18:13:11 +02:00
Piotr Siuszko
5dac986c84 Format code 2025-06-23 18:09:18 +02:00
Piotr Siuszko
7530568498 Clippy fixes 2025-06-23 18:06:11 +02:00
Piotr Siuszko
ef2ff40d75 Test without documentation fix, typo fixes 2025-06-23 18:02:32 +02:00
MevLyshkin
16278cb4a3
Merge branch 'main' into proper-json-schema 2025-06-23 17:53:31 +02:00
Piotr Siuszko
e93680baa3 Use Cow instead of String in JSON schema types 2025-06-23 17:20:16 +02:00
github-actions[bot]
a466084167
Bump Version after Release (#19774)
Bump version after release
This PR has been auto-generated

Fixes #19766

---------

Co-authored-by: Bevy Auto Releaser <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: François Mockers <francois.mockers@vleue.com>
Co-authored-by: François Mockers <mockersf@gmail.com>
2025-06-22 23:06:43 +00:00
Piotr Siuszko
16f9c87bdd Add InvalidJsonSchema error and helper impl for TypeRegistration 2025-06-21 21:55:58 +02:00
Piotr Siuszko
f2fd5707f0 Clean up JSON schema test messages 2025-06-21 21:50:23 +02:00