{"_id":"@blockflow-labs/slack","_rev":"1-d9fd59e2a893a5eadda4b732ea003cf3","name":"@blockflow-labs/slack","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@blockflow-labs/slack","version":"1.0.0","keywords":[],"author":"","license":"ISC","_id":"@blockflow-labs/slack@1.0.0","maintainers":[{"name":"blockflow-labs","email":"blockflowlabs@gmail.com"}],"dist":{"shasum":"4118deddef3213676e06021ece0ba4e3c616c81a","tarball":"https://registry.npmjs.org/@blockflow-labs/slack/-/slack-1.0.0.tgz","fileCount":14,"integrity":"sha512-hv+9xNuouipHZDOcAcc4AaSDYxUhJrpbBJpr18KrxRMqjGze3h0Gw3CS+F2ow8T1BL6IhD02ct+AT5SGl3xJjg==","signatures":[{"sig":"MEQCIFhU/WnacIl6ccCQDFNsyGmJZphZCYFDj7ir40eFkNqaAiAWFCUoNiHfB5aqNrlsZLjgm3UEpYdRzGQKp4QOSSU6HQ==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":8913},"main":"dist/index.js","types":"dist/index.d.ts","gitHead":"3b2b42b2d1c75ddafcb96fa57f9d29b4e2de0b0f","scripts":{"build":"tsc","deploy":"npm run package && npm publish --access public --prefix dist","package":"npm run build && npm install -g ."},"_npmUser":{"name":"blockflow-labs","email":"blockflowlabs@gmail.com"},"_npmVersion":"9.8.1","description":"blockflow slack wrapper","directories":{},"_nodeVersion":"16.13.0","dependencies":{"axios":"^1.7.4"},"_hasShrinkwrap":false,"devDependencies":{"typescript":"^5.5.3","@types/node":"^20.14.9"},"_npmOperationalInternal":{"tmp":"tmp/slack_1.0.0_1723636974896_0.39803172789127506","host":"s3://npm-registry-packages"}},"1.0.1":{"name":"@blockflow-labs/slack","version":"1.0.1","description":"blockflow slack wrapper","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc","package":"npm run build && npm install -g .","deploy":"npm run package && npm publish --access public --prefix dist"},"keywords":[],"author":"","license":"ISC","devDependencies":{"@types/node":"^20.14.9","typescript":"^5.5.3"},"dependencies":{"axios":"^1.7.4"},"_id":"@blockflow-labs/slack@1.0.1","gitHead":"226850e9c88508a2542f943b5c981d225d240a3c","_nodeVersion":"16.13.0","_npmVersion":"9.8.1","dist":{"integrity":"sha512-T6xZN53O+0QM1RY8CGLfkZReb27FFIFc8VhlnwKkVhlaCd/RZg6HVzF2lyFmquwGtkRZnZnF+5seVL0htSl07g==","shasum":"b0aa6f0b34dfe4cf77b9ed94535f377fe5e60cc8","tarball":"https://registry.npmjs.org/@blockflow-labs/slack/-/slack-1.0.1.tgz","fileCount":15,"unpackedSize":12364,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDqhe7avWS/2lj0bDm6CWg0mDAAkD5mBVRK8SrMyzLE/QIhAPaA2P2VWFtYP7mQ880cDgWSbdpnICLxNaeghP278CM9"}]},"_npmUser":{"name":"blockflow-labs","email":"blockflowlabs@gmail.com"},"directories":{},"maintainers":[{"name":"blockflow-labs","email":"blockflowlabs@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/slack_1.0.1_1723638497611_0.44335653350031023"},"_hasShrinkwrap":false}},"time":{"created":"2024-08-14T12:02:54.793Z","modified":"2024-08-14T12:28:17.973Z","1.0.0":"2024-08-14T12:02:55.061Z","1.0.1":"2024-08-14T12:28:17.786Z"},"license":"ISC","keywords":[],"description":"blockflow slack wrapper","maintainers":[{"name":"blockflow-labs","email":"blockflowlabs@gmail.com"}],"readme":"# SlackNotification Service\n\n## Introduction\n\nSlack is a TypeScript class that provides an easy-to-use interface for sending rich, formatted messages to Slack channels using Slack's webhook API. It supports creating messages with multiple sections, fields, and colored attachments.\n\n## Features\n\n- Send simple text messages\n- Create structured messages with sections and fields\n- Support for colored attachments\n- Chainable methods for easy message construction\n- Written in TypeScript for improved type safety\n\n## Installation\n\n```bash\nnpm i @blockflow-labs/slack\n```\n\n## Usage\n\nFirst, import the Slack class:\n\n```typescript\nimport { Slack } from \"@blockflow-labs/slack\";\n```\n\nThen, create an instance of the SlackNotification class with your Slack webhook URL:\n\n```typescript\nconst slack = new Slack(\"YOUR_SLACK_WEBHOOK_URL\");\n```\n\n### Sending a Simple Message\n\n```typescript\nawait slack.send(\"Hello, Slack!\");\n```\n\n### Creating a Message with Sections and Fields\n\n```typescript\nawait slack\n  .addSection(\"New User Registered\")\n  .addFields([\n    { title: \"Name\", value: \"John Doe\" },\n    { title: \"Email\", value: \"john@example.com\" },\n  ])\n  .send();\n```\n\n### Creating a Message with Colored Attachment\n\n```typescript\nawait slack\n  .startAttachment(\"#36a64f\")\n  .addSection(\"Instance Started\")\n  .addFields([\n    { title: \"Instance ID\", value: \"i-1234567890abcdef0\" },\n    { title: \"Type\", value: \"t2.micro\" },\n  ])\n  .endAttachment()\n  .send();\n```\n\n### Full Example\n\nHere's a more complex example that demonstrates multiple features:\n\n```typescript\nimport { Slack } from \"@blockflow-labs/slack\";\n\nconst slack = new Slack(\"YOUR_SLACK_WEBHOOK_URL\");\n\ninterface InstanceData {\n  id: string;\n  type: string;\n  region: string;\n}\n\nasync function sendInstanceNotification(\n  instance: InstanceData,\n  status: \"started\" | \"stopped\"\n) {\n  const color = status === \"started\" ? \"#36a64f\" : \"#ff0000\";\n  const title = `Instance ${status.charAt(0).toUpperCase() + status.slice(1)}`;\n\n  try {\n    await slack\n      .startAttachment(color)\n      .addSection(title)\n      .addFields([\n        { title: \"Instance ID\", value: instance.id },\n        { title: \"Type\", value: instance.type },\n        { title: \"Region\", value: instance.region },\n      ])\n      .endAttachment()\n      .send(`EC2 Instance ${status}`);\n\n    console.log(`Instance ${status} notification sent successfully`);\n  } catch (error) {\n    console.error(`Failed to send instance ${status} notification:`, error);\n  }\n}\n\n// Example usage\nconst instance: InstanceData = {\n  id: \"i-1234567890abcdef0\",\n  type: \"t2.micro\",\n  region: \"us-west-2\",\n};\n\nsendInstanceNotification(instance, \"started\");\n```\n\n## API Reference\n\n### `new SlackNotification(webhookUrl: string)`\n\nCreates a new instance of the SlackNotification class.\n\n### `addSection(text: string): this`\n\nAdds a new section to the message with the given text.\n\n### `addFields(fields: Array<{ title: string, value: string }>): this`\n\nAdds a new section with fields to the message.\n\n### `startAttachment(color: string): this`\n\nStarts a new attachment with the specified color.\n\n### `endAttachment(): this`\n\nEnds the current attachment.\n\n### `send(text?: string): Promise<any>`\n\nSends the constructed message to Slack. Optionally, you can provide text that will appear as the main message text.\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n## License\n\nThis project is licensed under the MIT License.\n","readmeFilename":"README.md"}