Skip to content

Conversation

andsmedeiros
Copy link

This commit provides support for Ember and EmberData >=5.x (including 6.x).

What was done?

This PR takes the Ember v4.x branch code and adapts it to Ember/Data >=5.x.
Also, converts this into a V2 addon.

What was not done?

This does NOT attempt to phase out EmberData's adapter paradigm yet.

Testing

Tests run fine via ember test, but ember-try fails.

Breaking changes

IMPORTANT! Underlying model naming

Due to compatibility reasons, ember-pouch used camelCase model names everywhere. This was deprecated and is planned for removal at Data 6.x.
This also removes all compatibility behaviour and passes model names as-is. This means that old data may be inaccessible.
The old behaviour can be restored by overriding the derived adapter's getRecordTypeName() method.

Transform exports

If transform:attachment or transform:attachments are needed, they now need to be explicitly exported by the consuming app:

E.g., for transform:attachment:

// my-app/app/transforms/attachment.js
export { default } from 'ember-pouch/transforms/attachment';

Afterword

As said before, I am available if anything is needed to getting this working well.

🖖🏽

I attempted to leave the logic untouch as much as possible, converting mostly notation, with a few exceptions:
- The `_onInit` event handler and `init` hooks had to be replaced by logic in the constructor and class fields.
- `_init` method was renamed to `prepare` because it is overridden in test app's adapters and couldn't be made a true private method. Also, naming it `init` would collide with EmberObject hooks.
- Made the constructor take the database object as parameter. Because `init` hooks runs after the constructor, this gave extending adapters enough time to set `this.db`. As we merged those into the constructor,  the change handler would not be set, as `db` would not be defined yet. This is a breaking change.

This commit also updates the test adapters to use this new constructor API.
… because it does not prove anything really.
…y be re-exportation of `PouchSerializer`.

Instead of providing the application serializer in the addon, defines it only in the dummy app.
- Corrects ESLint config file name
- dds rule to ignore variables starting with `_`
- Prevents import linting errors in the ESLint config file itself
- Moves `PouchModel` to `models/pouch.js`
- Exports the model from the new path
- Adds a model export from `/app`
- Exports `PouchDB`, with plugins already attached, directly from the addon
@backspace
Copy link
Collaborator

Thanks for your ongoing work on this. I don’t think I have release permissions which does seem like something to figure out before merging your other branch and then this. But I appreciate your dedication and I’ll review this in the next few days.

@andsmedeiros
Copy link
Author

Thanks @backspace! I can work on my app with this as it is currently by adding a git dependency directly. Also, the codebase is already quite useable as I am finding out, so I'm not in a hurry.
When you can advance with this I can help further. Until then, if I catch any errors, I'll go on updating both branches.

@broerse broerse mentioned this pull request Jul 8, 2025
@andsmedeiros
Copy link
Author

Note on the failing Floating Dependencies scenario:
I believe this is failing because, since Data 5.5, the configuration is expected to be under WarpDrive's namespace (related to this deprecation and this package).
I'm not sure how to work around this, maybe @embroider/macros can be used in ember-cli-build.js to conditionally define configuration.

@broerse
Copy link
Collaborator

broerse commented Jul 10, 2025

@jlami can you take a look at the failing checks?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants