From 7df51d5c9d5264884950bdf38f1a2c8dd9573302 Mon Sep 17 00:00:00 2001 From: Eduardo San Martin Morote Date: Wed, 26 Jun 2024 12:03:33 +0200 Subject: [PATCH] docs: fix links --- .../docs/api/@pinia/nuxt/functions/default.md | 25 + packages/docs/api/@pinia/nuxt/index.md | 21 + .../nuxt/interfaces/ModuleOptions.md} | 22 +- .../testing/functions/createTestingPinia.md | 32 + packages/docs/api/@pinia/testing/index.md | 22 + .../testing/interfaces/TestingOptions.md} | 68 +- .../@pinia/testing/interfaces/TestingPinia.md | 78 ++ packages/docs/api/index.md | 10 +- .../pinia.DefineSetupStoreOptions.md | 41 - .../interfaces/pinia.DefineStoreOptions.md | 110 -- .../pinia.DefineStoreOptionsBase.md | 28 - .../pinia.DefineStoreOptionsInPlugin.md | 111 -- packages/docs/api/interfaces/pinia.Pinia.md | 63 - .../interfaces/pinia.PiniaCustomProperties.md | 20 - .../pinia.PiniaCustomStateProperties.md | 17 - .../docs/api/interfaces/pinia.PiniaPlugin.md | 30 - .../interfaces/pinia.PiniaPluginContext.md | 52 - .../api/interfaces/pinia.StoreDefinition.md | 53 - .../api/interfaces/pinia.StoreProperties.md | 41 - ...inia.SubscriptionCallbackMutationDirect.md | 57 - ...bscriptionCallbackMutationPatchFunction.md | 56 - ...SubscriptionCallbackMutationPatchObject.md | 70 - .../pinia._StoreOnActionListenerContext.md | 91 -- ...pinia._SubscriptionCallbackMutationBase.md | 47 - .../interfaces/pinia_testing.TestingPinia.md | 84 -- packages/docs/api/modules/pinia.md | 1221 ----------------- packages/docs/api/modules/pinia_nuxt.md | 29 - packages/docs/api/modules/pinia_testing.md | 37 - .../enumerations/MutationType.md} | 18 +- .../api/pinia/functions/acceptHMRUpdate.md | 56 + .../docs/api/pinia/functions/createPinia.md | 19 + .../docs/api/pinia/functions/defineStore.md | 97 ++ .../docs/api/pinia/functions/disposePinia.md | 27 + .../api/pinia/functions/getActivePinia.md | 19 + .../docs/api/pinia/functions/mapActions.md | 123 ++ .../docs/api/pinia/functions/mapGetters.md | 130 ++ packages/docs/api/pinia/functions/mapState.md | 136 ++ .../docs/api/pinia/functions/mapStores.md | 47 + .../api/pinia/functions/mapWritableState.md | 91 ++ .../api/pinia/functions/setActivePinia.md | 63 + .../api/pinia/functions/setMapStoreSuffix.md | 27 + .../docs/api/pinia/functions/skipHydrate.md | 32 + .../docs/api/pinia/functions/storeToRefs.md | 32 + packages/docs/api/pinia/index.md | 96 ++ .../interfaces/DefineSetupStoreOptions.md | 42 + .../pinia/interfaces/DefineStoreOptions.md | 110 ++ .../interfaces/DefineStoreOptionsBase.md | 26 + .../interfaces/DefineStoreOptionsInPlugin.md | 111 ++ .../interfaces/MapStoresCustomization.md} | 8 +- packages/docs/api/pinia/interfaces/Pinia.md | 57 + .../pinia/interfaces/PiniaCustomProperties.md | 23 + .../interfaces/PiniaCustomStateProperties.md | 17 + .../docs/api/pinia/interfaces/PiniaPlugin.md | 28 + .../pinia/interfaces/PiniaPluginContext.md | 55 + .../pinia/interfaces/SetupStoreDefinition.md | 59 + .../api/pinia/interfaces/StoreDefinition.md | 53 + .../StoreOnActionListenerContext.md | 81 ++ .../api/pinia/interfaces/StoreProperties.md | 39 + .../interfaces/StoreWithState.md} | 134 +- .../SubscriptionCallbackMutationBase.md | 45 + .../SubscriptionCallbackMutationDirect.md | 57 + ...bscriptionCallbackMutationPatchFunction.md | 56 + ...SubscriptionCallbackMutationPatchObject.md | 68 + .../api/pinia/type-aliases/ActionsTree.md | 16 + .../docs/api/pinia/type-aliases/Awaited.md | 17 + .../api/pinia/type-aliases/DeepPartial.md | 21 + .../ExtractActionsFromSetupStore.md | 19 + .../ExtractActionsFromSetupStore_Keys.md | 20 + .../ExtractGettersFromSetupStore.md | 19 + .../ExtractGettersFromSetupStore_Keys.md | 20 + .../ExtractStateFromSetupStore.md | 19 + .../ExtractStateFromSetupStore_Keys.md | 20 + .../api/pinia/type-aliases/GettersTree.md | 20 + .../type-aliases/MapActionsObjectReturn.md | 21 + .../pinia/type-aliases/MapActionsReturn.md | 19 + .../type-aliases/MapStateObjectReturn.md | 27 + .../api/pinia/type-aliases/MapStateReturn.md | 23 + .../MapWritableStateObjectReturn.md | 21 + .../type-aliases/MapWritableStateReturn.md | 19 + .../docs/api/pinia/type-aliases/Method.md | 25 + .../pinia/type-aliases/PiniaStorePlugin.md | 19 + .../docs/api/pinia/type-aliases/Spread.md | 19 + .../docs/api/pinia/type-aliases/StateTree.md | 15 + packages/docs/api/pinia/type-aliases/Store.md | 25 + .../api/pinia/type-aliases/StoreActions.md | 20 + .../api/pinia/type-aliases/StoreGeneric.md | 17 + .../api/pinia/type-aliases/StoreGetters.md | 20 + .../api/pinia/type-aliases/StoreObject.md | 19 + .../type-aliases/StoreOnActionListener.md | 33 + .../StoreOnActionListenerContext.md | 26 + .../docs/api/pinia/type-aliases/StoreState.md | 20 + .../pinia/type-aliases/StoreWithActions.md | 20 + .../pinia/type-aliases/StoreWithGetters.md | 20 + .../type-aliases/SubscriptionCallback.md | 29 + .../SubscriptionCallbackMutation.md | 19 + .../docs/api/pinia/type-aliases/UnwrapAll.md | 20 + .../api/pinia/variables/PiniaVuePlugin.md | 37 + packages/docs/cookbook/testing.md | 2 +- 98 files changed, 2958 insertions(+), 2386 deletions(-) create mode 100644 packages/docs/api/@pinia/nuxt/functions/default.md create mode 100644 packages/docs/api/@pinia/nuxt/index.md rename packages/docs/api/{interfaces/pinia_nuxt.ModuleOptions.md => @pinia/nuxt/interfaces/ModuleOptions.md} (59%) create mode 100644 packages/docs/api/@pinia/testing/functions/createTestingPinia.md create mode 100644 packages/docs/api/@pinia/testing/index.md rename packages/docs/api/{interfaces/pinia_testing.TestingOptions.md => @pinia/testing/interfaces/TestingOptions.md} (60%) create mode 100644 packages/docs/api/@pinia/testing/interfaces/TestingPinia.md delete mode 100644 packages/docs/api/interfaces/pinia.DefineSetupStoreOptions.md delete mode 100644 packages/docs/api/interfaces/pinia.DefineStoreOptions.md delete mode 100644 packages/docs/api/interfaces/pinia.DefineStoreOptionsBase.md delete mode 100644 packages/docs/api/interfaces/pinia.DefineStoreOptionsInPlugin.md delete mode 100644 packages/docs/api/interfaces/pinia.Pinia.md delete mode 100644 packages/docs/api/interfaces/pinia.PiniaCustomProperties.md delete mode 100644 packages/docs/api/interfaces/pinia.PiniaCustomStateProperties.md delete mode 100644 packages/docs/api/interfaces/pinia.PiniaPlugin.md delete mode 100644 packages/docs/api/interfaces/pinia.PiniaPluginContext.md delete mode 100644 packages/docs/api/interfaces/pinia.StoreDefinition.md delete mode 100644 packages/docs/api/interfaces/pinia.StoreProperties.md delete mode 100644 packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationDirect.md delete mode 100644 packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md delete mode 100644 packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchObject.md delete mode 100644 packages/docs/api/interfaces/pinia._StoreOnActionListenerContext.md delete mode 100644 packages/docs/api/interfaces/pinia._SubscriptionCallbackMutationBase.md delete mode 100644 packages/docs/api/interfaces/pinia_testing.TestingPinia.md delete mode 100644 packages/docs/api/modules/pinia.md delete mode 100644 packages/docs/api/modules/pinia_nuxt.md delete mode 100644 packages/docs/api/modules/pinia_testing.md rename packages/docs/api/{enums/pinia.MutationType.md => pinia/enumerations/MutationType.md} (66%) create mode 100644 packages/docs/api/pinia/functions/acceptHMRUpdate.md create mode 100644 packages/docs/api/pinia/functions/createPinia.md create mode 100644 packages/docs/api/pinia/functions/defineStore.md create mode 100644 packages/docs/api/pinia/functions/disposePinia.md create mode 100644 packages/docs/api/pinia/functions/getActivePinia.md create mode 100644 packages/docs/api/pinia/functions/mapActions.md create mode 100644 packages/docs/api/pinia/functions/mapGetters.md create mode 100644 packages/docs/api/pinia/functions/mapState.md create mode 100644 packages/docs/api/pinia/functions/mapStores.md create mode 100644 packages/docs/api/pinia/functions/mapWritableState.md create mode 100644 packages/docs/api/pinia/functions/setActivePinia.md create mode 100644 packages/docs/api/pinia/functions/setMapStoreSuffix.md create mode 100644 packages/docs/api/pinia/functions/skipHydrate.md create mode 100644 packages/docs/api/pinia/functions/storeToRefs.md create mode 100644 packages/docs/api/pinia/index.md create mode 100644 packages/docs/api/pinia/interfaces/DefineSetupStoreOptions.md create mode 100644 packages/docs/api/pinia/interfaces/DefineStoreOptions.md create mode 100644 packages/docs/api/pinia/interfaces/DefineStoreOptionsBase.md create mode 100644 packages/docs/api/pinia/interfaces/DefineStoreOptionsInPlugin.md rename packages/docs/api/{interfaces/pinia.MapStoresCustomization.md => pinia/interfaces/MapStoresCustomization.md} (62%) create mode 100644 packages/docs/api/pinia/interfaces/Pinia.md create mode 100644 packages/docs/api/pinia/interfaces/PiniaCustomProperties.md create mode 100644 packages/docs/api/pinia/interfaces/PiniaCustomStateProperties.md create mode 100644 packages/docs/api/pinia/interfaces/PiniaPlugin.md create mode 100644 packages/docs/api/pinia/interfaces/PiniaPluginContext.md create mode 100644 packages/docs/api/pinia/interfaces/SetupStoreDefinition.md create mode 100644 packages/docs/api/pinia/interfaces/StoreDefinition.md create mode 100644 packages/docs/api/pinia/interfaces/StoreOnActionListenerContext.md create mode 100644 packages/docs/api/pinia/interfaces/StoreProperties.md rename packages/docs/api/{interfaces/pinia._StoreWithState.md => pinia/interfaces/StoreWithState.md} (54%) create mode 100644 packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationBase.md create mode 100644 packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationDirect.md create mode 100644 packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationPatchFunction.md create mode 100644 packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationPatchObject.md create mode 100644 packages/docs/api/pinia/type-aliases/ActionsTree.md create mode 100644 packages/docs/api/pinia/type-aliases/Awaited.md create mode 100644 packages/docs/api/pinia/type-aliases/DeepPartial.md create mode 100644 packages/docs/api/pinia/type-aliases/ExtractActionsFromSetupStore.md create mode 100644 packages/docs/api/pinia/type-aliases/ExtractActionsFromSetupStore_Keys.md create mode 100644 packages/docs/api/pinia/type-aliases/ExtractGettersFromSetupStore.md create mode 100644 packages/docs/api/pinia/type-aliases/ExtractGettersFromSetupStore_Keys.md create mode 100644 packages/docs/api/pinia/type-aliases/ExtractStateFromSetupStore.md create mode 100644 packages/docs/api/pinia/type-aliases/ExtractStateFromSetupStore_Keys.md create mode 100644 packages/docs/api/pinia/type-aliases/GettersTree.md create mode 100644 packages/docs/api/pinia/type-aliases/MapActionsObjectReturn.md create mode 100644 packages/docs/api/pinia/type-aliases/MapActionsReturn.md create mode 100644 packages/docs/api/pinia/type-aliases/MapStateObjectReturn.md create mode 100644 packages/docs/api/pinia/type-aliases/MapStateReturn.md create mode 100644 packages/docs/api/pinia/type-aliases/MapWritableStateObjectReturn.md create mode 100644 packages/docs/api/pinia/type-aliases/MapWritableStateReturn.md create mode 100644 packages/docs/api/pinia/type-aliases/Method.md create mode 100644 packages/docs/api/pinia/type-aliases/PiniaStorePlugin.md create mode 100644 packages/docs/api/pinia/type-aliases/Spread.md create mode 100644 packages/docs/api/pinia/type-aliases/StateTree.md create mode 100644 packages/docs/api/pinia/type-aliases/Store.md create mode 100644 packages/docs/api/pinia/type-aliases/StoreActions.md create mode 100644 packages/docs/api/pinia/type-aliases/StoreGeneric.md create mode 100644 packages/docs/api/pinia/type-aliases/StoreGetters.md create mode 100644 packages/docs/api/pinia/type-aliases/StoreObject.md create mode 100644 packages/docs/api/pinia/type-aliases/StoreOnActionListener.md create mode 100644 packages/docs/api/pinia/type-aliases/StoreOnActionListenerContext.md create mode 100644 packages/docs/api/pinia/type-aliases/StoreState.md create mode 100644 packages/docs/api/pinia/type-aliases/StoreWithActions.md create mode 100644 packages/docs/api/pinia/type-aliases/StoreWithGetters.md create mode 100644 packages/docs/api/pinia/type-aliases/SubscriptionCallback.md create mode 100644 packages/docs/api/pinia/type-aliases/SubscriptionCallbackMutation.md create mode 100644 packages/docs/api/pinia/type-aliases/UnwrapAll.md create mode 100644 packages/docs/api/pinia/variables/PiniaVuePlugin.md diff --git a/packages/docs/api/@pinia/nuxt/functions/default.md b/packages/docs/api/@pinia/nuxt/functions/default.md new file mode 100644 index 000000000..64c5fe3ff --- /dev/null +++ b/packages/docs/api/@pinia/nuxt/functions/default.md @@ -0,0 +1,25 @@ +--- +editLink: false +--- + +[**API Documentation**](../../../index.md) • **Docs** + +*** + +[API Documentation](../../../index.md) / [@pinia/nuxt](../index.md) / default + +# Function: default() + +> **default**(`this`, `inlineOptions`, `nuxt`): `_ModuleSetupReturn` + +## Parameters + +• **this**: `void` + +• **inlineOptions**: [`ModuleOptions`](../interfaces/ModuleOptions.md) + +• **nuxt**: `Nuxt` + +## Returns + +`_ModuleSetupReturn` diff --git a/packages/docs/api/@pinia/nuxt/index.md b/packages/docs/api/@pinia/nuxt/index.md new file mode 100644 index 000000000..9779e16be --- /dev/null +++ b/packages/docs/api/@pinia/nuxt/index.md @@ -0,0 +1,21 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / @pinia/nuxt + +# @pinia/nuxt + +## Index + +### Interfaces + +- [ModuleOptions](interfaces/ModuleOptions.md) + +### Functions + +- [default](functions/default.md) diff --git a/packages/docs/api/interfaces/pinia_nuxt.ModuleOptions.md b/packages/docs/api/@pinia/nuxt/interfaces/ModuleOptions.md similarity index 59% rename from packages/docs/api/interfaces/pinia_nuxt.ModuleOptions.md rename to packages/docs/api/@pinia/nuxt/interfaces/ModuleOptions.md index 3ba8a0ba7..715c6bc32 100644 --- a/packages/docs/api/interfaces/pinia_nuxt.ModuleOptions.md +++ b/packages/docs/api/@pinia/nuxt/interfaces/ModuleOptions.md @@ -2,35 +2,37 @@ editLink: false --- -[API Documentation](../index.md) / [@pinia/nuxt](../modules/pinia_nuxt.md) / ModuleOptions +[**API Documentation**](../../../index.md) • **Docs** -# Interface: ModuleOptions +*** + +[API Documentation](../../../index.md) / [@pinia/nuxt](../index.md) / ModuleOptions -[@pinia/nuxt](../modules/pinia_nuxt.md).ModuleOptions +# Interface: ModuleOptions ## Properties -### disableVuex +### disableVuex? -• `Optional` **disableVuex**: `boolean` +> `optional` **disableVuex**: `boolean` Pinia disables Vuex by default, set this option to `false` to avoid it and use Pinia alongside Vuex (Nuxt 2 only) -**`Default`** +#### Default `true` -___ +*** -### storesDirs +### storesDirs? -• `Optional` **storesDirs**: `string`[] +> `optional` **storesDirs**: `string`[] Automatically add stores dirs to the auto imports. This is the same as directly adding the dirs to the `imports.dirs` option. If you want to also import nested stores, you can use the glob pattern `./stores/**` -**`Default`** +#### Default `['stores']` diff --git a/packages/docs/api/@pinia/testing/functions/createTestingPinia.md b/packages/docs/api/@pinia/testing/functions/createTestingPinia.md new file mode 100644 index 000000000..916bb1aa2 --- /dev/null +++ b/packages/docs/api/@pinia/testing/functions/createTestingPinia.md @@ -0,0 +1,32 @@ +--- +editLink: false +--- + +[**API Documentation**](../../../index.md) • **Docs** + +*** + +[API Documentation](../../../index.md) / [@pinia/testing](../index.md) / createTestingPinia + +# Function: createTestingPinia() + +> **createTestingPinia**(`options`): [`TestingPinia`](../interfaces/TestingPinia.md) + +Creates a pinia instance designed for unit tests that **requires mocking** +the stores. By default, **all actions are mocked** and therefore not +executed. This allows you to unit test your store and components separately. +You can change this with the `stubActions` option. If you are using jest, +they are replaced with `jest.fn()`, otherwise, you must provide your own +`createSpy` option. + +## Parameters + +• **options**: [`TestingOptions`](../interfaces/TestingOptions.md) = `{}` + +options to configure the testing pinia + +## Returns + +[`TestingPinia`](../interfaces/TestingPinia.md) + +a augmented pinia instance diff --git a/packages/docs/api/@pinia/testing/index.md b/packages/docs/api/@pinia/testing/index.md new file mode 100644 index 000000000..91c5b083a --- /dev/null +++ b/packages/docs/api/@pinia/testing/index.md @@ -0,0 +1,22 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / @pinia/testing + +# @pinia/testing + +## Index + +### Interfaces + +- [TestingOptions](interfaces/TestingOptions.md) +- [TestingPinia](interfaces/TestingPinia.md) + +### Functions + +- [createTestingPinia](functions/createTestingPinia.md) diff --git a/packages/docs/api/interfaces/pinia_testing.TestingOptions.md b/packages/docs/api/@pinia/testing/interfaces/TestingOptions.md similarity index 60% rename from packages/docs/api/interfaces/pinia_testing.TestingOptions.md rename to packages/docs/api/@pinia/testing/interfaces/TestingOptions.md index 3d3db832d..333faeb54 100644 --- a/packages/docs/api/interfaces/pinia_testing.TestingOptions.md +++ b/packages/docs/api/@pinia/testing/interfaces/TestingOptions.md @@ -2,82 +2,74 @@ editLink: false --- -[API Documentation](../index.md) / [@pinia/testing](../modules/pinia_testing.md) / TestingOptions +[**API Documentation**](../../../index.md) • **Docs** -# Interface: TestingOptions +*** + +[API Documentation](../../../index.md) / [@pinia/testing](../index.md) / TestingOptions -[@pinia/testing](../modules/pinia_testing.md).TestingOptions +# Interface: TestingOptions ## Properties -### createSpy +### createSpy()? -• `Optional` **createSpy**: (`fn?`: (...`args`: `any`[]) => `any`) => (...`args`: `any`[]) => `any` +> `optional` **createSpy**: (`fn`?) => (...`args`) => `any` Function used to create a spy for actions and `$patch()`. Pre-configured with `jest.fn` in Jest projects or `vi.fn` in Vitest projects if `globals: true` is set. -#### Type declaration - -▸ (`fn?`): (...`args`: `any`[]) => `any` +#### Parameters -##### Parameters - -| Name | Type | -| :------ | :------ | -| `fn?` | (...`args`: `any`[]) => `any` | - -##### Returns +• **fn?** -`fn` +#### Returns -▸ (`...args`): `any` +`Function` ##### Parameters -| Name | Type | -| :------ | :------ | -| `...args` | `any`[] | +• ...**args**: `any`[] ##### Returns `any` -___ +*** -### fakeApp +### fakeApp? -• `Optional` **fakeApp**: `boolean` +> `optional` **fakeApp**: `boolean` Creates an empty App and calls `app.use(pinia)` with the created testing pinia. This allows you to use plugins while unit testing stores as plugins **will wait for pinia to be installed in order to be executed**. Defaults to false. -___ +*** -### initialState +### initialState? -• `Optional` **initialState**: [`StateTree`](../modules/pinia.md#StateTree) +> `optional` **initialState**: [`StateTree`](../../../pinia/type-aliases/StateTree.md) Allows defining a partial initial state of all your stores. This state gets applied after a store is created, allowing you to only set a few properties that are required in your test. -___ +*** -### plugins +### plugins? -• `Optional` **plugins**: [`PiniaPlugin`](pinia.PiniaPlugin.md)[] +> `optional` **plugins**: [`PiniaPlugin`](../../../pinia/interfaces/PiniaPlugin.md)[] Plugins to be installed before the testing plugin. Add any plugins used in your application that will be used while testing. -___ +*** -### stubActions +### stubActions? -• `Optional` **stubActions**: `boolean` +> `optional` **stubActions**: `boolean` When set to false, actions are only spied, but they will still get executed. When set to true, actions will be replaced with spies, resulting in their code @@ -85,21 +77,21 @@ not being executed. Defaults to true. NOTE: when providing `createSpy()`, it will **only** make the `fn` argument `undefined`. You still have to handle this in `createSpy()`. -___ +*** -### stubPatch +### stubPatch? -• `Optional` **stubPatch**: `boolean` +> `optional` **stubPatch**: `boolean` When set to true, calls to `$patch()` won't change the state. Defaults to false. NOTE: when providing `createSpy()`, it will **only** make the `fn` argument `undefined`. You still have to handle this in `createSpy()`. -___ +*** -### stubReset +### stubReset? -• `Optional` **stubReset**: `boolean` +> `optional` **stubReset**: `boolean` When set to true, calls to `$reset()` won't change the state. Defaults to false. diff --git a/packages/docs/api/@pinia/testing/interfaces/TestingPinia.md b/packages/docs/api/@pinia/testing/interfaces/TestingPinia.md new file mode 100644 index 000000000..1dea5c777 --- /dev/null +++ b/packages/docs/api/@pinia/testing/interfaces/TestingPinia.md @@ -0,0 +1,78 @@ +--- +editLink: false +--- + +[**API Documentation**](../../../index.md) • **Docs** + +*** + +[API Documentation](../../../index.md) / [@pinia/testing](../index.md) / TestingPinia + +# Interface: TestingPinia + +Pinia instance specifically designed for testing. Extends a regular +`Pinia` instance with test specific properties. + +## Extends + +- [`Pinia`](../../../pinia/interfaces/Pinia.md) + +## Properties + +### app + +> **app**: `App`\<`any`\> + +App used by Pinia + +*** + +### install() + +> **install**: (`app`) => `void` + +#### Parameters + +• **app**: `App`\<`any`\> + +#### Returns + +`void` + +#### Inherited from + +[`Pinia`](../../../pinia/interfaces/Pinia.md).[`install`](../../../pinia/interfaces/Pinia.md#install) + +*** + +### state + +> **state**: `Ref`\<`Record`\<`string`, [`StateTree`](../../../pinia/type-aliases/StateTree.md)\>\> + +root state + +#### Inherited from + +[`Pinia`](../../../pinia/interfaces/Pinia.md).[`state`](../../../pinia/interfaces/Pinia.md#state) + +## Methods + +### use() + +> **use**(`plugin`): [`Pinia`](../../../pinia/interfaces/Pinia.md) + +Adds a store plugin to extend every store + +#### Parameters + +• **plugin**: [`PiniaPlugin`](../../../pinia/interfaces/PiniaPlugin.md) + +store plugin to add + +#### Returns + +[`Pinia`](../../../pinia/interfaces/Pinia.md) + +#### Inherited from + +[`Pinia`](../../../pinia/interfaces/Pinia.md).[`use`](../../../pinia/interfaces/Pinia.md#use) diff --git a/packages/docs/api/index.md b/packages/docs/api/index.md index 4bf4c87fa..100f354c0 100644 --- a/packages/docs/api/index.md +++ b/packages/docs/api/index.md @@ -2,12 +2,14 @@ editLink: false --- -API Documentation +**API Documentation** • **Docs** + +*** # API Documentation ## Modules -- [@pinia/nuxt](modules/pinia_nuxt.md) -- [@pinia/testing](modules/pinia_testing.md) -- [pinia](modules/pinia.md) +- [@pinia/nuxt](@pinia/nuxt/index.md) +- [@pinia/testing](@pinia/testing/index.md) +- [pinia](pinia/index.md) diff --git a/packages/docs/api/interfaces/pinia.DefineSetupStoreOptions.md b/packages/docs/api/interfaces/pinia.DefineSetupStoreOptions.md deleted file mode 100644 index a9404d981..000000000 --- a/packages/docs/api/interfaces/pinia.DefineSetupStoreOptions.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / DefineSetupStoreOptions - -# Interface: DefineSetupStoreOptions\ - -[pinia](../modules/pinia.md).DefineSetupStoreOptions - -Options parameter of `defineStore()` for setup stores. Can be extended to -augment stores with the plugin API. - -**`See`** - -[DefineStoreOptionsBase](pinia.DefineStoreOptionsBase.md). - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](../modules/pinia.md#StateTree) | -| `G` | `G` | -| `A` | `A` | - -## Hierarchy - -- [`DefineStoreOptionsBase`](pinia.DefineStoreOptionsBase.md)\<`S`, [`Store`](../modules/pinia.md#Store)\<`Id`, `S`, `G`, `A`\>\> - - ↳ **`DefineSetupStoreOptions`** - -## Properties - -### actions - -• `Optional` **actions**: `A` - -Extracted actions. Added by useStore(). SHOULD NOT be added by the user when -creating the store. Can be used in plugins to get the list of actions in a -store defined with a setup function. Note this is always defined diff --git a/packages/docs/api/interfaces/pinia.DefineStoreOptions.md b/packages/docs/api/interfaces/pinia.DefineStoreOptions.md deleted file mode 100644 index 6d43bc67c..000000000 --- a/packages/docs/api/interfaces/pinia.DefineStoreOptions.md +++ /dev/null @@ -1,110 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / DefineStoreOptions - -# Interface: DefineStoreOptions\ - -[pinia](../modules/pinia.md).DefineStoreOptions - -Options parameter of `defineStore()` for option stores. Can be extended to -augment stores with the plugin API. - -**`See`** - -[DefineStoreOptionsBase](pinia.DefineStoreOptionsBase.md). - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](../modules/pinia.md#StateTree) | -| `G` | `G` | -| `A` | `A` | - -## Hierarchy - -- [`DefineStoreOptionsBase`](pinia.DefineStoreOptionsBase.md)\<`S`, [`Store`](../modules/pinia.md#Store)\<`Id`, `S`, `G`, `A`\>\> - - ↳ **`DefineStoreOptions`** - -## Properties - -### actions - -• `Optional` **actions**: `A` & `ThisType`\<`A` & `UnwrapRef`\<`S`\> & [`_StoreWithState`](pinia._StoreWithState.md)\<`Id`, `S`, `G`, `A`\> & [`_StoreWithGetters`](../modules/pinia.md#_StoreWithGetters)\<`G`\> & [`PiniaCustomProperties`](pinia.PiniaCustomProperties.md)\<`string`, [`StateTree`](../modules/pinia.md#StateTree), [`_GettersTree`](../modules/pinia.md#_GettersTree)\<[`StateTree`](../modules/pinia.md#StateTree)\>, [`_ActionsTree`](../modules/pinia.md#_ActionsTree)\>\> - -Optional object of actions. - -___ - -### getters - -• `Optional` **getters**: `G` & `ThisType`\<`UnwrapRef`\<`S`\> & [`_StoreWithGetters`](../modules/pinia.md#_StoreWithGetters)\<`G`\> & [`PiniaCustomProperties`](pinia.PiniaCustomProperties.md)\<`string`, [`StateTree`](../modules/pinia.md#StateTree), [`_GettersTree`](../modules/pinia.md#_GettersTree)\<[`StateTree`](../modules/pinia.md#StateTree)\>, [`_ActionsTree`](../modules/pinia.md#_ActionsTree)\>\> & [`_GettersTree`](../modules/pinia.md#_GettersTree)\<`S`\> - -Optional object of getters. - -___ - -### id - -• **id**: `Id` - -Unique string key to identify the store across the application. - -___ - -### state - -• `Optional` **state**: () => `S` - -Function to create a fresh state. **Must be an arrow function** to ensure -correct typings! - -#### Type declaration - -▸ (): `S` - -##### Returns - -`S` - -## Methods - -### hydrate - -▸ **hydrate**(`storeState`, `initialState`): `void` - -Allows hydrating the store during SSR when complex state (like client side only refs) are used in the store -definition and copying the value from `pinia.state` isn't enough. - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `storeState` | `UnwrapRef`\<`S`\> | the current state in the store | -| `initialState` | `UnwrapRef`\<`S`\> | initialState | - -#### Returns - -`void` - -**`Example`** - -If in your `state`, you use any `customRef`s, any `computed`s, or any `ref`s that have a different value on -Server and Client, you need to manually hydrate them. e.g., a custom ref that is stored in the local -storage: - -```ts -const useStore = defineStore('main', { - state: () => ({ - n: useLocalStorage('key', 0) - }), - hydrate(storeState, initialState) { - // @ts-expect-error: https://github.com/microsoft/TypeScript/issues/43826 - storeState.n = useLocalStorage('key', 0) - } -}) -``` diff --git a/packages/docs/api/interfaces/pinia.DefineStoreOptionsBase.md b/packages/docs/api/interfaces/pinia.DefineStoreOptionsBase.md deleted file mode 100644 index 9a94f16b0..000000000 --- a/packages/docs/api/interfaces/pinia.DefineStoreOptionsBase.md +++ /dev/null @@ -1,28 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / DefineStoreOptionsBase - -# Interface: DefineStoreOptionsBase\ - -[pinia](../modules/pinia.md).DefineStoreOptionsBase - -Options passed to `defineStore()` that are common between option and setup -stores. Extend this interface if you want to add custom options to both kinds -of stores. - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `S` | extends [`StateTree`](../modules/pinia.md#StateTree) | -| `Store` | `Store` | - -## Hierarchy - -- **`DefineStoreOptionsBase`** - - ↳ [`DefineStoreOptions`](pinia.DefineStoreOptions.md) - - ↳ [`DefineSetupStoreOptions`](pinia.DefineSetupStoreOptions.md) diff --git a/packages/docs/api/interfaces/pinia.DefineStoreOptionsInPlugin.md b/packages/docs/api/interfaces/pinia.DefineStoreOptionsInPlugin.md deleted file mode 100644 index d7fafe9f5..000000000 --- a/packages/docs/api/interfaces/pinia.DefineStoreOptionsInPlugin.md +++ /dev/null @@ -1,111 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / DefineStoreOptionsInPlugin - -# Interface: DefineStoreOptionsInPlugin\ - -[pinia](../modules/pinia.md).DefineStoreOptionsInPlugin - -Available `options` when creating a pinia plugin. - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](../modules/pinia.md#StateTree) | -| `G` | `G` | -| `A` | `A` | - -## Hierarchy - -- `Omit`\<[`DefineStoreOptions`](pinia.DefineStoreOptions.md)\<`Id`, `S`, `G`, `A`\>, ``"id"`` \| ``"actions"``\> - - ↳ **`DefineStoreOptionsInPlugin`** - -## Properties - -### actions - -• **actions**: `A` - -Extracted object of actions. Added by useStore() when the store is built -using the setup API, otherwise uses the one passed to `defineStore()`. -Defaults to an empty object if no actions are defined. - -___ - -### getters - -• `Optional` **getters**: `G` & `ThisType`\<`UnwrapRef`\<`S`\> & [`_StoreWithGetters`](../modules/pinia.md#_StoreWithGetters)\<`G`\> & [`PiniaCustomProperties`](pinia.PiniaCustomProperties.md)\<`string`, [`StateTree`](../modules/pinia.md#StateTree), [`_GettersTree`](../modules/pinia.md#_GettersTree)\<[`StateTree`](../modules/pinia.md#StateTree)\>, [`_ActionsTree`](../modules/pinia.md#_ActionsTree)\>\> & [`_GettersTree`](../modules/pinia.md#_GettersTree)\<`S`\> - -Optional object of getters. - -#### Inherited from - -Omit.getters - -___ - -### state - -• `Optional` **state**: () => `S` - -Function to create a fresh state. **Must be an arrow function** to ensure -correct typings! - -#### Type declaration - -▸ (): `S` - -##### Returns - -`S` - -#### Inherited from - -Omit.state - -## Methods - -### hydrate - -▸ **hydrate**(`storeState`, `initialState`): `void` - -Allows hydrating the store during SSR when complex state (like client side only refs) are used in the store -definition and copying the value from `pinia.state` isn't enough. - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `storeState` | `UnwrapRef`\<`S`\> | the current state in the store | -| `initialState` | `UnwrapRef`\<`S`\> | initialState | - -#### Returns - -`void` - -**`Example`** - -If in your `state`, you use any `customRef`s, any `computed`s, or any `ref`s that have a different value on -Server and Client, you need to manually hydrate them. e.g., a custom ref that is stored in the local -storage: - -```ts -const useStore = defineStore('main', { - state: () => ({ - n: useLocalStorage('key', 0) - }), - hydrate(storeState, initialState) { - // @ts-expect-error: https://github.com/microsoft/TypeScript/issues/43826 - storeState.n = useLocalStorage('key', 0) - } -}) -``` - -#### Inherited from - -Omit.hydrate diff --git a/packages/docs/api/interfaces/pinia.Pinia.md b/packages/docs/api/interfaces/pinia.Pinia.md deleted file mode 100644 index 9293ed8aa..000000000 --- a/packages/docs/api/interfaces/pinia.Pinia.md +++ /dev/null @@ -1,63 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / Pinia - -# Interface: Pinia - -[pinia](../modules/pinia.md).Pinia - -Every application must own its own pinia to be able to create stores - -## Hierarchy - -- **`Pinia`** - - ↳ [`TestingPinia`](pinia_testing.TestingPinia.md) - -## Properties - -### install - -• **install**: (`app`: `App`\<`any`\>) => `void` - -#### Type declaration - -▸ (`app`): `void` - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `app` | `App`\<`any`\> | - -##### Returns - -`void` - -___ - -### state - -• **state**: `Ref`\<`Record`\<`string`, [`StateTree`](../modules/pinia.md#StateTree)\>\> - -root state - -## Methods - -### use - -▸ **use**(`plugin`): [`Pinia`](pinia.Pinia.md) - -Adds a store plugin to extend every store - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `plugin` | [`PiniaPlugin`](pinia.PiniaPlugin.md) | store plugin to add | - -#### Returns - -[`Pinia`](pinia.Pinia.md) diff --git a/packages/docs/api/interfaces/pinia.PiniaCustomProperties.md b/packages/docs/api/interfaces/pinia.PiniaCustomProperties.md deleted file mode 100644 index 7c673408c..000000000 --- a/packages/docs/api/interfaces/pinia.PiniaCustomProperties.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / PiniaCustomProperties - -# Interface: PiniaCustomProperties\ - -[pinia](../modules/pinia.md).PiniaCustomProperties - -Interface to be extended by the user when they add properties through plugins. - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` = `string` | -| `S` | extends [`StateTree`](../modules/pinia.md#StateTree) = [`StateTree`](../modules/pinia.md#StateTree) | -| `G` | [`_GettersTree`](../modules/pinia.md#_GettersTree)\<`S`\> | -| `A` | [`_ActionsTree`](../modules/pinia.md#_ActionsTree) | diff --git a/packages/docs/api/interfaces/pinia.PiniaCustomStateProperties.md b/packages/docs/api/interfaces/pinia.PiniaCustomStateProperties.md deleted file mode 100644 index 927b75c27..000000000 --- a/packages/docs/api/interfaces/pinia.PiniaCustomStateProperties.md +++ /dev/null @@ -1,17 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / PiniaCustomStateProperties - -# Interface: PiniaCustomStateProperties\ - -[pinia](../modules/pinia.md).PiniaCustomStateProperties - -Properties that are added to every `store.$state` by `pinia.use()`. - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `S` | extends [`StateTree`](../modules/pinia.md#StateTree) = [`StateTree`](../modules/pinia.md#StateTree) | diff --git a/packages/docs/api/interfaces/pinia.PiniaPlugin.md b/packages/docs/api/interfaces/pinia.PiniaPlugin.md deleted file mode 100644 index 222585e95..000000000 --- a/packages/docs/api/interfaces/pinia.PiniaPlugin.md +++ /dev/null @@ -1,30 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / PiniaPlugin - -# Interface: PiniaPlugin - -[pinia](../modules/pinia.md).PiniaPlugin - -Plugin to extend every store. - -## Callable - -### PiniaPlugin - -▸ **PiniaPlugin**(`context`): `void` \| `Partial`\<[`PiniaCustomProperties`](pinia.PiniaCustomProperties.md)\<`string`, [`StateTree`](../modules/pinia.md#StateTree), [`_GettersTree`](../modules/pinia.md#_GettersTree)\<[`StateTree`](../modules/pinia.md#StateTree)\>, [`_ActionsTree`](../modules/pinia.md#_ActionsTree)\> & [`PiniaCustomStateProperties`](pinia.PiniaCustomStateProperties.md)\<[`StateTree`](../modules/pinia.md#StateTree)\>\> - -Plugin to extend every store. Returns an object to extend the store or -nothing. - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `context` | [`PiniaPluginContext`](pinia.PiniaPluginContext.md)\<`string`, [`StateTree`](../modules/pinia.md#StateTree), [`_GettersTree`](../modules/pinia.md#_GettersTree)\<[`StateTree`](../modules/pinia.md#StateTree)\>, [`_ActionsTree`](../modules/pinia.md#_ActionsTree)\> | Context | - -#### Returns - -`void` \| `Partial`\<[`PiniaCustomProperties`](pinia.PiniaCustomProperties.md)\<`string`, [`StateTree`](../modules/pinia.md#StateTree), [`_GettersTree`](../modules/pinia.md#_GettersTree)\<[`StateTree`](../modules/pinia.md#StateTree)\>, [`_ActionsTree`](../modules/pinia.md#_ActionsTree)\> & [`PiniaCustomStateProperties`](pinia.PiniaCustomStateProperties.md)\<[`StateTree`](../modules/pinia.md#StateTree)\>\> diff --git a/packages/docs/api/interfaces/pinia.PiniaPluginContext.md b/packages/docs/api/interfaces/pinia.PiniaPluginContext.md deleted file mode 100644 index cf9d7d05a..000000000 --- a/packages/docs/api/interfaces/pinia.PiniaPluginContext.md +++ /dev/null @@ -1,52 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / PiniaPluginContext - -# Interface: PiniaPluginContext\ - -[pinia](../modules/pinia.md).PiniaPluginContext - -Context argument passed to Pinia plugins. - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` = `string` | -| `S` | extends [`StateTree`](../modules/pinia.md#StateTree) = [`StateTree`](../modules/pinia.md#StateTree) | -| `G` | [`_GettersTree`](../modules/pinia.md#_GettersTree)\<`S`\> | -| `A` | [`_ActionsTree`](../modules/pinia.md#_ActionsTree) | - -## Properties - -### app - -• **app**: `App`\<`any`\> - -Current app created with `Vue.createApp()`. - -___ - -### options - -• **options**: [`DefineStoreOptionsInPlugin`](pinia.DefineStoreOptionsInPlugin.md)\<`Id`, `S`, `G`, `A`\> - -Initial options defining the store when calling `defineStore()`. - -___ - -### pinia - -• **pinia**: [`Pinia`](pinia.Pinia.md) - -pinia instance. - -___ - -### store - -• **store**: [`Store`](../modules/pinia.md#Store)\<`Id`, `S`, `G`, `A`\> - -Current store being extended. diff --git a/packages/docs/api/interfaces/pinia.StoreDefinition.md b/packages/docs/api/interfaces/pinia.StoreDefinition.md deleted file mode 100644 index 5188f394d..000000000 --- a/packages/docs/api/interfaces/pinia.StoreDefinition.md +++ /dev/null @@ -1,53 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / StoreDefinition - -# Interface: StoreDefinition\ - -[pinia](../modules/pinia.md).StoreDefinition - -Return type of `defineStore()`. Function that allows instantiating a store. - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` = `string` | -| `S` | extends [`StateTree`](../modules/pinia.md#StateTree) = [`StateTree`](../modules/pinia.md#StateTree) | -| `G` | [`_GettersTree`](../modules/pinia.md#_GettersTree)\<`S`\> | -| `A` | [`_ActionsTree`](../modules/pinia.md#_ActionsTree) | - -## Hierarchy - -- **`StoreDefinition`** - - ↳ [`SetupStoreDefinition`](pinia.SetupStoreDefinition.md) - -## Callable - -### StoreDefinition - -▸ **StoreDefinition**(`pinia?`, `hot?`): [`Store`](../modules/pinia.md#Store)\<`Id`, `S`, `G`, `A`\> - -Returns a store, creates it if necessary. - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `pinia?` | ``null`` \| [`Pinia`](pinia.Pinia.md) | Pinia instance to retrieve the store | -| `hot?` | [`StoreGeneric`](../modules/pinia.md#StoreGeneric) | dev only hot module replacement | - -#### Returns - -[`Store`](../modules/pinia.md#Store)\<`Id`, `S`, `G`, `A`\> - -## Properties - -### $id - -• **$id**: `Id` - -Id of the store. Used by map helpers. diff --git a/packages/docs/api/interfaces/pinia.StoreProperties.md b/packages/docs/api/interfaces/pinia.StoreProperties.md deleted file mode 100644 index 1b02cf638..000000000 --- a/packages/docs/api/interfaces/pinia.StoreProperties.md +++ /dev/null @@ -1,41 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / StoreProperties - -# Interface: StoreProperties\ - -[pinia](../modules/pinia.md).StoreProperties - -Properties of a store. - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | - -## Hierarchy - -- **`StoreProperties`** - - ↳ [`_StoreWithState`](pinia._StoreWithState.md) - -## Properties - -### $id - -• **$id**: `Id` - -Unique identifier of the store - -___ - -### \_customProperties - -• **\_customProperties**: `Set`\<`string`\> - -Used by devtools plugin to retrieve properties added with plugins. Removed -in production. Can be used by the user to add property keys of the store -that should be displayed in devtools. diff --git a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationDirect.md b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationDirect.md deleted file mode 100644 index 860c38279..000000000 --- a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationDirect.md +++ /dev/null @@ -1,57 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / SubscriptionCallbackMutationDirect - -# Interface: SubscriptionCallbackMutationDirect - -[pinia](../modules/pinia.md).SubscriptionCallbackMutationDirect - -Context passed to a subscription callback when directly mutating the state of -a store with `store.someState = newValue` or `store.$state.someState = -newValue`. - -## Hierarchy - -- [`_SubscriptionCallbackMutationBase`](pinia._SubscriptionCallbackMutationBase.md) - - ↳ **`SubscriptionCallbackMutationDirect`** - -## Properties - -### events - -• **events**: `DebuggerEvent` - -🔴 DEV ONLY, DO NOT use for production code. Different mutation calls. Comes from -https://vuejs.org/guide/extras/reactivity-in-depth.html#reactivity-debugging and allows to track mutations in -devtools and plugins **during development only**. - -#### Overrides - -[_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[events](pinia._SubscriptionCallbackMutationBase.md#events) - -___ - -### storeId - -• **storeId**: `string` - -`id` of the store doing the mutation. - -#### Inherited from - -[_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[storeId](pinia._SubscriptionCallbackMutationBase.md#storeId) - -___ - -### type - -• **type**: [`direct`](../enums/pinia.MutationType.md#direct) - -Type of the mutation. - -#### Overrides - -[_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[type](pinia._SubscriptionCallbackMutationBase.md#type) diff --git a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md deleted file mode 100644 index e023d25fe..000000000 --- a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md +++ /dev/null @@ -1,56 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / SubscriptionCallbackMutationPatchFunction - -# Interface: SubscriptionCallbackMutationPatchFunction - -[pinia](../modules/pinia.md).SubscriptionCallbackMutationPatchFunction - -Context passed to a subscription callback when `store.$patch()` is called -with a function. - -## Hierarchy - -- [`_SubscriptionCallbackMutationBase`](pinia._SubscriptionCallbackMutationBase.md) - - ↳ **`SubscriptionCallbackMutationPatchFunction`** - -## Properties - -### events - -• **events**: `DebuggerEvent`[] - -🔴 DEV ONLY, DO NOT use for production code. Different mutation calls. Comes from -https://vuejs.org/guide/extras/reactivity-in-depth.html#reactivity-debugging and allows to track mutations in -devtools and plugins **during development only**. - -#### Overrides - -[_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[events](pinia._SubscriptionCallbackMutationBase.md#events) - -___ - -### storeId - -• **storeId**: `string` - -`id` of the store doing the mutation. - -#### Inherited from - -[_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[storeId](pinia._SubscriptionCallbackMutationBase.md#storeId) - -___ - -### type - -• **type**: [`patchFunction`](../enums/pinia.MutationType.md#patchFunction) - -Type of the mutation. - -#### Overrides - -[_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[type](pinia._SubscriptionCallbackMutationBase.md#type) diff --git a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchObject.md b/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchObject.md deleted file mode 100644 index b63fd2186..000000000 --- a/packages/docs/api/interfaces/pinia.SubscriptionCallbackMutationPatchObject.md +++ /dev/null @@ -1,70 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / SubscriptionCallbackMutationPatchObject - -# Interface: SubscriptionCallbackMutationPatchObject\ - -[pinia](../modules/pinia.md).SubscriptionCallbackMutationPatchObject - -Context passed to a subscription callback when `store.$patch()` is called -with an object. - -## Type parameters - -| Name | -| :------ | -| `S` | - -## Hierarchy - -- [`_SubscriptionCallbackMutationBase`](pinia._SubscriptionCallbackMutationBase.md) - - ↳ **`SubscriptionCallbackMutationPatchObject`** - -## Properties - -### events - -• **events**: `DebuggerEvent`[] - -🔴 DEV ONLY, DO NOT use for production code. Different mutation calls. Comes from -https://vuejs.org/guide/extras/reactivity-in-depth.html#reactivity-debugging and allows to track mutations in -devtools and plugins **during development only**. - -#### Overrides - -[_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[events](pinia._SubscriptionCallbackMutationBase.md#events) - -___ - -### payload - -• **payload**: [`_DeepPartial`](../modules/pinia.md#_DeepPartial)\<`S`\> - -Object passed to `store.$patch()`. - -___ - -### storeId - -• **storeId**: `string` - -`id` of the store doing the mutation. - -#### Inherited from - -[_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[storeId](pinia._SubscriptionCallbackMutationBase.md#storeId) - -___ - -### type - -• **type**: [`patchObject`](../enums/pinia.MutationType.md#patchObject) - -Type of the mutation. - -#### Overrides - -[_SubscriptionCallbackMutationBase](pinia._SubscriptionCallbackMutationBase.md).[type](pinia._SubscriptionCallbackMutationBase.md#type) diff --git a/packages/docs/api/interfaces/pinia._StoreOnActionListenerContext.md b/packages/docs/api/interfaces/pinia._StoreOnActionListenerContext.md deleted file mode 100644 index 4fd238ec7..000000000 --- a/packages/docs/api/interfaces/pinia._StoreOnActionListenerContext.md +++ /dev/null @@ -1,91 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / \_StoreOnActionListenerContext - -# Interface: \_StoreOnActionListenerContext\ - -[pinia](../modules/pinia.md)._StoreOnActionListenerContext - -Actual type for [StoreOnActionListenerContext](../modules/pinia.md#StoreOnActionListenerContext). Exists for refactoring -purposes. For internal use only. -For internal use **only** - -## Type parameters - -| Name | Type | -| :------ | :------ | -| `Store` | `Store` | -| `ActionName` | extends `string` | -| `A` | `A` | - -## Properties - -### after - -• **after**: (`callback`: `A` extends `Record`\<`ActionName`, [`_Method`](../modules/pinia.md#_Method)\> ? (`resolvedReturn`: [`_Awaited`](../modules/pinia.md#_Awaited)\<`ReturnType`\<`A`\<`A`\>[`ActionName`]\>\>) => `void` : () => `void`) => `void` - -Sets up a hook once the action is finished. It receives the return value -of the action, if it's a Promise, it will be unwrapped. - -#### Type declaration - -▸ (`callback`): `void` - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `callback` | `A` extends `Record`\<`ActionName`, [`_Method`](../modules/pinia.md#_Method)\> ? (`resolvedReturn`: [`_Awaited`](../modules/pinia.md#_Awaited)\<`ReturnType`\<`A`\<`A`\>[`ActionName`]\>\>) => `void` : () => `void` | - -##### Returns - -`void` - -___ - -### args - -• **args**: `A` extends `Record`\<`ActionName`, [`_Method`](../modules/pinia.md#_Method)\> ? `Parameters`\<`A`\<`A`\>[`ActionName`]\> : `unknown`[] - -Parameters passed to the action - -___ - -### name - -• **name**: `ActionName` - -Name of the action - -___ - -### onError - -• **onError**: (`callback`: (`error`: `unknown`) => `void`) => `void` - -Sets up a hook if the action fails. Return `false` to catch the error and -stop it from propagating. - -#### Type declaration - -▸ (`callback`): `void` - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `callback` | (`error`: `unknown`) => `void` | - -##### Returns - -`void` - -___ - -### store - -• **store**: `Store` - -Store that is invoking the action diff --git a/packages/docs/api/interfaces/pinia._SubscriptionCallbackMutationBase.md b/packages/docs/api/interfaces/pinia._SubscriptionCallbackMutationBase.md deleted file mode 100644 index e01669801..000000000 --- a/packages/docs/api/interfaces/pinia._SubscriptionCallbackMutationBase.md +++ /dev/null @@ -1,47 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / \_SubscriptionCallbackMutationBase - -# Interface: \_SubscriptionCallbackMutationBase - -[pinia](../modules/pinia.md)._SubscriptionCallbackMutationBase - -Base type for the context passed to a subscription callback. Internal type. - -## Hierarchy - -- **`_SubscriptionCallbackMutationBase`** - - ↳ [`SubscriptionCallbackMutationDirect`](pinia.SubscriptionCallbackMutationDirect.md) - - ↳ [`SubscriptionCallbackMutationPatchFunction`](pinia.SubscriptionCallbackMutationPatchFunction.md) - - ↳ [`SubscriptionCallbackMutationPatchObject`](pinia.SubscriptionCallbackMutationPatchObject.md) - -## Properties - -### events - -• `Optional` **events**: `DebuggerEvent` \| `DebuggerEvent`[] - -🔴 DEV ONLY, DO NOT use for production code. Different mutation calls. Comes from -https://vuejs.org/guide/extras/reactivity-in-depth.html#reactivity-debugging and allows to track mutations in -devtools and plugins **during development only**. - -___ - -### storeId - -• **storeId**: `string` - -`id` of the store doing the mutation. - -___ - -### type - -• **type**: [`MutationType`](../enums/pinia.MutationType.md) - -Type of the mutation. diff --git a/packages/docs/api/interfaces/pinia_testing.TestingPinia.md b/packages/docs/api/interfaces/pinia_testing.TestingPinia.md deleted file mode 100644 index cc51968e3..000000000 --- a/packages/docs/api/interfaces/pinia_testing.TestingPinia.md +++ /dev/null @@ -1,84 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / [@pinia/testing](../modules/pinia_testing.md) / TestingPinia - -# Interface: TestingPinia - -[@pinia/testing](../modules/pinia_testing.md).TestingPinia - -Pinia instance specifically designed for testing. Extends a regular -`Pinia` instance with test specific properties. - -## Hierarchy - -- [`Pinia`](pinia.Pinia.md) - - ↳ **`TestingPinia`** - -## Properties - -### app - -• **app**: `App`\<`any`\> - -App used by Pinia - -___ - -### install - -• **install**: (`app`: `App`\<`any`\>) => `void` - -#### Type declaration - -▸ (`app`): `void` - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `app` | `App`\<`any`\> | - -##### Returns - -`void` - -#### Inherited from - -[Pinia](pinia.Pinia.md).[install](pinia.Pinia.md#install) - -___ - -### state - -• **state**: `Ref`\<`Record`\<`string`, [`StateTree`](../modules/pinia.md#StateTree)\>\> - -root state - -#### Inherited from - -[Pinia](pinia.Pinia.md).[state](pinia.Pinia.md#state) - -## Methods - -### use - -▸ **use**(`plugin`): [`Pinia`](pinia.Pinia.md) - -Adds a store plugin to extend every store - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `plugin` | [`PiniaPlugin`](pinia.PiniaPlugin.md) | store plugin to add | - -#### Returns - -[`Pinia`](pinia.Pinia.md) - -#### Inherited from - -[Pinia](pinia.Pinia.md).[use](pinia.Pinia.md#use) diff --git a/packages/docs/api/modules/pinia.md b/packages/docs/api/modules/pinia.md deleted file mode 100644 index ec7801937..000000000 --- a/packages/docs/api/modules/pinia.md +++ /dev/null @@ -1,1221 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / pinia - -# Module: pinia - -## Enumerations - -- [MutationType](../enums/pinia.MutationType.md) - -## Interfaces - -- [DefineSetupStoreOptions](../interfaces/pinia.DefineSetupStoreOptions.md) -- [DefineStoreOptions](../interfaces/pinia.DefineStoreOptions.md) -- [DefineStoreOptionsBase](../interfaces/pinia.DefineStoreOptionsBase.md) -- [DefineStoreOptionsInPlugin](../interfaces/pinia.DefineStoreOptionsInPlugin.md) -- [MapStoresCustomization](../interfaces/pinia.MapStoresCustomization.md) -- [Pinia](../interfaces/pinia.Pinia.md) -- [PiniaCustomProperties](../interfaces/pinia.PiniaCustomProperties.md) -- [PiniaCustomStateProperties](../interfaces/pinia.PiniaCustomStateProperties.md) -- [PiniaPlugin](../interfaces/pinia.PiniaPlugin.md) -- [PiniaPluginContext](../interfaces/pinia.PiniaPluginContext.md) -- [SetupStoreDefinition](../interfaces/pinia.SetupStoreDefinition.md) -- [StoreDefinition](../interfaces/pinia.StoreDefinition.md) -- [StoreProperties](../interfaces/pinia.StoreProperties.md) -- [SubscriptionCallbackMutationDirect](../interfaces/pinia.SubscriptionCallbackMutationDirect.md) -- [SubscriptionCallbackMutationPatchFunction](../interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md) -- [SubscriptionCallbackMutationPatchObject](../interfaces/pinia.SubscriptionCallbackMutationPatchObject.md) -- [\_StoreOnActionListenerContext](../interfaces/pinia._StoreOnActionListenerContext.md) -- [\_StoreWithState](../interfaces/pinia._StoreWithState.md) -- [\_SubscriptionCallbackMutationBase](../interfaces/pinia._SubscriptionCallbackMutationBase.md) - -## Type Aliases - -### PiniaStorePlugin - -Ƭ **PiniaStorePlugin**: [`PiniaPlugin`](../interfaces/pinia.PiniaPlugin.md) - -Plugin to extend every store. - -**`Deprecated`** - -use PiniaPlugin instead - -___ - -### StateTree - -Ƭ **StateTree**: `Record`\<`string` \| `number` \| `symbol`, `any`\> - -Generic state of a Store - -___ - -### Store - -Ƭ **Store**\<`Id`, `S`, `G`, `A`\>: [`_StoreWithState`](../interfaces/pinia._StoreWithState.md)\<`Id`, `S`, `G`, `A`\> & `UnwrapRef`\<`S`\> & [`_StoreWithGetters`](pinia.md#_StoreWithGetters)\<`G`\> & [`_ActionsTree`](pinia.md#_ActionsTree) extends `A` ? {} : `A` & [`PiniaCustomProperties`](../interfaces/pinia.PiniaCustomProperties.md)\<`Id`, `S`, `G`, `A`\> & [`PiniaCustomStateProperties`](../interfaces/pinia.PiniaCustomStateProperties.md)\<`S`\> - -Store type to build a store. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` = `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) = {} | -| `G` | {} | -| `A` | {} | - -___ - -### StoreActions - -Ƭ **StoreActions**\<`SS`\>: `SS` extends [`Store`](pinia.md#Store)\<`string`, [`StateTree`](pinia.md#StateTree), [`_GettersTree`](pinia.md#_GettersTree)\<[`StateTree`](pinia.md#StateTree)\>, infer A\> ? `A` : [`_ExtractActionsFromSetupStore`](pinia.md#_ExtractActionsFromSetupStore)\<`SS`\> - -Extract the actions of a store type. Works with both a Setup Store or an -Options Store. - -#### Type parameters - -| Name | -| :------ | -| `SS` | - -___ - -### StoreGeneric - -Ƭ **StoreGeneric**: [`Store`](pinia.md#Store)\<`string`, [`StateTree`](pinia.md#StateTree), [`_GettersTree`](pinia.md#_GettersTree)\<[`StateTree`](pinia.md#StateTree)\>, [`_ActionsTree`](pinia.md#_ActionsTree)\> - -Generic and type-unsafe version of Store. Doesn't fail on access with -strings, making it much easier to write generic functions that do not care -about the kind of store that is passed. - -___ - -### StoreGetters - -Ƭ **StoreGetters**\<`SS`\>: `SS` extends [`Store`](pinia.md#Store)\<`string`, [`StateTree`](pinia.md#StateTree), infer G, [`_ActionsTree`](pinia.md#_ActionsTree)\> ? [`_StoreWithGetters`](pinia.md#_StoreWithGetters)\<`G`\> : [`_ExtractGettersFromSetupStore`](pinia.md#_ExtractGettersFromSetupStore)\<`SS`\> - -Extract the getters of a store type. Works with both a Setup Store or an -Options Store. - -#### Type parameters - -| Name | -| :------ | -| `SS` | - -___ - -### StoreOnActionListener - -Ƭ **StoreOnActionListener**\<`Id`, `S`, `G`, `A`\>: (`context`: [`StoreOnActionListenerContext`](pinia.md#StoreOnActionListenerContext)\<`Id`, `S`, `G`, {} extends `A` ? [`_ActionsTree`](pinia.md#_ActionsTree) : `A`\>) => `void` - -Argument of `store.$onAction()` - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) | -| `G` | `G` | -| `A` | `A` | - -#### Type declaration - -▸ (`context`): `void` - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `context` | [`StoreOnActionListenerContext`](pinia.md#StoreOnActionListenerContext)\<`Id`, `S`, `G`, {} extends `A` ? [`_ActionsTree`](pinia.md#_ActionsTree) : `A`\> | - -##### Returns - -`void` - -___ - -### StoreOnActionListenerContext - -Ƭ **StoreOnActionListenerContext**\<`Id`, `S`, `G`, `A`\>: [`_ActionsTree`](pinia.md#_ActionsTree) extends `A` ? [`_StoreOnActionListenerContext`](../interfaces/pinia._StoreOnActionListenerContext.md)\<[`StoreGeneric`](pinia.md#StoreGeneric), `string`, [`_ActionsTree`](pinia.md#_ActionsTree)\> : \{ [Name in keyof A]: Name extends string ? \_StoreOnActionListenerContext\, Name, A\> : never }[keyof `A`] - -Context object passed to callbacks of `store.$onAction(context => {})` -TODO: should have only the Id, the Store and Actions to generate the proper object - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) | -| `G` | `G` | -| `A` | `A` | - -___ - -### StoreState - -Ƭ **StoreState**\<`SS`\>: `SS` extends [`Store`](pinia.md#Store)\<`string`, infer S, [`_GettersTree`](pinia.md#_GettersTree)\<[`StateTree`](pinia.md#StateTree)\>, [`_ActionsTree`](pinia.md#_ActionsTree)\> ? `UnwrapRef`\<`S`\> : [`_ExtractStateFromSetupStore`](pinia.md#_ExtractStateFromSetupStore)\<`SS`\> - -Extract the state of a store type. Works with both a Setup Store or an -Options Store. Note this unwraps refs. - -#### Type parameters - -| Name | -| :------ | -| `SS` | - -___ - -### SubscriptionCallback - -Ƭ **SubscriptionCallback**\<`S`\>: (`mutation`: [`SubscriptionCallbackMutation`](pinia.md#SubscriptionCallbackMutation)\<`S`\>, `state`: `UnwrapRef`\<`S`\>) => `void` - -Callback of a subscription - -#### Type parameters - -| Name | -| :------ | -| `S` | - -#### Type declaration - -▸ (`mutation`, `state`): `void` - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `mutation` | [`SubscriptionCallbackMutation`](pinia.md#SubscriptionCallbackMutation)\<`S`\> | -| `state` | `UnwrapRef`\<`S`\> | - -##### Returns - -`void` - -___ - -### SubscriptionCallbackMutation - -Ƭ **SubscriptionCallbackMutation**\<`S`\>: [`SubscriptionCallbackMutationDirect`](../interfaces/pinia.SubscriptionCallbackMutationDirect.md) \| [`SubscriptionCallbackMutationPatchObject`](../interfaces/pinia.SubscriptionCallbackMutationPatchObject.md)\<`S`\> \| [`SubscriptionCallbackMutationPatchFunction`](../interfaces/pinia.SubscriptionCallbackMutationPatchFunction.md) - -Context object passed to a subscription callback. - -#### Type parameters - -| Name | -| :------ | -| `S` | - -___ - -### \_ActionsTree - -Ƭ **\_ActionsTree**: `Record`\<`string`, [`_Method`](pinia.md#_Method)\> - -Type of an object of Actions. For internal usage only. -For internal use **only** - -___ - -### \_Awaited - -Ƭ **\_Awaited**\<`T`\>: `T` extends ``null`` \| `undefined` ? `T` : `T` extends `object` & \{ `then`: (`onfulfilled`: `F`) => `any` } ? `F` extends (`value`: infer V, ...`args`: `any`) => `any` ? [`_Awaited`](pinia.md#_Awaited)\<`V`\> : `never` : `T` - -#### Type parameters - -| Name | -| :------ | -| `T` | - -___ - -### \_DeepPartial - -Ƭ **\_DeepPartial**\<`T`\>: \{ [K in keyof T]?: \_DeepPartial\ } - -Recursive `Partial`. Used by [['$patch']](pinia.md#Store). - -For internal use **only** - -#### Type parameters - -| Name | -| :------ | -| `T` | - -___ - -### \_ExtractActionsFromSetupStore - -Ƭ **\_ExtractActionsFromSetupStore**\<`SS`\>: `SS` extends `undefined` \| `void` ? {} : [`_ExtractActionsFromSetupStore_Keys`](pinia.md#_ExtractActionsFromSetupStore_Keys)\<`SS`\> extends keyof `SS` ? `Pick`\<`SS`, [`_ExtractActionsFromSetupStore_Keys`](pinia.md#_ExtractActionsFromSetupStore_Keys)\<`SS`\>\> : `never` - -For internal use **only** - -#### Type parameters - -| Name | -| :------ | -| `SS` | - -___ - -### \_ExtractActionsFromSetupStore\_Keys - -Ƭ **\_ExtractActionsFromSetupStore\_Keys**\<`SS`\>: keyof \{ [K in keyof SS as SS[K] extends \_Method ? K : never]: any } - -Type that enables refactoring through IDE. -For internal use **only** - -#### Type parameters - -| Name | -| :------ | -| `SS` | - -___ - -### \_ExtractGettersFromSetupStore - -Ƭ **\_ExtractGettersFromSetupStore**\<`SS`\>: `SS` extends `undefined` \| `void` ? {} : [`_ExtractGettersFromSetupStore_Keys`](pinia.md#_ExtractGettersFromSetupStore_Keys)\<`SS`\> extends keyof `SS` ? `Pick`\<`SS`, [`_ExtractGettersFromSetupStore_Keys`](pinia.md#_ExtractGettersFromSetupStore_Keys)\<`SS`\>\> : `never` - -For internal use **only** - -#### Type parameters - -| Name | -| :------ | -| `SS` | - -___ - -### \_ExtractGettersFromSetupStore\_Keys - -Ƭ **\_ExtractGettersFromSetupStore\_Keys**\<`SS`\>: keyof \{ [K in keyof SS as SS[K] extends ComputedRef ? K : never]: any } - -Type that enables refactoring through IDE. -For internal use **only** - -#### Type parameters - -| Name | -| :------ | -| `SS` | - -___ - -### \_ExtractStateFromSetupStore - -Ƭ **\_ExtractStateFromSetupStore**\<`SS`\>: `SS` extends `undefined` \| `void` ? {} : [`_ExtractStateFromSetupStore_Keys`](pinia.md#_ExtractStateFromSetupStore_Keys)\<`SS`\> extends keyof `SS` ? [`_UnwrapAll`](pinia.md#_UnwrapAll)\<`Pick`\<`SS`, [`_ExtractStateFromSetupStore_Keys`](pinia.md#_ExtractStateFromSetupStore_Keys)\<`SS`\>\>\> : `never` - -For internal use **only** - -#### Type parameters - -| Name | -| :------ | -| `SS` | - -___ - -### \_ExtractStateFromSetupStore\_Keys - -Ƭ **\_ExtractStateFromSetupStore\_Keys**\<`SS`\>: keyof \{ [K in keyof SS as SS[K] extends \_Method \| ComputedRef ? never : K]: any } - -Type that enables refactoring through IDE. -For internal use **only** - -#### Type parameters - -| Name | -| :------ | -| `SS` | - -___ - -### \_GettersTree - -Ƭ **\_GettersTree**\<`S`\>: `Record`\<`string`, (`state`: `UnwrapRef`\<`S`\> & `UnwrapRef`\<[`PiniaCustomStateProperties`](../interfaces/pinia.PiniaCustomStateProperties.md)\<`S`\>\>) => `any` \| () => `any`\> - -Type of an object of Getters that infers the argument. For internal usage only. -For internal use **only** - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `S` | extends [`StateTree`](pinia.md#StateTree) | - -___ - -### \_MapActionsObjectReturn - -Ƭ **\_MapActionsObjectReturn**\<`A`, `T`\>: \{ [key in keyof T]: A[T[key]] } - -For internal use **only** - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `A` | `A` | -| `T` | extends `Record`\<`string`, keyof `A`\> | - -___ - -### \_MapActionsReturn - -Ƭ **\_MapActionsReturn**\<`A`\>: \{ [key in keyof A]: A[key] } - -For internal use **only** - -#### Type parameters - -| Name | -| :------ | -| `A` | - -___ - -### \_MapStateObjectReturn - -Ƭ **\_MapStateObjectReturn**\<`Id`, `S`, `G`, `A`, `T`\>: \{ [key in keyof T]: Function } - -For internal use **only** - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) | -| `G` | extends [`_GettersTree`](pinia.md#_GettersTree)\<`S`\> \| \{ `[key: string]`: `ComputedRef`; } | -| `A` | `A` | -| `T` | extends `Record`\<`string`, keyof `S` \| keyof `G` \| (`store`: [`Store`](pinia.md#Store)\<`Id`, `S`, `G`, `A`\>) => `any`\> = {} | - -___ - -### \_MapStateReturn - -Ƭ **\_MapStateReturn**\<`S`, `G`, `Keys`\>: \{ [key in Keys]: Function } - -For internal use **only** - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `S` | extends [`StateTree`](pinia.md#StateTree) | -| `G` | extends [`_GettersTree`](pinia.md#_GettersTree)\<`S`\> \| \{ `[key: string]`: `ComputedRef`; } | -| `Keys` | extends keyof `S` \| keyof `G` = keyof `S` \| keyof `G` | - -___ - -### \_MapWritableStateObjectReturn - -Ƭ **\_MapWritableStateObjectReturn**\<`S`, `T`\>: \{ [key in keyof T]: Object } - -For internal use **only** - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `S` | extends [`StateTree`](pinia.md#StateTree) | -| `T` | extends `Record`\<`string`, keyof `S`\> | - -___ - -### \_MapWritableStateReturn - -Ƭ **\_MapWritableStateReturn**\<`S`\>: \{ [key in keyof S]: Object } - -For internal use **only** - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `S` | extends [`StateTree`](pinia.md#StateTree) | - -___ - -### \_Method - -Ƭ **\_Method**: (...`args`: `any`[]) => `any` - -Generic type for a function that can infer arguments and return type - -For internal use **only** - -#### Type declaration - -▸ (`...args`): `any` - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `...args` | `any`[] | - -##### Returns - -`any` - -___ - -### \_Spread - -Ƭ **\_Spread**\<`A`\>: `A` extends [infer L, ...(infer R)] ? [`_StoreObject`](pinia.md#_StoreObject)\<`L`\> & [`_Spread`](pinia.md#_Spread)\<`R`\> : `unknown` - -For internal use **only**. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `A` | extends readonly `any`[] | - -___ - -### \_StoreObject - -Ƭ **\_StoreObject**\<`S`\>: `S` extends [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\ ? \{ [Id in \`$\{Ids}$\{MapStoresCustomization extends Record\<"suffix", infer Suffix\> ? Suffix : "Store"}\`]: Function } : {} - -For internal use **only**. - -#### Type parameters - -| Name | -| :------ | -| `S` | - -___ - -### \_StoreWithActions - -Ƭ **\_StoreWithActions**\<`A`\>: \{ [k in keyof A]: A[k] extends Function ? Function : never } - -Store augmented for actions. For internal usage only. -For internal use **only** - -#### Type parameters - -| Name | -| :------ | -| `A` | - -___ - -### \_StoreWithGetters - -Ƭ **\_StoreWithGetters**\<`G`\>: \{ readonly [k in keyof G]: G[k] extends Function ? R : UnwrapRef\ } - -Store augmented with getters. For internal usage only. -For internal use **only** - -#### Type parameters - -| Name | -| :------ | -| `G` | - -___ - -### \_UnwrapAll - -Ƭ **\_UnwrapAll**\<`SS`\>: \{ [K in keyof SS]: UnwrapRef\ } - -Type that enables refactoring through IDE. -For internal use **only** - -#### Type parameters - -| Name | -| :------ | -| `SS` | - -## Variables - -### PiniaVuePlugin - -• `Const` **PiniaVuePlugin**: `Plugin` - -Vue 2 Plugin that must be installed for pinia to work. Note **you don't need -this plugin if you are using Nuxt.js**. Use the `buildModule` instead: -https://pinia.vuejs.org/ssr/nuxt.html. - -**`Example`** - -```js -import Vue from 'vue' -import { PiniaVuePlugin, createPinia } from 'pinia' - -Vue.use(PiniaVuePlugin) -const pinia = createPinia() - -new Vue({ - el: '#app', - // ... - pinia, -}) -``` - -**`Param`** - -`Vue` imported from 'vue'. - -## Functions - -### acceptHMRUpdate - -▸ **acceptHMRUpdate**\<`Id`, `S`, `G`, `A`\>(`initialUseStore`, `hot`): (`newModule`: `any`) => `any` - -Creates an _accept_ function to pass to `import.meta.hot` in Vite applications. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` = `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) = [`StateTree`](pinia.md#StateTree) | -| `G` | extends [`_GettersTree`](pinia.md#_GettersTree)\<`S`\> = [`_GettersTree`](pinia.md#_GettersTree)\<`S`\> | -| `A` | [`_ActionsTree`](pinia.md#_ActionsTree) | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `initialUseStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> | return of the defineStore to hot update | -| `hot` | `any` | `import.meta.hot` | - -#### Returns - -`fn` - -▸ (`newModule`): `any` - -##### Parameters - -| Name | Type | -| :------ | :------ | -| `newModule` | `any` | - -##### Returns - -`any` - -**`Example`** - -```js -const useUser = defineStore(...) -if (import.meta.hot) { - import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot)) -} -``` - -___ - -### createPinia - -▸ **createPinia**(): [`Pinia`](../interfaces/pinia.Pinia.md) - -Creates a Pinia instance to be used by the application - -#### Returns - -[`Pinia`](../interfaces/pinia.Pinia.md) - -___ - -### defineStore - -▸ **defineStore**\<`Id`, `S`, `G`, `A`\>(`id`, `options`): [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> - -Creates a `useStore` function that retrieves the store instance - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) = {} | -| `G` | extends [`_GettersTree`](pinia.md#_GettersTree)\<`S`\> = {} | -| `A` | {} | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `id` | `Id` | id of the store (must be unique) | -| `options` | `Omit`\<[`DefineStoreOptions`](../interfaces/pinia.DefineStoreOptions.md)\<`Id`, `S`, `G`, `A`\>, ``"id"``\> | options to define the store | - -#### Returns - -[`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> - -▸ **defineStore**\<`Id`, `S`, `G`, `A`\>(`options`): [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> - -Creates a `useStore` function that retrieves the store instance - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) = {} | -| `G` | extends [`_GettersTree`](pinia.md#_GettersTree)\<`S`\> = {} | -| `A` | {} | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `options` | [`DefineStoreOptions`](../interfaces/pinia.DefineStoreOptions.md)\<`Id`, `S`, `G`, `A`\> | options to define the store | - -#### Returns - -[`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> - -▸ **defineStore**\<`Id`, `SS`\>(`id`, `storeSetup`, `options?`): [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, [`_ExtractStateFromSetupStore`](pinia.md#_ExtractStateFromSetupStore)\<`SS`\>, [`_ExtractGettersFromSetupStore`](pinia.md#_ExtractGettersFromSetupStore)\<`SS`\>, [`_ExtractActionsFromSetupStore`](pinia.md#_ExtractActionsFromSetupStore)\<`SS`\>\> - -Creates a `useStore` function that retrieves the store instance - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `SS` | `SS` | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `id` | `Id` | id of the store (must be unique) | -| `storeSetup` | () => `SS` | function that defines the store | -| `options?` | [`DefineSetupStoreOptions`](../interfaces/pinia.DefineSetupStoreOptions.md)\<`Id`, [`_ExtractStateFromSetupStore`](pinia.md#_ExtractStateFromSetupStore)\<`SS`\>, [`_ExtractGettersFromSetupStore`](pinia.md#_ExtractGettersFromSetupStore)\<`SS`\>, [`_ExtractActionsFromSetupStore`](pinia.md#_ExtractActionsFromSetupStore)\<`SS`\>\> | extra options | - -#### Returns - -[`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, [`_ExtractStateFromSetupStore`](pinia.md#_ExtractStateFromSetupStore)\<`SS`\>, [`_ExtractGettersFromSetupStore`](pinia.md#_ExtractGettersFromSetupStore)\<`SS`\>, [`_ExtractActionsFromSetupStore`](pinia.md#_ExtractActionsFromSetupStore)\<`SS`\>\> - -___ - -### disposePinia - -▸ **disposePinia**(`pinia`): `void` - -Dispose a Pinia instance by stopping its effectScope and removing the state, plugins and stores. This is mostly -useful in tests, with both a testing pinia or a regular pinia and in applications that use multiple pinia instances. -Once disposed, the pinia instance cannot be used anymore. - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `pinia` | [`Pinia`](../interfaces/pinia.Pinia.md) | pinia instance | - -#### Returns - -`void` - -___ - -### getActivePinia - -▸ **getActivePinia**(): `undefined` \| [`Pinia`](../interfaces/pinia.Pinia.md) - -Get the currently active pinia if there is any. - -#### Returns - -`undefined` \| [`Pinia`](../interfaces/pinia.Pinia.md) - -___ - -### mapActions - -▸ **mapActions**\<`Id`, `S`, `G`, `A`, `KeyMapper`\>(`useStore`, `keyMapper`): [`_MapActionsObjectReturn`](pinia.md#_MapActionsObjectReturn)\<`A`, `KeyMapper`\> - -Allows directly using actions from your store without using the composition -API (`setup()`) by generating an object to be spread in the `methods` field -of a component. The values of the object are the actions while the keys are -the names of the resulting methods. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) | -| `G` | extends [`_GettersTree`](pinia.md#_GettersTree)\<`S`\> | -| `A` | `A` | -| `KeyMapper` | extends `Record`\<`string`, keyof `A`\> | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> | store to map from | -| `keyMapper` | `KeyMapper` | object to define new names for the actions | - -#### Returns - -[`_MapActionsObjectReturn`](pinia.md#_MapActionsObjectReturn)\<`A`, `KeyMapper`\> - -**`Example`** - -```js -export default { - methods: { - // other methods properties - // useCounterStore has two actions named `increment` and `setCount` - ...mapActions(useCounterStore, { moar: 'increment', setIt: 'setCount' }) - }, - - created() { - this.moar() - this.setIt(2) - } -} -``` - -▸ **mapActions**\<`Id`, `S`, `G`, `A`\>(`useStore`, `keys`): [`_MapActionsReturn`](pinia.md#_MapActionsReturn)\<`A`\> - -Allows directly using actions from your store without using the composition -API (`setup()`) by generating an object to be spread in the `methods` field -of a component. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) | -| `G` | extends [`_GettersTree`](pinia.md#_GettersTree)\<`S`\> | -| `A` | `A` | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> | store to map from | -| `keys` | keyof `A`[] | array of action names to map | - -#### Returns - -[`_MapActionsReturn`](pinia.md#_MapActionsReturn)\<`A`\> - -**`Example`** - -```js -export default { - methods: { - // other methods properties - ...mapActions(useCounterStore, ['increment', 'setCount']) - }, - - created() { - this.increment() - this.setCount(2) // pass arguments as usual - } -} -``` - -___ - -### mapGetters - -▸ **mapGetters**\<`Id`, `S`, `G`, `A`, `KeyMapper`\>(`useStore`, `keyMapper`): [`_MapStateObjectReturn`](pinia.md#_MapStateObjectReturn)\<`Id`, `S`, `G`, `A`, `KeyMapper`\> - -Alias for `mapState()`. You should use `mapState()` instead. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) | -| `G` | extends [`_GettersTree`](pinia.md#_GettersTree)\<`S`\> \| \{ `[key: string]`: `ComputedRef`; } | -| `A` | `A` | -| `KeyMapper` | extends `Record`\<`string`, keyof `S` \| keyof `G` \| (`store`: [`Store`](pinia.md#Store)\<`Id`, `S`, `G`, `A`\>) => `any`\> | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> | -| `keyMapper` | `KeyMapper` | - -#### Returns - -[`_MapStateObjectReturn`](pinia.md#_MapStateObjectReturn)\<`Id`, `S`, `G`, `A`, `KeyMapper`\> - -**`Deprecated`** - -use `mapState()` instead. - -▸ **mapGetters**\<`Id`, `S`, `G`, `A`, `Keys`\>(`useStore`, `keys`): [`_MapStateReturn`](pinia.md#_MapStateReturn)\<`S`, `G`, `Keys`\> - -Alias for `mapState()`. You should use `mapState()` instead. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) | -| `G` | extends [`_GettersTree`](pinia.md#_GettersTree)\<`S`\> \| \{ `[key: string]`: `ComputedRef`; } | -| `A` | `A` | -| `Keys` | extends `string` \| `number` \| `symbol` | - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> | -| `keys` | readonly `Keys`[] | - -#### Returns - -[`_MapStateReturn`](pinia.md#_MapStateReturn)\<`S`, `G`, `Keys`\> - -**`Deprecated`** - -use `mapState()` instead. - -___ - -### mapState - -▸ **mapState**\<`Id`, `S`, `G`, `A`, `KeyMapper`\>(`useStore`, `keyMapper`): [`_MapStateObjectReturn`](pinia.md#_MapStateObjectReturn)\<`Id`, `S`, `G`, `A`, `KeyMapper`\> - -Allows using state and getters from one store without using the composition -API (`setup()`) by generating an object to be spread in the `computed` field -of a component. The values of the object are the state properties/getters -while the keys are the names of the resulting computed properties. -Optionally, you can also pass a custom function that will receive the store -as its first argument. Note that while it has access to the component -instance via `this`, it won't be typed. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) | -| `G` | extends [`_GettersTree`](pinia.md#_GettersTree)\<`S`\> \| \{ `[key: string]`: `ComputedRef`; } | -| `A` | `A` | -| `KeyMapper` | extends `Record`\<`string`, keyof `S` \| keyof `G` \| (`store`: [`Store`](pinia.md#Store)\<`Id`, `S`, `G`, `A`\>) => `any`\> | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> | store to map from | -| `keyMapper` | `KeyMapper` | object of state properties or getters | - -#### Returns - -[`_MapStateObjectReturn`](pinia.md#_MapStateObjectReturn)\<`Id`, `S`, `G`, `A`, `KeyMapper`\> - -**`Example`** - -```js -export default { - computed: { - // other computed properties - // useCounterStore has a state property named `count` and a getter `double` - ...mapState(useCounterStore, { - n: 'count', - triple: store => store.n * 3, - // note we can't use an arrow function if we want to use `this` - custom(store) { - return this.someComponentValue + store.n - }, - doubleN: 'double' - }) - }, - - created() { - this.n // 2 - this.doubleN // 4 - } -} -``` - -▸ **mapState**\<`Id`, `S`, `G`, `A`, `Keys`\>(`useStore`, `keys`): [`_MapStateReturn`](pinia.md#_MapStateReturn)\<`S`, `G`, `Keys`\> - -Allows using state and getters from one store without using the composition -API (`setup()`) by generating an object to be spread in the `computed` field -of a component. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) | -| `G` | extends [`_GettersTree`](pinia.md#_GettersTree)\<`S`\> \| \{ `[key: string]`: `ComputedRef`; } | -| `A` | `A` | -| `Keys` | extends `string` \| `number` \| `symbol` | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> | store to map from | -| `keys` | readonly `Keys`[] | array of state properties or getters | - -#### Returns - -[`_MapStateReturn`](pinia.md#_MapStateReturn)\<`S`, `G`, `Keys`\> - -**`Example`** - -```js -export default { - computed: { - // other computed properties - ...mapState(useCounterStore, ['count', 'double']) - }, - - created() { - this.count // 2 - this.double // 4 - } -} -``` - -___ - -### mapStores - -▸ **mapStores**\<`Stores`\>(`...stores`): [`_Spread`](pinia.md#_Spread)\<`Stores`\> - -Allows using stores without the composition API (`setup()`) by generating an -object to be spread in the `computed` field of a component. It accepts a list -of store definitions. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Stores` | extends `any`[] | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `...stores` | [...Stores[]] | list of stores to map to an object | - -#### Returns - -[`_Spread`](pinia.md#_Spread)\<`Stores`\> - -**`Example`** - -```js -export default { - computed: { - // other computed properties - ...mapStores(useUserStore, useCartStore) - }, - - created() { - this.userStore // store with id "user" - this.cartStore // store with id "cart" - } -} -``` - -___ - -### mapWritableState - -▸ **mapWritableState**\<`Id`, `S`, `G`, `A`, `KeyMapper`\>(`useStore`, `keyMapper`): [`_MapWritableStateObjectReturn`](pinia.md#_MapWritableStateObjectReturn)\<`S`, `KeyMapper`\> - -Same as `mapState()` but creates computed setters as well so the state can be -modified. Differently from `mapState()`, only `state` properties can be -added. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) | -| `G` | extends [`_GettersTree`](pinia.md#_GettersTree)\<`S`\> | -| `A` | `A` | -| `KeyMapper` | extends `Record`\<`string`, keyof `S`\> | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> | store to map from | -| `keyMapper` | `KeyMapper` | object of state properties | - -#### Returns - -[`_MapWritableStateObjectReturn`](pinia.md#_MapWritableStateObjectReturn)\<`S`, `KeyMapper`\> - -▸ **mapWritableState**\<`Id`, `S`, `G`, `A`, `Keys`\>(`useStore`, `keys`): \{ [K in Keys]: Object } - -Allows using state and getters from one store without using the composition -API (`setup()`) by generating an object to be spread in the `computed` field -of a component. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](pinia.md#StateTree) | -| `G` | extends [`_GettersTree`](pinia.md#_GettersTree)\<`S`\> | -| `A` | `A` | -| `Keys` | extends `string` \| `number` \| `symbol` | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `useStore` | [`StoreDefinition`](../interfaces/pinia.StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> | store to map from | -| `keys` | readonly `Keys`[] | array of state properties | - -#### Returns - -\{ [K in Keys]: Object } - -___ - -### setActivePinia - -▸ **setActivePinia**(`pinia`): [`Pinia`](../interfaces/pinia.Pinia.md) - -Sets or unsets the active pinia. Used in SSR and internally when calling -actions and getters - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `pinia` | [`Pinia`](../interfaces/pinia.Pinia.md) | Pinia instance | - -#### Returns - -[`Pinia`](../interfaces/pinia.Pinia.md) - -▸ **setActivePinia**(`pinia`): `undefined` - -Sets or unsets the active pinia. Used in SSR and internally when calling -actions and getters - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `pinia` | `undefined` | Pinia instance | - -#### Returns - -`undefined` - -▸ **setActivePinia**(`pinia`): `undefined` \| [`Pinia`](../interfaces/pinia.Pinia.md) - -Sets or unsets the active pinia. Used in SSR and internally when calling -actions and getters - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `pinia` | `undefined` \| [`Pinia`](../interfaces/pinia.Pinia.md) | Pinia instance | - -#### Returns - -`undefined` \| [`Pinia`](../interfaces/pinia.Pinia.md) - -___ - -### setMapStoreSuffix - -▸ **setMapStoreSuffix**(`suffix`): `void` - -Changes the suffix added by `mapStores()`. Can be set to an empty string. -Defaults to `"Store"`. Make sure to extend the MapStoresCustomization -interface if you are using TypeScript. - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `suffix` | `string` | new suffix | - -#### Returns - -`void` - -___ - -### skipHydrate - -▸ **skipHydrate**\<`T`\>(`obj`): `T` - -Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a -stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `T` | `any` | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `obj` | `T` | target object | - -#### Returns - -`T` - -obj - -___ - -### storeToRefs - -▸ **storeToRefs**\<`SS`\>(`store`): `StoreToRefs`\<`SS`\> - -Creates an object of references with all the state, getters, and plugin-added -state properties of the store. Similar to `toRefs()` but specifically -designed for Pinia stores so methods and non reactive properties are -completely ignored. - -#### Type parameters - -| Name | Type | -| :------ | :------ | -| `SS` | extends [`StoreGeneric`](pinia.md#StoreGeneric) | - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `store` | `SS` | store to extract the refs from | - -#### Returns - -`StoreToRefs`\<`SS`\> diff --git a/packages/docs/api/modules/pinia_nuxt.md b/packages/docs/api/modules/pinia_nuxt.md deleted file mode 100644 index 8d325af3f..000000000 --- a/packages/docs/api/modules/pinia_nuxt.md +++ /dev/null @@ -1,29 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / @pinia/nuxt - -# Module: @pinia/nuxt - -## Interfaces - -- [ModuleOptions](../interfaces/pinia_nuxt.ModuleOptions.md) - -## Functions - -### default - -▸ **default**(`this`, `inlineOptions`, `nuxt`): `_ModuleSetupReturn` - -#### Parameters - -| Name | Type | -| :------ | :------ | -| `this` | `void` | -| `inlineOptions` | [`ModuleOptions`](../interfaces/pinia_nuxt.ModuleOptions.md) | -| `nuxt` | `Nuxt` | - -#### Returns - -`_ModuleSetupReturn` diff --git a/packages/docs/api/modules/pinia_testing.md b/packages/docs/api/modules/pinia_testing.md deleted file mode 100644 index 6b0ba1bdc..000000000 --- a/packages/docs/api/modules/pinia_testing.md +++ /dev/null @@ -1,37 +0,0 @@ ---- -editLink: false ---- - -[API Documentation](../index.md) / @pinia/testing - -# Module: @pinia/testing - -## Interfaces - -- [TestingOptions](../interfaces/pinia_testing.TestingOptions.md) -- [TestingPinia](../interfaces/pinia_testing.TestingPinia.md) - -## Functions - -### createTestingPinia - -▸ **createTestingPinia**(`options?`): [`TestingPinia`](../interfaces/pinia_testing.TestingPinia.md) - -Creates a pinia instance designed for unit tests that **requires mocking** -the stores. By default, **all actions are mocked** and therefore not -executed. This allows you to unit test your store and components separately. -You can change this with the `stubActions` option. If you are using jest, -they are replaced with `jest.fn()`, otherwise, you must provide your own -`createSpy` option. - -#### Parameters - -| Name | Type | Description | -| :------ | :------ | :------ | -| `options` | [`TestingOptions`](../interfaces/pinia_testing.TestingOptions.md) | options to configure the testing pinia | - -#### Returns - -[`TestingPinia`](../interfaces/pinia_testing.TestingPinia.md) - -a augmented pinia instance diff --git a/packages/docs/api/enums/pinia.MutationType.md b/packages/docs/api/pinia/enumerations/MutationType.md similarity index 66% rename from packages/docs/api/enums/pinia.MutationType.md rename to packages/docs/api/pinia/enumerations/MutationType.md index 5f2b7fd40..6533c3a21 100644 --- a/packages/docs/api/enums/pinia.MutationType.md +++ b/packages/docs/api/pinia/enumerations/MutationType.md @@ -2,11 +2,13 @@ editLink: false --- -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / MutationType +[**API Documentation**](../../index.md) • **Docs** -# Enumeration: MutationType +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / MutationType -[pinia](../modules/pinia.md).MutationType +# Enumeration: MutationType Possible types for SubscriptionCallback @@ -14,7 +16,7 @@ Possible types for SubscriptionCallback ### direct -• **direct** = ``"direct"`` +> **direct**: `"direct"` Direct mutation of the state: @@ -22,21 +24,21 @@ Direct mutation of the state: - `store.$state.name = 'new name'` - `store.list.push('new item')` -___ +*** ### patchFunction -• **patchFunction** = ``"patch function"`` +> **patchFunction**: `"patch function"` Mutated the state with `$patch` and a function - `store.$patch(state => state.name = 'newName')` -___ +*** ### patchObject -• **patchObject** = ``"patch object"`` +> **patchObject**: `"patch object"` Mutated the state with `$patch` and an object diff --git a/packages/docs/api/pinia/functions/acceptHMRUpdate.md b/packages/docs/api/pinia/functions/acceptHMRUpdate.md new file mode 100644 index 000000000..b57f60816 --- /dev/null +++ b/packages/docs/api/pinia/functions/acceptHMRUpdate.md @@ -0,0 +1,56 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / acceptHMRUpdate + +# Function: acceptHMRUpdate() + +> **acceptHMRUpdate**\<`Id`, `S`, `G`, `A`\>(`initialUseStore`, `hot`): (`newModule`) => `any` + +Creates an _accept_ function to pass to `import.meta.hot` in Vite applications. + +## Type Parameters + +• **Id** *extends* `string` = `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) = [`StateTree`](../type-aliases/StateTree.md) + +• **G** *extends* [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> = [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> + +• **A** = [`_ActionsTree`](../type-aliases/ActionsTree.md) + +## Parameters + +• **initialUseStore**: [`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> + +return of the defineStore to hot update + +• **hot**: `any` + +`import.meta.hot` + +## Returns + +`Function` + +### Parameters + +• **newModule**: `any` + +### Returns + +`any` + +## Example + +```js +const useUser = defineStore(...) +if (import.meta.hot) { + import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot)) +} +``` diff --git a/packages/docs/api/pinia/functions/createPinia.md b/packages/docs/api/pinia/functions/createPinia.md new file mode 100644 index 000000000..4f6e303e5 --- /dev/null +++ b/packages/docs/api/pinia/functions/createPinia.md @@ -0,0 +1,19 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / createPinia + +# Function: createPinia() + +> **createPinia**(): [`Pinia`](../interfaces/Pinia.md) + +Creates a Pinia instance to be used by the application + +## Returns + +[`Pinia`](../interfaces/Pinia.md) diff --git a/packages/docs/api/pinia/functions/defineStore.md b/packages/docs/api/pinia/functions/defineStore.md new file mode 100644 index 000000000..42e6e8d1a --- /dev/null +++ b/packages/docs/api/pinia/functions/defineStore.md @@ -0,0 +1,97 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / defineStore + +# Function: defineStore() + +## defineStore(id, options) + +> **defineStore**\<`Id`, `S`, `G`, `A`\>(`id`, `options`): [`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> + +Creates a `useStore` function that retrieves the store instance + +### Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) = `object` + +• **G** *extends* [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> = `object` + +• **A** = `object` + +### Parameters + +• **id**: `Id` + +id of the store (must be unique) + +• **options**: `Omit`\<[`DefineStoreOptions`](../interfaces/DefineStoreOptions.md)\<`Id`, `S`, `G`, `A`\>, `"id"`\> + +options to define the store + +### Returns + +[`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> + +## defineStore(options) + +> **defineStore**\<`Id`, `S`, `G`, `A`\>(`options`): [`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> + +Creates a `useStore` function that retrieves the store instance + +### Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) = `object` + +• **G** *extends* [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> = `object` + +• **A** = `object` + +### Parameters + +• **options**: [`DefineStoreOptions`](../interfaces/DefineStoreOptions.md)\<`Id`, `S`, `G`, `A`\> + +options to define the store + +### Returns + +[`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> + +## defineStore(id, storeSetup, options) + +> **defineStore**\<`Id`, `SS`\>(`id`, `storeSetup`, `options`?): [`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, [`_ExtractStateFromSetupStore`](../type-aliases/ExtractStateFromSetupStore.md)\<`SS`\>, [`_ExtractGettersFromSetupStore`](../type-aliases/ExtractGettersFromSetupStore.md)\<`SS`\>, [`_ExtractActionsFromSetupStore`](../type-aliases/ExtractActionsFromSetupStore.md)\<`SS`\>\> + +Creates a `useStore` function that retrieves the store instance + +### Type Parameters + +• **Id** *extends* `string` + +• **SS** + +### Parameters + +• **id**: `Id` + +id of the store (must be unique) + +• **storeSetup** + +function that defines the store + +• **options?**: [`DefineSetupStoreOptions`](../interfaces/DefineSetupStoreOptions.md)\<`Id`, [`_ExtractStateFromSetupStore`](../type-aliases/ExtractStateFromSetupStore.md)\<`SS`\>, [`_ExtractGettersFromSetupStore`](../type-aliases/ExtractGettersFromSetupStore.md)\<`SS`\>, [`_ExtractActionsFromSetupStore`](../type-aliases/ExtractActionsFromSetupStore.md)\<`SS`\>\> + +extra options + +### Returns + +[`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, [`_ExtractStateFromSetupStore`](../type-aliases/ExtractStateFromSetupStore.md)\<`SS`\>, [`_ExtractGettersFromSetupStore`](../type-aliases/ExtractGettersFromSetupStore.md)\<`SS`\>, [`_ExtractActionsFromSetupStore`](../type-aliases/ExtractActionsFromSetupStore.md)\<`SS`\>\> diff --git a/packages/docs/api/pinia/functions/disposePinia.md b/packages/docs/api/pinia/functions/disposePinia.md new file mode 100644 index 000000000..a71007ba1 --- /dev/null +++ b/packages/docs/api/pinia/functions/disposePinia.md @@ -0,0 +1,27 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / disposePinia + +# Function: disposePinia() + +> **disposePinia**(`pinia`): `void` + +Dispose a Pinia instance by stopping its effectScope and removing the state, plugins and stores. This is mostly +useful in tests, with both a testing pinia or a regular pinia and in applications that use multiple pinia instances. +Once disposed, the pinia instance cannot be used anymore. + +## Parameters + +• **pinia**: [`Pinia`](../interfaces/Pinia.md) + +pinia instance + +## Returns + +`void` diff --git a/packages/docs/api/pinia/functions/getActivePinia.md b/packages/docs/api/pinia/functions/getActivePinia.md new file mode 100644 index 000000000..5a7922506 --- /dev/null +++ b/packages/docs/api/pinia/functions/getActivePinia.md @@ -0,0 +1,19 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / getActivePinia + +# Function: getActivePinia() + +> **getActivePinia**(): `undefined` \| [`Pinia`](../interfaces/Pinia.md) + +Get the currently active pinia if there is any. + +## Returns + +`undefined` \| [`Pinia`](../interfaces/Pinia.md) diff --git a/packages/docs/api/pinia/functions/mapActions.md b/packages/docs/api/pinia/functions/mapActions.md new file mode 100644 index 000000000..66dc9a40d --- /dev/null +++ b/packages/docs/api/pinia/functions/mapActions.md @@ -0,0 +1,123 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / mapActions + +# Function: mapActions() + +Allows directly using actions from your store without using the composition +API (`setup()`) by generating an object to be spread in the `methods` field +of a component. + +## Param + +store to map from + +## Param + +array or object + +## mapActions(useStore, keyMapper) + +> **mapActions**\<`Id`, `S`, `G`, `A`, `KeyMapper`\>(`useStore`, `keyMapper`): [`_MapActionsObjectReturn`](../type-aliases/MapActionsObjectReturn.md)\<`A`, `KeyMapper`\> + +Allows directly using actions from your store without using the composition +API (`setup()`) by generating an object to be spread in the `methods` field +of a component. The values of the object are the actions while the keys are +the names of the resulting methods. + +### Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) + +• **G** *extends* [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> + +• **A** + +• **KeyMapper** *extends* `Record`\<`string`, keyof `A`\> + +### Parameters + +• **useStore**: [`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> + +store to map from + +• **keyMapper**: `KeyMapper` + +object to define new names for the actions + +### Returns + +[`_MapActionsObjectReturn`](../type-aliases/MapActionsObjectReturn.md)\<`A`, `KeyMapper`\> + +### Example + +```js +export default { + methods: { + // other methods properties + // useCounterStore has two actions named `increment` and `setCount` + ...mapActions(useCounterStore, { moar: 'increment', setIt: 'setCount' }) + }, + + created() { + this.moar() + this.setIt(2) + } +} +``` + +## mapActions(useStore, keys) + +> **mapActions**\<`Id`, `S`, `G`, `A`\>(`useStore`, `keys`): [`_MapActionsReturn`](../type-aliases/MapActionsReturn.md)\<`A`\> + +Allows directly using actions from your store without using the composition +API (`setup()`) by generating an object to be spread in the `methods` field +of a component. + +### Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) + +• **G** *extends* [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> + +• **A** + +### Parameters + +• **useStore**: [`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> + +store to map from + +• **keys**: keyof `A`[] + +array of action names to map + +### Returns + +[`_MapActionsReturn`](../type-aliases/MapActionsReturn.md)\<`A`\> + +### Example + +```js +export default { + methods: { + // other methods properties + ...mapActions(useCounterStore, ['increment', 'setCount']) + }, + + created() { + this.increment() + this.setCount(2) // pass arguments as usual + } +} +``` diff --git a/packages/docs/api/pinia/functions/mapGetters.md b/packages/docs/api/pinia/functions/mapGetters.md new file mode 100644 index 000000000..28c8e5248 --- /dev/null +++ b/packages/docs/api/pinia/functions/mapGetters.md @@ -0,0 +1,130 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / mapGetters + +# Function: ~~mapGetters()~~ + +Alias for `mapState()`. You should use `mapState()` instead. + +## Deprecated + +use `mapState()` instead. + +## mapGetters(useStore, keyMapper) + +> **mapGetters**\<`Id`, `S`, `G`, `A`, `KeyMapper`\>(`useStore`, `keyMapper`): [`_MapStateObjectReturn`](../type-aliases/MapStateObjectReturn.md)\<`Id`, `S`, `G`, `A`, `KeyMapper`\> + +Allows using state and getters from one store without using the composition +API (`setup()`) by generating an object to be spread in the `computed` field +of a component. The values of the object are the state properties/getters +while the keys are the names of the resulting computed properties. +Optionally, you can also pass a custom function that will receive the store +as its first argument. Note that while it has access to the component +instance via `this`, it won't be typed. + +### Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) + +• **G** *extends* [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> \| `object` + +• **A** + +• **KeyMapper** *extends* `Record`\<`string`, keyof `S` \| keyof `G` \| (`store`) => `any`\> + +### Parameters + +• **useStore**: [`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> + +store to map from + +• **keyMapper**: `KeyMapper` + +object of state properties or getters + +### Returns + +[`_MapStateObjectReturn`](../type-aliases/MapStateObjectReturn.md)\<`Id`, `S`, `G`, `A`, `KeyMapper`\> + +### Example + +```js +export default { + computed: { + // other computed properties + // useCounterStore has a state property named `count` and a getter `double` + ...mapState(useCounterStore, { + n: 'count', + triple: store => store.n * 3, + // note we can't use an arrow function if we want to use `this` + custom(store) { + return this.someComponentValue + store.n + }, + doubleN: 'double' + }) + }, + + created() { + this.n // 2 + this.doubleN // 4 + } +} +``` + +## mapGetters(useStore, keys) + +> **mapGetters**\<`Id`, `S`, `G`, `A`, `Keys`\>(`useStore`, `keys`): [`_MapStateReturn`](../type-aliases/MapStateReturn.md)\<`S`, `G`, `Keys`\> + +Allows using state and getters from one store without using the composition +API (`setup()`) by generating an object to be spread in the `computed` field +of a component. + +### Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) + +• **G** *extends* [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> \| `object` + +• **A** + +• **Keys** *extends* `string` \| `number` \| `symbol` + +### Parameters + +• **useStore**: [`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> + +store to map from + +• **keys**: readonly `Keys`[] + +array of state properties or getters + +### Returns + +[`_MapStateReturn`](../type-aliases/MapStateReturn.md)\<`S`, `G`, `Keys`\> + +### Example + +```js +export default { + computed: { + // other computed properties + ...mapState(useCounterStore, ['count', 'double']) + }, + + created() { + this.count // 2 + this.double // 4 + } +} +``` diff --git a/packages/docs/api/pinia/functions/mapState.md b/packages/docs/api/pinia/functions/mapState.md new file mode 100644 index 000000000..0670d08ce --- /dev/null +++ b/packages/docs/api/pinia/functions/mapState.md @@ -0,0 +1,136 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / mapState + +# Function: mapState() + +Allows using state and getters from one store without using the composition +API (`setup()`) by generating an object to be spread in the `computed` field +of a component. + +## Param + +store to map from + +## Param + +array or object + +## mapState(useStore, keyMapper) + +> **mapState**\<`Id`, `S`, `G`, `A`, `KeyMapper`\>(`useStore`, `keyMapper`): [`_MapStateObjectReturn`](../type-aliases/MapStateObjectReturn.md)\<`Id`, `S`, `G`, `A`, `KeyMapper`\> + +Allows using state and getters from one store without using the composition +API (`setup()`) by generating an object to be spread in the `computed` field +of a component. The values of the object are the state properties/getters +while the keys are the names of the resulting computed properties. +Optionally, you can also pass a custom function that will receive the store +as its first argument. Note that while it has access to the component +instance via `this`, it won't be typed. + +### Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) + +• **G** *extends* [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> \| `object` + +• **A** + +• **KeyMapper** *extends* `Record`\<`string`, keyof `S` \| keyof `G` \| (`store`) => `any`\> + +### Parameters + +• **useStore**: [`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> + +store to map from + +• **keyMapper**: `KeyMapper` + +object of state properties or getters + +### Returns + +[`_MapStateObjectReturn`](../type-aliases/MapStateObjectReturn.md)\<`Id`, `S`, `G`, `A`, `KeyMapper`\> + +### Example + +```js +export default { + computed: { + // other computed properties + // useCounterStore has a state property named `count` and a getter `double` + ...mapState(useCounterStore, { + n: 'count', + triple: store => store.n * 3, + // note we can't use an arrow function if we want to use `this` + custom(store) { + return this.someComponentValue + store.n + }, + doubleN: 'double' + }) + }, + + created() { + this.n // 2 + this.doubleN // 4 + } +} +``` + +## mapState(useStore, keys) + +> **mapState**\<`Id`, `S`, `G`, `A`, `Keys`\>(`useStore`, `keys`): [`_MapStateReturn`](../type-aliases/MapStateReturn.md)\<`S`, `G`, `Keys`\> + +Allows using state and getters from one store without using the composition +API (`setup()`) by generating an object to be spread in the `computed` field +of a component. + +### Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) + +• **G** *extends* [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> \| `object` + +• **A** + +• **Keys** *extends* `string` \| `number` \| `symbol` + +### Parameters + +• **useStore**: [`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> + +store to map from + +• **keys**: readonly `Keys`[] + +array of state properties or getters + +### Returns + +[`_MapStateReturn`](../type-aliases/MapStateReturn.md)\<`S`, `G`, `Keys`\> + +### Example + +```js +export default { + computed: { + // other computed properties + ...mapState(useCounterStore, ['count', 'double']) + }, + + created() { + this.count // 2 + this.double // 4 + } +} +``` diff --git a/packages/docs/api/pinia/functions/mapStores.md b/packages/docs/api/pinia/functions/mapStores.md new file mode 100644 index 000000000..dda50915d --- /dev/null +++ b/packages/docs/api/pinia/functions/mapStores.md @@ -0,0 +1,47 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / mapStores + +# Function: mapStores() + +> **mapStores**\<`Stores`\>(...`stores`): [`_Spread`](../type-aliases/Spread.md)\<`Stores`\> + +Allows using stores without the composition API (`setup()`) by generating an +object to be spread in the `computed` field of a component. It accepts a list +of store definitions. + +## Type Parameters + +• **Stores** *extends* `any`[] + +## Parameters + +• ...**stores**: [`...Stores[]`] + +list of stores to map to an object + +## Returns + +[`_Spread`](../type-aliases/Spread.md)\<`Stores`\> + +## Example + +```js +export default { + computed: { + // other computed properties + ...mapStores(useUserStore, useCartStore) + }, + + created() { + this.userStore // store with id "user" + this.cartStore // store with id "cart" + } +} +``` diff --git a/packages/docs/api/pinia/functions/mapWritableState.md b/packages/docs/api/pinia/functions/mapWritableState.md new file mode 100644 index 000000000..caf59c3be --- /dev/null +++ b/packages/docs/api/pinia/functions/mapWritableState.md @@ -0,0 +1,91 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / mapWritableState + +# Function: mapWritableState() + +Allows using state and getters from one store without using the composition +API (`setup()`) by generating an object to be spread in the `computed` field +of a component. + +## Param + +store to map from + +## Param + +array or object + +## mapWritableState(useStore, keyMapper) + +> **mapWritableState**\<`Id`, `S`, `G`, `A`, `KeyMapper`\>(`useStore`, `keyMapper`): [`_MapWritableStateObjectReturn`](../type-aliases/MapWritableStateObjectReturn.md)\<`S`, `KeyMapper`\> + +Same as `mapState()` but creates computed setters as well so the state can be +modified. Differently from `mapState()`, only `state` properties can be +added. + +### Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) + +• **G** *extends* [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> + +• **A** + +• **KeyMapper** *extends* `Record`\<`string`, keyof `S`\> + +### Parameters + +• **useStore**: [`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> + +store to map from + +• **keyMapper**: `KeyMapper` + +object of state properties + +### Returns + +[`_MapWritableStateObjectReturn`](../type-aliases/MapWritableStateObjectReturn.md)\<`S`, `KeyMapper`\> + +## mapWritableState(useStore, keys) + +> **mapWritableState**\<`Id`, `S`, `G`, `A`, `Keys`\>(`useStore`, `keys`): `{ [K in Keys]: Object }` + +Allows using state and getters from one store without using the composition +API (`setup()`) by generating an object to be spread in the `computed` field +of a component. + +### Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) + +• **G** *extends* [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> + +• **A** + +• **Keys** *extends* `string` \| `number` \| `symbol` + +### Parameters + +• **useStore**: [`StoreDefinition`](../interfaces/StoreDefinition.md)\<`Id`, `S`, `G`, `A`\> + +store to map from + +• **keys**: readonly `Keys`[] + +array of state properties + +### Returns + +`{ [K in Keys]: Object }` diff --git a/packages/docs/api/pinia/functions/setActivePinia.md b/packages/docs/api/pinia/functions/setActivePinia.md new file mode 100644 index 000000000..110d134ec --- /dev/null +++ b/packages/docs/api/pinia/functions/setActivePinia.md @@ -0,0 +1,63 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / setActivePinia + +# Function: setActivePinia() + +Sets or unsets the active pinia. Used in SSR and internally when calling +actions and getters + +## Param + +Pinia instance + +## setActivePinia(pinia) + +> **setActivePinia**(`pinia`): [`Pinia`](../interfaces/Pinia.md) + +Sets or unsets the active pinia. Used in SSR and internally when calling +actions and getters + +### Parameters + +• **pinia**: [`Pinia`](../interfaces/Pinia.md) + +### Returns + +[`Pinia`](../interfaces/Pinia.md) + +## setActivePinia(pinia) + +> **setActivePinia**(`pinia`): `undefined` + +Sets or unsets the active pinia. Used in SSR and internally when calling +actions and getters + +### Parameters + +• **pinia**: `undefined` + +### Returns + +`undefined` + +## setActivePinia(pinia) + +> **setActivePinia**(`pinia`): `undefined` \| [`Pinia`](../interfaces/Pinia.md) + +Sets or unsets the active pinia. Used in SSR and internally when calling +actions and getters + +### Parameters + +• **pinia**: `undefined` \| [`Pinia`](../interfaces/Pinia.md) + +### Returns + +`undefined` \| [`Pinia`](../interfaces/Pinia.md) diff --git a/packages/docs/api/pinia/functions/setMapStoreSuffix.md b/packages/docs/api/pinia/functions/setMapStoreSuffix.md new file mode 100644 index 000000000..ae2a5b56a --- /dev/null +++ b/packages/docs/api/pinia/functions/setMapStoreSuffix.md @@ -0,0 +1,27 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / setMapStoreSuffix + +# Function: setMapStoreSuffix() + +> **setMapStoreSuffix**(`suffix`): `void` + +Changes the suffix added by `mapStores()`. Can be set to an empty string. +Defaults to `"Store"`. Make sure to extend the MapStoresCustomization +interface if you are using TypeScript. + +## Parameters + +• **suffix**: `string` + +new suffix + +## Returns + +`void` diff --git a/packages/docs/api/pinia/functions/skipHydrate.md b/packages/docs/api/pinia/functions/skipHydrate.md new file mode 100644 index 000000000..6ccbf2952 --- /dev/null +++ b/packages/docs/api/pinia/functions/skipHydrate.md @@ -0,0 +1,32 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / skipHydrate + +# Function: skipHydrate() + +> **skipHydrate**\<`T`\>(`obj`): `T` + +Tells Pinia to skip the hydration process of a given object. This is useful in setup stores (only) when you return a +stateful object in the store but it isn't really state. e.g. returning a router instance in a setup store. + +## Type Parameters + +• **T** = `any` + +## Parameters + +• **obj**: `T` + +target object + +## Returns + +`T` + +obj diff --git a/packages/docs/api/pinia/functions/storeToRefs.md b/packages/docs/api/pinia/functions/storeToRefs.md new file mode 100644 index 000000000..57851c64a --- /dev/null +++ b/packages/docs/api/pinia/functions/storeToRefs.md @@ -0,0 +1,32 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / storeToRefs + +# Function: storeToRefs() + +> **storeToRefs**\<`SS`\>(`store`): `StoreToRefs`\<`SS`\> + +Creates an object of references with all the state, getters, and plugin-added +state properties of the store. Similar to `toRefs()` but specifically +designed for Pinia stores so methods and non reactive properties are +completely ignored. + +## Type Parameters + +• **SS** *extends* [`StoreGeneric`](../type-aliases/StoreGeneric.md) + +## Parameters + +• **store**: `SS` + +store to extract the refs from + +## Returns + +`StoreToRefs`\<`SS`\> diff --git a/packages/docs/api/pinia/index.md b/packages/docs/api/pinia/index.md new file mode 100644 index 000000000..e09ada430 --- /dev/null +++ b/packages/docs/api/pinia/index.md @@ -0,0 +1,96 @@ +--- +editLink: false +--- + +[**API Documentation**](../index.md) • **Docs** + +*** + +[API Documentation](../index.md) / pinia + +# pinia + +## Index + +### Enumerations + +- [MutationType](enumerations/MutationType.md) + +### Interfaces + +- [DefineSetupStoreOptions](interfaces/DefineSetupStoreOptions.md) +- [DefineStoreOptions](interfaces/DefineStoreOptions.md) +- [DefineStoreOptionsBase](interfaces/DefineStoreOptionsBase.md) +- [DefineStoreOptionsInPlugin](interfaces/DefineStoreOptionsInPlugin.md) +- [MapStoresCustomization](interfaces/MapStoresCustomization.md) +- [Pinia](interfaces/Pinia.md) +- [PiniaCustomProperties](interfaces/PiniaCustomProperties.md) +- [PiniaCustomStateProperties](interfaces/PiniaCustomStateProperties.md) +- [PiniaPlugin](interfaces/PiniaPlugin.md) +- [PiniaPluginContext](interfaces/PiniaPluginContext.md) +- [SetupStoreDefinition](interfaces/SetupStoreDefinition.md) +- [StoreDefinition](interfaces/StoreDefinition.md) +- [StoreProperties](interfaces/StoreProperties.md) +- [SubscriptionCallbackMutationDirect](interfaces/SubscriptionCallbackMutationDirect.md) +- [SubscriptionCallbackMutationPatchFunction](interfaces/SubscriptionCallbackMutationPatchFunction.md) +- [SubscriptionCallbackMutationPatchObject](interfaces/SubscriptionCallbackMutationPatchObject.md) +- [\_StoreOnActionListenerContext](interfaces/StoreOnActionListenerContext.md) +- [\_StoreWithState](interfaces/StoreWithState.md) +- [\_SubscriptionCallbackMutationBase](interfaces/SubscriptionCallbackMutationBase.md) + +### Type Aliases + +- [PiniaStorePlugin](type-aliases/PiniaStorePlugin.md) +- [StateTree](type-aliases/StateTree.md) +- [Store](type-aliases/Store.md) +- [StoreActions](type-aliases/StoreActions.md) +- [StoreGeneric](type-aliases/StoreGeneric.md) +- [StoreGetters](type-aliases/StoreGetters.md) +- [StoreOnActionListener](type-aliases/StoreOnActionListener.md) +- [StoreOnActionListenerContext](type-aliases/StoreOnActionListenerContext.md) +- [StoreState](type-aliases/StoreState.md) +- [SubscriptionCallback](type-aliases/SubscriptionCallback.md) +- [SubscriptionCallbackMutation](type-aliases/SubscriptionCallbackMutation.md) +- [\_ActionsTree](type-aliases/ActionsTree.md) +- [\_Awaited](type-aliases/Awaited.md) +- [\_DeepPartial](type-aliases/DeepPartial.md) +- [\_ExtractActionsFromSetupStore](type-aliases/ExtractActionsFromSetupStore.md) +- [\_ExtractActionsFromSetupStore\_Keys](type-aliases/ExtractActionsFromSetupStore_Keys.md) +- [\_ExtractGettersFromSetupStore](type-aliases/ExtractGettersFromSetupStore.md) +- [\_ExtractGettersFromSetupStore\_Keys](type-aliases/ExtractGettersFromSetupStore_Keys.md) +- [\_ExtractStateFromSetupStore](type-aliases/ExtractStateFromSetupStore.md) +- [\_ExtractStateFromSetupStore\_Keys](type-aliases/ExtractStateFromSetupStore_Keys.md) +- [\_GettersTree](type-aliases/GettersTree.md) +- [\_MapActionsObjectReturn](type-aliases/MapActionsObjectReturn.md) +- [\_MapActionsReturn](type-aliases/MapActionsReturn.md) +- [\_MapStateObjectReturn](type-aliases/MapStateObjectReturn.md) +- [\_MapStateReturn](type-aliases/MapStateReturn.md) +- [\_MapWritableStateObjectReturn](type-aliases/MapWritableStateObjectReturn.md) +- [\_MapWritableStateReturn](type-aliases/MapWritableStateReturn.md) +- [\_Method](type-aliases/Method.md) +- [\_Spread](type-aliases/Spread.md) +- [\_StoreObject](type-aliases/StoreObject.md) +- [\_StoreWithActions](type-aliases/StoreWithActions.md) +- [\_StoreWithGetters](type-aliases/StoreWithGetters.md) +- [\_UnwrapAll](type-aliases/UnwrapAll.md) + +### Variables + +- [PiniaVuePlugin](variables/PiniaVuePlugin.md) + +### Functions + +- [acceptHMRUpdate](functions/acceptHMRUpdate.md) +- [createPinia](functions/createPinia.md) +- [defineStore](functions/defineStore.md) +- [disposePinia](functions/disposePinia.md) +- [getActivePinia](functions/getActivePinia.md) +- [mapActions](functions/mapActions.md) +- [mapGetters](functions/mapGetters.md) +- [mapState](functions/mapState.md) +- [mapStores](functions/mapStores.md) +- [mapWritableState](functions/mapWritableState.md) +- [setActivePinia](functions/setActivePinia.md) +- [setMapStoreSuffix](functions/setMapStoreSuffix.md) +- [skipHydrate](functions/skipHydrate.md) +- [storeToRefs](functions/storeToRefs.md) diff --git a/packages/docs/api/pinia/interfaces/DefineSetupStoreOptions.md b/packages/docs/api/pinia/interfaces/DefineSetupStoreOptions.md new file mode 100644 index 000000000..4ae0bd1fc --- /dev/null +++ b/packages/docs/api/pinia/interfaces/DefineSetupStoreOptions.md @@ -0,0 +1,42 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / DefineSetupStoreOptions + +# Interface: DefineSetupStoreOptions\ + +Options parameter of `defineStore()` for setup stores. Can be extended to +augment stores with the plugin API. + +## See + +[DefineStoreOptionsBase](DefineStoreOptionsBase.md). + +## Extends + +- [`DefineStoreOptionsBase`](DefineStoreOptionsBase.md)\<`S`, [`Store`](../type-aliases/Store.md)\<`Id`, `S`, `G`, `A`\>\> + +## Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) + +• **G** + +• **A** + +## Properties + +### actions? + +> `optional` **actions**: `A` + +Extracted actions. Added by useStore(). SHOULD NOT be added by the user when +creating the store. Can be used in plugins to get the list of actions in a +store defined with a setup function. Note this is always defined diff --git a/packages/docs/api/pinia/interfaces/DefineStoreOptions.md b/packages/docs/api/pinia/interfaces/DefineStoreOptions.md new file mode 100644 index 000000000..056e64334 --- /dev/null +++ b/packages/docs/api/pinia/interfaces/DefineStoreOptions.md @@ -0,0 +1,110 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / DefineStoreOptions + +# Interface: DefineStoreOptions\ + +Options parameter of `defineStore()` for option stores. Can be extended to +augment stores with the plugin API. + +## See + +[DefineStoreOptionsBase](DefineStoreOptionsBase.md). + +## Extends + +- [`DefineStoreOptionsBase`](DefineStoreOptionsBase.md)\<`S`, [`Store`](../type-aliases/Store.md)\<`Id`, `S`, `G`, `A`\>\> + +## Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) + +• **G** + +• **A** + +## Properties + +### actions? + +> `optional` **actions**: `A` & `ThisType`\<`A` & `UnwrapRef`\<`S`\> & [`_StoreWithState`](StoreWithState.md)\<`Id`, `S`, `G`, `A`\> & [`_StoreWithGetters`](../type-aliases/StoreWithGetters.md)\<`G`\> & [`PiniaCustomProperties`](PiniaCustomProperties.md)\<`string`, [`StateTree`](../type-aliases/StateTree.md), [`_GettersTree`](../type-aliases/GettersTree.md)\<[`StateTree`](../type-aliases/StateTree.md)\>, [`_ActionsTree`](../type-aliases/ActionsTree.md)\>\> + +Optional object of actions. + +*** + +### getters? + +> `optional` **getters**: `G` & `ThisType`\<`UnwrapRef`\<`S`\> & [`_StoreWithGetters`](../type-aliases/StoreWithGetters.md)\<`G`\> & [`PiniaCustomProperties`](PiniaCustomProperties.md)\<`string`, [`StateTree`](../type-aliases/StateTree.md), [`_GettersTree`](../type-aliases/GettersTree.md)\<[`StateTree`](../type-aliases/StateTree.md)\>, [`_ActionsTree`](../type-aliases/ActionsTree.md)\>\> & [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> + +Optional object of getters. + +*** + +### id + +> **id**: `Id` + +Unique string key to identify the store across the application. + +*** + +### state()? + +> `optional` **state**: () => `S` + +Function to create a fresh state. **Must be an arrow function** to ensure +correct typings! + +#### Returns + +`S` + +## Methods + +### hydrate()? + +> `optional` **hydrate**(`storeState`, `initialState`): `void` + +Allows hydrating the store during SSR when complex state (like client side only refs) are used in the store +definition and copying the value from `pinia.state` isn't enough. + +#### Parameters + +• **storeState**: `UnwrapRef`\<`S`\> + +the current state in the store + +• **initialState**: `UnwrapRef`\<`S`\> + +initialState + +#### Returns + +`void` + +#### Example + +If in your `state`, you use any `customRef`s, any `computed`s, or any `ref`s that have a different value on +Server and Client, you need to manually hydrate them. e.g., a custom ref that is stored in the local +storage: + +```ts +const useStore = defineStore('main', { + state: () => ({ + n: useLocalStorage('key', 0) + }), + hydrate(storeState, initialState) { + // @ts-expect-error: https://github.com/microsoft/TypeScript/issues/43826 + storeState.n = useLocalStorage('key', 0) + } +}) +``` diff --git a/packages/docs/api/pinia/interfaces/DefineStoreOptionsBase.md b/packages/docs/api/pinia/interfaces/DefineStoreOptionsBase.md new file mode 100644 index 000000000..21df47fe1 --- /dev/null +++ b/packages/docs/api/pinia/interfaces/DefineStoreOptionsBase.md @@ -0,0 +1,26 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / DefineStoreOptionsBase + +# Interface: DefineStoreOptionsBase\ + +Options passed to `defineStore()` that are common between option and setup +stores. Extend this interface if you want to add custom options to both kinds +of stores. + +## Extended by + +- [`DefineStoreOptions`](DefineStoreOptions.md) +- [`DefineSetupStoreOptions`](DefineSetupStoreOptions.md) + +## Type Parameters + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) + +• **Store** diff --git a/packages/docs/api/pinia/interfaces/DefineStoreOptionsInPlugin.md b/packages/docs/api/pinia/interfaces/DefineStoreOptionsInPlugin.md new file mode 100644 index 000000000..65cc86a3d --- /dev/null +++ b/packages/docs/api/pinia/interfaces/DefineStoreOptionsInPlugin.md @@ -0,0 +1,111 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / DefineStoreOptionsInPlugin + +# Interface: DefineStoreOptionsInPlugin\ + +Available `options` when creating a pinia plugin. + +## Extends + +- `Omit`\<[`DefineStoreOptions`](DefineStoreOptions.md)\<`Id`, `S`, `G`, `A`\>, `"id"` \| `"actions"`\> + +## Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) + +• **G** + +• **A** + +## Properties + +### actions + +> **actions**: `A` + +Extracted object of actions. Added by useStore() when the store is built +using the setup API, otherwise uses the one passed to `defineStore()`. +Defaults to an empty object if no actions are defined. + +*** + +### getters? + +> `optional` **getters**: `G` & `ThisType`\<`UnwrapRef`\<`S`\> & [`_StoreWithGetters`](../type-aliases/StoreWithGetters.md)\<`G`\> & [`PiniaCustomProperties`](PiniaCustomProperties.md)\<`string`, [`StateTree`](../type-aliases/StateTree.md), [`_GettersTree`](../type-aliases/GettersTree.md)\<[`StateTree`](../type-aliases/StateTree.md)\>, [`_ActionsTree`](../type-aliases/ActionsTree.md)\>\> & [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> + +Optional object of getters. + +#### Inherited from + +`Omit.getters` + +*** + +### state()? + +> `optional` **state**: () => `S` + +Function to create a fresh state. **Must be an arrow function** to ensure +correct typings! + +#### Returns + +`S` + +#### Inherited from + +`Omit.state` + +## Methods + +### hydrate()? + +> `optional` **hydrate**(`storeState`, `initialState`): `void` + +Allows hydrating the store during SSR when complex state (like client side only refs) are used in the store +definition and copying the value from `pinia.state` isn't enough. + +#### Parameters + +• **storeState**: `UnwrapRef`\<`S`\> + +the current state in the store + +• **initialState**: `UnwrapRef`\<`S`\> + +initialState + +#### Returns + +`void` + +#### Inherited from + +`Omit.hydrate` + +#### Example + +If in your `state`, you use any `customRef`s, any `computed`s, or any `ref`s that have a different value on +Server and Client, you need to manually hydrate them. e.g., a custom ref that is stored in the local +storage: + +```ts +const useStore = defineStore('main', { + state: () => ({ + n: useLocalStorage('key', 0) + }), + hydrate(storeState, initialState) { + // @ts-expect-error: https://github.com/microsoft/TypeScript/issues/43826 + storeState.n = useLocalStorage('key', 0) + } +}) +``` diff --git a/packages/docs/api/interfaces/pinia.MapStoresCustomization.md b/packages/docs/api/pinia/interfaces/MapStoresCustomization.md similarity index 62% rename from packages/docs/api/interfaces/pinia.MapStoresCustomization.md rename to packages/docs/api/pinia/interfaces/MapStoresCustomization.md index ea24732ad..066fb3050 100644 --- a/packages/docs/api/interfaces/pinia.MapStoresCustomization.md +++ b/packages/docs/api/pinia/interfaces/MapStoresCustomization.md @@ -2,11 +2,13 @@ editLink: false --- -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / MapStoresCustomization +[**API Documentation**](../../index.md) • **Docs** -# Interface: MapStoresCustomization +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / MapStoresCustomization -[pinia](../modules/pinia.md).MapStoresCustomization +# Interface: MapStoresCustomization Interface to allow customizing map helpers. Extend this interface with the following properties: diff --git a/packages/docs/api/pinia/interfaces/Pinia.md b/packages/docs/api/pinia/interfaces/Pinia.md new file mode 100644 index 000000000..78153c280 --- /dev/null +++ b/packages/docs/api/pinia/interfaces/Pinia.md @@ -0,0 +1,57 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / Pinia + +# Interface: Pinia + +Every application must own its own pinia to be able to create stores + +## Extended by + +- [`TestingPinia`](../../@pinia/testing/interfaces/TestingPinia.md) + +## Properties + +### install() + +> **install**: (`app`) => `void` + +#### Parameters + +• **app**: `App`\<`any`\> + +#### Returns + +`void` + +*** + +### state + +> **state**: `Ref`\<`Record`\<`string`, [`StateTree`](../type-aliases/StateTree.md)\>\> + +root state + +## Methods + +### use() + +> **use**(`plugin`): [`Pinia`](Pinia.md) + +Adds a store plugin to extend every store + +#### Parameters + +• **plugin**: [`PiniaPlugin`](PiniaPlugin.md) + +store plugin to add + +#### Returns + +[`Pinia`](Pinia.md) diff --git a/packages/docs/api/pinia/interfaces/PiniaCustomProperties.md b/packages/docs/api/pinia/interfaces/PiniaCustomProperties.md new file mode 100644 index 000000000..3fd6fd3c5 --- /dev/null +++ b/packages/docs/api/pinia/interfaces/PiniaCustomProperties.md @@ -0,0 +1,23 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / PiniaCustomProperties + +# Interface: PiniaCustomProperties\ + +Interface to be extended by the user when they add properties through plugins. + +## Type Parameters + +• **Id** *extends* `string` = `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) = [`StateTree`](../type-aliases/StateTree.md) + +• **G** = [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> + +• **A** = [`_ActionsTree`](../type-aliases/ActionsTree.md) diff --git a/packages/docs/api/pinia/interfaces/PiniaCustomStateProperties.md b/packages/docs/api/pinia/interfaces/PiniaCustomStateProperties.md new file mode 100644 index 000000000..9d9338aad --- /dev/null +++ b/packages/docs/api/pinia/interfaces/PiniaCustomStateProperties.md @@ -0,0 +1,17 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / PiniaCustomStateProperties + +# Interface: PiniaCustomStateProperties\ + +Properties that are added to every `store.$state` by `pinia.use()`. + +## Type Parameters + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) = [`StateTree`](../type-aliases/StateTree.md) diff --git a/packages/docs/api/pinia/interfaces/PiniaPlugin.md b/packages/docs/api/pinia/interfaces/PiniaPlugin.md new file mode 100644 index 000000000..2f1c9b38a --- /dev/null +++ b/packages/docs/api/pinia/interfaces/PiniaPlugin.md @@ -0,0 +1,28 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / PiniaPlugin + +# Interface: PiniaPlugin() + +Plugin to extend every store. + +> **PiniaPlugin**(`context`): `void` \| `Partial`\<[`PiniaCustomProperties`](PiniaCustomProperties.md)\<`string`, [`StateTree`](../type-aliases/StateTree.md), [`_GettersTree`](../type-aliases/GettersTree.md)\<[`StateTree`](../type-aliases/StateTree.md)\>, [`_ActionsTree`](../type-aliases/ActionsTree.md)\> & [`PiniaCustomStateProperties`](PiniaCustomStateProperties.md)\<[`StateTree`](../type-aliases/StateTree.md)\>\> + +Plugin to extend every store. Returns an object to extend the store or +nothing. + +## Parameters + +• **context**: [`PiniaPluginContext`](PiniaPluginContext.md)\<`string`, [`StateTree`](../type-aliases/StateTree.md), [`_GettersTree`](../type-aliases/GettersTree.md)\<[`StateTree`](../type-aliases/StateTree.md)\>, [`_ActionsTree`](../type-aliases/ActionsTree.md)\> + +Context + +## Returns + +`void` \| `Partial`\<[`PiniaCustomProperties`](PiniaCustomProperties.md)\<`string`, [`StateTree`](../type-aliases/StateTree.md), [`_GettersTree`](../type-aliases/GettersTree.md)\<[`StateTree`](../type-aliases/StateTree.md)\>, [`_ActionsTree`](../type-aliases/ActionsTree.md)\> & [`PiniaCustomStateProperties`](PiniaCustomStateProperties.md)\<[`StateTree`](../type-aliases/StateTree.md)\>\> diff --git a/packages/docs/api/pinia/interfaces/PiniaPluginContext.md b/packages/docs/api/pinia/interfaces/PiniaPluginContext.md new file mode 100644 index 000000000..5df66719d --- /dev/null +++ b/packages/docs/api/pinia/interfaces/PiniaPluginContext.md @@ -0,0 +1,55 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / PiniaPluginContext + +# Interface: PiniaPluginContext\ + +Context argument passed to Pinia plugins. + +## Type Parameters + +• **Id** *extends* `string` = `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) = [`StateTree`](../type-aliases/StateTree.md) + +• **G** = [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> + +• **A** = [`_ActionsTree`](../type-aliases/ActionsTree.md) + +## Properties + +### app + +> **app**: `App`\<`any`\> + +Current app created with `Vue.createApp()`. + +*** + +### options + +> **options**: [`DefineStoreOptionsInPlugin`](DefineStoreOptionsInPlugin.md)\<`Id`, `S`, `G`, `A`\> + +Initial options defining the store when calling `defineStore()`. + +*** + +### pinia + +> **pinia**: [`Pinia`](Pinia.md) + +pinia instance. + +*** + +### store + +> **store**: [`Store`](../type-aliases/Store.md)\<`Id`, `S`, `G`, `A`\> + +Current store being extended. diff --git a/packages/docs/api/pinia/interfaces/SetupStoreDefinition.md b/packages/docs/api/pinia/interfaces/SetupStoreDefinition.md new file mode 100644 index 000000000..1288a751e --- /dev/null +++ b/packages/docs/api/pinia/interfaces/SetupStoreDefinition.md @@ -0,0 +1,59 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / SetupStoreDefinition + +# Interface: SetupStoreDefinition()\ + +Return type of `defineStore()` with a setup function. +- `Id` is a string literal of the store's name +- `SS` is the return type of the setup function + +## See + +[StoreDefinition](StoreDefinition.md) + +## Extends + +- [`StoreDefinition`](StoreDefinition.md)\<`Id`, [`_ExtractStateFromSetupStore`](../type-aliases/ExtractStateFromSetupStore.md)\<`SS`\>, [`_ExtractGettersFromSetupStore`](../type-aliases/ExtractGettersFromSetupStore.md)\<`SS`\>, [`_ExtractActionsFromSetupStore`](../type-aliases/ExtractActionsFromSetupStore.md)\<`SS`\>\> + +## Type Parameters + +• **Id** *extends* `string` + +• **SS** + +> **SetupStoreDefinition**(`pinia`?, `hot`?): [`Store`](../type-aliases/Store.md)\<`Id`, [`_ExtractStateFromSetupStore`](../type-aliases/ExtractStateFromSetupStore.md)\<`SS`\>, [`_ExtractGettersFromSetupStore`](../type-aliases/ExtractGettersFromSetupStore.md)\<`SS`\>, [`_ExtractActionsFromSetupStore`](../type-aliases/ExtractActionsFromSetupStore.md)\<`SS`\>\> + +Returns a store, creates it if necessary. + +## Parameters + +• **pinia?**: `null` \| [`Pinia`](Pinia.md) + +Pinia instance to retrieve the store + +• **hot?**: [`StoreGeneric`](../type-aliases/StoreGeneric.md) + +dev only hot module replacement + +## Returns + +[`Store`](../type-aliases/Store.md)\<`Id`, [`_ExtractStateFromSetupStore`](../type-aliases/ExtractStateFromSetupStore.md)\<`SS`\>, [`_ExtractGettersFromSetupStore`](../type-aliases/ExtractGettersFromSetupStore.md)\<`SS`\>, [`_ExtractActionsFromSetupStore`](../type-aliases/ExtractActionsFromSetupStore.md)\<`SS`\>\> + +## Properties + +### $id + +> **$id**: `Id` + +Id of the store. Used by map helpers. + +#### Inherited from + +[`StoreDefinition`](StoreDefinition.md).[`$id`](StoreDefinition.md#$id) diff --git a/packages/docs/api/pinia/interfaces/StoreDefinition.md b/packages/docs/api/pinia/interfaces/StoreDefinition.md new file mode 100644 index 000000000..f046eef8f --- /dev/null +++ b/packages/docs/api/pinia/interfaces/StoreDefinition.md @@ -0,0 +1,53 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / StoreDefinition + +# Interface: StoreDefinition()\ + +Return type of `defineStore()`. Function that allows instantiating a store. + +## Extended by + +- [`SetupStoreDefinition`](SetupStoreDefinition.md) + +## Type Parameters + +• **Id** *extends* `string` = `string` + +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) = [`StateTree`](../type-aliases/StateTree.md) + +• **G** = [`_GettersTree`](../type-aliases/GettersTree.md)\<`S`\> + +• **A** = [`_ActionsTree`](../type-aliases/ActionsTree.md) + +> **StoreDefinition**(`pinia`?, `hot`?): [`Store`](../type-aliases/Store.md)\<`Id`, `S`, `G`, `A`\> + +Returns a store, creates it if necessary. + +## Parameters + +• **pinia?**: `null` \| [`Pinia`](Pinia.md) + +Pinia instance to retrieve the store + +• **hot?**: [`StoreGeneric`](../type-aliases/StoreGeneric.md) + +dev only hot module replacement + +## Returns + +[`Store`](../type-aliases/Store.md)\<`Id`, `S`, `G`, `A`\> + +## Properties + +### $id + +> **$id**: `Id` + +Id of the store. Used by map helpers. diff --git a/packages/docs/api/pinia/interfaces/StoreOnActionListenerContext.md b/packages/docs/api/pinia/interfaces/StoreOnActionListenerContext.md new file mode 100644 index 000000000..f8e254775 --- /dev/null +++ b/packages/docs/api/pinia/interfaces/StoreOnActionListenerContext.md @@ -0,0 +1,81 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_StoreOnActionListenerContext + +# Interface: \_StoreOnActionListenerContext\ + +Actual type for [StoreOnActionListenerContext](../type-aliases/StoreOnActionListenerContext.md). Exists for refactoring +purposes. For internal use only. +For internal use **only** + +## Type Parameters + +• **Store** + +• **ActionName** *extends* `string` + +• **A** + +## Properties + +### after() + +> **after**: (`callback`) => `void` + +Sets up a hook once the action is finished. It receives the return value +of the action, if it's a Promise, it will be unwrapped. + +#### Parameters + +• **callback**: `A` *extends* `Record`\<`ActionName`, [`_Method`](../type-aliases/Method.md)\> ? (`resolvedReturn`) => `void` : () => `void` + +#### Returns + +`void` + +*** + +### args + +> **args**: `A` *extends* `Record`\<`ActionName`, [`_Method`](../type-aliases/Method.md)\> ? `Parameters`\<`A`\<`A`\>\[`ActionName`\]\> : `unknown`[] + +Parameters passed to the action + +*** + +### name + +> **name**: `ActionName` + +Name of the action + +*** + +### onError() + +> **onError**: (`callback`) => `void` + +Sets up a hook if the action fails. Return `false` to catch the error and +stop it from propagating. + +#### Parameters + +• **callback** + +#### Returns + +`void` + +*** + +### store + +> **store**: `Store` + +Store that is invoking the action diff --git a/packages/docs/api/pinia/interfaces/StoreProperties.md b/packages/docs/api/pinia/interfaces/StoreProperties.md new file mode 100644 index 000000000..80adff222 --- /dev/null +++ b/packages/docs/api/pinia/interfaces/StoreProperties.md @@ -0,0 +1,39 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / StoreProperties + +# Interface: StoreProperties\ + +Properties of a store. + +## Extended by + +- [`_StoreWithState`](StoreWithState.md) + +## Type Parameters + +• **Id** *extends* `string` + +## Properties + +### $id + +> **$id**: `Id` + +Unique identifier of the store + +*** + +### \_customProperties + +> **\_customProperties**: `Set`\<`string`\> + +Used by devtools plugin to retrieve properties added with plugins. Removed +in production. Can be used by the user to add property keys of the store +that should be displayed in devtools. diff --git a/packages/docs/api/interfaces/pinia._StoreWithState.md b/packages/docs/api/pinia/interfaces/StoreWithState.md similarity index 54% rename from packages/docs/api/interfaces/pinia._StoreWithState.md rename to packages/docs/api/pinia/interfaces/StoreWithState.md index b28547807..d1927d099 100644 --- a/packages/docs/api/interfaces/pinia._StoreWithState.md +++ b/packages/docs/api/pinia/interfaces/StoreWithState.md @@ -2,54 +2,55 @@ editLink: false --- -[API Documentation](../index.md) / [pinia](../modules/pinia.md) / \_StoreWithState +[**API Documentation**](../../index.md) • **Docs** -# Interface: \_StoreWithState\ +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_StoreWithState -[pinia](../modules/pinia.md)._StoreWithState +# Interface: \_StoreWithState\ Base store with state and functions. Should not be used directly. -## Type parameters +## Extends -| Name | Type | -| :------ | :------ | -| `Id` | extends `string` | -| `S` | extends [`StateTree`](../modules/pinia.md#StateTree) | -| `G` | `G` | -| `A` | `A` | +- [`StoreProperties`](StoreProperties.md)\<`Id`\> -## Hierarchy +## Type Parameters -- [`StoreProperties`](pinia.StoreProperties.md)\<`Id`\> +• **Id** *extends* `string` - ↳ **`_StoreWithState`** +• **S** *extends* [`StateTree`](../type-aliases/StateTree.md) + +• **G** + +• **A** ## Properties ### $id -• **$id**: `Id` +> **$id**: `Id` Unique identifier of the store #### Inherited from -[StoreProperties](pinia.StoreProperties.md).[$id](pinia.StoreProperties.md#$id) +[`StoreProperties`](StoreProperties.md).[`$id`](StoreProperties.md#$id) -___ +*** ### $state -• **$state**: `UnwrapRef`\<`S`\> & [`PiniaCustomStateProperties`](pinia.PiniaCustomStateProperties.md)\<`S`\> +> **$state**: `UnwrapRef`\<`S`\> & [`PiniaCustomStateProperties`](PiniaCustomStateProperties.md)\<`S`\> State of the Store. Setting it will internally call `$patch()` to update the state. -___ +*** ### \_customProperties -• **\_customProperties**: `Set`\<`string`\> +> **\_customProperties**: `Set`\<`string`\> Used by devtools plugin to retrieve properties added with plugins. Removed in production. Can be used by the user to add property keys of the store @@ -57,13 +58,13 @@ that should be displayed in devtools. #### Inherited from -[StoreProperties](pinia.StoreProperties.md).[_customProperties](pinia.StoreProperties.md#_customProperties) +[`StoreProperties`](StoreProperties.md).[`_customProperties`](StoreProperties.md#_customProperties) ## Methods -### $dispose +### $dispose() -▸ **$dispose**(): `void` +> **$dispose**(): `void` Stops the associated effect scope of the store and remove it from the store registry. Plugins can override this method to cleanup any added effects. @@ -76,11 +77,11 @@ store is used again, it will reuse the previous state. `void` -___ +*** -### $onAction +### $onAction() -▸ **$onAction**(`callback`, `detached?`): () => `void` +> **$onAction**(`callback`, `detached`?): () => `void` Setups a callback to be called every time an action is about to get invoked. The callback receives an object with all the relevant information @@ -98,24 +99,25 @@ up when the component gets unmounted unless `detached` is set to true. #### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | -| `callback` | [`StoreOnActionListener`](../modules/pinia.md#StoreOnActionListener)\<`Id`, `S`, `G`, `A`\> | callback called before every action | -| `detached?` | `boolean` | detach the subscription from the context this is called from | +• **callback**: [`StoreOnActionListener`](../type-aliases/StoreOnActionListener.md)\<`Id`, `S`, `G`, `A`\> + +callback called before every action + +• **detached?**: `boolean` + +detach the subscription from the context this is called from #### Returns -`fn` +`Function` function that removes the watcher -▸ (): `void` - ##### Returns `void` -**`Example`** +#### Example ```js store.$onAction(({ after, onError }) => { @@ -132,51 +134,53 @@ store.$onAction(({ after, onError }) => { }) ``` -___ +*** -### $patch +### $patch() -▸ **$patch**(`partialState`): `void` +#### $patch(partialState) + +> **$patch**(`partialState`): `void` Applies a state patch to current state. Allows passing nested values -#### Parameters +##### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | -| `partialState` | [`_DeepPartial`](../modules/pinia.md#_DeepPartial)\<`UnwrapRef`\<`S`\>\> | patch to apply to the state | +• **partialState**: [`_DeepPartial`](../type-aliases/DeepPartial.md)\<`UnwrapRef`\<`S`\>\> -#### Returns +patch to apply to the state + +##### Returns `void` -▸ **$patch**\<`F`\>(`stateMutator`): `void` +#### $patch(stateMutator) + +> **$patch**\<`F`\>(`stateMutator`): `void` Group multiple changes into one function. Useful when mutating objects like Sets or arrays and applying an object patch isn't practical, e.g. appending to an array. The function passed to `$patch()` **must be synchronous**. -#### Type parameters +##### Type Parameters -| Name | Type | -| :------ | :------ | -| `F` | extends (`state`: `UnwrapRef`\<`S`\>) => `any` | +• **F** *extends* (`state`) => `any` -#### Parameters +##### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | -| `stateMutator` | `ReturnType`\<`F`\> extends `Promise`\<`any`\> ? `never` : `F` | function that mutates `state`, cannot be asynchronous | +• **stateMutator**: `ReturnType`\<`F`\> *extends* `Promise`\<`any`\> ? `never` : `F` -#### Returns +function that mutates `state`, cannot be asynchronous + +##### Returns `void` -___ +*** -### $reset +### $reset() -▸ **$reset**(): `void` +> **$reset**(): `void` Resets the store to its initial state by building a new state object. @@ -184,11 +188,11 @@ Resets the store to its initial state by building a new state object. `void` -___ +*** -### $subscribe +### $subscribe() -▸ **$subscribe**(`callback`, `options?`): () => `void` +> **$subscribe**(`callback`, `options`?): () => `void` Setups a callback to be called whenever the state changes. It also returns a function to remove the callback. Note that when calling `store.$subscribe()` inside of a component, it will be automatically cleaned up when the @@ -196,19 +200,21 @@ component gets unmounted unless `detached` is set to true. #### Parameters -| Name | Type | Description | -| :------ | :------ | :------ | -| `callback` | [`SubscriptionCallback`](../modules/pinia.md#SubscriptionCallback)\<`S`\> | callback passed to the watcher | -| `options?` | \{ `detached?`: `boolean` } & `WatchOptions`\<`boolean`\> | `watch` options + `detached` to detach the subscription from the context (usually a component) this is called from. Note that the `flush` option does not affect calls to `store.$patch()`. | +• **callback**: [`SubscriptionCallback`](../type-aliases/SubscriptionCallback.md)\<`S`\> + +callback passed to the watcher + +• **options?**: `object` & `WatchOptions`\<`boolean`\> + +`watch` options + `detached` to detach the subscription from the context (usually a component) +this is called from. Note that the `flush` option does not affect calls to `store.$patch()`. #### Returns -`fn` +`Function` function that removes the watcher -▸ (): `void` - ##### Returns `void` diff --git a/packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationBase.md b/packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationBase.md new file mode 100644 index 000000000..8d2754fbf --- /dev/null +++ b/packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationBase.md @@ -0,0 +1,45 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_SubscriptionCallbackMutationBase + +# Interface: \_SubscriptionCallbackMutationBase + +Base type for the context passed to a subscription callback. Internal type. + +## Extended by + +- [`SubscriptionCallbackMutationDirect`](SubscriptionCallbackMutationDirect.md) +- [`SubscriptionCallbackMutationPatchFunction`](SubscriptionCallbackMutationPatchFunction.md) +- [`SubscriptionCallbackMutationPatchObject`](SubscriptionCallbackMutationPatchObject.md) + +## Properties + +### events? + +> `optional` **events**: `DebuggerEvent` \| `DebuggerEvent`[] + +🔴 DEV ONLY, DO NOT use for production code. Different mutation calls. Comes from +https://vuejs.org/guide/extras/reactivity-in-depth.html#reactivity-debugging and allows to track mutations in +devtools and plugins **during development only**. + +*** + +### storeId + +> **storeId**: `string` + +`id` of the store doing the mutation. + +*** + +### type + +> **type**: [`MutationType`](../enumerations/MutationType.md) + +Type of the mutation. diff --git a/packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationDirect.md b/packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationDirect.md new file mode 100644 index 000000000..08a740736 --- /dev/null +++ b/packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationDirect.md @@ -0,0 +1,57 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / SubscriptionCallbackMutationDirect + +# Interface: SubscriptionCallbackMutationDirect + +Context passed to a subscription callback when directly mutating the state of +a store with `store.someState = newValue` or `store.$state.someState = +newValue`. + +## Extends + +- [`_SubscriptionCallbackMutationBase`](SubscriptionCallbackMutationBase.md) + +## Properties + +### events + +> **events**: `DebuggerEvent` + +🔴 DEV ONLY, DO NOT use for production code. Different mutation calls. Comes from +https://vuejs.org/guide/extras/reactivity-in-depth.html#reactivity-debugging and allows to track mutations in +devtools and plugins **during development only**. + +#### Overrides + +[`_SubscriptionCallbackMutationBase`](SubscriptionCallbackMutationBase.md).[`events`](SubscriptionCallbackMutationBase.md#events) + +*** + +### storeId + +> **storeId**: `string` + +`id` of the store doing the mutation. + +#### Inherited from + +[`_SubscriptionCallbackMutationBase`](SubscriptionCallbackMutationBase.md).[`storeId`](SubscriptionCallbackMutationBase.md#storeId) + +*** + +### type + +> **type**: [`direct`](../enumerations/MutationType.md#direct) + +Type of the mutation. + +#### Overrides + +[`_SubscriptionCallbackMutationBase`](SubscriptionCallbackMutationBase.md).[`type`](SubscriptionCallbackMutationBase.md#type) diff --git a/packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationPatchFunction.md b/packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationPatchFunction.md new file mode 100644 index 000000000..f6bacfd58 --- /dev/null +++ b/packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationPatchFunction.md @@ -0,0 +1,56 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / SubscriptionCallbackMutationPatchFunction + +# Interface: SubscriptionCallbackMutationPatchFunction + +Context passed to a subscription callback when `store.$patch()` is called +with a function. + +## Extends + +- [`_SubscriptionCallbackMutationBase`](SubscriptionCallbackMutationBase.md) + +## Properties + +### events + +> **events**: `DebuggerEvent`[] + +🔴 DEV ONLY, DO NOT use for production code. Different mutation calls. Comes from +https://vuejs.org/guide/extras/reactivity-in-depth.html#reactivity-debugging and allows to track mutations in +devtools and plugins **during development only**. + +#### Overrides + +[`_SubscriptionCallbackMutationBase`](SubscriptionCallbackMutationBase.md).[`events`](SubscriptionCallbackMutationBase.md#events) + +*** + +### storeId + +> **storeId**: `string` + +`id` of the store doing the mutation. + +#### Inherited from + +[`_SubscriptionCallbackMutationBase`](SubscriptionCallbackMutationBase.md).[`storeId`](SubscriptionCallbackMutationBase.md#storeId) + +*** + +### type + +> **type**: [`patchFunction`](../enumerations/MutationType.md#patchFunction) + +Type of the mutation. + +#### Overrides + +[`_SubscriptionCallbackMutationBase`](SubscriptionCallbackMutationBase.md).[`type`](SubscriptionCallbackMutationBase.md#type) diff --git a/packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationPatchObject.md b/packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationPatchObject.md new file mode 100644 index 000000000..8a4f417d1 --- /dev/null +++ b/packages/docs/api/pinia/interfaces/SubscriptionCallbackMutationPatchObject.md @@ -0,0 +1,68 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / SubscriptionCallbackMutationPatchObject + +# Interface: SubscriptionCallbackMutationPatchObject\ + +Context passed to a subscription callback when `store.$patch()` is called +with an object. + +## Extends + +- [`_SubscriptionCallbackMutationBase`](SubscriptionCallbackMutationBase.md) + +## Type Parameters + +• **S** + +## Properties + +### events + +> **events**: `DebuggerEvent`[] + +🔴 DEV ONLY, DO NOT use for production code. Different mutation calls. Comes from +https://vuejs.org/guide/extras/reactivity-in-depth.html#reactivity-debugging and allows to track mutations in +devtools and plugins **during development only**. + +#### Overrides + +[`_SubscriptionCallbackMutationBase`](SubscriptionCallbackMutationBase.md).[`events`](SubscriptionCallbackMutationBase.md#events) + +*** + +### payload + +> **payload**: [`_DeepPartial`](../type-aliases/DeepPartial.md)\<`UnwrapRef`\<`S`\>\> + +Object passed to `store.$patch()`. + +*** + +### storeId + +> **storeId**: `string` + +`id` of the store doing the mutation. + +#### Inherited from + +[`_SubscriptionCallbackMutationBase`](SubscriptionCallbackMutationBase.md).[`storeId`](SubscriptionCallbackMutationBase.md#storeId) + +*** + +### type + +> **type**: [`patchObject`](../enumerations/MutationType.md#patchObject) + +Type of the mutation. + +#### Overrides + +[`_SubscriptionCallbackMutationBase`](SubscriptionCallbackMutationBase.md).[`type`](SubscriptionCallbackMutationBase.md#type) diff --git a/packages/docs/api/pinia/type-aliases/ActionsTree.md b/packages/docs/api/pinia/type-aliases/ActionsTree.md new file mode 100644 index 000000000..de30e0915 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/ActionsTree.md @@ -0,0 +1,16 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_ActionsTree + +# Type Alias: \_ActionsTree + +> **\_ActionsTree**: `Record`\<`string`, [`_Method`](Method.md)\> + +Type of an object of Actions. For internal usage only. +For internal use **only** diff --git a/packages/docs/api/pinia/type-aliases/Awaited.md b/packages/docs/api/pinia/type-aliases/Awaited.md new file mode 100644 index 000000000..e3715f509 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/Awaited.md @@ -0,0 +1,17 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_Awaited + +# Type Alias: \_Awaited\ + +> **\_Awaited**\<`T`\>: `T` *extends* `null` \| `undefined` ? `T` : `T` *extends* `object` & `object` ? `F` *extends* (`value`, ...`args`) => `any` ? [`_Awaited`](Awaited.md)\<`V`\> : `never` : `T` + +## Type Parameters + +• **T** diff --git a/packages/docs/api/pinia/type-aliases/DeepPartial.md b/packages/docs/api/pinia/type-aliases/DeepPartial.md new file mode 100644 index 000000000..bf1119ace --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/DeepPartial.md @@ -0,0 +1,21 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_DeepPartial + +# Type Alias: \_DeepPartial\ + +> **\_DeepPartial**\<`T`\>: `{ [K in keyof T]?: _DeepPartial }` + +Recursive `Partial`. Used by [['$patch']](Store.md). + +For internal use **only** + +## Type Parameters + +• **T** diff --git a/packages/docs/api/pinia/type-aliases/ExtractActionsFromSetupStore.md b/packages/docs/api/pinia/type-aliases/ExtractActionsFromSetupStore.md new file mode 100644 index 000000000..2eb0e0ba9 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/ExtractActionsFromSetupStore.md @@ -0,0 +1,19 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_ExtractActionsFromSetupStore + +# Type Alias: \_ExtractActionsFromSetupStore\ + +> **\_ExtractActionsFromSetupStore**\<`SS`\>: `SS` *extends* `undefined` \| `void` ? `object` : [`_ExtractActionsFromSetupStore_Keys`](ExtractActionsFromSetupStore_Keys.md)\<`SS`\> *extends* keyof `SS` ? `Pick`\<`SS`, [`_ExtractActionsFromSetupStore_Keys`](ExtractActionsFromSetupStore_Keys.md)\<`SS`\>\> : `never` + +For internal use **only** + +## Type Parameters + +• **SS** diff --git a/packages/docs/api/pinia/type-aliases/ExtractActionsFromSetupStore_Keys.md b/packages/docs/api/pinia/type-aliases/ExtractActionsFromSetupStore_Keys.md new file mode 100644 index 000000000..bf4179369 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/ExtractActionsFromSetupStore_Keys.md @@ -0,0 +1,20 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_ExtractActionsFromSetupStore\_Keys + +# Type Alias: \_ExtractActionsFromSetupStore\_Keys\ + +> **\_ExtractActionsFromSetupStore\_Keys**\<`SS`\>: keyof `{ [K in keyof SS as SS[K] extends _Method ? K : never]: any }` + +Type that enables refactoring through IDE. +For internal use **only** + +## Type Parameters + +• **SS** diff --git a/packages/docs/api/pinia/type-aliases/ExtractGettersFromSetupStore.md b/packages/docs/api/pinia/type-aliases/ExtractGettersFromSetupStore.md new file mode 100644 index 000000000..bff831352 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/ExtractGettersFromSetupStore.md @@ -0,0 +1,19 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_ExtractGettersFromSetupStore + +# Type Alias: \_ExtractGettersFromSetupStore\ + +> **\_ExtractGettersFromSetupStore**\<`SS`\>: `SS` *extends* `undefined` \| `void` ? `object` : [`_ExtractGettersFromSetupStore_Keys`](ExtractGettersFromSetupStore_Keys.md)\<`SS`\> *extends* keyof `SS` ? `Pick`\<`SS`, [`_ExtractGettersFromSetupStore_Keys`](ExtractGettersFromSetupStore_Keys.md)\<`SS`\>\> : `never` + +For internal use **only** + +## Type Parameters + +• **SS** diff --git a/packages/docs/api/pinia/type-aliases/ExtractGettersFromSetupStore_Keys.md b/packages/docs/api/pinia/type-aliases/ExtractGettersFromSetupStore_Keys.md new file mode 100644 index 000000000..dd4b2a8f2 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/ExtractGettersFromSetupStore_Keys.md @@ -0,0 +1,20 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_ExtractGettersFromSetupStore\_Keys + +# Type Alias: \_ExtractGettersFromSetupStore\_Keys\ + +> **\_ExtractGettersFromSetupStore\_Keys**\<`SS`\>: keyof `{ [K in keyof SS as SS[K] extends ComputedRef ? K : never]: any }` + +Type that enables refactoring through IDE. +For internal use **only** + +## Type Parameters + +• **SS** diff --git a/packages/docs/api/pinia/type-aliases/ExtractStateFromSetupStore.md b/packages/docs/api/pinia/type-aliases/ExtractStateFromSetupStore.md new file mode 100644 index 000000000..5cdd0b7b5 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/ExtractStateFromSetupStore.md @@ -0,0 +1,19 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_ExtractStateFromSetupStore + +# Type Alias: \_ExtractStateFromSetupStore\ + +> **\_ExtractStateFromSetupStore**\<`SS`\>: `SS` *extends* `undefined` \| `void` ? `object` : [`_ExtractStateFromSetupStore_Keys`](ExtractStateFromSetupStore_Keys.md)\<`SS`\> *extends* keyof `SS` ? [`_UnwrapAll`](UnwrapAll.md)\<`Pick`\<`SS`, [`_ExtractStateFromSetupStore_Keys`](ExtractStateFromSetupStore_Keys.md)\<`SS`\>\>\> : `never` + +For internal use **only** + +## Type Parameters + +• **SS** diff --git a/packages/docs/api/pinia/type-aliases/ExtractStateFromSetupStore_Keys.md b/packages/docs/api/pinia/type-aliases/ExtractStateFromSetupStore_Keys.md new file mode 100644 index 000000000..aa1d7b6b1 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/ExtractStateFromSetupStore_Keys.md @@ -0,0 +1,20 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_ExtractStateFromSetupStore\_Keys + +# Type Alias: \_ExtractStateFromSetupStore\_Keys\ + +> **\_ExtractStateFromSetupStore\_Keys**\<`SS`\>: keyof \{ \[K in keyof SS as SS\[K\] extends \_Method \| ComputedRef ? never : K\]: any \} + +Type that enables refactoring through IDE. +For internal use **only** + +## Type Parameters + +• **SS** diff --git a/packages/docs/api/pinia/type-aliases/GettersTree.md b/packages/docs/api/pinia/type-aliases/GettersTree.md new file mode 100644 index 000000000..17da56e7a --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/GettersTree.md @@ -0,0 +1,20 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_GettersTree + +# Type Alias: \_GettersTree\ + +> **\_GettersTree**\<`S`\>: `Record`\<`string`, (`state`) => `any` \| () => `any`\> + +Type of an object of Getters that infers the argument. For internal usage only. +For internal use **only** + +## Type Parameters + +• **S** *extends* [`StateTree`](StateTree.md) diff --git a/packages/docs/api/pinia/type-aliases/MapActionsObjectReturn.md b/packages/docs/api/pinia/type-aliases/MapActionsObjectReturn.md new file mode 100644 index 000000000..7f996ff03 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/MapActionsObjectReturn.md @@ -0,0 +1,21 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_MapActionsObjectReturn + +# Type Alias: \_MapActionsObjectReturn\ + +> **\_MapActionsObjectReturn**\<`A`, `T`\>: `{ [key in keyof T]: A[T[key]] }` + +For internal use **only** + +## Type Parameters + +• **A** + +• **T** *extends* `Record`\<`string`, keyof `A`\> diff --git a/packages/docs/api/pinia/type-aliases/MapActionsReturn.md b/packages/docs/api/pinia/type-aliases/MapActionsReturn.md new file mode 100644 index 000000000..48d08dcb6 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/MapActionsReturn.md @@ -0,0 +1,19 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_MapActionsReturn + +# Type Alias: \_MapActionsReturn\ + +> **\_MapActionsReturn**\<`A`\>: `{ [key in keyof A]: A[key] }` + +For internal use **only** + +## Type Parameters + +• **A** diff --git a/packages/docs/api/pinia/type-aliases/MapStateObjectReturn.md b/packages/docs/api/pinia/type-aliases/MapStateObjectReturn.md new file mode 100644 index 000000000..77157d31e --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/MapStateObjectReturn.md @@ -0,0 +1,27 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_MapStateObjectReturn + +# Type Alias: \_MapStateObjectReturn\ + +> **\_MapStateObjectReturn**\<`Id`, `S`, `G`, `A`, `T`\>: `{ [key in keyof T]: Function }` + +For internal use **only** + +## Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](StateTree.md) + +• **G** *extends* [`_GettersTree`](GettersTree.md)\<`S`\> \| `object` + +• **A** + +• **T** *extends* `Record`\<`string`, keyof `S` \| keyof `G` \| (`store`) => `any`\> = `object` diff --git a/packages/docs/api/pinia/type-aliases/MapStateReturn.md b/packages/docs/api/pinia/type-aliases/MapStateReturn.md new file mode 100644 index 000000000..3e28ea0a4 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/MapStateReturn.md @@ -0,0 +1,23 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_MapStateReturn + +# Type Alias: \_MapStateReturn\ + +> **\_MapStateReturn**\<`S`, `G`, `Keys`\>: `{ [key in Keys]: key extends keyof Store ? Function : never }` + +For internal use **only** + +## Type Parameters + +• **S** *extends* [`StateTree`](StateTree.md) + +• **G** *extends* [`_GettersTree`](GettersTree.md)\<`S`\> \| `object` + +• **Keys** *extends* keyof `S` \| keyof `G` = keyof `S` \| keyof `G` diff --git a/packages/docs/api/pinia/type-aliases/MapWritableStateObjectReturn.md b/packages/docs/api/pinia/type-aliases/MapWritableStateObjectReturn.md new file mode 100644 index 000000000..89e8c2602 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/MapWritableStateObjectReturn.md @@ -0,0 +1,21 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_MapWritableStateObjectReturn + +# Type Alias: \_MapWritableStateObjectReturn\ + +> **\_MapWritableStateObjectReturn**\<`S`, `T`\>: `{ [key in keyof T]: Object }` + +For internal use **only** + +## Type Parameters + +• **S** *extends* [`StateTree`](StateTree.md) + +• **T** *extends* `Record`\<`string`, keyof `S`\> diff --git a/packages/docs/api/pinia/type-aliases/MapWritableStateReturn.md b/packages/docs/api/pinia/type-aliases/MapWritableStateReturn.md new file mode 100644 index 000000000..e1823e99b --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/MapWritableStateReturn.md @@ -0,0 +1,19 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_MapWritableStateReturn + +# Type Alias: \_MapWritableStateReturn\ + +> **\_MapWritableStateReturn**\<`S`\>: `{ [key in keyof S]: Object }` + +For internal use **only** + +## Type Parameters + +• **S** *extends* [`StateTree`](StateTree.md) diff --git a/packages/docs/api/pinia/type-aliases/Method.md b/packages/docs/api/pinia/type-aliases/Method.md new file mode 100644 index 000000000..e2aec2164 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/Method.md @@ -0,0 +1,25 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_Method + +# Type Alias: \_Method() + +> **\_Method**: (...`args`) => `any` + +Generic type for a function that can infer arguments and return type + +For internal use **only** + +## Parameters + +• ...**args**: `any`[] + +## Returns + +`any` diff --git a/packages/docs/api/pinia/type-aliases/PiniaStorePlugin.md b/packages/docs/api/pinia/type-aliases/PiniaStorePlugin.md new file mode 100644 index 000000000..b9bebce99 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/PiniaStorePlugin.md @@ -0,0 +1,19 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / PiniaStorePlugin + +# Type Alias: ~~PiniaStorePlugin~~ + +> **PiniaStorePlugin**: [`PiniaPlugin`](../interfaces/PiniaPlugin.md) + +Plugin to extend every store. + +## Deprecated + +use PiniaPlugin instead diff --git a/packages/docs/api/pinia/type-aliases/Spread.md b/packages/docs/api/pinia/type-aliases/Spread.md new file mode 100644 index 000000000..edd1eeed9 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/Spread.md @@ -0,0 +1,19 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_Spread + +# Type Alias: \_Spread\ + +> **\_Spread**\<`A`\>: `A` *extends* [infer L, `...(infer R)`] ? [`_StoreObject`](StoreObject.md)\<`L`\> & [`_Spread`](Spread.md)\<`R`\> : `unknown` + +For internal use **only**. + +## Type Parameters + +• **A** *extends* readonly `any`[] diff --git a/packages/docs/api/pinia/type-aliases/StateTree.md b/packages/docs/api/pinia/type-aliases/StateTree.md new file mode 100644 index 000000000..d611d84a4 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/StateTree.md @@ -0,0 +1,15 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / StateTree + +# Type Alias: StateTree + +> **StateTree**: `Record`\<`string` \| `number` \| `symbol`, `any`\> + +Generic state of a Store diff --git a/packages/docs/api/pinia/type-aliases/Store.md b/packages/docs/api/pinia/type-aliases/Store.md new file mode 100644 index 000000000..caaa2c884 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/Store.md @@ -0,0 +1,25 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / Store + +# Type Alias: Store\ + +> **Store**\<`Id`, `S`, `G`, `A`\>: [`_StoreWithState`](../interfaces/StoreWithState.md)\<`Id`, `S`, `G`, `A`\> & `UnwrapRef`\<`S`\> & [`_StoreWithGetters`](StoreWithGetters.md)\<`G`\> & [`_ActionsTree`](ActionsTree.md) *extends* `A` ? `object` : `A` & [`PiniaCustomProperties`](../interfaces/PiniaCustomProperties.md)\<`Id`, `S`, `G`, `A`\> & [`PiniaCustomStateProperties`](../interfaces/PiniaCustomStateProperties.md)\<`S`\> + +Store type to build a store. + +## Type Parameters + +• **Id** *extends* `string` = `string` + +• **S** *extends* [`StateTree`](StateTree.md) = `object` + +• **G** = `object` + +• **A** = `object` diff --git a/packages/docs/api/pinia/type-aliases/StoreActions.md b/packages/docs/api/pinia/type-aliases/StoreActions.md new file mode 100644 index 000000000..bfae84385 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/StoreActions.md @@ -0,0 +1,20 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / StoreActions + +# Type Alias: StoreActions\ + +> **StoreActions**\<`SS`\>: `SS` *extends* [`Store`](Store.md)\<`string`, [`StateTree`](StateTree.md), [`_GettersTree`](GettersTree.md)\<[`StateTree`](StateTree.md)\>, infer A\> ? `A` : [`_ExtractActionsFromSetupStore`](ExtractActionsFromSetupStore.md)\<`SS`\> + +Extract the actions of a store type. Works with both a Setup Store or an +Options Store. + +## Type Parameters + +• **SS** diff --git a/packages/docs/api/pinia/type-aliases/StoreGeneric.md b/packages/docs/api/pinia/type-aliases/StoreGeneric.md new file mode 100644 index 000000000..b43e7d667 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/StoreGeneric.md @@ -0,0 +1,17 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / StoreGeneric + +# Type Alias: StoreGeneric + +> **StoreGeneric**: [`Store`](Store.md)\<`string`, [`StateTree`](StateTree.md), [`_GettersTree`](GettersTree.md)\<[`StateTree`](StateTree.md)\>, [`_ActionsTree`](ActionsTree.md)\> + +Generic and type-unsafe version of Store. Doesn't fail on access with +strings, making it much easier to write generic functions that do not care +about the kind of store that is passed. diff --git a/packages/docs/api/pinia/type-aliases/StoreGetters.md b/packages/docs/api/pinia/type-aliases/StoreGetters.md new file mode 100644 index 000000000..2e47fd7be --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/StoreGetters.md @@ -0,0 +1,20 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / StoreGetters + +# Type Alias: StoreGetters\ + +> **StoreGetters**\<`SS`\>: `SS` *extends* [`Store`](Store.md)\<`string`, [`StateTree`](StateTree.md), infer G, [`_ActionsTree`](ActionsTree.md)\> ? [`_StoreWithGetters`](StoreWithGetters.md)\<`G`\> : [`_ExtractGettersFromSetupStore`](ExtractGettersFromSetupStore.md)\<`SS`\> + +Extract the getters of a store type. Works with both a Setup Store or an +Options Store. + +## Type Parameters + +• **SS** diff --git a/packages/docs/api/pinia/type-aliases/StoreObject.md b/packages/docs/api/pinia/type-aliases/StoreObject.md new file mode 100644 index 000000000..ac44b65a0 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/StoreObject.md @@ -0,0 +1,19 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_StoreObject + +# Type Alias: \_StoreObject\ + +> **\_StoreObject**\<`S`\>: `S` *extends* [`StoreDefinition`](../interfaces/StoreDefinition.md)\ ? \{ \[Id in \`$\{Ids\}$\{MapStoresCustomization extends Record\<"suffix", infer Suffix\> ? Suffix : "Store"\}\`\]: Function \} : `object` + +For internal use **only**. + +## Type Parameters + +• **S** diff --git a/packages/docs/api/pinia/type-aliases/StoreOnActionListener.md b/packages/docs/api/pinia/type-aliases/StoreOnActionListener.md new file mode 100644 index 000000000..b0759c939 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/StoreOnActionListener.md @@ -0,0 +1,33 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / StoreOnActionListener + +# Type Alias: StoreOnActionListener()\ + +> **StoreOnActionListener**\<`Id`, `S`, `G`, `A`\>: (`context`) => `void` + +Argument of `store.$onAction()` + +## Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](StateTree.md) + +• **G** + +• **A** + +## Parameters + +• **context**: [`StoreOnActionListenerContext`](StoreOnActionListenerContext.md)\<`Id`, `S`, `G`, `object` *extends* `A` ? [`_ActionsTree`](ActionsTree.md) : `A`\> + +## Returns + +`void` diff --git a/packages/docs/api/pinia/type-aliases/StoreOnActionListenerContext.md b/packages/docs/api/pinia/type-aliases/StoreOnActionListenerContext.md new file mode 100644 index 000000000..ebad81eb8 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/StoreOnActionListenerContext.md @@ -0,0 +1,26 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / StoreOnActionListenerContext + +# Type Alias: StoreOnActionListenerContext\ + +> **StoreOnActionListenerContext**\<`Id`, `S`, `G`, `A`\>: [`_ActionsTree`](ActionsTree.md) *extends* `A` ? [`_StoreOnActionListenerContext`](../interfaces/StoreOnActionListenerContext.md)\<[`StoreGeneric`](StoreGeneric.md), `string`, [`_ActionsTree`](ActionsTree.md)\> : `{ [Name in keyof A]: Name extends string ? _StoreOnActionListenerContext, Name, A> : never }`\[keyof `A`\] + +Context object passed to callbacks of `store.$onAction(context => {})` +TODO: should have only the Id, the Store and Actions to generate the proper object + +## Type Parameters + +• **Id** *extends* `string` + +• **S** *extends* [`StateTree`](StateTree.md) + +• **G** + +• **A** diff --git a/packages/docs/api/pinia/type-aliases/StoreState.md b/packages/docs/api/pinia/type-aliases/StoreState.md new file mode 100644 index 000000000..c77a697b4 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/StoreState.md @@ -0,0 +1,20 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / StoreState + +# Type Alias: StoreState\ + +> **StoreState**\<`SS`\>: `SS` *extends* [`Store`](Store.md)\<`string`, infer S, [`_GettersTree`](GettersTree.md)\<[`StateTree`](StateTree.md)\>, [`_ActionsTree`](ActionsTree.md)\> ? `UnwrapRef`\<`S`\> : [`_ExtractStateFromSetupStore`](ExtractStateFromSetupStore.md)\<`SS`\> + +Extract the state of a store type. Works with both a Setup Store or an +Options Store. Note this unwraps refs. + +## Type Parameters + +• **SS** diff --git a/packages/docs/api/pinia/type-aliases/StoreWithActions.md b/packages/docs/api/pinia/type-aliases/StoreWithActions.md new file mode 100644 index 000000000..ea05cb5b9 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/StoreWithActions.md @@ -0,0 +1,20 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_StoreWithActions + +# Type Alias: \_StoreWithActions\ + +> **\_StoreWithActions**\<`A`\>: `{ [k in keyof A]: A[k] extends Function ? Function : never }` + +Store augmented for actions. For internal usage only. +For internal use **only** + +## Type Parameters + +• **A** diff --git a/packages/docs/api/pinia/type-aliases/StoreWithGetters.md b/packages/docs/api/pinia/type-aliases/StoreWithGetters.md new file mode 100644 index 000000000..cddd9dec4 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/StoreWithGetters.md @@ -0,0 +1,20 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_StoreWithGetters + +# Type Alias: \_StoreWithGetters\ + +> **\_StoreWithGetters**\<`G`\>: `{ readonly [k in keyof G]: G[k] extends Function ? R : UnwrapRef }` + +Store augmented with getters. For internal usage only. +For internal use **only** + +## Type Parameters + +• **G** diff --git a/packages/docs/api/pinia/type-aliases/SubscriptionCallback.md b/packages/docs/api/pinia/type-aliases/SubscriptionCallback.md new file mode 100644 index 000000000..96dae270b --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/SubscriptionCallback.md @@ -0,0 +1,29 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / SubscriptionCallback + +# Type Alias: SubscriptionCallback()\ + +> **SubscriptionCallback**\<`S`\>: (`mutation`, `state`) => `void` + +Callback of a subscription + +## Type Parameters + +• **S** + +## Parameters + +• **mutation**: [`SubscriptionCallbackMutation`](SubscriptionCallbackMutation.md)\<`S`\> + +• **state**: `UnwrapRef`\<`S`\> + +## Returns + +`void` diff --git a/packages/docs/api/pinia/type-aliases/SubscriptionCallbackMutation.md b/packages/docs/api/pinia/type-aliases/SubscriptionCallbackMutation.md new file mode 100644 index 000000000..d7b5c18a4 --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/SubscriptionCallbackMutation.md @@ -0,0 +1,19 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / SubscriptionCallbackMutation + +# Type Alias: SubscriptionCallbackMutation\ + +> **SubscriptionCallbackMutation**\<`S`\>: [`SubscriptionCallbackMutationDirect`](../interfaces/SubscriptionCallbackMutationDirect.md) \| [`SubscriptionCallbackMutationPatchObject`](../interfaces/SubscriptionCallbackMutationPatchObject.md)\<`S`\> \| [`SubscriptionCallbackMutationPatchFunction`](../interfaces/SubscriptionCallbackMutationPatchFunction.md) + +Context object passed to a subscription callback. + +## Type Parameters + +• **S** diff --git a/packages/docs/api/pinia/type-aliases/UnwrapAll.md b/packages/docs/api/pinia/type-aliases/UnwrapAll.md new file mode 100644 index 000000000..7aaeae1eb --- /dev/null +++ b/packages/docs/api/pinia/type-aliases/UnwrapAll.md @@ -0,0 +1,20 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / \_UnwrapAll + +# Type Alias: \_UnwrapAll\ + +> **\_UnwrapAll**\<`SS`\>: `{ [K in keyof SS]: UnwrapRef }` + +Type that enables refactoring through IDE. +For internal use **only** + +## Type Parameters + +• **SS** diff --git a/packages/docs/api/pinia/variables/PiniaVuePlugin.md b/packages/docs/api/pinia/variables/PiniaVuePlugin.md new file mode 100644 index 000000000..976b4ad82 --- /dev/null +++ b/packages/docs/api/pinia/variables/PiniaVuePlugin.md @@ -0,0 +1,37 @@ +--- +editLink: false +--- + +[**API Documentation**](../../index.md) • **Docs** + +*** + +[API Documentation](../../index.md) / [pinia](../index.md) / PiniaVuePlugin + +# Variable: PiniaVuePlugin + +> `const` **PiniaVuePlugin**: `Plugin` + +Vue 2 Plugin that must be installed for pinia to work. Note **you don't need +this plugin if you are using Nuxt.js**. Use the `buildModule` instead: +https://pinia.vuejs.org/ssr/nuxt.html. + +## Example + +```js +import Vue from 'vue' +import { PiniaVuePlugin, createPinia } from 'pinia' + +Vue.use(PiniaVuePlugin) +const pinia = createPinia() + +new Vue({ + el: '#app', + // ... + pinia, +}) +``` + +## Param + +`Vue` imported from 'vue'. diff --git a/packages/docs/cookbook/testing.md b/packages/docs/cookbook/testing.md index 7d0dd9465..b7bc381a5 100644 --- a/packages/docs/cookbook/testing.md +++ b/packages/docs/cookbook/testing.md @@ -217,7 +217,7 @@ If you are interesting in learning more tricks like this, you should check out t ### Specifying the createSpy function -When using Jest, or vitest with `globals: true`, `createTestingPinia` automatically stubs actions using the spy function based on the existing test framework (`jest.fn` or `vitest.fn`). If you are not using `globals: true` or using a different framework, you'll need to provide a [createSpy](/api/interfaces/pinia_testing.TestingOptions.html#createspy) option: +When using Jest, or vitest with `globals: true`, `createTestingPinia` automatically stubs actions using the spy function based on the existing test framework (`jest.fn` or `vitest.fn`). If you are not using `globals: true` or using a different framework, you'll need to provide a [createSpy](../api/@pinia/testing/interfaces/TestingOptions.html#createSpy-) option: ::: code-group