Skip to content

Comments

Use DXOS for auth, storage, and sync#257

Open
bigdogwillfeed wants to merge 20 commits intomainfrom
dxos
Open

Use DXOS for auth, storage, and sync#257
bigdogwillfeed wants to merge 20 commits intomainfrom
dxos

Conversation

@bigdogwillfeed
Copy link
Member

@bigdogwillfeed bigdogwillfeed commented Mar 13, 2025

(PR includes #254 because only PRs to main get automatically deployed to a staging environment.)

This is a sizeable chunk of work, in large commits, pulled in from the prototyping work we did over in https://github.com/DevResults/xdev-dxos. The end result is a version of xdev that uses DXOS for auth, storage, and sync instead of the localfirst libraries and automerge (directly, anyway)

We found that DXOS had some pretty major shortcomings when it came to support for schema, so the definitions of our objects and the collections are all very different than before. More expectedly, the way that users and devices are defined and managed is also different (to account for the shape of the DXOS interfaces). Ultimately, we've got something that is similar in functionality as before.

You can run this locally with pnpm i; pnpm dev or pnpm i; pnpm build; pnpm start

  • Note that there is no sync server, so you need to have another peer online at the same time as you to do any synchronizing (including invitation accepting)
  • Also note that the invite links come in the form ?spaceInvitationCode=<code> and you can either manually change those into the form /join/<code> or paste just the code into the join box when joining a team. You'll need to do similar changes with the device linking.

Following https://reactrouter.com/upgrading/remix, I did `npx codemod remix/2/react-router/upgrade`, `pnpm install`, and `pnpm lint --fix` (to get rid of semi colons)
It's possible we'll want to customize the entry points in the future, but this change is what it took to get the app to function at all
navigate is now async so needs to be handled as such
# Conflicts:
#	pnpm-lock.yaml
replaced this extra bit of remix still lurking with the proper react-router syntax
react-router says it needs this
Replace localfirst and automerge packages with dxos. Update effect to match what dxos needs -- note this exposed a buggy test which I also fixed
Note we've made build a bit more complicated because the dxos shell is a separate react app. So we build the shell separately and then include both apps in the build directory
There are some big differences in how a dxos TypedObject behaves compared to an EffectSchema.Class:
1. there is no support (yet) for transforms, so we're treating dates and timestamps as strings and only referencing the foreign key instead of a fully hydrated object
2. there is no support (and perhaps no need) for the entire Collections and Root concepts
3. TypedObjects are `create`d instead of `new`ed
4. there is no support for getters (so we're storing computed values and have changed a lot about how ExtendedContact works)

This commit is still non-functional (the app doesn't run) but `pnpm test` passes
This is nearly all covered in dxos
Main categories of changes here:
- collections no longer exist, so we need to use callbacks
- objects have different creation syntax and required fields
- objects are no longer hydrated, so we need to prop drill the lookup collections and deal with dates as strings
- devices come from dxos and have a different shape (I use platform to build these for tests)
- extended members have no invitation status (invites are anonymous)

I think all of the stories are working correctly with `pnpm storybook`
This is faster and nicer than the dev server if you're just poking around
update the hooks and routes so that they work with the new DXOS shape of things
Basically, this is removing tests that are hard automate in dxos (team management through the shell) and giving persistence a little bit longer before refreshing the page
This gets the build working on my local machine :)
This prevents flaky tests due to dev server startup
@github-actions
Copy link

Azure Static Web Apps: Your stage site is ready! Visit it here: https://wonderful-water-0b2eba80f-257.eastus2.5.azurestaticapps.net

@bigdogwillfeed bigdogwillfeed changed the title Dxos Use DXOS for auth, storage, and sync Mar 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant