{"_id":"@antoinemairesse/vuex-crud","_rev":"4-8c567daebb253aa6803ecedb79df4a0e","name":"@antoinemairesse/vuex-crud","dist-tags":{"latest":"1.0.4"},"versions":{"1.0.0":{"name":"@antoinemairesse/vuex-crud","version":"1.0.0","description":"Vuex helper to create CRUD modules easily","main":"lib/index.js","scripts":{"build":"tsc && npm link","test":"echo \"Error: no test specified\" && exit 1","lint":"eslint --ext .js,.ts src","format":"prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\""},"author":"","license":"MIT","dependencies":{"axios":"^1.4.0","pluralize":"^8.0.0"},"devDependencies":{"@total-typescript/ts-reset":"^0.4.2","@types/pluralize":"^0.0.30","@typescript-eslint/eslint-plugin":"^6.4.0","@typescript-eslint/parser":"^6.4.0","eslint":"^8.47.0","prettier":"^3.0.2","typescript":"^5.1.6"},"gitHead":"6f9696e800710983d6a94f9d70b2a6b2ed006834","types":"./lib/index.d.ts","_id":"@antoinemairesse/vuex-crud@1.0.0","_nodeVersion":"20.4.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-KPH/q0cOltmR2mxfwsI4DG8DlmF2QcTlBtfRuSjU1l9ktOICGSky9pDPKQ5uAftKp7ej1qM+CnxB15MgB5u25w==","shasum":"6743a044c6cc3450e39473529b83beeeb20222da","tarball":"https://registry.npmjs.org/@antoinemairesse/vuex-crud/-/vuex-crud-1.0.0.tgz","fileCount":28,"unpackedSize":59114,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQChRVmSTmWlBk/GszihiiafGE5pccbn7OSpydgBDVP4yAIgKzMuxjT1valnNmjtupf0TUPP6xZJt+E0BmNgmVc+sF4="}]},"_npmUser":{"name":"antoinemairesse","email":"antoine.mairesse0@gmail.com"},"directories":{},"maintainers":[{"name":"antoinemairesse","email":"antoine.mairesse0@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vuex-crud_1.0.0_1692526242169_0.35621480464309174"},"_hasShrinkwrap":false},"1.0.1":{"name":"@antoinemairesse/vuex-crud","version":"1.0.1","description":"Vuex helper to create CRUD modules easily","main":"lib/index.js","scripts":{"build":"tsc && npm link","test":"echo \"Error: no test specified\" && exit 1","lint":"eslint --ext .js,.ts src","format":"prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\""},"author":"","license":"MIT","dependencies":{"axios":"^1.4.0","pluralize":"^8.0.0"},"devDependencies":{"@total-typescript/ts-reset":"^0.4.2","@types/pluralize":"^0.0.30","@typescript-eslint/eslint-plugin":"^6.4.0","@typescript-eslint/parser":"^6.4.0","eslint":"^8.47.0","prettier":"^3.0.2","typescript":"^5.1.6"},"gitHead":"23f5f44f020d8858666f91fb0da4438f8f0c2488","types":"./lib/index.d.ts","_id":"@antoinemairesse/vuex-crud@1.0.1","_nodeVersion":"20.4.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-rHawOjiaX1bvoS/XRChVC3ekocy90FBBmWgQfmUxBqhFdobMZk4Xb0s9DZXtuKSRKhKpiJWsP/FBjnRduQ8wtQ==","shasum":"809dbbac59388233477525ec344d6da9ba410165","tarball":"https://registry.npmjs.org/@antoinemairesse/vuex-crud/-/vuex-crud-1.0.1.tgz","fileCount":29,"unpackedSize":68120,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDMRNrxSUx2T2QQ3IdoMqvTnTQHKwFawVKUcBUQb3U2OQIgXl1xxdO0Z1Nx10LAPgVLv45wmxHCfPbkDfu96MJLe1M="}]},"_npmUser":{"name":"antoinemairesse","email":"antoine.mairesse0@gmail.com"},"directories":{},"maintainers":[{"name":"antoinemairesse","email":"antoine.mairesse0@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vuex-crud_1.0.1_1692526578977_0.7445753565311257"},"_hasShrinkwrap":false},"1.0.2":{"name":"@antoinemairesse/vuex-crud","version":"1.0.2","description":"Vuex helper to create CRUD modules easily","main":"lib/index.js","scripts":{"build":"tsc && npm link","test":"echo \"Error: no test specified\" && exit 1","lint":"eslint --ext .js,.ts src","format":"prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\""},"author":"","license":"MIT","dependencies":{"axios":"^1.4.0","pluralize":"^8.0.0"},"devDependencies":{"@total-typescript/ts-reset":"^0.4.2","@types/pluralize":"^0.0.30","@typescript-eslint/eslint-plugin":"^6.4.0","@typescript-eslint/parser":"^6.4.0","eslint":"^8.47.0","prettier":"^3.0.2","typescript":"^5.1.6"},"gitHead":"495ac83b9d9dc59038338fd4e915e8c25d1fe18f","types":"./lib/index.d.ts","_id":"@antoinemairesse/vuex-crud@1.0.2","_nodeVersion":"20.4.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-UTh8BF/zq6+QcirEAx0gHFhG2+f3NZHJNME8nBCYJLp5gWK+Un8k6QAyMrrsVFddPWrgCIf3BOTeWlCQ0FCecA==","shasum":"f6969644c59157d8c939c3fb33eb123c9e7cbe5e","tarball":"https://registry.npmjs.org/@antoinemairesse/vuex-crud/-/vuex-crud-1.0.2.tgz","fileCount":29,"unpackedSize":68174,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDwYB95jkyjspEQDJ/QoRLjR4Y1a9XcoemVSpEaTCOXEwIgWSCQkmXGB2KsabSy4UQsOMBP4LwTxZZHL+Khw2WGHfY="}]},"_npmUser":{"name":"antoinemairesse","email":"antoine.mairesse0@gmail.com"},"directories":{},"maintainers":[{"name":"antoinemairesse","email":"antoine.mairesse0@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vuex-crud_1.0.2_1692526742139_0.21001555296701646"},"_hasShrinkwrap":false},"1.0.3":{"name":"@antoinemairesse/vuex-crud","version":"1.0.3","description":"Vuex helper to create CRUD modules easily","main":"lib/index.js","scripts":{"build":"tsc && npm link","test":"echo \"Error: no test specified\" && exit 1","lint":"eslint --ext .js,.ts src","format":"prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\""},"repository":{"type":"git","url":"git+https://github.com/AntoineMairesse/vuex-crud.git"},"author":{"name":"Antoine MAIRESSE"},"license":"MIT","dependencies":{"axios":"^1.4.0","pluralize":"^8.0.0"},"devDependencies":{"@total-typescript/ts-reset":"^0.4.2","@types/pluralize":"^0.0.30","@typescript-eslint/eslint-plugin":"^6.4.0","@typescript-eslint/parser":"^6.4.0","eslint":"^8.47.0","prettier":"^3.0.2","typescript":"^5.1.6"},"gitHead":"44197bc76a2e1b1776c7aa3f1857c062cbb3a9e2","types":"./lib/index.d.ts","bugs":{"url":"https://github.com/AntoineMairesse/vuex-crud/issues"},"homepage":"https://github.com/AntoineMairesse/vuex-crud#readme","_id":"@antoinemairesse/vuex-crud@1.0.3","_nodeVersion":"20.4.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-jT/s8eVwABziP3wvU60hx/jwMC4aIbGLpE9j/cGmgp/3+g8z1YwhM+/tp8BgbF3Duj9uOIut7Nrv9zLlxUa4OQ==","shasum":"ea8b8a628c5e2b18e67f1cfa10460ce41bbe42a8","tarball":"https://registry.npmjs.org/@antoinemairesse/vuex-crud/-/vuex-crud-1.0.3.tgz","fileCount":29,"unpackedSize":68290,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC4ow+QldeLKaa9/+GGi4jkjv0WA389kXjo+n6+UIYGOQIhAJ2D6Z43Bl5JQt5cXvbK8iGe2arMCBGRa/P5OOskpjYE"}]},"_npmUser":{"name":"antoinemairesse","email":"antoine.mairesse0@gmail.com"},"directories":{},"maintainers":[{"name":"antoinemairesse","email":"antoine.mairesse0@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vuex-crud_1.0.3_1692527195217_0.6954602249277897"},"_hasShrinkwrap":false},"1.0.4":{"name":"@antoinemairesse/vuex-crud","version":"1.0.4","description":"Vuex helper to create CRUD modules easily","main":"lib/index.js","scripts":{"build":"tsc && npm link","test":"echo \"Error: no test specified\" && exit 1","lint":"eslint --ext .js,.ts src","format":"prettier --ignore-path .gitignore --write \"**/*.+(js|ts|json)\""},"repository":{"type":"git","url":"git+https://github.com/AntoineMairesse/vuex-crud.git"},"author":{"name":"Antoine MAIRESSE"},"license":"MIT","dependencies":{"axios":"^1.4.0","pluralize":"^8.0.0"},"devDependencies":{"@total-typescript/ts-reset":"^0.4.2","@types/pluralize":"^0.0.30","@typescript-eslint/eslint-plugin":"^6.4.0","@typescript-eslint/parser":"^6.4.0","eslint":"^8.47.0","prettier":"^3.0.2","typescript":"^5.1.6"},"gitHead":"c1bd74220549dedad942f9c31a16071ac0ed58cb","types":"./lib/index.d.ts","bugs":{"url":"https://github.com/AntoineMairesse/vuex-crud/issues"},"homepage":"https://github.com/AntoineMairesse/vuex-crud#readme","_id":"@antoinemairesse/vuex-crud@1.0.4","_nodeVersion":"20.4.0","_npmVersion":"9.7.2","dist":{"integrity":"sha512-g6eKRwXxtjjC51gRvMRwkj1LLp4ETr2dbwyWVS8qtvVI8IOa/hqXZZQGk+nAnxptjxEBvR8ffNV3RScGZVENQQ==","shasum":"321f04bffc28161f9fa26ee4f4d2bc8ee072ddf1","tarball":"https://registry.npmjs.org/@antoinemairesse/vuex-crud/-/vuex-crud-1.0.4.tgz","fileCount":18,"unpackedSize":44303,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFAvmiOeu2qknKte7DeLYSr/ePd+75UTKr1Nx94uuHvEAiEAw4oVZNwjTFG7JaeZEnCuQzhnEAJbv/BPIuGOxh0fTkI="}]},"_npmUser":{"name":"antoinemairesse","email":"antoine.mairesse0@gmail.com"},"directories":{},"maintainers":[{"name":"antoinemairesse","email":"antoine.mairesse0@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/vuex-crud_1.0.4_1692538960870_0.4805728179786508"},"_hasShrinkwrap":false}},"time":{"created":"2023-08-20T10:10:42.105Z","1.0.0":"2023-08-20T10:10:42.381Z","modified":"2023-08-20T13:42:41.285Z","1.0.1":"2023-08-20T10:16:19.207Z","1.0.2":"2023-08-20T10:19:02.433Z","1.0.3":"2023-08-20T10:26:35.465Z","1.0.4":"2023-08-20T13:42:41.116Z"},"maintainers":[{"name":"antoinemairesse","email":"antoine.mairesse0@gmail.com"}],"description":"Vuex helper to create CRUD modules easily","license":"MIT","readme":"# Vuex-CRUD\n\n**vuex-crud** is a library for Vuex that simplifies the process of creating CRUD modules  for resources in your Vue.js applications. It provides a structured way to define API interactions, state management, and action handling for common CRUD operations.\n\n## Installation\n\n```bash\nnpm install @antoinemairesse/vuex-crud\n```\n\n## Basic Usage\n\n1) Create your first CRUD module :\n\n```javascript\n// src/store/index.js\nimport { CrudModule } from '@antoinemairesse/vuex-crud'\nimport { createStore } from 'vuex'\n\nexport default createStore({\n    modules: {\n        books: new CrudModule('books').getModule()\n    }\n})\n```\n\n2) Use it in your components:\n\n```vue\n<template>\n  <main>\n    <div v-if=\"fetchingBooks\">Loading books...</div>\n    <div v-else v-for=\"book in books\" :key=\"book.id\">\n      <h1>{{ book.title }},</h1>\n      <h3>{{ book.genre }},</h3>\n      <h5>{{ book.publication_year }}</h5>\n    </div>\n  </main>\n</template>\n\n<script>\n  import { mapActions, mapState } from 'vuex';\n\n  export default {\n    name: 'books',\n    computed: {\n      ...mapState('books', ['books', 'fetchingBooks'])\n    },\n    methods: {\n      ...mapActions('books', ['fetchBooks'])\n    },\n    created() {\n      this.fetchBooks();\n    }\n  };\n</script>\n```\n\n### There are 5 crud actions, all associated with a vuex action, mutations & states :\n\n- #### `fetchItems` (example with `books` as the resource name):\n\n  - Default Axios config: `{ method: 'GET', url: /<resourceName> }`\n  - Vuex action name: `fetchBooks`\n  - Loading State: `fetchingBooks`\n  - Mutation for the loading state: `SET_FETCHING_BOOKS`\n  - State Mutation After Fetch: `SET_BOOKS`\n  - State affected by mutation: `books`\n\n- #### `getItem` (example with `books` as the resource name):\n\n    - Default Axios config: `{ method: 'GET', url: /<resourceName>/<actionData> }` (`actionData` is the data passed to the vuex action)\n    - Vuex action name: `fetchBooks`\n    - Loading State: `fetchingBooks`\n    - Mutation for the loading state (commited only if `commitState = true`): `SET_FETCHING_BOOKS`\n    - State Mutation After Fetch: `SET_CURRENT_BOOK`\n    - State affected by mutation: `currentBook`\n\n- #### `createItem` (example with `books` as the resource name):\n\n    - Default Axios config: `{ method: 'GET', url: /<resourceName>, data: actionData }` (`actionData` is the data passed to the vuex action)    \n    - Vuex action name: `createBook`\n    - Loading State: `creatingBook`\n    - Mutation for the loading state: `SET_CREATING_BOOKS`\n    - State Mutation After Fetch (commited only if `commitState = true` & `updateStateAfterAction = true`): `ADD_BOOK`\n    - State affected by mutation: `books`\n\n- #### `updateItem` (example with `books` as the resource name):\n\n    - Default Axios config: `{ method: 'GET', url: /<resourceName>/<actionData[idAttribute]>, data: actionData }` (`actionData` is the data passed to the vuex action, `idAttribute` is by default `id`, you can change it using the `setIdAttribute` method)\n    - Vuex action name: `updateBook`\n    - Loading State: `updatingBook`\n    - Mutation for the loading state: `SET_UPDATING_BOOKS`\n    - State Mutation After Fetch (commited only if `commitState = true` & `updateStateAfterAction = true`): `UPDATE_BOOK`\n    - State affected by mutation: `books`\n\n- #### `deleteItem` (example with `books` as the resource name):\n\n    - Default Axios config: `{ method: 'DELETE', url: /<resourceName>/<actionData> }` (`actionData` is the data passed to the vuex action) \n    - Vuex action name: `deleteBook`\n    - Loading State: `deletingBook`\n    - Mutation for the loading state: `SET_DELETING_BOOKS`\n    - State Mutation After Fetch (commited only if `commitState = true` & `updateStateAfterAction = true`): `DELETE_BOOK`\n    - State affected by mutation: `books`\n\n## Examples\nCheck out the <a href=\"https://github.com/AntoineMairesse/vuex-crud/tree/main/example\" target=\"_blank\">example</a> directory for usage examples.\n\n## Advanced Usage\n\n### The following options are available when creating a new CrudModule :\n\nFor types references, check out: <a href=\"https://github.com/AntoineMairesse/vuex-crud/blob/main/package/src/types/types.ts\" target=\"_blank\">types</a>\n\n```typescript\n\nenum CrudAction {\n    fetchItems = \"fetchItems\",\n    getItem = \"getItem\",\n    createItem = \"createItem\",\n    updateItem = \"updateItem\",\n    deleteItem = \"deleteItem\"\n}\n\ndeclare class CrudModule {\n    /**\n     * Create a new CrudModule instance.\n     * @param {string} resource - The name of the resource for the CRUD actions.\n     * @param {CrudAction[]} actionSelection - Selection of CRUD actions to add to the module\n     */\n    constructor(resource: string, actionSelection?: (keyof typeof CrudAction)[]);\n    /**\n     * Set additional custom actions for the CRUD module.\n     * @param {Actions} actions - Custom action methods to be added to the module.\n     * @returns {CrudModule} The updated CrudModule instance.\n     */\n    setAdditionalActions(actions: Actions): CrudModule;\n    /**\n     * Set additional custom state properties for the CRUD module.\n     * @param {State} state - Custom state properties to be added to the module.\n     * @returns {CrudModule} The updated CrudModule instance.\n     */\n    setAdditionalState(state: State): CrudModule;\n    /**\n     * Set additional custom mutations for the CRUD module.\n     * @param {Mutations} mutations - Custom mutations to be added to the module.\n     * @returns {CrudModule} The updated CrudModule instance.\n     */\n    setAdditionalMutations(mutations: Mutations): CrudModule;\n    /**\n     * Get the Vuex module configuration for the CRUD module.\n     * @returns {Module} An object representing the Vuex module configuration.\n     */\n    getModule(): Module;\n    /**\n     * Set the Axios instance for making API requests.\n     * @param {AxiosStatic} axios - The Axios instance to be used for API requests.\n     * @returns {CrudModule} The updated CrudModule instance.\n     */\n    setAxios(axios: AxiosStatic): CrudModule;\n    /**\n     * Set the attribute to be used as the ID for items.\n     * @param {string} value - The name of the ID attribute.\n     * @returns {CrudModule} The updated CrudModule instance.\n     */\n    setIdAttribute(value: string): CrudModule;\n    /**\n     * Set whether to update the state after an action (create/update/delete) is performed.\n     * @param {boolean} value - Whether to update the state after an action.\n     * @returns {CrudModule} The updated CrudModule instance.\n     */\n    setUpdateStateAfterAction(value: boolean): CrudModule;\n    /**\n     * Set whether to refresh data after an action (create/update/delete) is performed.\n     * @param {boolean} value - Whether to refresh data after an action.\n     * @returns {CrudModule} The updated CrudModule instance.\n     */\n    setRefreshAfterAction(value: boolean): CrudModule;\n    /**\n     * Set whether to commit the result of fetch actions.\n     * @param {boolean} value - Whether to commit state changes during actions.\n     * @returns {CrudModule} The updated CrudModule instance.\n     */\n    setCommitState(value: boolean): CrudModule;\n    /**\n     * Sets the custom API definition function for CRUD actions on a specified resource.\n     *\n     * @param {CustomAPIDefinitionFunction} func - The custom API definition function that will be used to define the API.\n     * @returns {CrudModule} The updated CrudModule instance.\n     */\n    setCustomAPIDefinition(func: CustomAPIDefinitionFunction): CrudModule;\n    /**\n     * Set a callback function to be executed on successful action completion.\n     * @param {ActionHandler} func - The function to be executed on action success.\n     * @returns {CrudModule} The updated CrudModule instance.\n     */\n    onActionSuccess(func: ActionHandler): CrudModule;\n    /**\n     * Set a callback function to be executed on action failure.\n     * @param {ActionHandler} func - The function to be executed on action error.\n     * @returns {CrudModule} The updated CrudModule instance.\n     */\n    onActionError(func: ActionHandler): CrudModule;\n    /**\n     * Helper function to create a custom action that also creates the associated loading state & mutation.\n     * @param {Action} action - The vuex action.\n     * @param {string} loadingStateName - The name of the loading state\n     * @param {string} loadingMutationName - The name of the mutation function that sets the loading state\n     * @returns {CrudModule} The updated CrudModule instance.\n     * @example\n     *\n     * async function fetchFilteredBooks({ commit }, actionData) {\n     *   const { data } = await api({\n     *     method: 'POST',\n     *     url: '/books/filter',\n     *     data: actionData\n     *   })\n     *   commit('SET_BOOKS', data)\n     * }\n     *\n     * CrudModule.createCustomAction(fetchFilteredBooks,'fetchingFilteredBooks', 'SET_FETCHING_FILTERED_BOOKS');\n     */\n    createCustomAction(action: Action, loadingStateName: string, loadingMutationName: string): CrudModule;\n    getFactory(): CrudModuleFactory;\n}\n```\n\n\n## License\n\nThe MIT License (MIT) - See file 'LICENSE' in this project","readmeFilename":"README.md","homepage":"https://github.com/AntoineMairesse/vuex-crud#readme","repository":{"type":"git","url":"git+https://github.com/AntoineMairesse/vuex-crud.git"},"author":{"name":"Antoine MAIRESSE"},"bugs":{"url":"https://github.com/AntoineMairesse/vuex-crud/issues"}}