{"bugs":{"url":"https://github.com/trufflesuite/truffle/issues"},"dist":{"shasum":"a5263da96a7b2cfbf451d918da441b5a1820ced2","tarball":"https://registry.npmjs.org/@truffle/dashboard-message-bus-client/-/dashboard-message-bus-client-0.1.0-alpha.2.tgz","fileCount":30,"integrity":"sha512-DakjH4hAfux/qE+uL7W1ICEMsMqUBPs/nbJ0bvikst83cPTEnahcro9ndzPzaVvyobDrHh4eZW5i0GzQJfEj/g==","signatures":[{"sig":"MEQCIB74ofqWe1j3pG/wL+oBItOTAX9fxhgyHGrE6eaK48+rAiAisNbv6JIQCs0/11N7ccM0uvGiq4eFavqf7SL6Z0UCFg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":55693,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJiteI/ACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmoTuw//SIlb1QdSHyDSntUrOBERruWJEZCNITT6udiVPzworxH5sf33\r\nn4XFMOKlKR3+Dwr/8z3iVKzFPBMY/yRaT9MjRAd4qz6d6N+NOfygQiv8+hCg\r\n4OmIORliqfQUjO5E2/ZGpkeSH1BqZxPH7VHuj7k1UeXTqhNv/3IjQGbxltgo\r\nIvzh5kYPBaWGzfXWffBs1tbK4FPLMd/fFyTIVR5ACKR8I0q5EcreICAzkd6n\r\ngAw7MmxdfSI9Y2tke8r7N+/HTIJa8DB2TCXYJhqajRTKcGs8bJvxUgcWsWEh\r\n/6DGabW3xuTkLu/PqiPeJr37xwRQacnCiVYWUId0H6HPlXpBn6vOvItF0p6B\r\nQBt1UXUAD250YwksSEgk58UwI40dTpIPpnMT9f/vFDBX+UKNxD4hB4m7l7s3\r\nD3H+WAuwaf5vsqLQsQ9ZN+gvxrhxUxEQj59f0fqg+E5PYPcP48xsTMyCMysr\r\nl3b30/GYUR8rHX1yO6u1UhIIBKqFJCzlfyiepjF0irV9XYW4OFECJKEpK10+\r\naErH5PVQcUOMbdYctmByD58IZiHEIXF6oI3TQ/H/E+tTAq5K+7Jbb4RRY7yV\r\nzs2uCi9+Vm1mQfrNOA7pemu38V0hOzRef+XHYtLu4KJvqRZX6zEalEMizpMB\r\nBH/QNC3PI1kKJdmwfjqO2DrEsLCpxH69+bk=\r\n=TCNx\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index.js","name":"@truffle/dashboard-message-bus-client","types":"dist/index.d.ts","readme":"# `@truffle/dashboard-message-bus-client`\n\nThis library is used for connecting with the message bus that powers the\nTruffle dashboard.\n\n## Usage\n\n### Connecting to the message bus and producing a message\n\n```ts\nimport { DashboardMessageBusClient } from \"@truffle/dashboard-message-bus-client\";\n\nconst client = new DashboardMessageBusClient({ port, host });\n\nconst message = {\n  type: \"helloWorld\",\n  id: new DateTime().getTime(),\n  payload: {\n    hello: \"world\"\n  }\n};\n\nconst messageLifecycle = await client.publish(message);\n```\n\n#### The lifecycle of published messages\n\nPublishing a message creates a lifecycle for that message. The lifecycle is tracked by the publisher as an object of type `PublishedMessageLifecycle<MessageType, ResponseType>`.\n\nPublish message lifecycles terminate in one of three ways:\n\n1. Receipt of a corresponding response message\n2. Invalidation of the message\n3. Abandonment of the message\n\n##### Waiting for a response to a message\n\nTo enable request/response messaging (e.g. proxied JSON-RPC messages), publish\nlifecycles contain a promise that resolves when a response to the originally\npublished message is received.\n\n```ts\nconst response = await publishLifecycle.response;\n```\n\n##### Abandoning messages\n\nTo allow for fire-and-forget messages (e.g. event data), simply call the\n`abandon` method on the lifecycle object.\n\n**Important**: If the `abandon` method of the publish lifecycle is not called,\nthe process will hang forever on exit, as it will forever be waiting for a\nresponse that will never arive.\n\n```ts\nawait messageLifecycle.abandon();\n```\n\n##### Invalidating messages (aka message cancellation)\n\nThe consumer of a published message often will need to perform some longer\nrunning operation as a result of that message. To cancel that work, or to\ncommunicate to the consumer that the message is no longer valid, simply call\n`cancel` on the publish lifecycle.\n\n```ts\nawait messageLifecycle.invalidate();\n```\n\n### Consuming and responding to messages\n\nMessages can be consumed by calling the `subscribe` method of the client. The\n`subscribe` method returns a `DashboardMessageSubscription` object. This object\nemits `message` events whenever messages are received that match the\nsubscription's filter.\n\nReceived messages are wrapped up in a lifecycle object similar to the one used for publishing messages, however there's only a single `respond` method.\n\n```ts\nimport { DashboardMessageBusClient } from \"@truffle/dashboard-message-bus-client\";\n\nconst client = new DashboardMessageBusClient({ port, host });\n\n// omitting the type string in the options object will return a subscription\n// for all messages\nconst subscription = client.subscribe({\n  type: \"helloWorld\"\n});\n\nsubscription.on(\"message\", receivedMessageLifecycle => {\n  const helloTarget = receivedMessageLifecycle.message.payload.hello;\n\n  if (helloTarget.toLowerCase() === \"world\") {\n    // respond by passing your response payload directly to the response\n    await receivedMessageLifecycle.respond({\n      someArbitraryResponse:\n        \"Why hello there. Pleased to make your acquaintance\"\n    });\n  } else {\n    await receivedMessageLifecycle.respond({\n      error: `I'm sorry, you have the wrong number. This is world, not \"${helloTarget}\"`\n    });\n  }\n});\n```\n","gitHead":"4ad7d2c4c7ba31fc5e02c831d615cc58e863c2cd","license":"MIT","scripts":{"build":"tsc","prepare":"yarn build"},"_npmUser":{"name":"eggplantzzz","email":"pobol234@gmail.com"},"homepage":"https://github.com/trufflesuite/truffle/tree/master/packages/dashboard-message-bus-client#readme","keywords":["ethereum","etherscan","ipfs","solidity","verify-source","sourcify","compile"],"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"git+https://github.com/trufflesuite/truffle.git","type":"git","directory":"packages/dashboard-message-bus-client"},"_npmVersion":"lerna/4.0.0/node@v16.15.0+arm64 (darwin)","description":"Client library for accessing the truffle dashboard's message bus","directories":{"lib":"lib"},"maintainers":[{"name":"cliffoo","email":"cliffzhang08@gmail.com"},{"name":"benjamincburns","email":"benjamin.c.burns@gmail.com"},{"name":"kevinbluer","email":"kevin@bluer.com"},{"name":"tenthirtyone","email":"ASherbuck@gmail.com"},{"name":"lsqproduction","email":"ll@trufflesuite.com"},{"name":"kevinweaver","email":"kevinweaver2@gmail.com"},{"name":"leeftk","email":"leandro.faria@consensys.net"},{"name":"gnidan","email":"nick@gnidan.org"},{"name":"haltman","email":"harry.j.altman@gmail.com"},{"name":"eggplantzzz","email":"pobol234@gmail.com"},{"name":"fainashalts","email":"fainashalts@gmail.com"},{"name":"rkalis","email":"roscokalis@gmail.com"},{"name":"cds-amal","email":"cds.sudama@gmail.com"}],"_nodeVersion":"16.15.0","dependencies":{"axios":"^0.24.0","debug":"^4.3.1","delay":"^5.0.0","isomorphic-ws":"^4.0.1","@truffle/promise-tracker":"^0.1.0-alpha.2","@truffle/dashboard-message-bus-common":"^0.1.0-alpha.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","devDependencies":{"typescript":"^4.1.4","@types/node":"^16.11.6","@types/debug":"^4.1.5","tiny-typed-emitter":"^2.1.0"},"_npmOperationalInternal":{"tmp":"tmp/dashboard-message-bus-client_0.1.0-alpha.2_1656087103658_0.847007255387304","host":"s3://npm-registry-packages"},"_id":"@truffle/dashboard-message-bus-client@0.1.0-alpha.2","version":"0.1.0-alpha.2"}