{"_id":"@alexkeating/dao-data","name":"@alexkeating/dao-data","dist-tags":{"latest":"0.0.12"},"versions":{"0.0.12":{"name":"@alexkeating/dao-data","version":"0.0.12","type":"commonjs","homepage":"https://github.com/HausDAO/daohaus-monorepo#readme","issues":"https://github.com/HausDAO/daohaus-monorepo/issues?q=is%3Aissue+is%3Aopen","license":"MIT","keywords":["daohaus","dao-data","daohaus data"],"repository":{"type":"git","url":"git+ssh://git@github.com/HausDAO/daohaus-monorepo.git","directory":"libs/dao-data"},"main":"./src/index.js","typings":"./src/index.d.ts","dependencies":{"@daohaus/common-utilities":"0.0.11","ethers":"^5.6.5","react":"^18.2.0","date-fns":"^2.28.0","numbro":"^2.3.6","react-hook-form":"^7.33.1","cross-fetch":"^3.1.5","graphql":"^16.3.0","graphql-request":"^4.2.0","tslib":"^2.0.0"},"peerDependencies":{},"gitHead":"dc36ebdb7c308a5b8b6cf4dabe3f996a665bf250","description":"Our **DAO Data SDK** is a library that provides a set of functions for interacting with the DAO data. This includes querying subgraphs, querying our jobs, and other tools.","bugs":{"url":"https://github.com/HausDAO/daohaus-monorepo/issues"},"_id":"@alexkeating/dao-data@0.0.12","_nodeVersion":"18.7.0","_npmVersion":"8.15.0","dist":{"integrity":"sha512-dP4htD5EUwKIV+U0TAeRepcBS0N+8wz9zseP+M1X5qj1KV/uDVGytFXvPU9kWonkmQFmZ9wNm9bkuTskNYtpqg==","shasum":"319b3a618dca52e1f282976836f01cf2b1adc14c","tarball":"https://registry.npmjs.org/@alexkeating/dao-data/-/dao-data-0.0.12.tgz","fileCount":75,"unpackedSize":432377,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDxuIb2LFOL4GT8MWfD+GGuFax0GoZtMPlHW1wz3r4IswIgVKpjx0teFKBLA7DaujOEga+vw4uIaqU1KA+aBry86Cg="}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjElVLACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmqQXBAAimMlq3q7xNx2gWPLBeh3GS7sF11VQvfPRZY9oSuxT6D8B+Ge\r\nB6xahhQb/lrBNttgOOOTBt7/+IjR7c+JfDd12uRoGrCtSQXEoM9GNtUa4/Ii\r\nz7AKooFUIImK4roLiMiTOxM1lGFzwCClPiRfLg/oN6HyU00KgnSCIqn+7Xns\r\nJe+3UEzgPcrh88VUGXd+IPqwTgO3YE6D0/PYXoBI+gfNYuB1ek7/orj24m+7\r\npT9/prWyeDybKR89pm9NDdS42ZCEwUuIFqlTsrXKha80FVihAzCYcvNvQrFK\r\n4uQHqlkSnp/yQLdlWIVww0JCR6dEr8nzaU9PMDB3qAe7wfAl3Qp3M0/JkT+n\r\nMP0lnHnG1lMP+3U1ypVtqbbZH/pzHdon5Ld/MYTXrNUzU5DBtMUBLCnDiW46\r\nGkNqgnZgfhbhDDDUpqUjv5djwYNPzfBxcfuJ6oqxtTMW8N0ZP4DCs/szHTol\r\niTlGbGqGJpZ4K1pBxhCYaYCj9AbwcWfE+mIe+SOHhxYmZbyoSCnzGA5paZN4\r\nIszk6mxRI+qmKzaOSIJfFJUgBzDOOgUciGdh7fa9VWN47ucYiN+UVxbRlL5J\r\nfVyTWtLOxEV2iMs3JpKqcc5P1Q7Sl4bKWmwmRd87nUjgeyp+0vKNtlG4YF9b\r\nv8x6wSSqKaMRd1jVu0/OOkPQCMau75o7H9s=\r\n=y0Mt\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"alexkeating","email":"atk315315@gmail.com"},"directories":{},"maintainers":[{"name":"alexkeating","email":"atk315315@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/dao-data_0.0.12_1662145867278_0.6359919512030496"},"_hasShrinkwrap":false}},"time":{"created":"2022-09-02T19:11:07.212Z","0.0.12":"2022-09-02T19:11:07.478Z","modified":"2022-09-02T19:11:07.653Z"},"maintainers":[{"name":"alexkeating","email":"atk315315@gmail.com"}],"description":"Our **DAO Data SDK** is a library that provides a set of functions for interacting with the DAO data. This includes querying subgraphs, querying our jobs, and other tools.","homepage":"https://github.com/HausDAO/daohaus-monorepo#readme","keywords":["daohaus","dao-data","daohaus data"],"repository":{"type":"git","url":"git+ssh://git@github.com/HausDAO/daohaus-monorepo.git","directory":"libs/dao-data"},"bugs":{"url":"https://github.com/HausDAO/daohaus-monorepo/issues"},"license":"MIT","readme":"# DAO Data SDK\n\nOur **DAO Data SDK** is a library that provides a set of functions for interacting with the DAO data. This includes querying subgraphs, querying our jobs, and other tools.\n\nThis library was generated with [Nx](https://nx.dev).\n\n## Installation\n\nOnce this package is published on `npm` we'll have instructions in how to import and use in your apps. If you're using it from inside the monorepo, you can import directly from the package.\n\nThe package name for importing is `@daohaus/data`. If you're working on another package inside the monorepo, such as a feature or an app, you can reference it via this namespace, such as `import { Haus } from '@daohaus/dao-data';`\n\n## Building\n\nRun `nx build dao-data` to build the library.\n\n## Usage\n\nThe SDK provides a `Haus` class that you'll need to import into your component and instantiate it:\n\n```jsx\n// App.tsx\n\nimport { Haus } from '@daohaus/dao-data';\n\nconst haus = Haus.create();\n```\n\nOnce this is imported you can access the SDK methods that are available. For example, to use the functionality related to user profiles, you can use the following:\n\n```jsx\n// App.tsx\n\nconst profile = await haus.profile.get(address);\n\nconst profileDaoMemberships = await haus.profile.listDaosByMember({\n  networkId: ['0x5'],\n});\n```\n\nYou'll want to wrap this in a `try/catch` block to handle any errors that may occur like you would with other asynchronous calls.\n\n## Core Features\n\nWe'll be adding more documentation and detail to this section, so keep checking back.\n\n### Profile\n\nThe SDK provides a `profile` method that includes functionality related to profiles. This includes interacting with [Lens](https://lens.xyz/) to get a user's profile. We have a series of fallbacks in place if a user doesn't have a basic profile set. In the future we plan to interact with [Ceramic](https://ceramic.network/) to get a user's profile:\n\n```js\nconst haus = Haus.create();\n\nconst profile = await haus.profile.get('0x0');\n// console.log(profile)\n// {\n//   address: '0x0',\n//   ens: 'woodrowwilson.eth',\n//   image: 'ifshash',\n//   name: 'woody',\n//   description: '28th president of the united states of america',\n//   emoji: \"🦅\"\n// }\n\nconst profileDaoMemberships = await haus.profile.listDaosByMember({\n  memberAddress: '0x0',\n  networkId: ['0x5'],\n});\n// console.log(profileDaoMemberships)\n// [{\n//   address: '0x0somedaocontractaddress',\n//   name: 'potusDAO',\n//   ... more dao data\n// }]\n```\n\n### Query\n\nThe SDK provides a `query` method that can be used for querying the subgraph for DAO related data such as DAO members, proposals, and more.\n\n#### List queries\n\n```js\nconst daos = await haus.query.listDaos({\n  networkId: '0x5',\n});\n\nconst proposals = await haus.query.listProposals({\n  networkId: '0x5',\n  filter: { dao: '0x0' },\n});\n\nconst members = await haus.query.listMembers({\n  networkId: '0x5',\n  filter: { dao: '0x0' },\n  ordering: {\n    orderBy: 'shares'\n    orderDirection: 'asc'\n  },\n  pagination: {\n    pageSize: 4,\n    offset: 0,\n  }\n});\n```\n\n#### Find queries\n\n```js\nconst dao = await haus.query.findDao({\n  networkId: '0x5',\n  dao: '0x0',\n  includeTokens: true,\n});\n\nconst proposal = await query.findProposal({\n  networkId: '0x5',\n  dao: '0x0',\n  proposalId: '3',\n});\n\nconst member = await query.findMember({\n  networkId: '0x5',\n  dao: '0x0',\n  memberAddress: '0x123',\n});\n```\n\n#### Optional Query Parameters\n\n**filters**\n\nProvide any query the graph supports on fields within the entity you are querying.\n\nexample:\n\n```js\n{\n  createdAt_gte: '1656693140'\n}\n\n{\n  createdAt_lt: '1656693140',\n  totalShares_gt: '10000000000000000000'\n}\n```\n\n[The Graph Docs](https://thegraph.com/docs/en/developer/graphql-api/#all-filters)\n\n[Subgraph Schema](https://github.com/HausDAO/daohaus-monorepo/blob/develop/apps/v3-subgraph/schema.graphql)\n\n**ordering**\n\nProvide a field to order by and the order direction (asc or desc).\n\nexample:\n\n```js\n{\n  orderBy: 'createdAt',\n  orderDirection: 'asc'\n}\n\n{\n  totalShares: '1656693140',\n  orderDirection: 'desc'\n}\n```\n\n**pagination**\n\nProvide options for pagination. The SDK supports offest and cursor pagination. Offset pagination will return query options for fetching the next page and previous page. Cursor pagination is better for larger data sets, defaults sort to the ID field and provides query options for fetching the next page.\n\n```js\n{\n  pageSize: '20',\n  offset: '0'\n}\n\n{\n  pageSize: '2000',\n  lastId: '0'\n}\n\n## Running Unit Tests\n\nRun `NODE_OPTIONS=--experimental-vm-modules nx run dao-data:test` to execute the unit tests via [Jest](https://jestjs.io).\n\nBe sure to include the `NODE_OPTIONS=--experimental-vm-modules` flag when running the tests or else the tests will throw an error.\n\n## Generating GraphQL Schema and Types\n\n1. When updates are deployed to the Daohaus V3 subgraphs, a new schema should be generated\n\n   run `nx generate-gql-schema dao-data` to create a new `src/subgraph/schema.graphql` file\n\n2. When there is a new schema or new query files are added, new types should be generated\n\n   run `nx generate-gql-types dao-data` to create type files for each query file in `src/subgraph/queries`\n```\n","readmeFilename":"README.md"}