{"bugs":{"url":"https://github.com/textileio/js-threads/issues"},"dist":{"shasum":"0c0f5b846b321e98186850f7aca48de5b88d5f62","tarball":"https://registry.npmjs.org/@textile/threads-client/-/threads-client-1.0.0-alpha.1.tgz","fileCount":22,"integrity":"sha512-CIcS9dVhoX6drBsbPHSW6uWprZe50jcNlStR+0l4ETdnnkIa24bCasPz/0wNvqCOM1vj+IOzwp/hdsP7WYMXKg==","signatures":[{"sig":"MEYCIQCC5pZcl4UiSYLFPKEgh0O4oV++APjtAS3aD6YZa+SALAIhAOo9Jy7kXyi/GI+/1j+FwivX6cw+8/dyhj1RLB1ycAJT","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":230464,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfa7GkCRA9TVsSAnZWagAAs/sP/04Z2+2FZY091y2aw4tg\nl0EEYbH9L9Kkii+V6mtStxJR008kyjsDq8GaVGmIqW4mW6HbLPpNdF+QyayZ\n2bg8AuTuH9uw6mNGd9n68E3HRo/oMVr71lTP3vfTJC6TMd3lcjy/KOPcfHh9\n66x5VC2zBfY2ZOMuO2e2J6Djw7l+54hCki7qAMAnTXD1tR/b2HO8JDK1YLUI\nrBACdcKo6ThenK7YgcBSsWhvvrcnT8hlkJzqa//SQJcUEm4TdOamVwrengxi\nTvcGsHsTL5fPDdlrx0PYVuyuguNZjlPEBbNXm+/xYkdyrKm9E4lklad1nMHN\nFjVXO27bC2gKIOQqrowBonX43n9ZMAzvuEi8dOcOlerHCiukLa5EQMxVIU+7\ntngUzCeD3pik9vV0hIoH+TQg9AwQL9Wf+DT0A0v9vjr/yazB3/fkAxdspBf8\n22W/Z0y0hBxy56CTXj0ocG4NHc/r3DgoTQBETRD8Q6UE4eD6Ietsc0m34iB0\nPymS5Woj+4WK2tLFbO2qLBlk1QPa2dqX9LJ43clcjLgxAX/IO+YwEqrLMc06\nntBvuaykt8403pYpYInrt9hUvzkUSTX3BryCEzft6CxC5FOwrqicf5svtJg2\nT8HZogB737DYNGd4xmhEqnWMB5f7AsmcMrDRlQzkw0f1epacJhCWL3fNSdAG\nwEDg\r\n=aSSW\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/index","name":"@textile/threads-client","types":"dist/index","readme":"# Threads Client _(threads-client)_\n\nServer-side (remote) event sourced storage layer for Textile's Threads protocol & database\n\n[![Textile](https://img.shields.io/badge/made%20by-Textile-informational.svg)](https://textile.io)\n[![License](https://img.shields.io/github/license/textileio/js-threads.svg)](../../LICENSE)\n[![npm (scoped)](https://img.shields.io/npm/v/@textile/threads-client.svg)](https://www.npmjs.com/package/@textile/threads-client)\n\nThis sub-package is part of [`js-threads`](https://github.com/textileio/js-threads). See the [top-level documentation](https://textileio.github.io/js-threads) for details.\n\n## Install\n\n```\nnpm install @textile/threads-client\n```\n\n## Usage\n\n**create a threads client**\n\n```typescript\nimport {Client} from '@textile/threads'\n\nconst client = new Client()\n```\n\n**create a threads client using Textile Hub APIs**\n\n[Read the full Hub API documentation](https://textileio.github.io/js-hub/docs).\n\n**create a store**\n\n```typescript\nimport {Client, Identity, ThreadID, UserAuth} from '@textile/threads'\n\nasync function newToken (client: Client, user: Identity) {\n  const token = await client.getToken(user)\n  return token\n}\n\nasync function createDB (client: Client) {\n  const thread: ThreadID = await client.newDB()\n  return thread\n}\n\nasync function collectionFromObject (client: Client, thread: ThreadID, name: string, obj: any) {\n  await client.newCollectionFromObject(thread, name, obj)\n  return\n}\n\nasync function setup (auth: UserAuth) {\n  const user = await Client.randomIdentity()\n\n  const client = await Client.withUserAuth(auth)\n\n  const token = await newToken(client, user)\n  \n  const thread = await createDB(client)\n\n  const astronaut = {name: 'Buzz', missions: 3}\n  await collectionFromObject(client, thread, 'astronauts', astronaut)\n}\n```\n\n**get all instances**\n\n```typescript\nimport {Client, ThreadID} from '@textile/threads'\nasync function findEntity (client: Client, threadId: ThreadID, collection: string) {\n  const found = await client.find(threadId, collection, {})\n  console.debug('found:', found.instancesList.length)\n}\n```\n\n**add an instance**\n\n```typescript\nimport {Client, ThreadID} from '@textile/threads'\n// matches YourModel and schema\nasync function create (client: Client, threadId: ThreadID, collection: string) {\n  const created = await client.create(threadId, collection, [{\n    some: 'data',\n    numbers: [1, 2, 3]\n  }])\n}\n```\n\n## React Native\n\nThe following has been tested on **Android Only**.\n\n`js-thread-client` should be compatible with React Native. Here are some helpful pointers if you find issues testing it out.\n\n### Connecting to the threads daemon\n\nYou can run the daemon released as part of the early preview. To do so, \n\n```sh\ngit clone git@github.com:textileio/go-threads.git\ncd go-threads\ngo run threadsd/main.go\n```\n\n**Make daemon available to RN**\n\nYou can make the daemon API port available to your app with,\n\n```sh\nadb reverse tcp:6007 tcp:6007\n```\n\nAltenatively, you can ensure this is run whenever you run your app by modifying your `package.json` as follows.\n\n```json\n{\n  ...\n  \"scripts\": {\n    ...\n    \"bind\": \"adb reverse tcp:6007 tcp:6007\",\n    \"android\": \"npm run bind && npx react-native run-android\",\n    ...\n  },\n  ...\n}\n```\n\nThen, run your app with,\n\n```sh\nnpm run android\n```\n\n### Buffer not found\n\n`js-threads-client` relies on Buffer being available. To make `Buffer` available in your project, you may need to introduce a shim. Here are the steps.\n\n**install rn-nodeify**\n\nread more about [rn-nodeify](https://github.com/tradle/rn-nodeify#readme).\n\n```js\nnpm install -G rn-nodeify\n```\n\n**run nodeify in the root of your project**\n\n```js\nrn-nodeify --install buffer --hack\n```\n\nThis will create a `shim.js` in the root of your project. You need to import this at the top of your apps entry file (e.g. `indes.js`). \n\nThe top of `index.js` would look like, \n\n```js\nrequire('./shim')\n...\n```\n\n**add nodeify to your postinstall**\n\nEnsure that the shim is still configured after any module updates. Inside `package.json` add the following line to your `scripts` tag,\n\n```json\n{\n  ...\n  \"scripts\": {\n    ...\n    \"postinstall\": \"rn-nodeify --install buffer --hack\"\n  }\n}\n```\n","gitHead":"148d04d3e8ee24d06e4b2aca97e87e1fd154bc36","license":"MIT","scripts":{"build":"npx tsc -b tsconfig.json","clean":"npx rimraf ./dist ./tsconfig.tsbuildinfo","prepare":"npm run build","prebuild":"npm run clean","test:browser":"polendina --cleanup --timeout 60 src/**/*.spec.ts --webpack-config ../../webpack.test.js","prepublishOnly":"npm run build"},"_npmUser":{"name":"carsonfarmer","email":"carson@textile.io"},"homepage":"https://github.com/textileio/js-threads#readme","references":[{"path":"../id"},{"path":"../multiaddr"},{"path":"../core"},{"path":"../context"},{"path":"../security"},{"path":"../transport"}],"repository":{"url":"git+https://github.com/textileio/js-threads.git","type":"git"},"_npmVersion":"lerna/3.22.1/node@v13.10.1+x64 (darwin)","description":"Server-side (remote) event sourced storage layer for Textile's Threads protocol & database","directories":{},"maintainers":[{"name":"asutula","email":"aaron@textile.io"},{"name":"carsonfarmer","email":"carson@textile.io"},{"name":"andrewxhill","email":"andrew@textile.io"},{"name":"sanderpick","email":"sanderpick@gmail.com"},{"name":"textileio","email":"sander@textile.io"}],"_nodeVersion":"13.10.1","dependencies":{"cids":"^0.8.3","to-json-schema":"^0.2.5","@textile/crypto":"^0.1.0","google-protobuf":"^3.10.0","@textile/context":"^0.6.9","@types/multibase":"^0.6.0","@textile/security":"^0.2.8","@textile/multiaddr":"^0.0.25","@textile/threads-id":"^0.1.14","@textile/threads-core":"^0.3.2","@types/to-json-schema":"^0.2.0","@types/google-protobuf":"^3.7.2","@textile/grpc-transport":"^0.0.4","@improbable-eng/grpc-web":"^0.13.0","@textile/threads-client-grpc":"^1.0.0-rc1"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/threads-client_1.0.0-alpha.1_1600893347968_0.3621675491575591","host":"s3://npm-registry-packages"},"_id":"@textile/threads-client@1.0.0-alpha.1","version":"1.0.0-alpha.1"}