Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove janky schema from http API #2181

Merged
merged 4 commits into from
Feb 11, 2025
Merged

Conversation

coolreader18
Copy link
Collaborator

@coolreader18 coolreader18 commented Jan 27, 2025

Description of Changes

Get rid of the weird stuff in describe and just return a RawModuleDef.

Expected complexity level and risk

2 - changes api a decent amount but only to return an already well-established format.

Testing

  • Smoketests cover this wrt to CLI changes.

@coolreader18 coolreader18 force-pushed the noa/proper-schema-api branch from 2cde444 to 8e8cc48 Compare February 3, 2025 21:03
@coolreader18 coolreader18 marked this pull request as ready for review February 3, 2025 21:03
@coolreader18 coolreader18 added the api-break A PR that makes an API breaking change label Feb 3, 2025
@coolreader18
Copy link
Collaborator Author

I semi-rewrote the invalid_arguments stuff because it was interacting with the api through serde_json::Values instead of ModuleDef, and it was much easier to just make it use ModuleDef than to keep the weird stuff.

@bfops
Copy link
Collaborator

bfops commented Feb 4, 2025

I don't think I'm equipped to review the non-CLI "meat" of this PR, sorry.

@bfops
Copy link
Collaborator

bfops commented Feb 4, 2025

Question about testing - Did this PR change the expected output format of spacetime describe at all? The smoketests just seem to test that the CLI exits successfully, but I don't see, like, snapshot tests or anything. I don't specifically think that we need them, just trying to understand the expected impact here.

Edit: Yeah I think on further review of the changes to spacetime call especially, it would be good to have some clarity on what the final output looks like now and making sure that it still looks reasonable for users.

@coolreader18
Copy link
Collaborator Author

I don't think there's really any use case for spacetime describe atm besides some sort of scripting. Ideally I think its default behavior would be to show a nice human-readable description of the module or the selected item. Maybe its current behavior should be put behind a --json flag, or it should just be removed entirely until it has a better spec?

@bfops
Copy link
Collaborator

bfops commented Feb 5, 2025

I don't think there's really any use case for spacetime describe atm besides some sort of scripting. Ideally I think its default behavior would be to show a nice human-readable description of the module or the selected item. Maybe its current behavior should be put behind a --json flag, or it should just be removed entirely until it has a better spec?

Yeah I don't think we particularly need to preserve the old output, but I do think we want to make sure that describe and call still have reasonable-looking outputs.

I do think we've told some folks with larger DBs to inspect them via describe, so I don't think we should remove it entirely. We're going to mark it as "unstable" for 1.0 though, so we can totally keep changing it / breaking it.

Copy link
Contributor

@cloutiertyler cloutiertyler left a comment

Choose a reason for hiding this comment

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

This all looks quite good to me. It's definitely an improvement. I ran it on quickstart-chat

{
  "typespace": {
    "types": [
      {
        "Product": {
          "elements": [
            {
              "name": {
                "some": "sender"
              },
              "algebraic_type": {
                "Product": {
                  "elements": [
                    {
                      "name": {
                        "some": "__identity__"
                      },
                      "algebraic_type": {
                        "U256": []
                      }
                    }
                  ]
                }
              }
            },
            {
              "name": {
                "some": "sent"
              },
              "algebraic_type": {
                "Product": {
                  "elements": [
                    {
                      "name": {
                        "some": "__timestamp_micros_since_unix_epoch__"
                      },
                      "algebraic_type": {
                        "I64": []
                      }
                    }
                  ]
                }
              }
            },
            {
              "name": {
                "some": "text"
              },
              "algebraic_type": {
                "String": []
              }
            }
          ]
        }
      },
      {
        "Product": {
          "elements": [
            {
              "name": {
                "some": "identity"
              },
              "algebraic_type": {
                "Product": {
                  "elements": [
                    {
                      "name": {
                        "some": "__identity__"
                      },
                      "algebraic_type": {
                        "U256": []
                      }
                    }
                  ]
                }
              }
            },
            {
              "name": {
                "some": "name"
              },
              "algebraic_type": {
                "Sum": {
                  "variants": [
                    {
                      "name": {
                        "some": "some"
                      },
                      "algebraic_type": {
                        "String": []
                      }
                    },
                    {
                      "name": {
                        "some": "none"
                      },
                      "algebraic_type": {
                        "Product": {
                          "elements": []
                        }
                      }
                    }
                  ]
                }
              }
            },
            {
              "name": {
                "some": "online"
              },
              "algebraic_type": {
                "Bool": []
              }
            }
          ]
        }
      }
    ]
  },
  "tables": [
    {
      "name": "message",
      "product_type_ref": 0,
      "primary_key": [],
      "indexes": [],
      "constraints": [],
      "sequences": [],
      "schedule": {
        "none": []
      },
      "table_type": {
        "User": []
      },
      "table_access": {
        "Public": []
      }
    },
    {
      "name": "user",
      "product_type_ref": 1,
      "primary_key": [
        0
      ],
      "indexes": [
        {
          "name": {
            "some": "user_identity_idx_btree"
          },
          "accessor_name": {
            "some": "identity"
          },
          "algorithm": {
            "BTree": [
              0
            ]
          }
        }
      ],
      "constraints": [
        {
          "name": {
            "some": "user_identity_key"
          },
          "data": {
            "Unique": {
              "columns": [
                0
              ]
            }
          }
        }
      ],
      "sequences": [],
      "schedule": {
        "none": []
      },
      "table_type": {
        "User": []
      },
      "table_access": {
        "Public": []
      }
    }
  ],
  "reducers": [
    {
      "name": "identity_connected",
      "params": {
        "elements": []
      },
      "lifecycle": {
        "some": {
          "OnConnect": []
        }
      }
    },
    {
      "name": "identity_disconnected",
      "params": {
        "elements": []
      },
      "lifecycle": {
        "some": {
          "OnDisconnect": []
        }
      }
    },
    {
      "name": "init",
      "params": {
        "elements": []
      },
      "lifecycle": {
        "some": {
          "Init": []
        }
      }
    },
    {
      "name": "send_message",
      "params": {
        "elements": [
          {
            "name": {
              "some": "text"
            },
            "algebraic_type": {
              "String": []
            }
          }
        ]
      },
      "lifecycle": {
        "none": []
      }
    },
    {
      "name": "set_name",
      "params": {
        "elements": [
          {
            "name": {
              "some": "name"
            },
            "algebraic_type": {
              "String": []
            }
          }
        ]
      },
      "lifecycle": {
        "none": []
      }
    }
  ],
  "types": [
    {
      "name": {
        "scope": [],
        "name": "Message"
      },
      "ty": 0,
      "custom_ordering": true
    },
    {
      "name": {
        "scope": [],
        "name": "User"
      },
      "ty": 1,
      "custom_ordering": true
    }
  ],
  "misc_exports": [],
  "row_level_security": []
}

@cloutiertyler cloutiertyler added this pull request to the merge queue Feb 11, 2025
Merged via the queue into master with commit cf68225 Feb 11, 2025
12 of 13 checks passed
@coolreader18 coolreader18 mentioned this pull request Feb 11, 2025
1 task
kazimuth added a commit to clockworklabs/com.clockworklabs.spacetimedbsdk that referenced this pull request Feb 11, 2025
## Description of Changes

Switches to Bearer authentication, which is the more proper auth schema
to use with tokens.

## API

 - [ ] This is an API breaking change to the SDK

## Requires SpacetimeDB PRs
- clockworklabs/SpacetimeDB#2181

## Testsuite
*If you would like to run the your SDK changes in this PR against a
specific SpacetimeDB branch, specify that here. This can be a branch
name or a link to a PR.*

SpacetimeDB branch name: master

---------

Co-authored-by: Zeke Foppa <[email protected]>
Co-authored-by: rekhoff <[email protected]>
Co-authored-by: James Gilles <[email protected]>
@coolreader18 coolreader18 linked an issue Feb 28, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-break A PR that makes an API breaking change release-1.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove cruft from schema API endpoint
3 participants