{"_id":"@blipicodes/medusa-plugin-store-credit","name":"@blipicodes/medusa-plugin-store-credit","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.1":{"name":"@blipicodes/medusa-plugin-store-credit","version":"1.0.1","description":"Offer store credit to customers that they can spend in your shop.","author":{"name":"Ivo Limić","email":"ivo@agilo.co"},"license":"MIT","keywords":["medusa","medusa-plugin","medusa-plugin-bundles","ecommerce","headless"],"scripts":{"clean":"cross-env ./node_modules/.bin/rimraf dist","build":"cross-env npm run clean && npm run build:server && npm run build:admin","build:server":"cross-env npm run clean && tsc -p tsconfig.server.json","build:admin":"cross-env medusa-admin build","watch":"cross-env tsc --watch","prepare":"cross-env NODE_ENV=production yarn run build:server && cross-env NODE_ENV=production medusa-admin bundle","test":"cross-env jest","seed":"cross-env medusa seed -f ./data/seed.json","start":"cross-env npm run build && medusa start","start:custom":"cross-env npm run build && node --preserve-symlinks --trace-warnings index.js","dev":"cross-env npm run build:server && medusa develop"},"dependencies":{"medusa-core-utils":"^1.2.0"},"devDependencies":{"@babel/cli":"^7.14.3","@babel/core":"^7.14.3","@babel/preset-typescript":"^7.21.4","@hookform/error-message":"^2.0.1","@medusajs/admin":"^7.1.1","@medusajs/medusa":"^1.18.0","@medusajs/medusa-cli":"^1.3.21","@radix-ui/react-avatar":"^1.0.1","@radix-ui/react-collapsible":"^1.0.1","@radix-ui/react-dialog":"^1.0.2","@radix-ui/react-dropdown-menu":"^2.0.2","@radix-ui/react-popover":"^1.0.3","@radix-ui/react-portal":"^1.0.2","@radix-ui/react-select":"^2.0.0","@radix-ui/react-switch":"^1.0.1","@radix-ui/react-tooltip":"^1.0.3","@types/express":"^4.17.13","@types/jest":"^27.4.0","@types/node":"^17.0.8","babel-preset-medusa-package":"^1.1.19","clsx":"^1.2.1","copy-to-clipboard":"^3.3.1","cross-env":"^7.0.3","emoji-picker-react":"^4.4.3","eslint":"^6.8.0","jest":"^27.3.1","lodash":"^4.17.21","medusa-interfaces":"^1.3.7","medusa-react":"^9.0.11","moment":"^2.29.4","qs":"^6.11.2","react-datepicker":"^4.8.0","react-highlight-words":"^0.18.0","react-hook-form":"7.38.0","react-hot-toast":"2.4.0","react-i18next":"^12.3.1","react-json-tree":"^0.17.0","react-router-dom":"6.8.0","react-select":"^5.5.4","react-table":"^7.7.0","rimraf":"^3.0.2","ts-jest":"^27.0.7","ts-loader":"^9.2.6","typeorm":"^0.3.16","typescript":"^4.5.2"},"peerDependencies":{"@hookform/error-message":"*","@medusajs/admin":"^7.1.1","@medusajs/medusa":"^1.18.0","@radix-ui/react-avatar":"*","@radix-ui/react-collapsible":"*","@radix-ui/react-dialog":"*","@radix-ui/react-dropdown-menu":"*","@radix-ui/react-popover":"*","@radix-ui/react-portal":"*","@radix-ui/react-select":"*","@radix-ui/react-switch":"*","@radix-ui/react-tooltip":"*","clsx":"*","copy-to-clipboard":"*","emoji-picker-react":"*","lodash":"*","medusa-interfaces":"^1.3.7","medusa-react":"^9.0.11","moment":"*","qs":"*","react-datepicker":"*","react-highlight-words":"*","react-hook-form":"*","react-hot-toast":"*","react-i18next":"*","react-json-tree":"*","react-router-dom":"*","react-select":"*","react-table":"*","typeorm":"*"},"jest":{"globals":{"ts-jest":{"tsconfig":"tsconfig.spec.json"}},"moduleFileExtensions":["js","json","ts"],"testPathIgnorePatterns":["/node_modules/","<rootDir>/node_modules/"],"rootDir":"src","testRegex":"(/__tests__/.*|\\.(test|spec))\\.(ts|js)$","transform":{".ts":"ts-jest"},"collectCoverageFrom":["**/*.(t|j)s"],"coverageDirectory":"./coverage","testEnvironment":"node"},"_id":"@blipicodes/medusa-plugin-store-credit@1.0.1","gitHead":"6bea5c7c3934ac4e8706de780a3d2d555853e4ca","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-cr3Ul2VdzgRj9Wqghks4LfcLvyzek5R/tWp1OXLUTFqTDyxdLwCdPX/gYx1lzAEAcdPS6BZ0XSjIAvfFPBdBbg==","shasum":"2f8ba7dcc84b557d790f45e7638536a63c08337e","tarball":"https://registry.npmjs.org/@blipicodes/medusa-plugin-store-credit/-/medusa-plugin-store-credit-1.0.1.tgz","fileCount":77,"unpackedSize":449691,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCcsx165KuRxmrjoJVe2OZM7qYMgNG85faz5ZictMnANwIgOG1WUcgN72+nGob7rrDLpM5aAgdUXmU6Fl70q3cKNCk="}]},"_npmUser":{"name":"blipicodes","email":"gpascualg93@gmail.com"},"directories":{},"maintainers":[{"name":"blipicodes","email":"gpascualg93@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/medusa-plugin-store-credit_1.0.1_1736737639174_0.026869934022218933"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-13T03:07:19.059Z","1.0.1":"2025-01-13T03:07:19.359Z","modified":"2025-01-13T03:07:19.642Z"},"maintainers":[{"name":"blipicodes","email":"gpascualg93@gmail.com"}],"description":"Offer store credit to customers that they can spend in your shop.","keywords":["medusa","medusa-plugin","medusa-plugin-bundles","ecommerce","headless"],"author":{"name":"Ivo Limić","email":"ivo@agilo.co"},"license":"MIT","readme":"# Medusa Store Credit\r\n\r\nGive store credit to customers that they can spend in your shop.\r\n\r\n<p>\r\n  <a href=\"./LICENSE\">\r\n    <img src=\"https://img.shields.io/badge/license-MIT-blue\" alt=\"MedusaWP is released under the MIT license.\" />\r\n  </a>\r\n  <a href=\"https://nodejs.org/\" target=\"_blank\">\r\n    <img src=\"https://img.shields.io/badge/Node.js-%5E20-brightgreen\" alt=\"Node.js ^20\">\r\n  </a>\r\n  <a href=\"https://twitter.com/intent/follow?screen_name=Agilo\">\r\n    <img src=\"https://img.shields.io/twitter/follow/Agilo\" alt=\"X (formerly Twitter) Follow\">\r\n  </a>\r\n</p>\r\n\r\n## Features\r\n\r\n- Give store credit to customers that they can spend in your shop.\r\n- Store credit allows customers to make multiple purchases until the credit is exhausted.\r\n- It can be used as a personal refund or compensation card in case there’s a problem with your product or service.\r\n\r\n---\r\n\r\n## Prerequisites\r\n\r\n- [Medusa backend](https://docs.medusajs.com/development/backend/install)\r\n\r\n---\r\n\r\n## How to Install\r\n\r\n1\\. Run the following command in the directory of the Medusa backend:\r\n\r\n```bash\r\nnpm i @agilo/medusa-plugin-store-credit\r\n```\r\n\r\n2\\. In `medusa-config.js` add the following at the end of the `plugins` array:\r\n\r\n```js\r\nconst plugins = [\r\n  // ...\r\n  {\r\n    resolve: \"@agilo/medusa-plugin-store-credit\",\r\n    options: {\r\n      enableUI: true,\r\n    },\r\n  },\r\n];\r\n```\r\n\r\n3\\. Run the following command in the directory of the Medusa backend to run the migrations:\r\n\r\n```bash\r\nnpx medusa migrations run\r\n```\r\n\r\n---\r\n\r\n## Test the Plugin\r\n\r\n1\\. Start your Medusa backend and admin dashboard, eg.:\r\n\r\n```bash\r\nnpm run dev\r\n```\r\n\r\n2\\. Visit Store Credit screen in the admin dashboard to assign store credit to a customer.\r\n\r\n3\\. Implement your storefront.\r\n\r\nThe plugin extends the storefront `Cart`, `Customer` and `Order` models with store credit information you can use to implement your storefront, eg.:\r\n\r\n- `/store/carts/{id}` - `cart` will contain `store_credit_total` field which is the total store credit available to be used in that cart\r\n- `/store/customers/me` - `customer` will contain `store_credits` array with all store credits available per region for the logged in customer\r\n- `/store/customers/me/orders` - `order` will contain `store_credit_total`, `store_credit_transactions` and `store_credits` which were used in the order\r\n\r\nAn example storefront implementation can be found in https://github.com/Agilo/medusa-plugin-store-credit/tree/master/packages/medusa-storefront\r\n\r\n## Contributing\r\n\r\nWe welcome contributions from the community to help make this project even better. Please feel free to open pull requests or issues. Thank you for considering contributing, and we look forward to collaborating with you!\r\n\r\nBelow you can find the [plugin development guide](#plugin-development) that will help you get started with running Medusa Store Credit in your local environment.\r\n\r\n### Plugin Development\r\n\r\n#### Prerequisites\r\n\r\n- [Docker](https://docs.docker.com/get-docker/)\r\n- [Node.js v20](https://nodejs.org/en/download/)\r\n  - We suggest using [nvm](https://github.com/nvm-sh/nvm) or [fnm](https://github.com/Schniz/fnm) to manage your Node.js versions.\r\n- [Yarn v3](https://v3.yarnpkg.com/getting-started/install)\r\n- [Yalc](https://github.com/wclr/yalc)\r\n\r\n#### Running Locally\r\n\r\nFollow these step-by-step instructions to run the project locally:\r\n\r\n1. `git clone https://github.com/Agilo/medusa-plugin-store-credit.git` - clone the monorepo\r\n2. `cd medusa-plugin-store-credit` - position into the project directory\r\n3. `cp .env.example .env` - set up docker-compose environment variables\r\n4. `docker compose up` - start Medusa Docker containers\r\n5. Open a new terminal tab\r\n6. `yarn install && yarn run setup` - install dependencies in all packages\r\n7. `cd packages/medusa && medusa migrations run && cd ../..` - run the migrations\r\n8. `cd packages/medusa && yarn run seed:plugin && cd ../..` - seed the database\r\n9. `yarn run start` - build the packages and start the Medusa dev server and plugin watcher\r\n\r\nMedusa Admin is now available at http://localhost:7001 and Medusa Storefront at http://localhost:8000\r\n\r\nDefault credentials for Medusa Admin are:\r\n\r\n```\r\nadmin@medusa-test.com\r\nsupersecret\r\n```\r\n\r\nOnce you have the project running locally you can start making changes to the plugin in `packages/medusa-plugin-store-credit/src` and see them reflected in the Medusa Admin and Storefront.\r\n\r\n#### Generating migrations\r\n\r\nUnfortunately DX when generating migrations which extend or relate to core entities is not great, but here's a workflow that works:\r\n\r\n1. `yarn run start` - make sure workflow is running\r\n2. `cp packages/medusa-plugin-store-credit/.env.example packages/medusa-plugin-store-credit/.env` - copy and edit environment variables\r\n3. `cd packages/medusa-plugin-store-credit/src/migrations` - navigate to the plugin dir\r\n4. `npx typeorm migration:generate -d datasource.js src/migrations/StoreCreditUpdate` - this will generate a migration file with a bunch of migrations in `src/migrations/<timestamp>-StoreCreditUpdate.ts`, the migration file will contain migrations for both core medusa entities and your plugin entities. You can now cherry pick the migrations you want to run and delete the rest.\r\n5. In the `packages/medusa` dir run `medusa migrations run`\r\n\r\n#### Available Commands\r\n\r\n- `yarn run setup` - install dependencies in all packages\r\n- `yarn run start` - build the packages and start the Medusa dev server and plugin watcher\r\n- `yarn run sync` - use yalc to publish and push `medusa-plugin-store-credit` to Medusa backend\r\n\r\n#### Docker Services\r\n\r\nDocker services are defined in `docker-compose.yml` file.\r\n\r\n- `postgres` - PostgreSQL database server for Medusa available on localhost:5432, you can change credentials and port in `.env` and `packages/medusa/.env` files\r\n- `redis` - Redis server for Medusa available on localhost:6379\r\n\r\n## Additional Resources\r\n\r\n- [Medusa Documentation](https://docs.medusajs.com/)\r\n- [Medusa Development Documentation](https://docs.medusajs.com/development/overview)\r\n\r\n## License\r\n\r\nThis project is licensed under the [MIT License](./LICENSE).\r\n\r\n## Credits\r\n\r\nMedusaWP is developed and maintained by [AGILO](https://agilo.co/).  \r\nHuge thanks to [all contributors](https://github.com/Agilo/medusa-plugin-store-credit/graphs/contributors).\r\n","readmeFilename":"README.md"}