{"_id":"@bloombug/maintenance-task","_rev":"1-9265d49e983496ecbb2337b6587545bc","name":"@bloombug/maintenance-task","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@bloombug/maintenance-task","version":"0.1.0","author":{"name":"Ryan Macdonald","email":"hi@ryanmacdonald.ca"},"description":"Some helpers for running maintenance tasks","license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/macdonaldr93/maintenance-task-js.git"},"scripts":{"build":"tsc -p tsconfig.json"},"dependencies":{"tslib":"^2"},"devDependencies":{"@types/node":"^20"},"licenseText":"MIT License\n\nCopyright (c) 2023 Ryan Macdonald\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@bloombug/maintenance-task@0.1.0","dist":{"shasum":"7c480a6de41a46edbd7829b57cb25908aac58c13","integrity":"sha512-FZZPY4BQzudOhaGJH+NcQk+QKdxUqzpOF+/AQGmiqelqjuV/FvCmZvoOoE+zMsHzDW2KXuDO+xf7rhrvPG6E4g==","tarball":"https://registry.npmjs.org/@bloombug/maintenance-task/-/maintenance-task-0.1.0.tgz","fileCount":33,"unpackedSize":21860,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGuauckKghwNT5+9b97QoBAEs7leS9ty7nPhafZNCARWAiALSQycbCz7kd8CHHTfh3JBH++0PogGwnWOjTDcklAwKA=="}]},"_npmUser":{"name":"macdonaldr93","email":"hi@ryanmacdonald.ca"},"directories":{},"maintainers":[{"name":"macdonaldr93","email":"hi@ryanmacdonald.ca"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/maintenance-task_0.1.0_1701801091313_0.20802804368477434"},"_hasShrinkwrap":false},"0.2.0":{"name":"@bloombug/maintenance-task","version":"0.2.0","author":{"name":"Ryan Macdonald","email":"hi@ryanmacdonald.ca"},"description":"Some helpers for running maintenance tasks","license":"MIT","main":"dist/index.js","types":"dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/macdonaldr93/maintenance-task-js.git"},"scripts":{"build":"tsc -p tsconfig.json"},"dependencies":{"tslib":"^2"},"devDependencies":{"@types/node":"^20"},"licenseText":"MIT License\n\nCopyright (c) 2023 Ryan Macdonald\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","_id":"@bloombug/maintenance-task@0.2.0","dist":{"shasum":"fdbfe4fdb08762233e653bb25f713a31db92a1b1","integrity":"sha512-EUv4/UZxFyfRjnmhHg4znavfLWJ15HULJSpOP8ST7WIMVmiLMGawtwxIXdc1ZPYeN0L8k+ld0JzIWqjTLc0bNQ==","tarball":"https://registry.npmjs.org/@bloombug/maintenance-task/-/maintenance-task-0.2.0.tgz","fileCount":33,"unpackedSize":21950,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCHj44wKRVaecGV3MJyg4sEIFefteynoIiV/TQEIFXrXAIgfA5sAPNXlX4kvsGu78ZtTmA94LJqhE8JImghLjlBLo0="}]},"_npmUser":{"name":"macdonaldr93","email":"hi@ryanmacdonald.ca"},"directories":{},"maintainers":[{"name":"macdonaldr93","email":"hi@ryanmacdonald.ca"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/maintenance-task_0.2.0_1701802012703_0.4623385342707671"},"_hasShrinkwrap":false}},"time":{"created":"2023-12-05T18:31:31.312Z","0.1.0":"2023-12-05T18:31:31.475Z","modified":"2023-12-05T18:46:53.094Z","0.2.0":"2023-12-05T18:46:52.880Z"},"maintainers":[{"name":"macdonaldr93","email":"hi@ryanmacdonald.ca"}],"description":"Some helpers for running maintenance tasks","repository":{"type":"git","url":"git+https://github.com/macdonaldr93/maintenance-task-js.git"},"author":{"name":"Ryan Macdonald","email":"hi@ryanmacdonald.ca"},"license":"MIT","readme":"# @bloombug/maintenance-tasks\n\nSome helpers for running maintenance tasks.\n\n## Getting started\n\n```bash\n# for npm\nnpm install @bloombug/liquidlite\n# for yarn\nyarn add @bloombug/liquidlite\n```\n\n## Usage\n\n```ts\nimport { PrismaClient } from '@prisma/client';\nimport {\n  MaintenanceRunner,\n  MaintenanceTask,\n} from '@bloombug/maintenance-tasks';\nimport { v4 } from 'uuid';\nimport logger from './logger';\n\nconst db = new PrismaClient();\n\nclass ExampleTask implements MaintenanceTask {\n  constructor() {\n    this.id = '5f609566-d722-4f4c-b296-689596a05e2b';\n    this.name = 'ExampleTask';\n    this.description = 'Iterates over all posts and creates a snapshot';\n    this.source = ExampleTask.toString();\n  }\n\n  collection() {\n    return db.post.findMany();\n  }\n\n  async process({ runner, taskRun }, post) {\n    await db.snapshot.create({\n      data: {\n        taskRunId: taskRun.id,\n        owner: post.author,\n        entity: post.id,\n        metadata: JSON.stringify(post),\n      },\n    });\n  }\n}\n\nconst runner = new MaintenanceRunner({\n  generateId: () => v4(),\n  logger,\n  taskRunCreate: data => db.taskRun.create({ data }),\n  taskRunUpdate: data => db.taskRun.update({ where: { id: data.id }, data }),\n});\nconst task = new ExampleTask();\n\nawait runner.run(task);\n```\n","readmeFilename":"README.md"}