{"_id":"@benjy2976/pmsg","_rev":"6-230f3b0b88704b6496c92d1aff39c00e","name":"@benjy2976/pmsg","dist-tags":{"latest":"0.1.5"},"versions":{"0.1.0":{"name":"@benjy2976/pmsg","version":"0.1.0","keywords":["pinia","generator","model","store"],"author":{"name":"Walther Raul II Benjamin Aguirre Tello"},"license":"MIT","_id":"@benjy2976/pmsg@0.1.0","maintainers":[{"name":"benjy2976","email":"benjy_2976@hotmail.com"}],"homepage":"https://github.com/benjy2976/pmsg#readme","bugs":{"url":"https://github.com/benjy2976/pmsg/issues"},"dist":{"shasum":"87623fa428775c318be860b409ecdfaf2f0ca241","tarball":"https://registry.npmjs.org/@benjy2976/pmsg/-/pmsg-0.1.0.tgz","fileCount":9,"integrity":"sha512-cZNoCu2Pd7lbcYl5xOiS1rl6tS0XzPhLllw8FkD/UEL8UpGGPNfcXYLE5CMBZG9nuBZsqjWLWAVN+w4/EekDUQ==","signatures":[{"sig":"MEUCIQC0/c0To64vxJmdKDEs1C+mKPfseSfs576G/vwwFyxguAIgM1YsSNSLm16PslHqS31YiquKSRoFA6cwtssl1cnlQiU=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":36207},"main":"src/Model.js","gitHead":"1de0a51a7b92731d0fa34c14df3d9a1a5145bf10","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"benjy2976","email":"benjy_2976@hotmail.com"},"repository":{"url":"git+https://github.com/benjy2976/pmsg.git","type":"git"},"_npmVersion":"10.9.2","description":"generator of models and store default for pinia","directories":{},"_nodeVersion":"22.13.0","dependencies":{"axios":"^1.0.0","js-md5":"^0.8.3"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.25.1","eslint-plugin-n":"^15.6.1","eslint-plugin-import":"^2.27.5","eslint-plugin-promise":"^6.1.1"},"_npmOperationalInternal":{"tmp":"tmp/pmsg_0.1.0_1752525349896_0.6475024371169611","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@benjy2976/pmsg","version":"0.1.1","keywords":["pinia","generator","model","store"],"author":{"name":"Walther Raul II Benjamin Aguirre Tello"},"license":"MIT","_id":"@benjy2976/pmsg@0.1.1","maintainers":[{"name":"benjy2976","email":"benjy_2976@hotmail.com"}],"homepage":"https://github.com/benjy2976/pmsg#readme","bugs":{"url":"https://github.com/benjy2976/pmsg/issues"},"dist":{"shasum":"5cfa14bdf74cc9da34910c053c8de3c87ef7a8f0","tarball":"https://registry.npmjs.org/@benjy2976/pmsg/-/pmsg-0.1.1.tgz","fileCount":9,"integrity":"sha512-FBw8p2VYvBc+j9P3GkwHsjnybbi5JW3mPhFifkBLOX3wCuJuKvOhHb6Tr0qBkQtWEVq4pK3Z1YenzyYM6Krlug==","signatures":[{"sig":"MEQCIFeQF91AvplhE1aXfe0jl2nGU11VgDB3u+e9KwiJTlF8AiBpDaIs+NXxhXD8AeBylHD9VYfOQOf68vcbd7ACD44qsA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":37462},"main":"src/Model.js","gitHead":"57c2ce247287e97988a295e297cb3a16d8fe9d8e","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"benjy2976","email":"benjy_2976@hotmail.com"},"repository":{"url":"git+https://github.com/benjy2976/pmsg.git","type":"git"},"_npmVersion":"10.9.2","description":"generator of models and store default for pinia","directories":{},"_nodeVersion":"22.13.0","dependencies":{"axios":"^1.0.0","js-md5":"^0.8.3"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.25.1","eslint-plugin-n":"^15.6.1","eslint-plugin-import":"^2.27.5","eslint-plugin-promise":"^6.1.1"},"_npmOperationalInternal":{"tmp":"tmp/pmsg_0.1.1_1752526872365_0.325200218023759","host":"s3://npm-registry-packages-npm-production"}},"0.1.2":{"name":"@benjy2976/pmsg","version":"0.1.2","keywords":["pinia","generator","model","store"],"author":{"name":"Walther Raul II Benjamin Aguirre Tello"},"license":"MIT","_id":"@benjy2976/pmsg@0.1.2","maintainers":[{"name":"benjy2976","email":"benjy_2976@hotmail.com"}],"homepage":"https://github.com/benjy2976/pmsg#readme","bugs":{"url":"https://github.com/benjy2976/pmsg/issues"},"dist":{"shasum":"50d0cbf459a0f91c343e5d51daa7e54b973939c9","tarball":"https://registry.npmjs.org/@benjy2976/pmsg/-/pmsg-0.1.2.tgz","fileCount":9,"integrity":"sha512-N7lQYZye4wmfeBS33P5zfdgRY61cYA5b+DpHiqS67gLdzpv48PI+fShuodtQwP4QW+m+Yl4OQAM7jMwHq0jGFg==","signatures":[{"sig":"MEQCIDdLLC7YXETWe8tmyV7uBey9nm4lhE6hq2BflZGv4P+NAiBUpdHfalvv2GTwumT9d4GCuUQuLjP4GSsSAT0LIxdRwA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":37599},"main":"src/Model.js","gitHead":"9b2d6a720f651b3ef16873b7d567ccc248e36998","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"benjy2976","email":"benjy_2976@hotmail.com"},"repository":{"url":"git+https://github.com/benjy2976/pmsg.git","type":"git"},"_npmVersion":"10.9.2","description":"generator of models and store default for pinia","directories":{},"_nodeVersion":"22.13.0","dependencies":{"axios":"^1.0.0","js-md5":"^0.8.3"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.25.1","eslint-plugin-n":"^15.6.1","eslint-plugin-import":"^2.27.5","eslint-plugin-promise":"^6.1.1"},"_npmOperationalInternal":{"tmp":"tmp/pmsg_0.1.2_1752623027321_0.8264864501379605","host":"s3://npm-registry-packages-npm-production"}},"0.1.3":{"name":"@benjy2976/pmsg","version":"0.1.3","keywords":["pinia","generator","model","store"],"author":{"name":"Walther Raul II Benjamin Aguirre Tello"},"license":"MIT","_id":"@benjy2976/pmsg@0.1.3","maintainers":[{"name":"benjy2976","email":"benjy_2976@hotmail.com"}],"homepage":"https://github.com/benjy2976/pmsg#readme","bugs":{"url":"https://github.com/benjy2976/pmsg/issues"},"dist":{"shasum":"7de76f9b8bac643ccc59e1dec1d465d0aa8db6fb","tarball":"https://registry.npmjs.org/@benjy2976/pmsg/-/pmsg-0.1.3.tgz","fileCount":9,"integrity":"sha512-a64D3kWdePT4wpVHerV/wOgWBOphdDz++GiDcjSod178oH/8ZbthRWikYgkZ/K40yfs7Py7oRuOnOe7CWTXarQ==","signatures":[{"sig":"MEQCIDOHuwD2Yq8DnnJt1/qOo8x0KBGJsEqDElnLaybnq3CHAiASgrXuKtSuag4C51IqOp/yo6fwGdjgeAynCLD88WgcPw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":37716},"main":"src/Model.js","gitHead":"55dabc0ca0ad566a5897bf86e25f1746419ce9e1","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"benjy2976","email":"benjy_2976@hotmail.com"},"repository":{"url":"git+https://github.com/benjy2976/pmsg.git","type":"git"},"_npmVersion":"10.9.4","description":"generator of models and store default for pinia","directories":{},"_nodeVersion":"22.21.1","dependencies":{"axios":"^1.0.0","js-md5":"^0.8.3"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.25.1","eslint-plugin-n":"^15.6.1","eslint-plugin-import":"^2.27.5","eslint-plugin-promise":"^6.1.1"},"_npmOperationalInternal":{"tmp":"tmp/pmsg_0.1.3_1764726258042_0.7775283567268714","host":"s3://npm-registry-packages-npm-production"}},"0.1.4":{"name":"@benjy2976/pmsg","version":"0.1.4","keywords":["pinia","generator","model","store"],"author":{"name":"Walther Raul II Benjamin Aguirre Tello"},"license":"MIT","_id":"@benjy2976/pmsg@0.1.4","maintainers":[{"name":"benjy2976","email":"benjy_2976@hotmail.com"}],"homepage":"https://github.com/benjy2976/pmsg#readme","bugs":{"url":"https://github.com/benjy2976/pmsg/issues"},"dist":{"shasum":"42c321ae45b737614ca8739c0b53838e21a71bbe","tarball":"https://registry.npmjs.org/@benjy2976/pmsg/-/pmsg-0.1.4.tgz","fileCount":9,"integrity":"sha512-IetWTViOPCKcEJEpvo3ibS81tj5DxYzCNOeKTgkyBr2qw7wLlp9TWsrcmjSeO1H7qmrUA8xciGbH+3irD3czHg==","signatures":[{"sig":"MEQCIF3fh3WcqJe6gyvpegueijGvEx8+zMZy531SIkz56TqRAiA08ruqGm6jfC2Cfbn+rBE2rXf2TTstqY+8D+UaUckg9A==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":38460},"main":"src/Model.js","gitHead":"bb0825af085c286f52d472409244ab1c8db665ff","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"_npmUser":{"name":"benjy2976","email":"benjy_2976@hotmail.com"},"repository":{"url":"git+https://github.com/benjy2976/pmsg.git","type":"git"},"_npmVersion":"10.9.4","description":"generator of models and store default for pinia","directories":{},"_nodeVersion":"22.21.1","dependencies":{"axios":"^1.0.0","js-md5":"^0.8.3"},"_hasShrinkwrap":false,"devDependencies":{"eslint":"^9.25.1","eslint-plugin-n":"^15.6.1","eslint-plugin-import":"^2.27.5","eslint-plugin-promise":"^6.1.1"},"_npmOperationalInternal":{"tmp":"tmp/pmsg_0.1.4_1765220506761_0.8089416957235005","host":"s3://npm-registry-packages-npm-production"}},"0.1.5":{"name":"@benjy2976/pmsg","version":"0.1.5","description":"generator of models and store default for pinia","main":"src/Model.js","scripts":{"test":"echo \"Error: no test specified\" && exit 1"},"repository":{"type":"git","url":"git+https://github.com/benjy2976/pmsg.git"},"keywords":["pinia","generator","model","store"],"author":{"name":"Walther Raul II Benjamin Aguirre Tello"},"license":"MIT","bugs":{"url":"https://github.com/benjy2976/pmsg/issues"},"homepage":"https://github.com/benjy2976/pmsg#readme","dependencies":{"axios":"^1.0.0","js-md5":"^0.8.3"},"devDependencies":{"eslint":"^9.25.1","eslint-plugin-import":"^2.27.5","eslint-plugin-n":"^15.6.1","eslint-plugin-promise":"^6.1.1"},"gitHead":"9043c6722b38ca178e2186c5a963fafa3af04fe6","_id":"@benjy2976/pmsg@0.1.5","_nodeVersion":"24.12.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-aO3oSOj89NjRmCp9K2iKBrHeuzTHTeXBfvpqJ806zd2JNZYN3TTMLqkgR5iLxxuhIqDjChPWPQtrl6H/QWREBQ==","shasum":"0d5242eb332031a2fbc7d3e83c6fe417a7bbc875","tarball":"https://registry.npmjs.org/@benjy2976/pmsg/-/pmsg-0.1.5.tgz","fileCount":9,"unpackedSize":38468,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQC+81VoW5Ur3ZExLS6J3i/LE9QMWXq8ETYwYup3Xup5GAIgEH2f88lHzTP2l7mxe4s5+syW6iEtiDKMn56vlRsdEDA="}]},"_npmUser":{"name":"benjy2976","email":"benjy_2976@hotmail.com"},"directories":{},"maintainers":[{"name":"benjy2976","email":"benjy_2976@hotmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/pmsg_0.1.5_1766957393747_0.2185134287318613"},"_hasShrinkwrap":false}},"time":{"created":"2025-07-14T20:35:49.730Z","modified":"2025-12-28T21:29:54.077Z","0.1.0":"2025-07-14T20:35:50.074Z","0.1.1":"2025-07-14T21:01:12.592Z","0.1.2":"2025-07-15T23:43:47.499Z","0.1.3":"2025-12-03T01:44:18.220Z","0.1.4":"2025-12-08T19:01:46.902Z","0.1.5":"2025-12-28T21:29:53.884Z"},"bugs":{"url":"https://github.com/benjy2976/pmsg/issues"},"author":{"name":"Walther Raul II Benjamin Aguirre Tello"},"license":"MIT","homepage":"https://github.com/benjy2976/pmsg#readme","keywords":["pinia","generator","model","store"],"repository":{"type":"git","url":"git+https://github.com/benjy2976/pmsg.git"},"description":"generator of models and store default for pinia","maintainers":[{"name":"benjy2976","email":"benjy_2976@hotmail.com"}],"readme":"# pinia-model-store-generator pmsg\nThis is a powerful package to consume data from webservices and use it as a model, centralizing the control of routes and\n making the call to data from the server much more friendly.\n\neste es un paquete potente para consumir datos de webservices y utilizarlo como modelo, centralizado el control de las \nrutas y haciendo mucha mas amable la llamada a los datos desde el servidor\n\nIt also provides a tool that creates a template with the main actions for state control with Pinia.\n\ntambien provee de una herramienta que crea una plantilla con las principales acciones para el control de estados con Pinia\n\n## Installing\n\nUsing npm:\n\n```bash\n$ npm install @benjy2976/pmsg\n```\n\n\n## Example\nNOTE: if you use a md5 validation and the store functionality you can download the resource from the server once,\nan re download only if the data was changed.\n\nyou can create a core/product.js file and put the next code\n\n```js\nexport default {\n    alias     : 'product' ,//alias utilizado para almacenar en el localstorage\n    route     : '/api/auth/product',//ruta donde se encuentra el resource\n    hash      : false,//la condicional si se va a validar el md5\n    store     : false,//la condicional que define si se guardara en el localstorage\n    methods   : null, //define los métodos adicionales utilizados por el modelo\n\n    /*config for storeDefault*/\n    key       : 'id',//define el primary key que se usara para acceder al objeto\n    name      : 'name',//nombre del atributo name en la base de datos\n    maxRelationsResolve: 1//la cantidad de veces que resolvera la relacion default 1\n    relations : [// Relaciones con otros models\n        {\n            attribute: 'brand_id',\n            alias: 'brand',//si no se define se asume le mismo nombre que attribute\n            module: 'brands',\n            hasMany: false// si no se define se asumen como falso\n        },\n    ],\n    selectable: false,//condicional para definir si el objeto es seleccionable\n    default   : {\n        id:null,\n        brand_id:null,\n        name:null\n    },//valor del objeto por defecto,\n    params    : {modeljs: true}//aquí se configuran parámetros adicionales a enviar en los request\n   \n}\n\n```\n\nyou can create a core/category.js file and put the next code\n\n```js\nexport default {\n    alias     : 'brand' ,//alias utilizado para almacenar en el localstorage\n    route     : '/api/auth/brand',//ruta donde se encuentra el resource\n    hash      : false,//la condicional si se va a validar el md5\n    store     : false,//la condicional que define si se guardara en el localstorage\n    methods   : null, //define los métodos adicionales utilizados por el modelo\n\n    /*config for storeDefault*/\n    key       : 'id',//define el primary key que se usara para acceder al objeto\n    name      : 'name',//nombre del atributo name en la base de datos\n    maxRelationsResolve: 1//la cantidad de veces que resolvera la relacion default 1\n    relations : [// Relaciones con otros models\n        {\n          attribute : 'brand_id',\n          alias     : 'products',\n          module    : 'products',\n          hasMany   : true//se pone false para que busque a traves del pivot\n        },\n    ],\n    selectable: false,//condicional para definir si el objeto es seleccionable\n    default   : {\n        id:null,\n        name:null\n    },//valor del objeto por defecto,\n    params    : {modeljs: true}//aquí se configuran parámetros adicionales a enviar en los request\n   \n}\n\n```\ncreate core/index.js\n\n```js\nimport Model from '@benjy2976/pmsg'\nimport createApiService from '@/core/services/ApiService'\nconst Apiservice = createApiService(import.meta.env.VITE_API_URL || 'http://localhost:8083/api')\n\nimport configProduct from './product'\nimport configBrand from './brand'\nexport const Producto = new Model(configProduct, Apiservice)\nexport const Brand = new Model(configBrand, Apiservice)\n\n```\n\nso where ever you are you can call the product Model\n\n```js\nimport {Producto} from './core'\n\nProducto.show(1)\n//this code create a request to the server an return a request to the object with the id Nr 1\n```\n\nif you are using Pinia you can create the storeDefault\ncrating the next structure\n```js\n/stores\n/stores/modules\n```\ninto /stores/modules you can create a products.js file\n```js\n//import {Product} from '../../models' //import if necessary\n\n\nconst state = {\n    //here you can redefine or define new states\n    //by default its going to create the next stores\n    /\n    itemSelected:{},\n    items:Array[],\n    keysAsinc: [],\n    keysTemp: [],\n    key: config.key,\n    moduleAlias: config.moduleAlias,\n    maxRelationsResolve: config.maxRelationsResolve,\n    relations: config.relations,\n    syncStatus: config.sync,//here you define whether sync() or setItems() will be used\n    selectedStatus: false,\n    timeOutAsinc:null\n\n     \n    //you do not need to define it, it is going to create automatically \n}\n\nconst getters = {\n    //here you can redefine or define new getters\n    //by default its going to create the next getters\n    \n    key: 'id',\n    // Getter para obtener el nombre del objeto seleccionado\n    name: (id) => {...},\n    // Getter para obtener el objeto seleccionado\n    find: (id) => {...},\n    // Getter para obtener la lista de objetos\n    list: [...],\n    // Getter para obtener la lista de objetos filtrados\n    filter: (filter) => [...],\n    // Getter para obtener el objeto seleccionado\n    selected: {...}\n    // Getter para resolver las relaciones \n    //** se debe de sobrecargar este metodo si se quiere poner funciones personalizadas***\n    resolve: {...}\n    \n   \n    // Getter para obtener el indice de la tabla\n    //you do not need to define it, it is going to create automatically \n    //also you can create other getters if you need\n}\n\nconst actions = {\n    //here you can redefine or define new actions\n    //by default its going to create the next actions\n    /* esta accion almacena todos los keys que con los que se le invoca en un periodo de 100ms para realizar una peticion al servicor con los datos de todas esas keys */\n    checkAsinc ({ state, getters, dispatch, commit }, key )//this action stores all the keys with which it is invoked in a period of 100ms to make a request to the service with the data of all those keys\n    /* esta accion invoca a  show del modelo y almacena la respuesta */\n    show ({ dispatch })//this action invoque at the show fron the model and store the response into the state.items\n    //*** esta acción invoca getAll(params) del modelo y almacena la respuesta en state.items. ***\n    get(params)//this action invoque at the getAll(params) from the model and store the response into a state.items \n    //*** esta acción se invoca después de que se envía el get, puede redefinirlo si lo necesita ***\n    afterGet()//this action is called after the get is dispatched, you yo can redefine it if you need\n    //*** esta acción crea un nuevo item, llama a create(item) desde el modelo y agrega la respuesta ***\n    create(item)//this action create a new item, call to the create(item) from the model and add the response \n    //at the state.items list\n    //*** esta acción modifica un  item, llama a update(item) desde el modelo y agrega la respuesta ***\n    update(item)//this action update a item, call to the update(item) from the model and add the response \n    //at the state.items list\n    //*** esta acción elimina un nuevo elemento, llama a eliminar (elemento) del modelo y agrega la respuesta ***\n    delete(item)//this action delete a new item, call to the delete(item) from the model and add the response \n    //*** action para llamar SET_ITEMS mutacion, para reemplazar todo el state.items ***\n    setItems(items)//action to call SET_ITEMS mutation, to replace all the state.items\n    //*** esta accion setea state.syncStatus ****\n    setSyncStatus(syncStatus)//this action set the state.syncStatus\n    //*** action para determinar si se actualizara un objeto o varios de acuerdo al formato de llegada de la data ***\n    sync(item/items)//action to determine if one object or several is updated according to the data arrival format\n    //*** action para sincronizar objetos (items) con los objetos almacenado en el store ***\n    syncItems(items)//action to synchronize objects (items) with the objects stored in the store\n    //*** action para sincronizar un objeto (item) con un objeto almacenado en el store ***\n    syncItem(item)//action to synchronize an object (item) with an object stored in the store\n    //at the state.items list\n    //*** estas acciones seleccionan un elemento de la lista de elementos y ponen el valor en un estado. ***\n    selectItem(id)//this actions select one item from the list of items and put the value into a state.item\n    //*** esta acción se llama después de que se envía el artículo seleccionado, puede redefinirlo si lo necesita ***\n    afterSelect()//this action is called after the selectItem is dispatched, you yo can redefine it if you need\n    //*** esta accion de seleccioan el itemSelected ***\n    deselect()//this action deselect the itemSelected\n    \n    //you do not need to define it, it is going to create automatically \n    //also you can create other getters if you need\n}\n\nexport default {\n  state,\n  getters,\n  actions,\n}\n\n\n```\nyou need to create a file index.js into a /stores folder you have two ways to declare the state\n\n````js\nimport { defineStore } from \"pinia\";\nimport { Producto } from '@/core/models/index.js';\n\nconst {state,getters,actions} = Producto.getStore();\nconst useProductosStore = defineStore(Producto.alias, {\n  state   : () => ({...state}),\n  getters : {...getters},\n  actions : {...actions},\n}\n)\nexport default useProductosStore;\n````\nin your Component component.vue \n\nin your app.js you can invoque like this\n````js\n\n\nimport useProductosStore from '@/stores/auth/ProcutosStore'\nconst productosStore = useProductosStore()\n\nproductosStore.get().then(()=>{\n  console.log(productosStore.list)\n})\n\n````","readmeFilename":"README.md"}