From 98571e555fbc1a059868a43862054223e916781d Mon Sep 17 00:00:00 2001 From: Alec Gibson <12036746+alecgibson@users.noreply.github.com> Date: Thu, 8 Jun 2023 10:24:13 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Allow=20getters=20to=20be=20reconfi?= =?UTF-8?q?gured?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit At the moment, getters cannot be stubbed in tests, because they're defined as unconfigurable. This change adds a `configurableGetters` option to the `Module` options, which is `false` by default (keeps existing behaviour). If this flag is set to `true`, we allow getters to be reconfigured, which lets us stub them. --- README.md | 25 ++++++++++ dist/cjs/index.js | 21 +++----- dist/cjs/index.js.map | 2 +- dist/esm/index.js | 21 +++----- dist/esm/index.js.map | 2 +- dist/types/moduleoptions.d.ts | 8 +++ src/module/staticGenerators.ts | 20 +++----- src/moduleoptions.ts | 9 ++++ test/getmodule/getmodule_getter.ts | 6 +++ .../getmodule_getter_configurable.ts | 49 +++++++++++++++++++ 10 files changed, 120 insertions(+), 43 deletions(-) create mode 100644 test/getmodule/getmodule_getter_configurable.ts diff --git a/README.md b/README.md index 684cf25..cd28931 100644 --- a/README.md +++ b/README.md @@ -410,3 +410,28 @@ import { config } from 'vuex-module-decorators' // Set rawError to true by default on all @Action decorators config.rawError = true ``` + +## Stubbing for tests + +Actions and mutations can be stubbed like any other function using - for example - [`sinon`](https://sinonjs.org/). + +By default, getters are readonly, and cannot be reconfigured, which prevents stubbing. + +To override this behaviour in a test environment, set the `configurableGetters` flag: + +```typescript +import { Module, VuexModule, Mutation } from 'vuex-module-decorators' + +@Module({ + name: 'MyModule', + configurableGetters: true, +}) +export default class MyStoreModule extends VuexModule { + public test: string = 'initial' + + @Mutation + public setTest(val: string) { + this.test = val + } +} +``` diff --git a/dist/cjs/index.js b/dist/cjs/index.js index f2b60ba..e07d3d9 100644 --- a/dist/cjs/index.js +++ b/dist/cjs/index.js @@ -169,20 +169,13 @@ function staticStateGenerator(module, modOpt, statics) { } function staticGetterGenerator(module, modOpt, statics) { Object.keys(module.getters).forEach(function (key) { - if (module.namespaced) { - Object.defineProperty(statics, key, { - get: function () { - return statics.store.getters["".concat(modOpt.name, "/").concat(key)]; - } - }); - } - else { - Object.defineProperty(statics, key, { - get: function () { - return statics.store.getters[key]; - } - }); - } + var moduleKey = module.namespaced ? "".concat(modOpt.name, "/").concat(key) : key; + Object.defineProperty(statics, key, { + configurable: !!modOpt.configurableGetters, + get: function () { + return statics.store.getters[moduleKey]; + } + }); }); } function staticMutationGenerator(module, modOpt, statics) { diff --git a/dist/cjs/index.js.map b/dist/cjs/index.js.map index 529d638..28e677a 100644 --- a/dist/cjs/index.js.map +++ b/dist/cjs/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../../src/helpers.ts","../../src/vuexmodule.ts","../../src/module/stateFactory.ts","../../src/module/staticGenerators.ts","../../src/module/index.ts","../../src/config.ts","../../src/action.ts","../../src/mutation.ts","../../src/mutationaction.ts"],"sourcesContent":["/**\n * Takes the properties on object from parameter source and adds them to the object\n * parameter target\n * @param {object} target Object to have properties copied onto from y\n * @param {object} source Object with properties to be copied to x\n */\nexport function addPropertiesToObject(target: any, source: any) {\n for (let k of Object.keys(source || {})) {\n Object.defineProperty(target, k, {\n get: () => source[k]\n })\n }\n}\n\n/**\n * Returns a namespaced name of the module to be used as a store getter\n * @param module\n */\nexport function getModuleName(module: any): string {\n if (!module._vmdModuleName) {\n throw new Error(`ERR_GET_MODULE_NAME : Could not get module accessor.\n Make sure your module has name, we can't make accessors for unnamed modules\n i.e. @Module({ name: 'something' })`)\n }\n return `vuexModuleDecorators/${module._vmdModuleName}`\n}\n","import {\n ActionTree,\n GetterTree,\n Module as Mod,\n ModuleTree,\n MutationTree,\n Store,\n ActionContext\n} from 'vuex'\nimport { getModuleName } from './helpers'\n\nexport class VuexModule, R = any> implements Mod {\n /*\n * To use with `extends Class` syntax along with decorators\n */\n static namespaced?: boolean\n static state?: any | (() => any)\n static getters?: GetterTree\n static actions?: ActionTree\n static mutations?: MutationTree\n static modules?: ModuleTree\n\n /*\n * To use with `new VuexModule({})` syntax\n */\n\n modules?: ModuleTree\n namespaced?: boolean\n getters?: GetterTree\n state?: S | (() => S)\n mutations?: MutationTree\n actions?: ActionTree\n context!: ActionContext\n\n constructor(module: Mod) {\n this.actions = module.actions\n this.mutations = module.mutations\n this.state = module.state\n this.getters = module.getters\n this.namespaced = module.namespaced\n this.modules = module.modules\n }\n}\ntype ConstructorOf = { new (...args: any[]): C }\n\nexport function getModule(\n moduleClass: ConstructorOf,\n store?: Store\n): M {\n const moduleName = getModuleName(moduleClass)\n if (store && store.getters[moduleName]) {\n return store.getters[moduleName]\n } else if ((moduleClass as any)._statics) {\n return (moduleClass as any)._statics\n }\n\n const genStatic: (providedStore?: Store) => M = (moduleClass as any)._genStatic\n if (!genStatic) {\n throw new Error(`ERR_GET_MODULE_NO_STATICS : Could not get module accessor.\n Make sure your module has name, we can't make accessors for unnamed modules\n i.e. @Module({ name: 'something' })`)\n }\n\n const storeModule = genStatic(store)\n\n if (store) {\n store.getters[moduleName] = storeModule\n } else {\n ;(moduleClass as any)._statics = storeModule\n }\n\n return storeModule\n}\n","import { Module as Mod } from 'vuex'\n\nconst reservedKeys = ['actions', 'getters', 'mutations', 'modules', 'state', 'namespaced', 'commit']\nexport function stateFactory(module: Function & Mod) {\n const state = new module.prototype.constructor({})\n const s = {} as S\n Object.keys(state).forEach((key: string) => {\n if (reservedKeys.indexOf(key) !== -1) {\n if (typeof state[key] !== 'undefined') {\n throw new Error(\n `ERR_RESERVED_STATE_KEY_USED: You cannot use the following\n ['actions', 'getters', 'mutations', 'modules', 'state', 'namespaced', 'commit']\n as fields in your module. These are reserved as they have special purpose in Vuex`\n )\n }\n return\n }\n if (state.hasOwnProperty(key)) {\n if (typeof state[key] !== 'function') {\n ;(s as any)[key] = state[key]\n }\n }\n })\n\n return s\n}\n","import { ActionTree, GetterTree, Module as Mod, MutationTree } from 'vuex'\nimport { DynamicModuleOptions } from '../moduleoptions'\n\nexport function staticStateGenerator(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n const state: S = modOpt.stateFactory ? (module as any).state() : module.state\n Object.keys(state).forEach((key) => {\n if (state.hasOwnProperty(key)) {\n // If not undefined or function means it is a state value\n if (['undefined', 'function'].indexOf(typeof (state as any)[key]) === -1) {\n Object.defineProperty(statics, key, {\n get() {\n const path = modOpt.name.split('/')\n let data = statics.store.state\n for (let segment of path) {\n data = data[segment]\n }\n return data[key]\n }\n })\n }\n }\n })\n}\n\nexport function staticGetterGenerator(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n Object.keys(module.getters as GetterTree).forEach((key) => {\n if (module.namespaced) {\n Object.defineProperty(statics, key, {\n get() {\n return statics.store.getters[`${modOpt.name}/${key}`]\n }\n })\n } else {\n Object.defineProperty(statics, key, {\n get() {\n return statics.store.getters[key]\n }\n })\n }\n })\n}\n\nexport function staticMutationGenerator(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n Object.keys(module.mutations as MutationTree).forEach((key) => {\n if (module.namespaced) {\n statics[key] = function (...args: any[]) {\n statics.store.commit(`${modOpt.name}/${key}`, ...args)\n }\n } else {\n statics[key] = function (...args: any[]) {\n statics.store.commit(key, ...args)\n }\n }\n })\n}\n\nexport function staticActionGenerators(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n Object.keys(module.actions as ActionTree).forEach((key) => {\n if (module.namespaced) {\n statics[key] = async function (...args: any[]) {\n return statics.store.dispatch(`${modOpt.name}/${key}`, ...args)\n }\n } else {\n statics[key] = async function (...args: any[]) {\n return statics.store.dispatch(key, ...args)\n }\n }\n })\n}\n","import { GetterTree, Module as Mod, Store } from 'vuex'\nimport { DynamicModuleOptions, ModuleOptions } from '../moduleoptions'\nimport { stateFactory as sf } from './stateFactory'\nimport { addPropertiesToObject } from '../helpers'\nimport {\n staticActionGenerators,\n staticGetterGenerator,\n staticMutationGenerator,\n staticStateGenerator\n} from './staticGenerators'\n\nfunction registerDynamicModule(module: Mod, modOpt: DynamicModuleOptions) {\n if (!modOpt.name) {\n throw new Error('Name of module not provided in decorator options')\n }\n\n if (!modOpt.store) {\n throw new Error('Store not provided in decorator options when using dynamic option')\n }\n\n modOpt.store.registerModule(\n modOpt.name, // TODO: Handle nested modules too in future\n module,\n { preserveState: modOpt.preserveState || false }\n )\n}\n\nfunction addGettersToModule(\n targetModule: Function & Mod,\n srcModule: Function & Mod\n) {\n Object.getOwnPropertyNames(srcModule.prototype).forEach((funcName: string) => {\n const descriptor = Object.getOwnPropertyDescriptor(\n srcModule.prototype,\n funcName\n ) as PropertyDescriptor\n if (descriptor.get && targetModule.getters) {\n targetModule.getters[funcName] = function (\n state: S,\n getters: GetterTree,\n rootState: any,\n rootGetters: GetterTree\n ) {\n const thisObj = { context: { state, getters, rootState, rootGetters } }\n addPropertiesToObject(thisObj, state)\n addPropertiesToObject(thisObj, getters)\n const got = (descriptor.get as Function).call(thisObj)\n return got\n }\n }\n })\n}\n\nfunction moduleDecoratorFactory(moduleOptions: ModuleOptions) {\n return function (constructor: TFunction): TFunction | void {\n const module: Function & Mod = constructor\n const stateFactory = () => sf(module)\n\n if (!module.state) {\n module.state = moduleOptions && moduleOptions.stateFactory ? stateFactory : stateFactory()\n }\n if (!module.getters) {\n module.getters = {} as GetterTree\n }\n if (!module.namespaced) {\n module.namespaced = moduleOptions && moduleOptions.namespaced\n }\n let parentModule = Object.getPrototypeOf(module)\n while (parentModule.name !== 'VuexModule' && parentModule.name !== '') {\n addGettersToModule(module, parentModule)\n parentModule = Object.getPrototypeOf(parentModule)\n }\n addGettersToModule(module, module)\n const modOpt = moduleOptions as DynamicModuleOptions\n if (modOpt.name) {\n Object.defineProperty(constructor, '_genStatic', {\n value: (store?: Store) => {\n let statics = { store: store || modOpt.store }\n if (!statics.store) {\n throw new Error(`ERR_STORE_NOT_PROVIDED: To use getModule(), either the module\n should be decorated with store in decorator, i.e. @Module({store: store}) or\n store should be passed when calling getModule(), i.e. getModule(MyModule, this.$store)`)\n }\n // =========== For statics ==============\n // ------ state -------\n staticStateGenerator(module, modOpt, statics)\n\n // ------- getters -------\n if (module.getters) {\n staticGetterGenerator(module, modOpt, statics)\n }\n\n // -------- mutations --------\n if (module.mutations) {\n staticMutationGenerator(module, modOpt, statics)\n }\n // -------- actions ---------\n if (module.actions) {\n staticActionGenerators(module, modOpt, statics)\n }\n return statics\n }\n })\n\n Object.defineProperty(constructor, '_vmdModuleName', {\n value: modOpt.name\n })\n }\n\n if (modOpt.dynamic) {\n registerDynamicModule(module, modOpt)\n }\n return constructor\n }\n}\n\nexport function Module(module: Function & Mod): void\nexport function Module(options: ModuleOptions): ClassDecorator\n\nexport function Module(modOrOpt: ModuleOptions | (Function & Mod)) {\n if (typeof (modOrOpt as any) === 'function') {\n /*\n * @Module decorator called without options (directly on the class definition)\n */\n moduleDecoratorFactory({})(modOrOpt as Function & Mod)\n } else {\n /*\n * @Module({...}) decorator called with options\n */\n return moduleDecoratorFactory(modOrOpt)\n }\n}\n","export const config: IConfig = {}\n\nexport interface IConfig {\n rawError?: boolean\n}\n","import { Action as Act, ActionContext, Module as Mod, Payload } from 'vuex'\nimport { getModule, VuexModule } from './vuexmodule'\nimport { addPropertiesToObject, getModuleName } from './helpers'\nimport { config } from './config'\n\n/**\n * Parameters that can be passed to the @Action decorator\n */\nexport interface ActionDecoratorParams {\n commit?: string\n rawError?: boolean\n root?: boolean\n}\nfunction actionDecoratorFactory(params?: ActionDecoratorParams): MethodDecorator {\n const { commit = undefined, rawError = !!config.rawError, root = false } = params || {}\n return function (target: Object, key: string | symbol, descriptor: TypedPropertyDescriptor) {\n const module = target.constructor as Mod\n if (!module.hasOwnProperty('actions')) {\n module.actions = Object.assign({}, module.actions)\n }\n const actionFunction: Function = descriptor.value\n const action: Act = async function (\n context: ActionContext,\n payload: Payload\n ) {\n try {\n let actionPayload = null\n\n if ((module as any)._genStatic) {\n const moduleName = getModuleName(module)\n const moduleAccessor = context.rootGetters[moduleName]\n ? context.rootGetters[moduleName]\n : getModule(module as typeof VuexModule)\n moduleAccessor.context = context\n actionPayload = await actionFunction.call(moduleAccessor, payload)\n } else {\n const thisObj = { context }\n addPropertiesToObject(thisObj, context.state)\n addPropertiesToObject(thisObj, context.getters)\n actionPayload = await actionFunction.call(thisObj, payload)\n }\n if (commit) {\n context.commit(commit, actionPayload)\n }\n return actionPayload\n } catch (e: any) {\n throw rawError\n ? e\n : new Error(\n 'ERR_ACTION_ACCESS_UNDEFINED: Are you trying to access ' +\n 'this.someMutation() or this.someGetter inside an @Action? \\n' +\n 'That works only in dynamic modules. \\n' +\n 'If not dynamic use this.context.commit(\"mutationName\", payload) ' +\n 'and this.context.getters[\"getterName\"]' +\n '\\n' +\n new Error(`Could not perform action ${key.toString()}`).stack +\n '\\n' +\n e.stack\n )\n }\n }\n module.actions![key as string] = root ? { root, handler: action } : action\n }\n}\n\nexport function Action(\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => R>\n): void\nexport function Action(params: ActionDecoratorParams): MethodDecorator\n\n/**\n * The @Action decorator turns an async function into an Vuex action\n *\n * @param targetOrParams the module class\n * @param key name of the action\n * @param descriptor the action function descriptor\n * @constructor\n */\nexport function Action(\n targetOrParams: T | ActionDecoratorParams,\n key?: string | symbol,\n descriptor?: TypedPropertyDescriptor<(...args: any[]) => R>\n) {\n if (!key && !descriptor) {\n /*\n * This is the case when `targetOrParams` is params.\n * i.e. when used as -\n *
\n        @Action({commit: 'incrCount'})\n        async getCountDelta() {\n          return 5\n        }\n     * 
\n */\n return actionDecoratorFactory(targetOrParams as ActionDecoratorParams)\n } else {\n /*\n * This is the case when @Action is called on action function\n * without any params\n *
\n     *   @Action\n     *   async doSomething() {\n     *    ...\n     *   }\n     * 
\n */\n actionDecoratorFactory()(targetOrParams, key!, descriptor!)\n }\n}\n","import { Module as Mod, Mutation as Mut, Payload } from 'vuex'\n\nexport function Mutation(\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => R>\n) {\n const module = target.constructor as Mod\n if (!module.hasOwnProperty('mutations')) {\n module.mutations = Object.assign({}, module.mutations)\n }\n const mutationFunction: Function = descriptor.value!\n const mutation: Mut = function (state: typeof target, payload: Payload) {\n mutationFunction.call(state, payload)\n }\n module.mutations![key as string] = mutation\n}\n","import { Action as Act, ActionContext, Module as Mod, Mutation as Mut, Payload, Store } from 'vuex'\nimport { addPropertiesToObject } from './helpers'\n\nexport interface MutationActionParams {\n mutate?: (keyof Partial)[]\n rawError?: boolean\n root?: boolean\n}\n\nfunction mutationActionDecoratorFactory(params: MutationActionParams) {\n return function (\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise | undefined>>\n ) {\n const module = target.constructor as Mod\n if (!module.hasOwnProperty('mutations')) {\n module.mutations = Object.assign({}, module.mutations)\n }\n if (!module.hasOwnProperty('actions')) {\n module.actions = Object.assign({}, module.actions)\n }\n const mutactFunction = descriptor.value as (payload: any) => Promise\n\n const action: Act = async function (\n context: ActionContext,\n payload: Payload\n ) {\n try {\n const thisObj = { context }\n addPropertiesToObject(thisObj, context.state)\n addPropertiesToObject(thisObj, context.getters)\n const actionPayload = await mutactFunction.call(thisObj, payload)\n if (actionPayload === undefined) return\n context.commit(key as string, actionPayload)\n } catch (e: any) {\n if (params.rawError) {\n throw e\n } else {\n console.error('Could not perform action ' + key.toString())\n console.error(e)\n return Promise.reject(e)\n }\n }\n }\n\n const mutation: Mut = function (\n state: typeof target | Store,\n payload: Payload & { [k in keyof T]: any }\n ) {\n if (!params.mutate) {\n params.mutate = Object.keys(payload) as (keyof T)[]\n }\n for (let stateItem of params.mutate) {\n if (state.hasOwnProperty(stateItem) && payload.hasOwnProperty(stateItem)) {\n ;(state as T)[stateItem] = payload[stateItem]\n } else {\n throw new Error(`ERR_MUTATE_PARAMS_NOT_IN_PAYLOAD\n In @MutationAction, mutate: ['a', 'b', ...] array keys must\n match with return type = {a: {}, b: {}, ...} and must\n also be in state.`)\n }\n }\n }\n module.actions![key as string] = params.root ? { root: true, handler: action } : action\n module.mutations![key as string] = mutation\n }\n}\n\nexport function MutationAction(\n target: { [k in keyof T]: T[k] | null },\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise>\n): void\n\nexport function MutationAction(\n params: MutationActionParams\n): (\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise>\n) => void\n\n/**\n * The @MutationAction decorator turns this into an action that further calls a mutation\n * Both the action and the mutation are generated for you\n *\n * @param paramsOrTarget the params or the target class\n * @param key the name of the function\n * @param descriptor the function body\n * @constructor\n */\nexport function MutationAction(\n paramsOrTarget: MutationActionParams | M,\n key?: string | symbol,\n descriptor?: TypedPropertyDescriptor<(...args: any[]) => Promise | undefined>>\n):\n | ((\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise | undefined>>\n ) => void)\n | void {\n if (!key && !descriptor) {\n /*\n * This is the case when `paramsOrTarget` is params.\n * i.e. when used as -\n *
\n        @MutationAction({mutate: ['incrCount']})\n        async getCountDelta() {\n          return {incrCount: 5}\n        }\n     * 
\n */\n return mutationActionDecoratorFactory(paramsOrTarget as MutationActionParams)\n } else {\n /*\n * This is the case when `paramsOrTarget` is target.\n * i.e. when used as -\n *
\n        @MutationAction\n        async getCountDelta() {\n          return {incrCount: 5}\n        }\n     * 
\n */\n mutationActionDecoratorFactory({} as MutationActionParams)(\n paramsOrTarget as K,\n key!,\n descriptor!\n )\n }\n}\n"],"names":["stateFactory","sf"],"mappings":";;;;AAAA;;;;;;SAMgB,qBAAqB,CAAC,MAAW,EAAE,MAAW;4BACnD,CAAC;QACR,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE;YAC/B,GAAG,EAAE,cAAM,OAAA,MAAM,CAAC,CAAC,CAAC,GAAA;SACrB,CAAC,C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C;YAE1C,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;gBAClB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAgB,CAAA;aACpD;YACD,KAAsB,UAAa,EAAb,KAAA,MAAM,CAAC,MAAM,EAAb,cAAa,EAAb,IAAa,EAAE;gBAAhC,IAAI,SAAS,SAAA;gBAChB,IAAI,KAAK,CAAC,cAAc,CAAC,SAAS,CAAC,IAAI,OAAO,CAAC,cAAc,CAAC,SAAS,CAAC,EAAE;oBACtE,KAAW,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,SAAS,CAAC,CAAA;iBAC9C;qBAAM;oBACL,MAAM,IAAI,KAAK,CAAC,uMAGE,CAAC,CAAA;iBACpB;aACF;SACF,CAAA;QACD,MAAM,CAAC,OAAQ,CAAC,GAAa,CAAC,GAAG,MAAM,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;QACvF,MAAM,CAAC,SAAU,CAAC,GAAa,CAAC,GAAG,QAAQ,CAAA;KAC5C,CAAA;AACH,CAAC;AAgBD;;;;;;;;;SASgB,cAAc,CAC5B,cAA2C,EAC3C,GAAqB,EACrB,UAAyF;IAQzF,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE;;;;;;;;;;;QAWvB,OAAO,8BAA8B,CAAC,cAAyC,CAAC,CAAA;KACjF;SAAM;;;;;;;;;;;QAWL,8BAA8B,CAAC,EAA6B,CAAC,CAC3D,cAAmB,EACnB,GAAI,EACJ,UAAW,CACZ,CAAA;KACF;AACH;;;;;;;;;;"} \ No newline at end of file +{"version":3,"file":"index.js","sources":["../../src/helpers.ts","../../src/vuexmodule.ts","../../src/module/stateFactory.ts","../../src/module/staticGenerators.ts","../../src/module/index.ts","../../src/config.ts","../../src/action.ts","../../src/mutation.ts","../../src/mutationaction.ts"],"sourcesContent":["/**\n * Takes the properties on object from parameter source and adds them to the object\n * parameter target\n * @param {object} target Object to have properties copied onto from y\n * @param {object} source Object with properties to be copied to x\n */\nexport function addPropertiesToObject(target: any, source: any) {\n for (let k of Object.keys(source || {})) {\n Object.defineProperty(target, k, {\n get: () => source[k]\n })\n }\n}\n\n/**\n * Returns a namespaced name of the module to be used as a store getter\n * @param module\n */\nexport function getModuleName(module: any): string {\n if (!module._vmdModuleName) {\n throw new Error(`ERR_GET_MODULE_NAME : Could not get module accessor.\n Make sure your module has name, we can't make accessors for unnamed modules\n i.e. @Module({ name: 'something' })`)\n }\n return `vuexModuleDecorators/${module._vmdModuleName}`\n}\n","import {\n ActionTree,\n GetterTree,\n Module as Mod,\n ModuleTree,\n MutationTree,\n Store,\n ActionContext\n} from 'vuex'\nimport { getModuleName } from './helpers'\n\nexport class VuexModule, R = any> implements Mod {\n /*\n * To use with `extends Class` syntax along with decorators\n */\n static namespaced?: boolean\n static state?: any | (() => any)\n static getters?: GetterTree\n static actions?: ActionTree\n static mutations?: MutationTree\n static modules?: ModuleTree\n\n /*\n * To use with `new VuexModule({})` syntax\n */\n\n modules?: ModuleTree\n namespaced?: boolean\n getters?: GetterTree\n state?: S | (() => S)\n mutations?: MutationTree\n actions?: ActionTree\n context!: ActionContext\n\n constructor(module: Mod) {\n this.actions = module.actions\n this.mutations = module.mutations\n this.state = module.state\n this.getters = module.getters\n this.namespaced = module.namespaced\n this.modules = module.modules\n }\n}\ntype ConstructorOf = { new (...args: any[]): C }\n\nexport function getModule(\n moduleClass: ConstructorOf,\n store?: Store\n): M {\n const moduleName = getModuleName(moduleClass)\n if (store && store.getters[moduleName]) {\n return store.getters[moduleName]\n } else if ((moduleClass as any)._statics) {\n return (moduleClass as any)._statics\n }\n\n const genStatic: (providedStore?: Store) => M = (moduleClass as any)._genStatic\n if (!genStatic) {\n throw new Error(`ERR_GET_MODULE_NO_STATICS : Could not get module accessor.\n Make sure your module has name, we can't make accessors for unnamed modules\n i.e. @Module({ name: 'something' })`)\n }\n\n const storeModule = genStatic(store)\n\n if (store) {\n store.getters[moduleName] = storeModule\n } else {\n ;(moduleClass as any)._statics = storeModule\n }\n\n return storeModule\n}\n","import { Module as Mod } from 'vuex'\n\nconst reservedKeys = ['actions', 'getters', 'mutations', 'modules', 'state', 'namespaced', 'commit']\nexport function stateFactory(module: Function & Mod) {\n const state = new module.prototype.constructor({})\n const s = {} as S\n Object.keys(state).forEach((key: string) => {\n if (reservedKeys.indexOf(key) !== -1) {\n if (typeof state[key] !== 'undefined') {\n throw new Error(\n `ERR_RESERVED_STATE_KEY_USED: You cannot use the following\n ['actions', 'getters', 'mutations', 'modules', 'state', 'namespaced', 'commit']\n as fields in your module. These are reserved as they have special purpose in Vuex`\n )\n }\n return\n }\n if (state.hasOwnProperty(key)) {\n if (typeof state[key] !== 'function') {\n ;(s as any)[key] = state[key]\n }\n }\n })\n\n return s\n}\n","import { ActionTree, GetterTree, Module as Mod, MutationTree } from 'vuex'\nimport { DynamicModuleOptions } from '../moduleoptions'\n\nexport function staticStateGenerator(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n const state: S = modOpt.stateFactory ? (module as any).state() : module.state\n Object.keys(state).forEach((key) => {\n if (state.hasOwnProperty(key)) {\n // If not undefined or function means it is a state value\n if (['undefined', 'function'].indexOf(typeof (state as any)[key]) === -1) {\n Object.defineProperty(statics, key, {\n get() {\n const path = modOpt.name.split('/')\n let data = statics.store.state\n for (let segment of path) {\n data = data[segment]\n }\n return data[key]\n }\n })\n }\n }\n })\n}\n\nexport function staticGetterGenerator(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n Object.keys(module.getters as GetterTree).forEach((key) => {\n const moduleKey = module.namespaced ? `${modOpt.name}/${key}` : key\n Object.defineProperty(statics, key, {\n configurable: !!modOpt.configurableGetters,\n get() {\n return statics.store.getters[moduleKey]\n }\n })\n })\n}\n\nexport function staticMutationGenerator(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n Object.keys(module.mutations as MutationTree).forEach((key) => {\n if (module.namespaced) {\n statics[key] = function (...args: any[]) {\n statics.store.commit(`${modOpt.name}/${key}`, ...args)\n }\n } else {\n statics[key] = function (...args: any[]) {\n statics.store.commit(key, ...args)\n }\n }\n })\n}\n\nexport function staticActionGenerators(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n Object.keys(module.actions as ActionTree).forEach((key) => {\n if (module.namespaced) {\n statics[key] = async function (...args: any[]) {\n return statics.store.dispatch(`${modOpt.name}/${key}`, ...args)\n }\n } else {\n statics[key] = async function (...args: any[]) {\n return statics.store.dispatch(key, ...args)\n }\n }\n })\n}\n","import { GetterTree, Module as Mod, Store } from 'vuex'\nimport { DynamicModuleOptions, ModuleOptions } from '../moduleoptions'\nimport { stateFactory as sf } from './stateFactory'\nimport { addPropertiesToObject } from '../helpers'\nimport {\n staticActionGenerators,\n staticGetterGenerator,\n staticMutationGenerator,\n staticStateGenerator\n} from './staticGenerators'\n\nfunction registerDynamicModule(module: Mod, modOpt: DynamicModuleOptions) {\n if (!modOpt.name) {\n throw new Error('Name of module not provided in decorator options')\n }\n\n if (!modOpt.store) {\n throw new Error('Store not provided in decorator options when using dynamic option')\n }\n\n modOpt.store.registerModule(\n modOpt.name, // TODO: Handle nested modules too in future\n module,\n { preserveState: modOpt.preserveState || false }\n )\n}\n\nfunction addGettersToModule(\n targetModule: Function & Mod,\n srcModule: Function & Mod\n) {\n Object.getOwnPropertyNames(srcModule.prototype).forEach((funcName: string) => {\n const descriptor = Object.getOwnPropertyDescriptor(\n srcModule.prototype,\n funcName\n ) as PropertyDescriptor\n if (descriptor.get && targetModule.getters) {\n targetModule.getters[funcName] = function (\n state: S,\n getters: GetterTree,\n rootState: any,\n rootGetters: GetterTree\n ) {\n const thisObj = { context: { state, getters, rootState, rootGetters } }\n addPropertiesToObject(thisObj, state)\n addPropertiesToObject(thisObj, getters)\n const got = (descriptor.get as Function).call(thisObj)\n return got\n }\n }\n })\n}\n\nfunction moduleDecoratorFactory(moduleOptions: ModuleOptions) {\n return function (constructor: TFunction): TFunction | void {\n const module: Function & Mod = constructor\n const stateFactory = () => sf(module)\n\n if (!module.state) {\n module.state = moduleOptions && moduleOptions.stateFactory ? stateFactory : stateFactory()\n }\n if (!module.getters) {\n module.getters = {} as GetterTree\n }\n if (!module.namespaced) {\n module.namespaced = moduleOptions && moduleOptions.namespaced\n }\n let parentModule = Object.getPrototypeOf(module)\n while (parentModule.name !== 'VuexModule' && parentModule.name !== '') {\n addGettersToModule(module, parentModule)\n parentModule = Object.getPrototypeOf(parentModule)\n }\n addGettersToModule(module, module)\n const modOpt = moduleOptions as DynamicModuleOptions\n if (modOpt.name) {\n Object.defineProperty(constructor, '_genStatic', {\n value: (store?: Store) => {\n let statics = { store: store || modOpt.store }\n if (!statics.store) {\n throw new Error(`ERR_STORE_NOT_PROVIDED: To use getModule(), either the module\n should be decorated with store in decorator, i.e. @Module({store: store}) or\n store should be passed when calling getModule(), i.e. getModule(MyModule, this.$store)`)\n }\n // =========== For statics ==============\n // ------ state -------\n staticStateGenerator(module, modOpt, statics)\n\n // ------- getters -------\n if (module.getters) {\n staticGetterGenerator(module, modOpt, statics)\n }\n\n // -------- mutations --------\n if (module.mutations) {\n staticMutationGenerator(module, modOpt, statics)\n }\n // -------- actions ---------\n if (module.actions) {\n staticActionGenerators(module, modOpt, statics)\n }\n return statics\n }\n })\n\n Object.defineProperty(constructor, '_vmdModuleName', {\n value: modOpt.name\n })\n }\n\n if (modOpt.dynamic) {\n registerDynamicModule(module, modOpt)\n }\n return constructor\n }\n}\n\nexport function Module(module: Function & Mod): void\nexport function Module(options: ModuleOptions): ClassDecorator\n\nexport function Module(modOrOpt: ModuleOptions | (Function & Mod)) {\n if (typeof (modOrOpt as any) === 'function') {\n /*\n * @Module decorator called without options (directly on the class definition)\n */\n moduleDecoratorFactory({})(modOrOpt as Function & Mod)\n } else {\n /*\n * @Module({...}) decorator called with options\n */\n return moduleDecoratorFactory(modOrOpt)\n }\n}\n","export const config: IConfig = {}\n\nexport interface IConfig {\n rawError?: boolean\n}\n","import { Action as Act, ActionContext, Module as Mod, Payload } from 'vuex'\nimport { getModule, VuexModule } from './vuexmodule'\nimport { addPropertiesToObject, getModuleName } from './helpers'\nimport { config } from './config'\n\n/**\n * Parameters that can be passed to the @Action decorator\n */\nexport interface ActionDecoratorParams {\n commit?: string\n rawError?: boolean\n root?: boolean\n}\nfunction actionDecoratorFactory(params?: ActionDecoratorParams): MethodDecorator {\n const { commit = undefined, rawError = !!config.rawError, root = false } = params || {}\n return function (target: Object, key: string | symbol, descriptor: TypedPropertyDescriptor) {\n const module = target.constructor as Mod\n if (!module.hasOwnProperty('actions')) {\n module.actions = Object.assign({}, module.actions)\n }\n const actionFunction: Function = descriptor.value\n const action: Act = async function (\n context: ActionContext,\n payload: Payload\n ) {\n try {\n let actionPayload = null\n\n if ((module as any)._genStatic) {\n const moduleName = getModuleName(module)\n const moduleAccessor = context.rootGetters[moduleName]\n ? context.rootGetters[moduleName]\n : getModule(module as typeof VuexModule)\n moduleAccessor.context = context\n actionPayload = await actionFunction.call(moduleAccessor, payload)\n } else {\n const thisObj = { context }\n addPropertiesToObject(thisObj, context.state)\n addPropertiesToObject(thisObj, context.getters)\n actionPayload = await actionFunction.call(thisObj, payload)\n }\n if (commit) {\n context.commit(commit, actionPayload)\n }\n return actionPayload\n } catch (e: any) {\n throw rawError\n ? e\n : new Error(\n 'ERR_ACTION_ACCESS_UNDEFINED: Are you trying to access ' +\n 'this.someMutation() or this.someGetter inside an @Action? \\n' +\n 'That works only in dynamic modules. \\n' +\n 'If not dynamic use this.context.commit(\"mutationName\", payload) ' +\n 'and this.context.getters[\"getterName\"]' +\n '\\n' +\n new Error(`Could not perform action ${key.toString()}`).stack +\n '\\n' +\n e.stack\n )\n }\n }\n module.actions![key as string] = root ? { root, handler: action } : action\n }\n}\n\nexport function Action(\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => R>\n): void\nexport function Action(params: ActionDecoratorParams): MethodDecorator\n\n/**\n * The @Action decorator turns an async function into an Vuex action\n *\n * @param targetOrParams the module class\n * @param key name of the action\n * @param descriptor the action function descriptor\n * @constructor\n */\nexport function Action(\n targetOrParams: T | ActionDecoratorParams,\n key?: string | symbol,\n descriptor?: TypedPropertyDescriptor<(...args: any[]) => R>\n) {\n if (!key && !descriptor) {\n /*\n * This is the case when `targetOrParams` is params.\n * i.e. when used as -\n *
\n        @Action({commit: 'incrCount'})\n        async getCountDelta() {\n          return 5\n        }\n     * 
\n */\n return actionDecoratorFactory(targetOrParams as ActionDecoratorParams)\n } else {\n /*\n * This is the case when @Action is called on action function\n * without any params\n *
\n     *   @Action\n     *   async doSomething() {\n     *    ...\n     *   }\n     * 
\n */\n actionDecoratorFactory()(targetOrParams, key!, descriptor!)\n }\n}\n","import { Module as Mod, Mutation as Mut, Payload } from 'vuex'\n\nexport function Mutation(\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => R>\n) {\n const module = target.constructor as Mod\n if (!module.hasOwnProperty('mutations')) {\n module.mutations = Object.assign({}, module.mutations)\n }\n const mutationFunction: Function = descriptor.value!\n const mutation: Mut = function (state: typeof target, payload: Payload) {\n mutationFunction.call(state, payload)\n }\n module.mutations![key as string] = mutation\n}\n","import { Action as Act, ActionContext, Module as Mod, Mutation as Mut, Payload, Store } from 'vuex'\nimport { addPropertiesToObject } from './helpers'\n\nexport interface MutationActionParams {\n mutate?: (keyof Partial)[]\n rawError?: boolean\n root?: boolean\n}\n\nfunction mutationActionDecoratorFactory(params: MutationActionParams) {\n return function (\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise | undefined>>\n ) {\n const module = target.constructor as Mod\n if (!module.hasOwnProperty('mutations')) {\n module.mutations = Object.assign({}, module.mutations)\n }\n if (!module.hasOwnProperty('actions')) {\n module.actions = Object.assign({}, module.actions)\n }\n const mutactFunction = descriptor.value as (payload: any) => Promise\n\n const action: Act = async function (\n context: ActionContext,\n payload: Payload\n ) {\n try {\n const thisObj = { context }\n addPropertiesToObject(thisObj, context.state)\n addPropertiesToObject(thisObj, context.getters)\n const actionPayload = await mutactFunction.call(thisObj, payload)\n if (actionPayload === undefined) return\n context.commit(key as string, actionPayload)\n } catch (e: any) {\n if (params.rawError) {\n throw e\n } else {\n console.error('Could not perform action ' + key.toString())\n console.error(e)\n return Promise.reject(e)\n }\n }\n }\n\n const mutation: Mut = function (\n state: typeof target | Store,\n payload: Payload & { [k in keyof T]: any }\n ) {\n if (!params.mutate) {\n params.mutate = Object.keys(payload) as (keyof T)[]\n }\n for (let stateItem of params.mutate) {\n if (state.hasOwnProperty(stateItem) && payload.hasOwnProperty(stateItem)) {\n ;(state as T)[stateItem] = payload[stateItem]\n } else {\n throw new Error(`ERR_MUTATE_PARAMS_NOT_IN_PAYLOAD\n In @MutationAction, mutate: ['a', 'b', ...] array keys must\n match with return type = {a: {}, b: {}, ...} and must\n also be in state.`)\n }\n }\n }\n module.actions![key as string] = params.root ? { root: true, handler: action } : action\n module.mutations![key as string] = mutation\n }\n}\n\nexport function MutationAction(\n target: { [k in keyof T]: T[k] | null },\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise>\n): void\n\nexport function MutationAction(\n params: MutationActionParams\n): (\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise>\n) => void\n\n/**\n * The @MutationAction decorator turns this into an action that further calls a mutation\n * Both the action and the mutation are generated for you\n *\n * @param paramsOrTarget the params or the target class\n * @param key the name of the function\n * @param descriptor the function body\n * @constructor\n */\nexport function MutationAction(\n paramsOrTarget: MutationActionParams | M,\n key?: string | symbol,\n descriptor?: TypedPropertyDescriptor<(...args: any[]) => Promise | undefined>>\n):\n | ((\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise | undefined>>\n ) => void)\n | void {\n if (!key && !descriptor) {\n /*\n * This is the case when `paramsOrTarget` is params.\n * i.e. when used as -\n *
\n        @MutationAction({mutate: ['incrCount']})\n        async getCountDelta() {\n          return {incrCount: 5}\n        }\n     * 
\n */\n return mutationActionDecoratorFactory(paramsOrTarget as MutationActionParams)\n } else {\n /*\n * This is the case when `paramsOrTarget` is target.\n * i.e. when used as -\n *
\n        @MutationAction\n        async getCountDelta() {\n          return {incrCount: 5}\n        }\n     * 
\n */\n mutationActionDecoratorFactory({} as MutationActionParams)(\n paramsOrTarget as K,\n key!,\n descriptor!\n )\n }\n}\n"],"names":["stateFactory","sf"],"mappings":";;;;AAAA;;;;;;SAMgB,qBAAqB,CAAC,MAAW,EAAE,MAAW;4BACnD,CAAC;QACR,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE;YAC/B,GAAG,EAAE,cAAM,OAAA,MAAM,CAAC,CAAC,CAAC,GAAA;SACrB,CAAC,CAAA;;IAHJ,KAAc,UAAyB,EAAzB,KAAA,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,EAAzB,cAAyB,EAAzB,IAAyB;QAAlC,IAAI,CAAC,SAAA;gBAAD,CAAC;KAIT;AACH,CAAC;AAED;;;;SAIgB,aAAa,CAAC,MAAW;IACvC,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,oLAEsB,CAAC,CAAA;KACxC;IACD,OAAO,+BAAwB,MAAM,CAAC,cAAc,CAAE,CAAA;AACxD;;;ICSE,oBAAY,MAAmB;QAC7B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QACjC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;QACzB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAA;QACnC,IAAI,CAAC,OA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AAqB,EACrB,UAAyF;IAQzF,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE;;;;;;;;;;;QAWvB,OAAO,8BAA8B,CAAC,cAAyC,CAAC,CAAA;KACjF;SAAM;;;;;;;;;;;QAWL,8BAA8B,CAAC,EAA6B,CAAC,CAC3D,cAAmB,EACnB,GAAI,EACJ,UAAW,CACZ,CAAA;KACF;AACH;;;;;;;;;;"} \ No newline at end of file diff --git a/dist/esm/index.js b/dist/esm/index.js index 284b8d6..04e05aa 100644 --- a/dist/esm/index.js +++ b/dist/esm/index.js @@ -165,20 +165,13 @@ function staticStateGenerator(module, modOpt, statics) { } function staticGetterGenerator(module, modOpt, statics) { Object.keys(module.getters).forEach(function (key) { - if (module.namespaced) { - Object.defineProperty(statics, key, { - get: function () { - return statics.store.getters["".concat(modOpt.name, "/").concat(key)]; - } - }); - } - else { - Object.defineProperty(statics, key, { - get: function () { - return statics.store.getters[key]; - } - }); - } + var moduleKey = module.namespaced ? "".concat(modOpt.name, "/").concat(key) : key; + Object.defineProperty(statics, key, { + configurable: !!modOpt.configurableGetters, + get: function () { + return statics.store.getters[moduleKey]; + } + }); }); } function staticMutationGenerator(module, modOpt, statics) { diff --git a/dist/esm/index.js.map b/dist/esm/index.js.map index 88cc220..58d2c40 100644 --- a/dist/esm/index.js.map +++ b/dist/esm/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","sources":["../../src/helpers.ts","../../src/vuexmodule.ts","../../src/module/stateFactory.ts","../../src/module/staticGenerators.ts","../../src/module/index.ts","../../src/config.ts","../../src/action.ts","../../src/mutation.ts","../../src/mutationaction.ts"],"sourcesContent":["/**\n * Takes the properties on object from parameter source and adds them to the object\n * parameter target\n * @param {object} target Object to have properties copied onto from y\n * @param {object} source Object with properties to be copied to x\n */\nexport function addPropertiesToObject(target: any, source: any) {\n for (let k of Object.keys(source || {})) {\n Object.defineProperty(target, k, {\n get: () => source[k]\n })\n }\n}\n\n/**\n * Returns a namespaced name of the module to be used as a store getter\n * @param module\n */\nexport function getModuleName(module: any): string {\n if (!module._vmdModuleName) {\n throw new Error(`ERR_GET_MODULE_NAME : Could not get module accessor.\n Make sure your module has name, we can't make accessors for unnamed modules\n i.e. @Module({ name: 'something' })`)\n }\n return `vuexModuleDecorators/${module._vmdModuleName}`\n}\n","import {\n ActionTree,\n GetterTree,\n Module as Mod,\n ModuleTree,\n MutationTree,\n Store,\n ActionContext\n} from 'vuex'\nimport { getModuleName } from './helpers'\n\nexport class VuexModule, R = any> implements Mod {\n /*\n * To use with `extends Class` syntax along with decorators\n */\n static namespaced?: boolean\n static state?: any | (() => any)\n static getters?: GetterTree\n static actions?: ActionTree\n static mutations?: MutationTree\n static modules?: ModuleTree\n\n /*\n * To use with `new VuexModule({})` syntax\n */\n\n modules?: ModuleTree\n namespaced?: boolean\n getters?: GetterTree\n state?: S | (() => S)\n mutations?: MutationTree\n actions?: ActionTree\n context!: ActionContext\n\n constructor(module: Mod) {\n this.actions = module.actions\n this.mutations = module.mutations\n this.state = module.state\n this.getters = module.getters\n this.namespaced = module.namespaced\n this.modules = module.modules\n }\n}\ntype ConstructorOf = { new (...args: any[]): C }\n\nexport function getModule(\n moduleClass: ConstructorOf,\n store?: Store\n): M {\n const moduleName = getModuleName(moduleClass)\n if (store && store.getters[moduleName]) {\n return store.getters[moduleName]\n } else if ((moduleClass as any)._statics) {\n return (moduleClass as any)._statics\n }\n\n const genStatic: (providedStore?: Store) => M = (moduleClass as any)._genStatic\n if (!genStatic) {\n throw new Error(`ERR_GET_MODULE_NO_STATICS : Could not get module accessor.\n Make sure your module has name, we can't make accessors for unnamed modules\n i.e. @Module({ name: 'something' })`)\n }\n\n const storeModule = genStatic(store)\n\n if (store) {\n store.getters[moduleName] = storeModule\n } else {\n ;(moduleClass as any)._statics = storeModule\n }\n\n return storeModule\n}\n","import { Module as Mod } from 'vuex'\n\nconst reservedKeys = ['actions', 'getters', 'mutations', 'modules', 'state', 'namespaced', 'commit']\nexport function stateFactory(module: Function & Mod) {\n const state = new module.prototype.constructor({})\n const s = {} as S\n Object.keys(state).forEach((key: string) => {\n if (reservedKeys.indexOf(key) !== -1) {\n if (typeof state[key] !== 'undefined') {\n throw new Error(\n `ERR_RESERVED_STATE_KEY_USED: You cannot use the following\n ['actions', 'getters', 'mutations', 'modules', 'state', 'namespaced', 'commit']\n as fields in your module. These are reserved as they have special purpose in Vuex`\n )\n }\n return\n }\n if (state.hasOwnProperty(key)) {\n if (typeof state[key] !== 'function') {\n ;(s as any)[key] = state[key]\n }\n }\n })\n\n return s\n}\n","import { ActionTree, GetterTree, Module as Mod, MutationTree } from 'vuex'\nimport { DynamicModuleOptions } from '../moduleoptions'\n\nexport function staticStateGenerator(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n const state: S = modOpt.stateFactory ? (module as any).state() : module.state\n Object.keys(state).forEach((key) => {\n if (state.hasOwnProperty(key)) {\n // If not undefined or function means it is a state value\n if (['undefined', 'function'].indexOf(typeof (state as any)[key]) === -1) {\n Object.defineProperty(statics, key, {\n get() {\n const path = modOpt.name.split('/')\n let data = statics.store.state\n for (let segment of path) {\n data = data[segment]\n }\n return data[key]\n }\n })\n }\n }\n })\n}\n\nexport function staticGetterGenerator(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n Object.keys(module.getters as GetterTree).forEach((key) => {\n if (module.namespaced) {\n Object.defineProperty(statics, key, {\n get() {\n return statics.store.getters[`${modOpt.name}/${key}`]\n }\n })\n } else {\n Object.defineProperty(statics, key, {\n get() {\n return statics.store.getters[key]\n }\n })\n }\n })\n}\n\nexport function staticMutationGenerator(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n Object.keys(module.mutations as MutationTree).forEach((key) => {\n if (module.namespaced) {\n statics[key] = function (...args: any[]) {\n statics.store.commit(`${modOpt.name}/${key}`, ...args)\n }\n } else {\n statics[key] = function (...args: any[]) {\n statics.store.commit(key, ...args)\n }\n }\n })\n}\n\nexport function staticActionGenerators(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n Object.keys(module.actions as ActionTree).forEach((key) => {\n if (module.namespaced) {\n statics[key] = async function (...args: any[]) {\n return statics.store.dispatch(`${modOpt.name}/${key}`, ...args)\n }\n } else {\n statics[key] = async function (...args: any[]) {\n return statics.store.dispatch(key, ...args)\n }\n }\n })\n}\n","import { GetterTree, Module as Mod, Store } from 'vuex'\nimport { DynamicModuleOptions, ModuleOptions } from '../moduleoptions'\nimport { stateFactory as sf } from './stateFactory'\nimport { addPropertiesToObject } from '../helpers'\nimport {\n staticActionGenerators,\n staticGetterGenerator,\n staticMutationGenerator,\n staticStateGenerator\n} from './staticGenerators'\n\nfunction registerDynamicModule(module: Mod, modOpt: DynamicModuleOptions) {\n if (!modOpt.name) {\n throw new Error('Name of module not provided in decorator options')\n }\n\n if (!modOpt.store) {\n throw new Error('Store not provided in decorator options when using dynamic option')\n }\n\n modOpt.store.registerModule(\n modOpt.name, // TODO: Handle nested modules too in future\n module,\n { preserveState: modOpt.preserveState || false }\n )\n}\n\nfunction addGettersToModule(\n targetModule: Function & Mod,\n srcModule: Function & Mod\n) {\n Object.getOwnPropertyNames(srcModule.prototype).forEach((funcName: string) => {\n const descriptor = Object.getOwnPropertyDescriptor(\n srcModule.prototype,\n funcName\n ) as PropertyDescriptor\n if (descriptor.get && targetModule.getters) {\n targetModule.getters[funcName] = function (\n state: S,\n getters: GetterTree,\n rootState: any,\n rootGetters: GetterTree\n ) {\n const thisObj = { context: { state, getters, rootState, rootGetters } }\n addPropertiesToObject(thisObj, state)\n addPropertiesToObject(thisObj, getters)\n const got = (descriptor.get as Function).call(thisObj)\n return got\n }\n }\n })\n}\n\nfunction moduleDecoratorFactory(moduleOptions: ModuleOptions) {\n return function (constructor: TFunction): TFunction | void {\n const module: Function & Mod = constructor\n const stateFactory = () => sf(module)\n\n if (!module.state) {\n module.state = moduleOptions && moduleOptions.stateFactory ? stateFactory : stateFactory()\n }\n if (!module.getters) {\n module.getters = {} as GetterTree\n }\n if (!module.namespaced) {\n module.namespaced = moduleOptions && moduleOptions.namespaced\n }\n let parentModule = Object.getPrototypeOf(module)\n while (parentModule.name !== 'VuexModule' && parentModule.name !== '') {\n addGettersToModule(module, parentModule)\n parentModule = Object.getPrototypeOf(parentModule)\n }\n addGettersToModule(module, module)\n const modOpt = moduleOptions as DynamicModuleOptions\n if (modOpt.name) {\n Object.defineProperty(constructor, '_genStatic', {\n value: (store?: Store) => {\n let statics = { store: store || modOpt.store }\n if (!statics.store) {\n throw new Error(`ERR_STORE_NOT_PROVIDED: To use getModule(), either the module\n should be decorated with store in decorator, i.e. @Module({store: store}) or\n store should be passed when calling getModule(), i.e. getModule(MyModule, this.$store)`)\n }\n // =========== For statics ==============\n // ------ state -------\n staticStateGenerator(module, modOpt, statics)\n\n // ------- getters -------\n if (module.getters) {\n staticGetterGenerator(module, modOpt, statics)\n }\n\n // -------- mutations --------\n if (module.mutations) {\n staticMutationGenerator(module, modOpt, statics)\n }\n // -------- actions ---------\n if (module.actions) {\n staticActionGenerators(module, modOpt, statics)\n }\n return statics\n }\n })\n\n Object.defineProperty(constructor, '_vmdModuleName', {\n value: modOpt.name\n })\n }\n\n if (modOpt.dynamic) {\n registerDynamicModule(module, modOpt)\n }\n return constructor\n }\n}\n\nexport function Module(module: Function & Mod): void\nexport function Module(options: ModuleOptions): ClassDecorator\n\nexport function Module(modOrOpt: ModuleOptions | (Function & Mod)) {\n if (typeof (modOrOpt as any) === 'function') {\n /*\n * @Module decorator called without options (directly on the class definition)\n */\n moduleDecoratorFactory({})(modOrOpt as Function & Mod)\n } else {\n /*\n * @Module({...}) decorator called with options\n */\n return moduleDecoratorFactory(modOrOpt)\n }\n}\n","export const config: IConfig = {}\n\nexport interface IConfig {\n rawError?: boolean\n}\n","import { Action as Act, ActionContext, Module as Mod, Payload } from 'vuex'\nimport { getModule, VuexModule } from './vuexmodule'\nimport { addPropertiesToObject, getModuleName } from './helpers'\nimport { config } from './config'\n\n/**\n * Parameters that can be passed to the @Action decorator\n */\nexport interface ActionDecoratorParams {\n commit?: string\n rawError?: boolean\n root?: boolean\n}\nfunction actionDecoratorFactory(params?: ActionDecoratorParams): MethodDecorator {\n const { commit = undefined, rawError = !!config.rawError, root = false } = params || {}\n return function (target: Object, key: string | symbol, descriptor: TypedPropertyDescriptor) {\n const module = target.constructor as Mod\n if (!module.hasOwnProperty('actions')) {\n module.actions = Object.assign({}, module.actions)\n }\n const actionFunction: Function = descriptor.value\n const action: Act = async function (\n context: ActionContext,\n payload: Payload\n ) {\n try {\n let actionPayload = null\n\n if ((module as any)._genStatic) {\n const moduleName = getModuleName(module)\n const moduleAccessor = context.rootGetters[moduleName]\n ? context.rootGetters[moduleName]\n : getModule(module as typeof VuexModule)\n moduleAccessor.context = context\n actionPayload = await actionFunction.call(moduleAccessor, payload)\n } else {\n const thisObj = { context }\n addPropertiesToObject(thisObj, context.state)\n addPropertiesToObject(thisObj, context.getters)\n actionPayload = await actionFunction.call(thisObj, payload)\n }\n if (commit) {\n context.commit(commit, actionPayload)\n }\n return actionPayload\n } catch (e: any) {\n throw rawError\n ? e\n : new Error(\n 'ERR_ACTION_ACCESS_UNDEFINED: Are you trying to access ' +\n 'this.someMutation() or this.someGetter inside an @Action? \\n' +\n 'That works only in dynamic modules. \\n' +\n 'If not dynamic use this.context.commit(\"mutationName\", payload) ' +\n 'and this.context.getters[\"getterName\"]' +\n '\\n' +\n new Error(`Could not perform action ${key.toString()}`).stack +\n '\\n' +\n e.stack\n )\n }\n }\n module.actions![key as string] = root ? { root, handler: action } : action\n }\n}\n\nexport function Action(\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => R>\n): void\nexport function Action(params: ActionDecoratorParams): MethodDecorator\n\n/**\n * The @Action decorator turns an async function into an Vuex action\n *\n * @param targetOrParams the module class\n * @param key name of the action\n * @param descriptor the action function descriptor\n * @constructor\n */\nexport function Action(\n targetOrParams: T | ActionDecoratorParams,\n key?: string | symbol,\n descriptor?: TypedPropertyDescriptor<(...args: any[]) => R>\n) {\n if (!key && !descriptor) {\n /*\n * This is the case when `targetOrParams` is params.\n * i.e. when used as -\n *
\n        @Action({commit: 'incrCount'})\n        async getCountDelta() {\n          return 5\n        }\n     * 
\n */\n return actionDecoratorFactory(targetOrParams as ActionDecoratorParams)\n } else {\n /*\n * This is the case when @Action is called on action function\n * without any params\n *
\n     *   @Action\n     *   async doSomething() {\n     *    ...\n     *   }\n     * 
\n */\n actionDecoratorFactory()(targetOrParams, key!, descriptor!)\n }\n}\n","import { Module as Mod, Mutation as Mut, Payload } from 'vuex'\n\nexport function Mutation(\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => R>\n) {\n const module = target.constructor as Mod\n if (!module.hasOwnProperty('mutations')) {\n module.mutations = Object.assign({}, module.mutations)\n }\n const mutationFunction: Function = descriptor.value!\n const mutation: Mut = function (state: typeof target, payload: Payload) {\n mutationFunction.call(state, payload)\n }\n module.mutations![key as string] = mutation\n}\n","import { Action as Act, ActionContext, Module as Mod, Mutation as Mut, Payload, Store } from 'vuex'\nimport { addPropertiesToObject } from './helpers'\n\nexport interface MutationActionParams {\n mutate?: (keyof Partial)[]\n rawError?: boolean\n root?: boolean\n}\n\nfunction mutationActionDecoratorFactory(params: MutationActionParams) {\n return function (\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise | undefined>>\n ) {\n const module = target.constructor as Mod\n if (!module.hasOwnProperty('mutations')) {\n module.mutations = Object.assign({}, module.mutations)\n }\n if (!module.hasOwnProperty('actions')) {\n module.actions = Object.assign({}, module.actions)\n }\n const mutactFunction = descriptor.value as (payload: any) => Promise\n\n const action: Act = async function (\n context: ActionContext,\n payload: Payload\n ) {\n try {\n const thisObj = { context }\n addPropertiesToObject(thisObj, context.state)\n addPropertiesToObject(thisObj, context.getters)\n const actionPayload = await mutactFunction.call(thisObj, payload)\n if (actionPayload === undefined) return\n context.commit(key as string, actionPayload)\n } catch (e: any) {\n if (params.rawError) {\n throw e\n } else {\n console.error('Could not perform action ' + key.toString())\n console.error(e)\n return Promise.reject(e)\n }\n }\n }\n\n const mutation: Mut = function (\n state: typeof target | Store,\n payload: Payload & { [k in keyof T]: any }\n ) {\n if (!params.mutate) {\n params.mutate = Object.keys(payload) as (keyof T)[]\n }\n for (let stateItem of params.mutate) {\n if (state.hasOwnProperty(stateItem) && payload.hasOwnProperty(stateItem)) {\n ;(state as T)[stateItem] = payload[stateItem]\n } else {\n throw new Error(`ERR_MUTATE_PARAMS_NOT_IN_PAYLOAD\n In @MutationAction, mutate: ['a', 'b', ...] array keys must\n match with return type = {a: {}, b: {}, ...} and must\n also be in state.`)\n }\n }\n }\n module.actions![key as string] = params.root ? { root: true, handler: action } : action\n module.mutations![key as string] = mutation\n }\n}\n\nexport function MutationAction(\n target: { [k in keyof T]: T[k] | null },\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise>\n): void\n\nexport function MutationAction(\n params: MutationActionParams\n): (\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise>\n) => void\n\n/**\n * The @MutationAction decorator turns this into an action that further calls a mutation\n * Both the action and the mutation are generated for you\n *\n * @param paramsOrTarget the params or the target class\n * @param key the name of the function\n * @param descriptor the function body\n * @constructor\n */\nexport function MutationAction(\n paramsOrTarget: MutationActionParams | M,\n key?: string | symbol,\n descriptor?: TypedPropertyDescriptor<(...args: any[]) => Promise | undefined>>\n):\n | ((\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise | undefined>>\n ) => void)\n | void {\n if (!key && !descriptor) {\n /*\n * This is the case when `paramsOrTarget` is params.\n * i.e. when used as -\n *
\n        @MutationAction({mutate: ['incrCount']})\n        async getCountDelta() {\n          return {incrCount: 5}\n        }\n     * 
\n */\n return mutationActionDecoratorFactory(paramsOrTarget as MutationActionParams)\n } else {\n /*\n * This is the case when `paramsOrTarget` is target.\n * i.e. when used as -\n *
\n        @MutationAction\n        async getCountDelta() {\n          return {incrCount: 5}\n        }\n     * 
\n */\n mutationActionDecoratorFactory({} as MutationActionParams)(\n paramsOrTarget as K,\n key!,\n descriptor!\n )\n }\n}\n"],"names":["stateFactory","sf"],"mappings":"AAAA;;;;;;SAMgB,qBAAqB,CAAC,MAAW,EAAE,MAAW;4BACnD,CAAC;QACR,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE;YAC/B,GAAG,EAAE,cAAM,OAAA,MAAM,CAAC,CAAC,CAAC,GAAA;SACrB,CAAC,CAAA;;IAHJ,KAAc,UAAyB,EAAzB,KAAA,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,EAAzB,cAAyB,EAAzB,IAAyB;QAAlC,IAAI,CAAC,SAAA;gBAAD,CAAC;KAIT;AACH,CAAC;AAED;;;;SAIgB,aAAa,CAAC,MAAW;IACvC,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,oLAEsB,CAAC,CAAA;KACxC;IACD,OAAO,+BAAwB,MAAM,CAAC,cAAc,CAAE,CAAA;AACxD;;;ICSE,oBAAY,MAAmB;QAC7B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,SAAS,GAAG,MAAM,CAAC,SAAS,CAAA;QACjC,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAA;QACzB,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;QAC7B,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC,UAAU,CAAA;QACnC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAA;KAC9B;IACH,iBAAC;AAAD,CAAC,IAAA;SAGe,SAAS,CACvB,WAA6B,EAC7B,KAAkB;IAElB,IAAM,UAAU,GAAG,aAAa,CAAC,WAAW,CAAC,CAAA;IAC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AWvB,OAAO,8BAA8B,CAAC,cAAyC,CAAC,CAAA;KACjF;SAAM;;;;;;;;;;;QAWL,8BAA8B,CAAC,EAA6B,CAAC,CAC3D,cAAmB,EACnB,GAAI,EACJ,UAAW,CACZ,CAAA;KACF;AACH;;;;"} \ No newline at end of file +{"version":3,"file":"index.js","sources":["../../src/helpers.ts","../../src/vuexmodule.ts","../../src/module/stateFactory.ts","../../src/module/staticGenerators.ts","../../src/module/index.ts","../../src/config.ts","../../src/action.ts","../../src/mutation.ts","../../src/mutationaction.ts"],"sourcesContent":["/**\n * Takes the properties on object from parameter source and adds them to the object\n * parameter target\n * @param {object} target Object to have properties copied onto from y\n * @param {object} source Object with properties to be copied to x\n */\nexport function addPropertiesToObject(target: any, source: any) {\n for (let k of Object.keys(source || {})) {\n Object.defineProperty(target, k, {\n get: () => source[k]\n })\n }\n}\n\n/**\n * Returns a namespaced name of the module to be used as a store getter\n * @param module\n */\nexport function getModuleName(module: any): string {\n if (!module._vmdModuleName) {\n throw new Error(`ERR_GET_MODULE_NAME : Could not get module accessor.\n Make sure your module has name, we can't make accessors for unnamed modules\n i.e. @Module({ name: 'something' })`)\n }\n return `vuexModuleDecorators/${module._vmdModuleName}`\n}\n","import {\n ActionTree,\n GetterTree,\n Module as Mod,\n ModuleTree,\n MutationTree,\n Store,\n ActionContext\n} from 'vuex'\nimport { getModuleName } from './helpers'\n\nexport class VuexModule, R = any> implements Mod {\n /*\n * To use with `extends Class` syntax along with decorators\n */\n static namespaced?: boolean\n static state?: any | (() => any)\n static getters?: GetterTree\n static actions?: ActionTree\n static mutations?: MutationTree\n static modules?: ModuleTree\n\n /*\n * To use with `new VuexModule({})` syntax\n */\n\n modules?: ModuleTree\n namespaced?: boolean\n getters?: GetterTree\n state?: S | (() => S)\n mutations?: MutationTree\n actions?: ActionTree\n context!: ActionContext\n\n constructor(module: Mod) {\n this.actions = module.actions\n this.mutations = module.mutations\n this.state = module.state\n this.getters = module.getters\n this.namespaced = module.namespaced\n this.modules = module.modules\n }\n}\ntype ConstructorOf = { new (...args: any[]): C }\n\nexport function getModule(\n moduleClass: ConstructorOf,\n store?: Store\n): M {\n const moduleName = getModuleName(moduleClass)\n if (store && store.getters[moduleName]) {\n return store.getters[moduleName]\n } else if ((moduleClass as any)._statics) {\n return (moduleClass as any)._statics\n }\n\n const genStatic: (providedStore?: Store) => M = (moduleClass as any)._genStatic\n if (!genStatic) {\n throw new Error(`ERR_GET_MODULE_NO_STATICS : Could not get module accessor.\n Make sure your module has name, we can't make accessors for unnamed modules\n i.e. @Module({ name: 'something' })`)\n }\n\n const storeModule = genStatic(store)\n\n if (store) {\n store.getters[moduleName] = storeModule\n } else {\n ;(moduleClass as any)._statics = storeModule\n }\n\n return storeModule\n}\n","import { Module as Mod } from 'vuex'\n\nconst reservedKeys = ['actions', 'getters', 'mutations', 'modules', 'state', 'namespaced', 'commit']\nexport function stateFactory(module: Function & Mod) {\n const state = new module.prototype.constructor({})\n const s = {} as S\n Object.keys(state).forEach((key: string) => {\n if (reservedKeys.indexOf(key) !== -1) {\n if (typeof state[key] !== 'undefined') {\n throw new Error(\n `ERR_RESERVED_STATE_KEY_USED: You cannot use the following\n ['actions', 'getters', 'mutations', 'modules', 'state', 'namespaced', 'commit']\n as fields in your module. These are reserved as they have special purpose in Vuex`\n )\n }\n return\n }\n if (state.hasOwnProperty(key)) {\n if (typeof state[key] !== 'function') {\n ;(s as any)[key] = state[key]\n }\n }\n })\n\n return s\n}\n","import { ActionTree, GetterTree, Module as Mod, MutationTree } from 'vuex'\nimport { DynamicModuleOptions } from '../moduleoptions'\n\nexport function staticStateGenerator(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n const state: S = modOpt.stateFactory ? (module as any).state() : module.state\n Object.keys(state).forEach((key) => {\n if (state.hasOwnProperty(key)) {\n // If not undefined or function means it is a state value\n if (['undefined', 'function'].indexOf(typeof (state as any)[key]) === -1) {\n Object.defineProperty(statics, key, {\n get() {\n const path = modOpt.name.split('/')\n let data = statics.store.state\n for (let segment of path) {\n data = data[segment]\n }\n return data[key]\n }\n })\n }\n }\n })\n}\n\nexport function staticGetterGenerator(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n Object.keys(module.getters as GetterTree).forEach((key) => {\n const moduleKey = module.namespaced ? `${modOpt.name}/${key}` : key\n Object.defineProperty(statics, key, {\n configurable: !!modOpt.configurableGetters,\n get() {\n return statics.store.getters[moduleKey]\n }\n })\n })\n}\n\nexport function staticMutationGenerator(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n Object.keys(module.mutations as MutationTree).forEach((key) => {\n if (module.namespaced) {\n statics[key] = function (...args: any[]) {\n statics.store.commit(`${modOpt.name}/${key}`, ...args)\n }\n } else {\n statics[key] = function (...args: any[]) {\n statics.store.commit(key, ...args)\n }\n }\n })\n}\n\nexport function staticActionGenerators(\n module: Function & Mod,\n modOpt: DynamicModuleOptions,\n statics: any\n) {\n Object.keys(module.actions as ActionTree).forEach((key) => {\n if (module.namespaced) {\n statics[key] = async function (...args: any[]) {\n return statics.store.dispatch(`${modOpt.name}/${key}`, ...args)\n }\n } else {\n statics[key] = async function (...args: any[]) {\n return statics.store.dispatch(key, ...args)\n }\n }\n })\n}\n","import { GetterTree, Module as Mod, Store } from 'vuex'\nimport { DynamicModuleOptions, ModuleOptions } from '../moduleoptions'\nimport { stateFactory as sf } from './stateFactory'\nimport { addPropertiesToObject } from '../helpers'\nimport {\n staticActionGenerators,\n staticGetterGenerator,\n staticMutationGenerator,\n staticStateGenerator\n} from './staticGenerators'\n\nfunction registerDynamicModule(module: Mod, modOpt: DynamicModuleOptions) {\n if (!modOpt.name) {\n throw new Error('Name of module not provided in decorator options')\n }\n\n if (!modOpt.store) {\n throw new Error('Store not provided in decorator options when using dynamic option')\n }\n\n modOpt.store.registerModule(\n modOpt.name, // TODO: Handle nested modules too in future\n module,\n { preserveState: modOpt.preserveState || false }\n )\n}\n\nfunction addGettersToModule(\n targetModule: Function & Mod,\n srcModule: Function & Mod\n) {\n Object.getOwnPropertyNames(srcModule.prototype).forEach((funcName: string) => {\n const descriptor = Object.getOwnPropertyDescriptor(\n srcModule.prototype,\n funcName\n ) as PropertyDescriptor\n if (descriptor.get && targetModule.getters) {\n targetModule.getters[funcName] = function (\n state: S,\n getters: GetterTree,\n rootState: any,\n rootGetters: GetterTree\n ) {\n const thisObj = { context: { state, getters, rootState, rootGetters } }\n addPropertiesToObject(thisObj, state)\n addPropertiesToObject(thisObj, getters)\n const got = (descriptor.get as Function).call(thisObj)\n return got\n }\n }\n })\n}\n\nfunction moduleDecoratorFactory(moduleOptions: ModuleOptions) {\n return function (constructor: TFunction): TFunction | void {\n const module: Function & Mod = constructor\n const stateFactory = () => sf(module)\n\n if (!module.state) {\n module.state = moduleOptions && moduleOptions.stateFactory ? stateFactory : stateFactory()\n }\n if (!module.getters) {\n module.getters = {} as GetterTree\n }\n if (!module.namespaced) {\n module.namespaced = moduleOptions && moduleOptions.namespaced\n }\n let parentModule = Object.getPrototypeOf(module)\n while (parentModule.name !== 'VuexModule' && parentModule.name !== '') {\n addGettersToModule(module, parentModule)\n parentModule = Object.getPrototypeOf(parentModule)\n }\n addGettersToModule(module, module)\n const modOpt = moduleOptions as DynamicModuleOptions\n if (modOpt.name) {\n Object.defineProperty(constructor, '_genStatic', {\n value: (store?: Store) => {\n let statics = { store: store || modOpt.store }\n if (!statics.store) {\n throw new Error(`ERR_STORE_NOT_PROVIDED: To use getModule(), either the module\n should be decorated with store in decorator, i.e. @Module({store: store}) or\n store should be passed when calling getModule(), i.e. getModule(MyModule, this.$store)`)\n }\n // =========== For statics ==============\n // ------ state -------\n staticStateGenerator(module, modOpt, statics)\n\n // ------- getters -------\n if (module.getters) {\n staticGetterGenerator(module, modOpt, statics)\n }\n\n // -------- mutations --------\n if (module.mutations) {\n staticMutationGenerator(module, modOpt, statics)\n }\n // -------- actions ---------\n if (module.actions) {\n staticActionGenerators(module, modOpt, statics)\n }\n return statics\n }\n })\n\n Object.defineProperty(constructor, '_vmdModuleName', {\n value: modOpt.name\n })\n }\n\n if (modOpt.dynamic) {\n registerDynamicModule(module, modOpt)\n }\n return constructor\n }\n}\n\nexport function Module(module: Function & Mod): void\nexport function Module(options: ModuleOptions): ClassDecorator\n\nexport function Module(modOrOpt: ModuleOptions | (Function & Mod)) {\n if (typeof (modOrOpt as any) === 'function') {\n /*\n * @Module decorator called without options (directly on the class definition)\n */\n moduleDecoratorFactory({})(modOrOpt as Function & Mod)\n } else {\n /*\n * @Module({...}) decorator called with options\n */\n return moduleDecoratorFactory(modOrOpt)\n }\n}\n","export const config: IConfig = {}\n\nexport interface IConfig {\n rawError?: boolean\n}\n","import { Action as Act, ActionContext, Module as Mod, Payload } from 'vuex'\nimport { getModule, VuexModule } from './vuexmodule'\nimport { addPropertiesToObject, getModuleName } from './helpers'\nimport { config } from './config'\n\n/**\n * Parameters that can be passed to the @Action decorator\n */\nexport interface ActionDecoratorParams {\n commit?: string\n rawError?: boolean\n root?: boolean\n}\nfunction actionDecoratorFactory(params?: ActionDecoratorParams): MethodDecorator {\n const { commit = undefined, rawError = !!config.rawError, root = false } = params || {}\n return function (target: Object, key: string | symbol, descriptor: TypedPropertyDescriptor) {\n const module = target.constructor as Mod\n if (!module.hasOwnProperty('actions')) {\n module.actions = Object.assign({}, module.actions)\n }\n const actionFunction: Function = descriptor.value\n const action: Act = async function (\n context: ActionContext,\n payload: Payload\n ) {\n try {\n let actionPayload = null\n\n if ((module as any)._genStatic) {\n const moduleName = getModuleName(module)\n const moduleAccessor = context.rootGetters[moduleName]\n ? context.rootGetters[moduleName]\n : getModule(module as typeof VuexModule)\n moduleAccessor.context = context\n actionPayload = await actionFunction.call(moduleAccessor, payload)\n } else {\n const thisObj = { context }\n addPropertiesToObject(thisObj, context.state)\n addPropertiesToObject(thisObj, context.getters)\n actionPayload = await actionFunction.call(thisObj, payload)\n }\n if (commit) {\n context.commit(commit, actionPayload)\n }\n return actionPayload\n } catch (e: any) {\n throw rawError\n ? e\n : new Error(\n 'ERR_ACTION_ACCESS_UNDEFINED: Are you trying to access ' +\n 'this.someMutation() or this.someGetter inside an @Action? \\n' +\n 'That works only in dynamic modules. \\n' +\n 'If not dynamic use this.context.commit(\"mutationName\", payload) ' +\n 'and this.context.getters[\"getterName\"]' +\n '\\n' +\n new Error(`Could not perform action ${key.toString()}`).stack +\n '\\n' +\n e.stack\n )\n }\n }\n module.actions![key as string] = root ? { root, handler: action } : action\n }\n}\n\nexport function Action(\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => R>\n): void\nexport function Action(params: ActionDecoratorParams): MethodDecorator\n\n/**\n * The @Action decorator turns an async function into an Vuex action\n *\n * @param targetOrParams the module class\n * @param key name of the action\n * @param descriptor the action function descriptor\n * @constructor\n */\nexport function Action(\n targetOrParams: T | ActionDecoratorParams,\n key?: string | symbol,\n descriptor?: TypedPropertyDescriptor<(...args: any[]) => R>\n) {\n if (!key && !descriptor) {\n /*\n * This is the case when `targetOrParams` is params.\n * i.e. when used as -\n *
\n        @Action({commit: 'incrCount'})\n        async getCountDelta() {\n          return 5\n        }\n     * 
\n */\n return actionDecoratorFactory(targetOrParams as ActionDecoratorParams)\n } else {\n /*\n * This is the case when @Action is called on action function\n * without any params\n *
\n     *   @Action\n     *   async doSomething() {\n     *    ...\n     *   }\n     * 
\n */\n actionDecoratorFactory()(targetOrParams, key!, descriptor!)\n }\n}\n","import { Module as Mod, Mutation as Mut, Payload } from 'vuex'\n\nexport function Mutation(\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => R>\n) {\n const module = target.constructor as Mod\n if (!module.hasOwnProperty('mutations')) {\n module.mutations = Object.assign({}, module.mutations)\n }\n const mutationFunction: Function = descriptor.value!\n const mutation: Mut = function (state: typeof target, payload: Payload) {\n mutationFunction.call(state, payload)\n }\n module.mutations![key as string] = mutation\n}\n","import { Action as Act, ActionContext, Module as Mod, Mutation as Mut, Payload, Store } from 'vuex'\nimport { addPropertiesToObject } from './helpers'\n\nexport interface MutationActionParams {\n mutate?: (keyof Partial)[]\n rawError?: boolean\n root?: boolean\n}\n\nfunction mutationActionDecoratorFactory(params: MutationActionParams) {\n return function (\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise | undefined>>\n ) {\n const module = target.constructor as Mod\n if (!module.hasOwnProperty('mutations')) {\n module.mutations = Object.assign({}, module.mutations)\n }\n if (!module.hasOwnProperty('actions')) {\n module.actions = Object.assign({}, module.actions)\n }\n const mutactFunction = descriptor.value as (payload: any) => Promise\n\n const action: Act = async function (\n context: ActionContext,\n payload: Payload\n ) {\n try {\n const thisObj = { context }\n addPropertiesToObject(thisObj, context.state)\n addPropertiesToObject(thisObj, context.getters)\n const actionPayload = await mutactFunction.call(thisObj, payload)\n if (actionPayload === undefined) return\n context.commit(key as string, actionPayload)\n } catch (e: any) {\n if (params.rawError) {\n throw e\n } else {\n console.error('Could not perform action ' + key.toString())\n console.error(e)\n return Promise.reject(e)\n }\n }\n }\n\n const mutation: Mut = function (\n state: typeof target | Store,\n payload: Payload & { [k in keyof T]: any }\n ) {\n if (!params.mutate) {\n params.mutate = Object.keys(payload) as (keyof T)[]\n }\n for (let stateItem of params.mutate) {\n if (state.hasOwnProperty(stateItem) && payload.hasOwnProperty(stateItem)) {\n ;(state as T)[stateItem] = payload[stateItem]\n } else {\n throw new Error(`ERR_MUTATE_PARAMS_NOT_IN_PAYLOAD\n In @MutationAction, mutate: ['a', 'b', ...] array keys must\n match with return type = {a: {}, b: {}, ...} and must\n also be in state.`)\n }\n }\n }\n module.actions![key as string] = params.root ? { root: true, handler: action } : action\n module.mutations![key as string] = mutation\n }\n}\n\nexport function MutationAction(\n target: { [k in keyof T]: T[k] | null },\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise>\n): void\n\nexport function MutationAction(\n params: MutationActionParams\n): (\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise>\n) => void\n\n/**\n * The @MutationAction decorator turns this into an action that further calls a mutation\n * Both the action and the mutation are generated for you\n *\n * @param paramsOrTarget the params or the target class\n * @param key the name of the function\n * @param descriptor the function body\n * @constructor\n */\nexport function MutationAction(\n paramsOrTarget: MutationActionParams | M,\n key?: string | symbol,\n descriptor?: TypedPropertyDescriptor<(...args: any[]) => Promise | undefined>>\n):\n | ((\n target: T,\n key: string | symbol,\n descriptor: TypedPropertyDescriptor<(...args: any[]) => Promise | undefined>>\n ) => void)\n | void {\n if (!key && !descriptor) {\n /*\n * This is the case when `paramsOrTarget` is params.\n * i.e. when used as -\n *
\n        @MutationAction({mutate: ['incrCount']})\n        async getCountDelta() {\n          return {incrCount: 5}\n        }\n     * 
\n */\n return mutationActionDecoratorFactory(paramsOrTarget as MutationActionParams)\n } else {\n /*\n * This is the case when `paramsOrTarget` is target.\n * i.e. when used as -\n *
\n        @MutationAction\n        async getCountDelta() {\n          return {incrCount: 5}\n        }\n     * 
\n */\n mutationActionDecoratorFactory({} as MutationActionParams)(\n paramsOrTarget as K,\n key!,\n descriptor!\n )\n }\n}\n"],"names":["stateFactory","sf"],"mappings":"AAAA;;;;;;SAMgB,qBAAqB,CAAC,MAAW,EAAE,MAAW;4BACnD,CAAC;QACR,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,CAAC,EAAE;YAC/B,GAAG,EAAE,cAAM,OAAA,MAAM,CAAC,CAAC,CAAC,GAAA;SACrB,CAAC,CAAA;;IAHJ,KAAc,UAAyB,EAAzB,KAAA,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC,EAAzB,cAAyB,EAAzB,IAAyB;QAAlC,IAAI,CAAC,SAAA;gBAAD,CAAC;KAIT;AACH,CAAC;AAED;;;;SAIgB,aAAa,CAAC,MAAW;IACvC,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE;QAC1B,MAAM,IAAI,KAAK,CAAC,oLAEsB,CAAC,CAAA;KACxC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AAA;iBAC9C;qBAAM;oBACL,MAAM,IAAI,KAAK,CAAC,uMAGE,CAAC,CAAA;iBACpB;aACF;SACF,CAAA;QACD,MAAM,CAAC,OAAQ,CAAC,GAAa,CAAC,GAAG,MAAM,CAAC,IAAI,GAAG,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,CAAA;QACvF,MAAM,CAAC,SAAU,CAAC,GAAa,CAAC,GAAG,QAAQ,CAAA;KAC5C,CAAA;AACH,CAAC;AAgBD;;;;;;;;;SASgB,cAAc,CAC5B,cAA2C,EAC3C,GAAqB,EACrB,UAAyF;IAQzF,IAAI,CAAC,GAAG,IAAI,CAAC,UAAU,EAAE;;;;;;;;;;;QAWvB,OAAO,8BAA8B,CAAC,cAAyC,CAAC,CAAA;KACjF;SAAM;;;;;;;;;;;QAWL,8BAA8B,CAAC,EAA6B,CAAC,CAC3D,cAAmB,EACnB,GAAI,EACJ,UAAW,CACZ,CAAA;KACF;AACH;;;;"} \ No newline at end of file diff --git a/dist/types/moduleoptions.d.ts b/dist/types/moduleoptions.d.ts index eddd249..7c53e85 100644 --- a/dist/types/moduleoptions.d.ts +++ b/dist/types/moduleoptions.d.ts @@ -15,6 +15,10 @@ export interface StaticModuleOptions { * Whether to generate a plain state object, or a state factory for the module */ stateFactory?: boolean; + /** + * Allow getters to have their property definitions redefined. Useful for stubbing in tests. + */ + configurableGetters?: boolean; } export interface DynamicModuleOptions { /** @@ -41,5 +45,9 @@ export interface DynamicModuleOptions { * Whether to generate a plain state object, or a state factory for the module */ stateFactory?: boolean; + /** + * Allow getters to have their property definitions redefined. Useful for stubbing in tests. + */ + configurableGetters?: boolean; } export declare type ModuleOptions = StaticModuleOptions | DynamicModuleOptions; diff --git a/src/module/staticGenerators.ts b/src/module/staticGenerators.ts index a86c15c..e06d2f2 100644 --- a/src/module/staticGenerators.ts +++ b/src/module/staticGenerators.ts @@ -32,19 +32,13 @@ export function staticGetterGenerator( statics: any ) { Object.keys(module.getters as GetterTree).forEach((key) => { - if (module.namespaced) { - Object.defineProperty(statics, key, { - get() { - return statics.store.getters[`${modOpt.name}/${key}`] - } - }) - } else { - Object.defineProperty(statics, key, { - get() { - return statics.store.getters[key] - } - }) - } + const moduleKey = module.namespaced ? `${modOpt.name}/${key}` : key + Object.defineProperty(statics, key, { + configurable: !!modOpt.configurableGetters, + get() { + return statics.store.getters[moduleKey] + } + }) }) } diff --git a/src/moduleoptions.ts b/src/moduleoptions.ts index c06d3ca..a1b8455 100644 --- a/src/moduleoptions.ts +++ b/src/moduleoptions.ts @@ -15,6 +15,10 @@ export interface StaticModuleOptions { * Whether to generate a plain state object, or a state factory for the module */ stateFactory?: boolean + /** + * Allow getters to have their property definitions redefined. Useful for stubbing in tests. + */ + configurableGetters?: boolean } export interface DynamicModuleOptions { @@ -47,6 +51,11 @@ export interface DynamicModuleOptions { * Whether to generate a plain state object, or a state factory for the module */ stateFactory?: boolean + + /** + * Allow getters to have their property definitions redefined. Useful for stubbing in tests. + */ + configurableGetters?: boolean } export type ModuleOptions = StaticModuleOptions | DynamicModuleOptions diff --git a/test/getmodule/getmodule_getter.ts b/test/getmodule/getmodule_getter.ts index 49bf6b0..bc6f4ee 100644 --- a/test/getmodule/getmodule_getter.ts +++ b/test/getmodule/getmodule_getter.ts @@ -34,4 +34,10 @@ describe('using getters on getModule()', () => { expect(getModule(MyNamespacedModule).value).to.equal(10) expect(getModule(MyNamespacedModule).twofold).to.equal(20) }) + + it('cannot reconfigure the getters', function () { + expect(() => { + Object.defineProperty(getModule(MyModule), 'twofold', {value: 'foo'}) + }).to.throw(TypeError, 'Cannot redefine property') + }) }) diff --git a/test/getmodule/getmodule_getter_configurable.ts b/test/getmodule/getmodule_getter_configurable.ts new file mode 100644 index 0000000..6a3a749 --- /dev/null +++ b/test/getmodule/getmodule_getter_configurable.ts @@ -0,0 +1,49 @@ +import Vuex from 'vuex' +import Vue from 'vue' +Vue.use(Vuex) +import { getModule, Module, VuexModule } from '../..' +import { expect } from 'chai' + +const store = new Vuex.Store({}) + +@Module({ name: 'mm', store, dynamic: true, configurableGetters: true }) +class DynamicModule extends VuexModule { + public value = 10 + + public get twofold(): number { + return this.value * 2 + } +} + +@Module({name: 'mm', store, configurableGetters: true}) +class StaticModule extends VuexModule { + public value = 10 + + public get twofold(): number { + return this.value * 2 + } +} + +describe('using getters on dynamic getModule()', () => { + it('getter should return adjusted value', function() { + expect(getModule(DynamicModule).value).to.equal(10) + expect(getModule(DynamicModule).twofold).to.equal(20) + }) + + it('can reconfigure the getters', function () { + Object.defineProperty(getModule(DynamicModule), 'twofold', {value: 'foo'}) + expect(getModule(DynamicModule).twofold).to.equal('foo'); + }) +}) + +describe('using getters on static getModule()', () => { + it('getter should return adjusted value', function () { + expect(getModule(StaticModule).value).to.equal(10) + expect(getModule(StaticModule).twofold).to.equal(20) + }) + + it('can reconfigure the getters', function () { + Object.defineProperty(getModule(StaticModule), 'twofold', {value: 'foo'}) + expect(getModule(StaticModule).twofold).to.equal('foo'); + }) +})