feathers-pinia

Connect your Feathers API to the elegant data store for Vue

Stars
52
Committers
19

Bot releases are hidden (Show)

feathers-pinia - v4.5.4

Published by marshallswain 5 months ago

What's Changed

Full Changelog: https://github.com/marshallswain/feathers-pinia/compare/v4.5.3...v4.5.4

feathers-pinia - v4.4.1 Latest Release

Published by marshallswain 6 months ago

What's Changed

New Contributors

Full Changelog: https://github.com/marshallswain/feathers-pinia/compare/v4.2.6...v4.4.1

feathers-pinia - fix: refactor dynamic nested computed in useAuth

Published by marshallswain 7 months ago

It's possible that the nested dynamic computed is breaking reactivity. The nested computed has been replaced with a direct reference to the stored value in itemsById.

feathers-pinia - fix: internal `byId` storage now uses `ref`

Published by marshallswain 7 months ago

Some reactivity in Pinia breaks when you use reactive instead of ref. This update switched the byId object to use a ref to fix reactivity.

🎁 useBackup

The new useBackup utility is the opposite of working with clones. Instead of binding your form to a clone, you use
the original record. It keeps a copy, letting you call backup or restore to revert changes. The save method
auto-diffs from the backup, keeping data size to a minimum.

🎁 New Relationship Utilities

New methods have been added to the FeathersPinia Client. These utilities can be used inside setupInstance functions to
help form relationships between services:

🔥 storeAssociated Deprecated

As of Feathers-Pinia v4.2, the storeAssociated utility has been replaced with a suite of smaller, more-flexible,
single-purpose utilities. See Data Modeling for the new way to store associated data.

🎁 Share Stores Between Services

The PiniaServiceConfig interface now accepts a storeName string. storeName {String} is the name of the store to use for the service. It defaults to service:${servicePath}. You can also use storeName to make two services share the same store.

🎁 Proxy Services

The PiniaServiceConfig interface now also accepts an instanceServicePath string. The instanceServicePath {String} overrides the service used for instance-level service methods, like patch, and remove. This is useful for "proxy" services. For example: pages/full loads the page record with populated data, but you want to patch/remove the record through the pages service.

Also New

  • Expose the diff util: the internal diff utility is now available in the exports.

Fixes

  • Fixes an issue with Cloudflare Workers compatibility (which do not support EventEmitter)
  • The useFind internal watch now uses flush: 'sync' to prevent an infinite loop during SSR.
feathers-pinia - 🔥 Revert the bug that the last bug "fix" caused.

Published by marshallswain about 1 year ago

It turns out that faulty conditional was saving us from a more serious problem. It caused a large fire when my CPU went up in flames. Just kidding. It just wasn't a simple fix, after all.

Reverts the changes made in this release: https://github.com/marshallswain/feathers-pinia/releases/tag/v3.0.6

feathers-pinia - 🐜 Addresses a faulty conditional for find responses

Published by marshallswain about 1 year ago

Intended to solve the find response not being handled, as described in this issue: https://github.com/marshallswain/feathers-pinia/issues/126

feathers-pinia - 🐜 Fix mismatch type error for some Feathers Clients

Published by marshallswain about 1 year ago

All @feathersjs/ packages have been updated to the latest versions. As a result, some internal types were updated to prevent errors when using the FeathersPinia client.

The documentation has also been updated to show how to ensure all FeathersPiniaService methods are available for untyped Feathers clients. See the "Common Pitfalls" section on this page: https://feathers-pinia.pages.dev/guide/common-patterns.html

The basic gist is that you need to provide a ServiceTypes generic when calling the feathers() function:

// import the FeathersService type
import { feathers, type FeathersService } from '@feathersjs/feathers'

// Create a ServiceTypes generic
type ServiceTypes = Record<string, FeathersService>

// Provide `ServiceTypes` in angle brackets before the parentheses
const feathersClient = feathers<ServiceTypes>()
feathers-pinia - 🐜 Fix OFetch adapter swallowing errors

Published by marshallswain over 1 year ago

The included feathers-ofetch adapter was swallowing Feathers errors and turning them into a plain text error. Now the full error from the server is correctly returned from requests.

This didn't have any effect on WebSocket communication, which did not experience the error.

feathers-pinia - 🎁 Environment compatibility upgrades

Published by marshallswain over 1 year ago

There are no practical changes for existing users, but this release improves compatibility with some Node.js versions and WebContainers.

Many thanks to @FossPrime! ❤️

feathers-pinia - 🐜 Fix types: move `@feathersjs` packages to peerDependencies

Published by marshallswain over 1 year ago

This release moves all @feathersjs packages to peerDependencies to fix an issue where Types are out of sync every time a new FeathersJS release is published.

feathers-pinia - 🍻 Dependency Maintenance

Published by marshallswain over 1 year ago

Nothing really noteworthy. Move along. 😁

feathers-pinia - 🎁 Integrated Storage Sync

Published by marshallswain over 1 year ago

The syncWithStorage plugin is now built in and can be enabled in the createPiniaClient configuration.

Here are some examples. Read more in the documentation:

Sync All Service Data

Here's how to set it up for the entire Feathers-Pinia client instance:

export const api = createPiniaClient(feathersClient, {
  idField: '_id',
  pinia,
  syncWithStorage: true,
  storage: window.localStorage,
})

Note that you must provide the global-only storage option AND the syncWithStorage option to enable the feature.

Sync Individual Service Data

Here's how to enable storage sync for a single service:

export const api = createPiniaClient(feathersClient, {
  idField: '_id',
  pinia,
  syncWithStorage: false,
  storage: window.localStorage,
  services: {
    'my-service': {
      syncWithStorage: true
    }
  }
})

Customize Storage Keys

You can customize which store keys are synchronized to storage by passing an array to syncWithStorage. You must
provide all keys, since this will override the default value, which is ['itemsById', 'pagination'].

export const api = createPiniaClient(feathersClient, {
  idField: '_id',
  pinia,
  syncWithStorage: ['itemsById', 'pagination', 'tempsById'],
  storage: window.localStorage,
})
feathers-pinia - 🐜 bugfix for hybrid useFind after removing an item

Published by marshallswain over 1 year ago

Fixes a bug where removing an item would cause a temporary item to be created in its place. Only applies to useFind with paginateOn: 'hybrid'

feathers-pinia - `useFind`'s `find` is back, new `defaultLimit` option

Published by marshallswain over 1 year ago

🎁 new defaultLimit option

A new defaultLimit option lets you change the default query $limit to something other than 10.

useFind's find util functionality restored

🐜 The params are now cached and called internally when you call find without any params.

feathers-pinia - 🐜 allLocalData bug fixes

Published by marshallswain over 1 year ago

allLocalData now shows the correct data during pending state.

feathers-pinia - 🐜 Fix pending state during pagination

Published by marshallswain over 1 year ago

The correct data is now shown while switching pages during pagination.

feathers-pinia - 🎁 Initial Hybrid Pagination with `useFind`

Published by marshallswain over 1 year ago

Breaking Change

The paginateOnServer option has been changed to paginateOn: 'server'.

paginateOn offers three modes

  • client is the current default. It's the same as the previous paginateOnServer: false.
  • server is the same as the previous paginateOnServer: true.
  • hybrid is a combination of server and client. It pulls one page at a time from the server while maintaining live lists.

Hybrid Pagination with useFind

Enable hybrid pagination on useFind by setting paginateOn: 'hybrid'. Then you can enjoy server-paginated data while still enjoying live lists.

Implementation Summary

Hybrid pagination works similar to server pagination. It keeps track of the current query and the records that were received for it. It then uses the first returned record as a checkpoint while analyzing the $skip in the query. Here are some starting-point scenarios of how it behaves:

  • $limit: 10, $skip: 0 will return the first page of results. New results that sort to the top of the list will appear as normal for client pagination.
  • $limit: 10, $skip: 10 will return the second page of results from the server. useFind will recognize that we don't have any records in the store that come before the first record in the current page. This means there's an empty ten-record buffer that needs to be filled before the realtime data will update the live list. This will be made more accurate in the future by watching for created and patched events that come in and adjusting the buffer, accordingly.

See more details in the test file: https://github.com/marshallswain/feathers-pinia/blob/v3/tests/use-find-get/use-find-hybrid.test.ts

feathers-pinia - 🐜 Fix `useAuth` Custom Types, update packages

Published by marshallswain over 1 year ago

Fix useAuth Custom Types

You can now completely replace AuthenticateData with a custom type. TypeScript no longer throws a fit when you do this:

interface AuthenticateData {
  strategy: 'jwt' | 'local' | 'ldap'
  accessToken?: string
  tuid?: string
  password?: string
}

defineStore('auth', () => {
  const utils = useAuth<AuthenticateData>({ api }) // custom type passed in the generic
  utils.reAuthenticate()
  return { ...utils }
})

Update packages

Upgrades to the latest FeathersJS release and fixes breaking changes in the latest Vitest update.