├── .editorconfig ├── .eslintignore ├── .eslintrc.js ├── .gitattributes ├── .github └── FUNDING.yml ├── .gitignore ├── .npmignore ├── .prettierignore ├── .prettierrc ├── .vscode ├── launch.json └── settings.json ├── LICENSE ├── README.md ├── build └── rollup.js ├── dist ├── index.cjs.js └── index.esm.js ├── docs ├── .vuepress │ ├── config.js │ ├── deploy.sh │ └── styles │ │ ├── index.styl │ │ └── palette.styl ├── README.md ├── add-and-manage-data.md ├── config-example.md ├── extra-features.md ├── faq.md ├── feedback.md ├── firestore-fields-and-functions.md ├── hooks.md ├── query-data.md └── setup.md ├── new sync.js ├── package-lock.json ├── package.json ├── patches └── mock-cloud-firestore+0.12.0.patch ├── src ├── declarations.ts ├── index.ts ├── module │ ├── actions.ts │ ├── defaultConfig.ts │ ├── errorCheckConfig.ts │ ├── errors.ts │ ├── getters.ts │ ├── index.ts │ ├── mutations.ts │ └── state.ts └── utils │ ├── apiHelpers.ts │ ├── arrayHelpers.ts │ ├── debounceHelper.ts │ ├── incrementHelper.ts │ ├── log.ts │ ├── payloadHelpers.ts │ └── setDefaultValues.ts ├── test ├── DBChannel.js ├── actionsCollection.js ├── actionsDoc.js ├── actions_arrays.js ├── actions_increment.js ├── checks.js ├── getters.js ├── helpers │ ├── firestore.ts │ ├── firestoreMock.js │ ├── index.cjs.js │ ├── index.ts │ ├── store │ │ ├── defaultValuesSetupColNOProp.ts │ │ ├── defaultValuesSetupColProp.ts │ │ ├── defaultValuesSetupDocNOProp.ts │ │ ├── defaultValuesSetupDocProp.ts │ │ ├── docModeWithPathVar.ts │ │ ├── index.ts │ │ ├── initialDoc.ts │ │ ├── mainCharacter.ts │ │ ├── mainCharacterVEA.ts │ │ ├── multipleOpenDBChannels.ts │ │ ├── pokemonBox.ts │ │ ├── pokemonBoxVEA.ts │ │ ├── preventInitialDoc.ts │ │ ├── serverHooks.ts │ │ ├── store.ts │ │ ├── testMutationsNoStateProp.ts │ │ ├── testMutationsWithStateProp.ts │ │ ├── testNestedFillables.ts │ │ ├── testNestedGuard.ts │ │ ├── testPathVar.ts │ │ ├── testPathVar2.ts │ │ └── user.ts │ ├── utils │ │ └── setDefaultValues.js │ └── wait.js ├── initialDoc.js ├── mutations.js ├── serverHooks.js ├── syncDefaultValues.js ├── syncFillablesGuard.js ├── syncHooks.js ├── user.js ├── utils │ ├── apiHelpers.js │ ├── arrayHelpers.js │ ├── payloadHelpers.js │ └── setDefaultValues.js └── vuex-easy-access.js ├── tsconfig.json ├── types ├── declarations.d.ts ├── index.d.ts ├── module │ ├── actions.d.ts │ ├── defaultConfig.d.ts │ ├── errorCheckConfig.d.ts │ ├── errors.d.ts │ ├── getters.d.ts │ ├── index.d.ts │ ├── mutations.d.ts │ └── state.d.ts ├── src │ ├── index.d.ts │ ├── module │ │ ├── actions.d.ts │ │ ├── defaultConfig.d.ts │ │ ├── errorCheckConfig.d.ts │ │ ├── errors.d.ts │ │ ├── getters.d.ts │ │ ├── index.d.ts │ │ ├── mutations.d.ts │ │ └── state.d.ts │ └── utils │ │ ├── apiHelpers.d.ts │ │ ├── arrayHelpers.d.ts │ │ ├── debounceHelper.d.ts │ │ ├── incrementHelper.d.ts │ │ ├── payloadHelpers.d.ts │ │ └── setDefaultValues.d.ts ├── test │ └── helpers │ │ ├── firestore.d.ts │ │ ├── index.d.ts │ │ └── store │ │ ├── defaultValuesSetupColNOProp.d.ts │ │ ├── defaultValuesSetupColProp.d.ts │ │ ├── defaultValuesSetupDocNOProp.d.ts │ │ ├── defaultValuesSetupDocProp.d.ts │ │ ├── docModeWithPathVar.d.ts │ │ ├── index.d.ts │ │ ├── initialDoc.d.ts │ │ ├── mainCharacter.d.ts │ │ ├── mainCharacterVEA.d.ts │ │ ├── multipleOpenDBChannels.d.ts │ │ ├── pokemonBox.d.ts │ │ ├── pokemonBoxVEA.d.ts │ │ ├── preventInitialDoc.d.ts │ │ ├── serverHooks.d.ts │ │ ├── store.d.ts │ │ ├── testMutationsNoStateProp.d.ts │ │ ├── testMutationsWithStateProp.d.ts │ │ ├── testNestedFillables.d.ts │ │ ├── testNestedGuard.d.ts │ │ ├── testPathVar.d.ts │ │ ├── testPathVar2.d.ts │ │ └── user.d.ts └── utils │ ├── apiHelpers.d.ts │ ├── arrayHelpers.d.ts │ ├── debounceHelper.d.ts │ ├── incrementHelper.d.ts │ ├── log.d.ts │ ├── payloadHelpers.d.ts │ └── setDefaultValues.d.ts └── wallaby.conf.js /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | charset = utf-8 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | insert_final_newline = true 9 | trim_trailing_whitespace = true 10 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | /dist 2 | -------------------------------------------------------------------------------- /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | parser: '@typescript-eslint/parser', 4 | parserOptions: { 5 | ecmaVersion: 2020, 6 | sourceType: 'module' 7 | }, 8 | env: { 9 | browser: true 10 | }, 11 | extends: [ 12 | // https://github.com/vuejs/eslint-plugin-vue#priority-a-essential-error-prevention 13 | // consider switching to `plugin:vue/strongly-recommended` or `plugin:vue/recommended` for stricter rules. 14 | 'plugin:vue/essential', 15 | // https://github.com/standard/standard/blob/master/docs/RULES-en.md 16 | 'standard' 17 | ], 18 | // required to lint *.vue files 19 | plugins: [ 20 | '@typescript-eslint', 21 | 'vue' 22 | ], 23 | globals: { 24 | 'ga': true, // Google Analytics 25 | 'cordova': true, 26 | '__statics': true 27 | }, 28 | // add your custom rules here 29 | 'rules': { 30 | "@typescript-eslint/semi": "off", 31 | 'space-before-function-paren': 'off', 32 | 'indent': 'off', 33 | // allow async-await 34 | 'generator-star-spacing': 'off', 35 | 36 | // allow paren-less arrow functions 37 | 'arrow-parens': 0, 38 | 'one-var': 0, 39 | 40 | 'import/first': 0, 41 | 'import/named': 2, 42 | 'import/namespace': 2, 43 | 'import/default': 2, 44 | 'import/export': 2, 45 | 'import/extensions': 0, 46 | 'import/no-unresolved': 0, 47 | 'import/no-extraneous-dependencies': 0, 48 | 'comma-dangle': 0, 49 | 'no-unused-vars': 1, 50 | 'prefer-const': 1, 51 | 'no-new': 1, 52 | 'vue/valid-v-on': 0, 53 | 54 | // allow debugger during development 55 | 'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Auto detect text files and perform LF normalization 2 | * text=auto 3 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: mesqueeb 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | docs/.vuepress/.temp 3 | docs/.vuepress/dist 4 | .rpt2_cache 5 | .cache 6 | .env 7 | .env.js 8 | .idea 9 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | /src 2 | /test 3 | /docs 4 | /build 5 | -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | **/*.d.ts 2 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "printWidth": 100, 3 | "tabWidth": 2, 4 | "singleQuote": true, 5 | "trailingComma": "es5", 6 | "semi": false, 7 | "bracketSpacing": true, 8 | "endOfLine": "lf" 9 | } 10 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "node", 9 | "request": "launch", 10 | "name": "Debug AVA test file", 11 | "runtimeExecutable": "${workspaceFolder}/node_modules/.bin/ava", 12 | "runtimeArgs": [ 13 | "debug", 14 | "--break", 15 | "${file}" 16 | ], 17 | "port": 9229, 18 | "outputCapture": "std", 19 | "skipFiles": [ 20 | "/**/*.js" 21 | ] 22 | } 23 | ] 24 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "editor.formatOnSave": false 3 | } 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Luca Ban - Mesqueeb 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Vuex Easy Firestore 🔥 2 | 3 | In just 4 lines of code, get your vuex module in complete 2-way sync with firestore: 4 | 5 | ```js 6 | const userModule = { 7 | firestorePath: 'users/{userId}/data', 8 | firestoreRefType: 'collection', // or 'doc' 9 | moduleName: 'user', 10 | statePropName: 'docs', 11 | // the rest of your module here 12 | } 13 | // add userModule as vuex plugin wrapped in vuex-easy-firestore 14 | ``` 15 | 16 | and Alakazam! Now you have a vuex module called `user` with `state: {docs: {}}`. 17 | All firestore documents in your collection will be added with the doc's id as key inside `docs` in your state. 18 | 19 | Now you just update and add docs with `dispatch('user/set', newItem)` and forget about the rest! 20 | 21 | Other features include hooks, fillables (limit props to sync), default values (add props on sync), a fetch function and much more... 22 | 23 | [Installation and setup](https://mesqueeb.github.io/vuex-easy-firestore/setup.html#installation)  → 24 | 25 | # Motivation 26 | 27 | I didn't like writing an entire an API wrapper from scratch for firestore every single project. If only a vuex module could be in perfect sync with firestore without having to code all the boilerplate yourself... 28 | 29 | And that's how Vuex Easy Firestore was born. 30 | 31 | # Documentation 32 | 33 | See the all new documentation made with VuePress! 34 | 35 | **[Full documentation](https://mesqueeb.github.io/vuex-easy-firestore)** 36 | 37 | # Support 38 | 39 | If you like what I built, you can say thanks by buying me a coffee! :) 40 | 41 | Buy Me A Coffee 42 | 43 | Thank you so much!! Every little bit helps. 44 | -------------------------------------------------------------------------------- /build/rollup.js: -------------------------------------------------------------------------------- 1 | /* eslint-disable */ 2 | 3 | // npm install rollup-plugin-typescript2 typescript --save-dev 4 | import typescript from 'rollup-plugin-typescript2' 5 | // import { terser } from 'rollup-plugin-terser' 6 | // import resolve from 'rollup-plugin-node-resolve' 7 | 8 | // ------------------------------------------------------------------------------------------ 9 | // formats 10 | // ------------------------------------------------------------------------------------------ 11 | // amd – Asynchronous Module Definition, used with module loaders like RequireJS 12 | // cjs – CommonJS, suitable for Node and Browserify/Webpack 13 | // esm – Keep the bundle as an ES module file 14 | // iife – A self-executing function, suitable for inclusion as a