{"bugs":{"url":"https://github.com/textileio/js-threads/issues"},"dist":{"shasum":"9038f3f28acb5cd8f86c3a0d3fc3e8af17112507","tarball":"https://registry.npmjs.org/@textile/threads-client/-/threads-client-1.4.0-alpha.4.tgz","fileCount":24,"integrity":"sha512-v3HHeEk/E8NVsPhY+hhR8Nlw9kW7Z7HfH+rE4KgjOD8Hdb3jdMY50I/p8anOkIzS2EDkt9CSK9BtugsFlnzjSg==","signatures":[{"sig":"MEUCIAJC6vCzWF/DYcLMmPtK2AtnQyYOHs+GhLvHfOYYmF0sAiEAoaBbjh1JDDyKVE3pBgbin47biQ7pxlMJa/1qPb5FCCA=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":1177176,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJf0SkkCRA9TVsSAnZWagAAn+QQAIUgYdQdLFPZ1HSKdhVE\nhupYwPdeqQ7hK4JOZonT0G40yeE65QDWbJkbAdMNzN+upNAxVaI7dMJT0zkD\nrorGOjgUB/orMlYcpK5LZlt58d+VdSjnxf8piE08D9WImxkF5ajm1XZeo5IH\nD6byYaxDagn1i5SaV+lEuJckPeDTIdL2qJ6xyry1uHjgD30kIJ7EIzdd0gSC\nPp2Au0UP//yMml+efhBBzsT8izXmmjrWIgtGFcu5kFdvKwJT1ZYrb5kiA6wG\nTlgxf1MJOFx7P4Qztj6q+7gee+IRdb9W8rQwmydtrsWVU7zz5WH9vlIBqoA5\nNyVrgAGlUrpfQcBeg4d3t573wB9dkUocdvcwG0Vscezfk+oNf28qveuaUiiz\noazW2HNWiiYMiaoY+ttZbDsKTymOWo3XdQkAdFGCK0cKpK9OJcXIHQmNAvw9\nsDvxdNMSKLr+kqBmbHQ43ZGFc+3JMw1qLeN80U6x3JOeEff6VDhQFu3gPeYY\nxX00J8UDi86BT+gvO9U34a/nTdPQl7QYWoC2cb9i5GQ6Tc6cduKqxwFvbvBJ\nKNeRtq0rK5zaRoGGV+H88xfH8MMaT8Su1YYDjVSSLsmBFcxSn9wVQc260aAE\n2r2Q47faY0Wthleu+EWe1zzn/VPZdQBIyzaHHP53hKvxT9t9EfAboVbqHOvt\nQMdA\r\n=Q/GO\r\n-----END PGP SIGNATURE-----\r\n"},"main":"dist/cjs/index.js","name":"@textile/threads-client","types":"dist/cjs/index.d.ts","module":"dist/esm/index.js","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, PrivateKey} 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, obj, { name })\n  return\n}\n\nasync function setup (auth: UserAuth) {\n  const user = PrivateKey.fromRandom()\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.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","gitHead":"dc1fc1ca34def706cc1cd8ef4308a13c3da08b41","license":"MIT","scripts":{"build":"npm run build:cjs","clean":"npx rimraf ./dist","build:cjs":"npx tsc -b ./tsconfig.json","test:browser":"polendina --cleanup --timeout 60 src/**/*.spec.ts --webpack-config ../../webpack.test.js"},"_npmUser":{"name":"carsonfarmer","email":"carson@textile.io"},"homepage":"https://github.com/textileio/js-threads#readme","repository":{"url":"git+https://github.com/textileio/js-threads.git","type":"git"},"_npmVersion":"lerna/3.22.1/node@v14.15.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":"14.15.1","dependencies":{"to-json-schema":"^0.2.5","@textile/crypto":"^2.0.0","@textile/context":"^0.10.0-alpha.4","@textile/security":"^0.7.0-alpha.4","@textile/multiaddr":"^0.4.0-alpha.3","@textile/threads-id":"^0.4.0-alpha.3","@types/to-json-schema":"^0.2.0","@textile/grpc-transport":"^0.3.0-alpha.3","@improbable-eng/grpc-web":"^0.13.0","@textile/threads-client-grpc":"^1.0.2"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"readmeFilename":"README.md","_npmOperationalInternal":{"tmp":"tmp/threads-client_1.4.0-alpha.4_1607543076306_0.12851368864601076","host":"s3://npm-registry-packages"},"_id":"@textile/threads-client@1.4.0-alpha.4","version":"1.4.0-alpha.4"}