{"_id":"@cskartikey/bolt-prisma","name":"@cskartikey/bolt-prisma","dist-tags":{"latest":"1.0.5"},"versions":{"1.0.5":{"name":"@cskartikey/bolt-prisma","version":"1.0.5","description":"Bolt for JavaScript Installation Store Extension - Prisma","main":"dist/index.js","scripts":{"bolt":"npm run prepare && npx ts-node src/tests/bolt-example.ts","prepare":"npm run build","build":"tsc","build:clean":"shx rm -rf ./dist ./coverage ./.nyc_output","lint":"eslint --fix --ext .ts src","mocha":"TS_NODE_PROJECT=tsconfig.json nyc mocha --config .mocharc.json \"src/**/*.spec.ts\"","prisma":"npx prisma migrate dev --name init && npx prisma generate","test":"npm run lint && npm run prisma && npm run mocha","coverage":"codecov","watch":"npx nodemon --watch 'src' --ext 'ts' --exec npm run build"},"repository":{"type":"git","url":"git+https://github.com/seratch/slack-bolt-extensions.git"},"keywords":["Prisma","OAuth","Bolt","Slack","Slack Platform","Slack Bot","Slack API"],"author":{"name":"Kazuhiro Sera"},"license":"MIT","bugs":{"url":"https://github.com/seratch/slack-bolt-extensions/issues"},"homepage":"https://github.com/seratch/slack-bolt-extensions#readme","dependencies":{"@prisma/client":"^3.15.2","@slack/logger":"^3.0.0","@slack/oauth":"^2.5.4","@types/node":"^17.0.45"},"devDependencies":{"bolt-extension-test-kit":"file:../bolt-extension-test-kit","prisma":"^3.15.2"},"_id":"@cskartikey/bolt-prisma@1.0.5","gitHead":"0245c048ece9454fb9fac0a7969d852a29c8ffb1","types":"./dist/index.d.ts","_nodeVersion":"18.20.3","_npmVersion":"10.7.0","dist":{"integrity":"sha512-Bip7vVQQ8l/PsOr3oTogjZD3y4aJs2+okhJ1hkDDitUeqGOs01la17brRg11ZZiFhrGqd/tLaQU2I5plriKuog==","shasum":"384e9c8f300ffa4ffcf67520d37a2fb25562d6de","tarball":"https://registry.npmjs.org/@cskartikey/bolt-prisma/-/bolt-prisma-1.0.5.tgz","fileCount":19,"unpackedSize":36779,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDIQ4z8iKkM/6whAYTA+u9leQSpofHnyMQqBYXRFy4sjAiBEmTczbtvtVk35/8q46QUKSj99islWv9hzk9rDGeOADw=="}]},"_npmUser":{"name":"cskartikey","email":"skartikey314@gmail.com"},"directories":{},"maintainers":[{"name":"cskartikey","email":"skartikey314@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/bolt-prisma_1.0.5_1725389056029_0.37420561027737764"},"_hasShrinkwrap":false}},"time":{"created":"2024-09-03T18:44:15.932Z","1.0.5":"2024-09-03T18:44:16.228Z","modified":"2024-09-03T18:44:16.504Z"},"maintainers":[{"name":"cskartikey","email":"skartikey314@gmail.com"}],"description":"Bolt for JavaScript Installation Store Extension - Prisma","homepage":"https://github.com/seratch/slack-bolt-extensions#readme","keywords":["Prisma","OAuth","Bolt","Slack","Slack Platform","Slack Bot","Slack API"],"repository":{"type":"git","url":"git+https://github.com/seratch/slack-bolt-extensions.git"},"author":{"name":"Kazuhiro Sera"},"bugs":{"url":"https://github.com/seratch/slack-bolt-extensions/issues"},"license":"MIT","readme":"## Bolt for JavaScript: Prisma InstallationStore\n\nThis module provides an `InstallationStore` implementation for [Prisma](https://www.prisma.io/) users.\n\n### Getting Started\n\nYou can create a simple Node app project using the following `package.json` and `tsconfig.json`. Of course, if you would like to use some build tool such as [webpack](https://webpack.js.org/), you can go with your own way and add the necessary dependencies.\n\n##### package.json\n\n```json\n{\n  \"name\": \"bolt-prisma-app\",\n  \"version\": \"0.1.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"start\": \"rm -rf dist/ && tsc && npx ts-node src/index.ts\"\n  },\n  \"author\": \"Kazuhiro Sera\",\n  \"license\": \"MIT\",\n  \"dependencies\": {\n    \"@slack/bolt\": \"^3.12.2\",\n    \"@seratch_/bolt-prisma\": \"^1.0.0\",\n    \"sqlite3\": \"4.2.0\",\n    \"@prisma/client\": \"^3.9.2\"\n  },\n  \"devDependencies\": {\n    \"prisma\": \"^3.9.2\",\n    \"ts-node\": \"^10.5.0\",\n    \"typescript\": \"^4.5.5\"\n  }\n}\n```\n\n##### tsconfig.json\n\n```json\n{\n  \"compilerOptions\": {\n    \"emitDecoratorMetadata\": true,\n    \"experimentalDecorators\": true,\n    \"allowJs\": true,\n    \"esModuleInterop\": true,\n    \"outDir\": \"dist\",\n  },\n  \"include\": [\"src/**/*\"]\n}\n```\n\n##### Create a new Slack app at api.slack.com/apps\n\nThe next step is to create a new Slack app configuration. You can use the following App Manifest configuration data for it.\n\n```yaml\ndisplay_information:\n  name: prisma-oauth-test-app\nfeatures:\n  bot_user:\n    display_name: prisma-oauth-test-app\noauth_config:\n  redirect_urls:\n    - https://xxx.ngrok.io/slack/oauth_redirect\n  scopes:\n    bot:\n      - commands\n      - chat:write\n      - app_mentions:read\nsettings:\n  event_subscriptions:\n    bot_events:\n      - app_mention\n  interactivity:\n    is_enabled: true\n  socket_mode_enabled: true\n```\n\n### Configure your Prisma schema\n\nThe next step is to configure your Prisma schema.\n\n##### prisma/schema.prisma\n\n```prisma\ngenerator client {\n    provider = \"prisma-client-js\"\n}\n\ndatasource db {\n    provider = \"sqlite\"\n    url      = env(\"DATABASE_URL\")\n}\n\nmodel SlackAppInstallation {\n    @@map(\"slack_app_installation\")\n\n    id                              Int       @id @default(autoincrement())\n    clientId                        String?   @map(\"client_id\")\n    appId                           String?   @map(\"app_id\")\n    enterpriseId                    String?   @map(\"enterprise_id\")\n    enterpriseName                  String?   @map(\"enterprise_name\")\n    enterpriseUrl                   String?   @map(\"enterprise_url\")\n    teamId                          String?   @map(\"team_id\")\n    teamName                        String?   @map(\"team_name\")\n    botToken                        String?   @map(\"bot_token\")\n    botId                           String?   @map(\"bot_id\")\n    botUserId                       String?   @map(\"bot_user_id\")\n    botScopes                       String?   @map(\"bot_scopes\")\n    botRefreshToken                 String?   @map(\"bot_refresh_token\")\n    botTokenExpiresAt               DateTime? @map(\"bot_token_expires_at\")\n    userId                          String?   @map(\"user_id\")\n    userToken                       String?   @map(\"user_token\")\n    userScopes                      String?   @map(\"user_scopes\")\n    userRefreshToken                String?   @map(\"user_refresh_token\")\n    userTokenExpiresAt              DateTime? @map(\"user_token_expires_at\")\n    incomingWebhookUrl              String?   @map(\"incoming_webhook_url\")\n    incomingWebhookChannel          String?   @map(\"incoming_webhook_channel\")\n    incomingWebhookChannelId        String?   @map(\"incoming_webhook_channel_id\")\n    incomingWebhookConfigurationUrl String?   @map(\"incoming_webhook_configuration_url\")\n    isEnterpriseInstall             Boolean   @default(false) @map(\"is_enterprise_install\")\n    tokenType                       String    @default(\"bot\") @map(\"token_type\")\n    installedAt                     DateTime  @default(now()) @map(\"installed_at\")\n    // This is an example custom property\n    memo                            String?\n}\n```\n\nYou can setup a file-based database by running the following comamnds:\n\n```bash\nnpm i\nexport DATABASE_URL=\"file:./dev.db\"\nnpx prisma migrate dev --name init\nnpx prisma generate\n```\n\n### Place your source code in the project\n\nThe last step is to add your code in the project and spin up your app. You can use the following code as-is.\n\n##### src/index.ts\n\n```typescript\nimport { App } from '@slack/bolt';\nimport { ConsoleLogger, LogLevel } from '@slack/logger';\nimport { PrismaClient } from '@prisma/client';\nimport { PrismaInstallationStore } from '@seratch_/bolt-prisma';\n\nconst logger = new ConsoleLogger();\nlogger.setLevel(LogLevel.DEBUG);\n\nconst prismaClient = new PrismaClient({log: [{emit: 'stdout', level: 'query'}]});\nconst installationStore = new PrismaInstallationStore({\n  // The name `slackAppInstallation` can be different\n  // if you use a different name in your Prisma schema\n  prismaTable: prismaClient.slackAppInstallation,\n  clientId: process.env.SLACK_CLIENT_ID,\n  logger,\n});\n\nconst app = new App({\n  socketMode: true,\n  appToken: process.env.SLACK_APP_TOKEN,\n  signingSecret: process.env.SLACK_SIGNING_SECRET,\n  clientId: process.env.SLACK_CLIENT_ID,\n  clientSecret: process.env.SLACK_CLIENT_SECRET,\n  stateSecret: process.env.SLACK_STATE_SECRET,\n  scopes: ['commands', 'chat:write', 'app_mentions:read'],\n  installerOptions: {\n    directInstall: true,\n  },\n  installationStore,\n  logger,\n});\n\napp.event('app_mention', async ({ event, say }) => {\n  await say({\n    text: `<@${event.user}> Hi there :wave:`,\n    blocks: [\n      {\n        type: 'section',\n        text: {\n          type: 'mrkdwn',\n          text: `<@${event.user}> Hi there :wave:`,\n        },\n      },\n    ],\n  });\n});\n\n(async () => {\n  await app.start();\n  logger.info('⚡️ Bolt app is running!');\n})();\n```\n\nFinally, your app is now available for running! Set all the required env variables, hit `npm start`, and then enable your public URL endpoint (you may want to use some proxy tool such as [ngrok](https://ngrok.com/)).\n\n```bash\nexport SLACK_CLIENT_ID=\nexport SLACK_CLIENT_SECRET=\nexport SLACK_SIGNING_SECRET=\nexport SLACK_STATE_SECRET=secret\nexport SLACK_APP_TOKEN=\nnpm start\n# Visit https://{your public domain}/slack/install\n```\n\nNow you can install the app into your Slack workspace from `https://{your public domain}/slack/install`. Enjoy!\n","readmeFilename":"README.md"}