{"_id":"@ash0080/hasura-sdk","_rev":"5-0c42b9c28e6dc2f1c19f6ff973740149","time":{"created":"2021-12-31T07:22:08.252Z","1.0.0":"2021-12-31T07:12:09.563Z","modified":"2022-04-04T15:45:15.489Z","1.0.1":"2021-12-31T07:22:08.540Z","1.1.0":"2022-01-08T07:26:19.676Z"},"name":"@ash0080/hasura-sdk","dist-tags":{"latest":"1.1.0"},"versions":{"1.0.1":{"name":"@ash0080/hasura-sdk","version":"1.0.1","description":"Hasura Healthz/Schema/Metadata/PGdump API SDK. Written in TypeScript, Carefully tested and fixed some official bugs","main":"build/main","typings":"build/main/index.d.ts","module":"build/module/index.js","repository":{"type":"git","url":"git+https://github.com/ash0080/hasura-sdk.git"},"license":"MIT","keywords":[],"directories":{"test":"test"},"scripts":{"test":"env $(cat .env) tap --ts -j1 -R=specy -o report.tap","lint":"eslint . --cache --fix --ext .ts,.tsx","prebuild":"del-cli dist","build":"tsc -p tsconfig.json && tsc -p tsconfig.module.json","start":"node dist/index.js","prepublishOnly":"pnpm build  --enable-pre-post-scripts"},"author":"","dependencies":{"@types/node":"^17.0.4","phin":"^3.6.1","serialize-error":"8.1.0","type-fest":"^2.8.0"},"devDependencies":{"@typescript-eslint/eslint-plugin":"^5.8.0","@typescript-eslint/parser":"^5.8.0","console-table-printer":"^2.10.0","del-cli":"^4.0.1","eslint":"^8.5.0","knex":"^0.95.15","msw":"^0.36.3","pino":"^7.6.1","pino-pretty":"^7.3.0","tap":"^15.1.5","ts-node":"^10.1.0","typescript":"^4.5.4"},"gitHead":"aba9dd4344965cec45574bec5c402d77a0fc0bca","bugs":{"url":"https://github.com/ash0080/hasura-sdk/issues"},"homepage":"https://github.com/ash0080/hasura-sdk#readme","_id":"@ash0080/hasura-sdk@1.0.1","_nodeVersion":"14.18.2","_npmVersion":"8.3.0","dist":{"integrity":"sha512-gwrMH5ooKldtTARB0ofuVnlsYA6XpfEO+X2j/BDujH2Y/urhj6tWPnf9ct8BmQgnBFPeSzd4aCf/9/KcVYsjow==","shasum":"4410528c9c24671daec969139ba036314db37266","tarball":"https://registry.npmjs.org/@ash0080/hasura-sdk/-/hasura-sdk-1.0.1.tgz","fileCount":163,"unpackedSize":992545,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhzq+gCRA9TVsSAnZWagAAnnEP/2Ir/D4njA+xgLi/E2WH\nKdsooyM6fhMMirNMIPxGQldAypP4YZJPwyXhFFOWcmVnFoWsR+GNom+ZYy9e\nMrTULOp2llK5b7tPcVOIdnUBv91Xrb+1sIlX/g1LQOaJktdGZ3XG5n+cCqM0\nXJJBe/dEY0OrlkgLkX8VwMU6K/AutOgae5QbPS25rWvkD7rQbQQM7mPOI4na\n2aONM2Zfau7bTqyotm4PT5DG8J2/KDIJoKw0/MsRVLCuFerJ9idqWdxHzH2D\nH8NP48i7gOZI2bLPNCu5Fbon2vZCn+GceWxGjI3REPX4A1fPc+bWpDU4FUvj\nNDksFPXK+I0dGB4tSMAo1FQE6OJtr+veJ/TDx4aT0R8fY34lG9q8OOqjyiaP\nhOQIxnSV+v4RsLlnX/AuaEmkidVLAxzwMvFw+fSSch5OOshJqQV+vWUkQSlI\nhALF2BvDjUXfhj1XfDTtLl/YMTYm9vST+jUtlH+gXdqvM2xAtY76ePN55Cy3\nXSwdfnQsqdzoI4Ikc2FRvBx7feso4IvJGFXeoqt1zVK6hh/YjCN/FOYr8+5f\nZ9eGpTiJrKAx4eZyXjPQvDwAyVDF2ZWfpwxmXWMbgLIpwy8DWZ4Gs9laa4HV\nbRb4bJwi+eBv0fLAd8zuUKFRtb8bgXV9nmigHi/LvpCf9gtqO+FyfCYjY7xA\nb7Ee\r\n=5pmg\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDpISdIXbG8N5uVUBKzRSPFbReuB2yd8IQEuMLKJfvc4QIhALdUz4wpiZONEaXt7qxG53jFqrV1xPnoD3WTVtWJ3n1y"}]},"_npmUser":{"name":"ash0080","email":"ash0080@gmail.com"},"maintainers":[{"name":"ash0080","email":"ash0080@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hasura-sdk_1.0.1_1640935328303_0.7995795167442585"},"_hasShrinkwrap":false},"1.1.0":{"name":"@ash0080/hasura-sdk","version":"1.1.0","description":"Hasura Healthz/Schema/Metadata/PGdump API SDK. Written in TypeScript, Carefully tested and fixed some official bugs","main":"build/main","typings":"build/main/index.d.ts","module":"build/module/index.js","repository":{"type":"git","url":"git+https://github.com/ash0080/hasura-sdk.git"},"license":"MIT","keywords":[],"directories":{"test":"test"},"scripts":{"test":"env $(cat .env) tap --ts -j1 -R=specy -o report.tap -w test/**/*.ts","lint":"eslint . --cache --fix --ext .ts,.tsx","prebuild":"del-cli dist","build":"tsc -p tsconfig.json && tsc -p tsconfig.module.json","start":"node dist/index.js","prepublishOnly":"pnpm build  --enable-pre-post-scripts"},"author":"","dependencies":{"@types/node":"^17.0.4","phin":"^3.6.1","serialize-error":"8.1.0","type-fest":"^2.8.0"},"devDependencies":{"@typescript-eslint/eslint-plugin":"^5.8.0","@typescript-eslint/parser":"^5.8.0","console-table-printer":"^2.10.0","del-cli":"^4.0.1","eslint":"^8.5.0","knex":"^0.95.15","msw":"^0.36.3","pino":"^7.6.1","pino-pretty":"^7.3.0","tap":"^15.1.5","ts-node":"^10.1.0","typescript":"^4.5.4"},"gitHead":"aba9dd4344965cec45574bec5c402d77a0fc0bca","bugs":{"url":"https://github.com/ash0080/hasura-sdk/issues"},"homepage":"https://github.com/ash0080/hasura-sdk#readme","_id":"@ash0080/hasura-sdk@1.1.0","_nodeVersion":"14.18.2","_npmVersion":"8.3.0","dist":{"integrity":"sha512-Uoz+6flO8KK73fuomARmjXFfxvYeQwPSpn0L7XF2C8OkMoNABiZJ5Zr06aGKX9vZEaxR83dx5Ob6JhiICAOChg==","shasum":"eb552f036444a6f374d0c3472caf157708714288","tarball":"https://registry.npmjs.org/@ash0080/hasura-sdk/-/hasura-sdk-1.1.0.tgz","fileCount":97,"unpackedSize":258188,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJh2TybCRA9TVsSAnZWagAAseMQAJo+tQLyWDzOukzJ/K6c\nqZW+w9zkMAysJzDW7wrgdODstgMoXQdE/rsgJHnxIyzUseN7FGXvLUD2NOJJ\nBMgNp+6SZJYDnUkO3Ub68F7UHK6R8MaKTHnu1ZfTp6OLrDPhN76/pJekHIp5\nfLPM79VsMxEDMp7WHvka5V0nl1NSMvKTxor5XUrLFptqEaCL6UT9To1NXn1o\nR+dEofAcEQP78Q3eD8AmUjtZSu/Q5JWest7WeNEqq9WH16uLs4hOIx89MDd0\nB+w2e49Dzum/W2ataGPnzUwwj19D2YwobXwzTu9KUB9RPuDqWtdg+0YGmxFO\nNqnHE+PJl6kFyhXa+qMAeoxZ1DOj4Kjuj7p+c0rKRSECSPEGdOIl/oUV8anJ\nBE8awK58mrqfVtWLSFTmamwyZzNn6rJelhKTk/QmSpMfaLRmjZnuNOK918ab\nqPTUJwLVSSjx2Q8n22CgBwHu4Kp23qd/H4y2gEkGyPSSdD/M42R6TdkCF502\n2ut1Q8NOmRNUAgzUyWDqGBu/VvRgpdd2nOofvASdPVUimzvDEOaZal59xhdE\nVHhzx+3RSgagoLPHJzsYx+hYAEordjFvwb/U3FN3+p8t36LRpJQ6Nx8u3htG\nIoAfejHdtn3w6TziXjd8rQPCLoYZ0G9wFra7LAcTLwv3iUZbVEM9mG+T0Ezt\ng+Of\r\n=VvdT\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIE5QJfOgrChfsbxclMWLtg+yxjA8SF2UNC5RGypua8vZAiAm7ZmY22JbBjtdadhrDlufUfhM14Z5kN2Eo/9pYtFHPA=="}]},"_npmUser":{"name":"ash0080","email":"ash0080@gmail.com"},"maintainers":[{"name":"ash0080","email":"ash0080@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/hasura-sdk_1.1.0_1641626779226_0.9915216931173041"},"_hasShrinkwrap":false}},"maintainers":[{"name":"ash0080","email":"ash0080@gmail.com"}],"description":"Hasura Healthz/Schema/Metadata/PGdump API SDK. Written in TypeScript, Carefully tested and fixed some official bugs","homepage":"https://github.com/ash0080/hasura-sdk#readme","keywords":[],"repository":{"type":"git","url":"git+https://github.com/ash0080/hasura-sdk.git"},"bugs":{"url":"https://github.com/ash0080/hasura-sdk/issues"},"license":"MIT","readme":"# @ash0080/hasura-sdk\nHasura Healthz/Schema/Metadata/PGdump API SDK. Written in TypeScript,\nCarefully tested and well orgnized.\n\n## Movtive\nHasura does not provide a full official API SDK so far, in some projects that aim to extend hasura, we often see developers injecting SQL directly into postgres and modifying metadata by migration, which may make the initialization of the project less reliable.\nSince hasura provided a REST API, why don't we use it?\n\n## Installation\n\n```yarn add @ash0080/hasura-sdk```\n\n```npm install @ash0080/hasura-sdk```\n\n```cp .env.example to /path to your project/.env```\n\n## Usage\n```\n// From Ver 1.1.0, you can using enviroment variables or options, or mixture to config the SDK,\n// This change is to better integrate with other frameworks, such as fastify\nimport genSDK from '@ash/hasura-sdk'\nconst {metadata as m, schema as s} = genSDK()\nconst runASQL = s.sql({sql: `SELECT version()`})\nconst sqlResp = await runASQL.run()\n\n// Or you can use it in a bulk\nconst bulkResp = await s.bulk([\n  runASQL.json()\n  //...other sql operations\n])\n\n// Call a metadata API\nconst trackATable = m.table.track({table: {schema: 'public', name: 'user'}})\n// or short for default schema {table: 'user'}\n\nconst metaResp = await trackATable.run()\n\n// or bulk\nconst bulkResp = await m.bulk([\n  trackTable.toJson()\n  //...other metadata operations\n])\n```\nFor details, you can check index.ts under each corresponding folders\nOr, check test files for all examples !\n\n## Coverage\n```text\n--------------|---------|----------|---------|---------|-------------------\nFile          | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s\n--------------|---------|----------|---------|---------|-------------------\nAll files     |    95.1 |    67.64 |   96.38 |   95.03 |\n src          |     100 |       90 |     100 |     100 |\n  queries.ts  |     100 |       90 |     100 |     100 | 93,103\n src/healthz  |    90.9 |    66.66 |     100 |   88.88 |\n  index.ts    |    90.9 |    66.66 |     100 |   88.88 | 12\n src/helper   |   70.58 |     12.5 |   33.33 |   70.58 |\n  client.ts   |     100 |      100 |     100 |     100 |\n  error.ts    |   54.54 |     12.5 |   33.33 |   54.54 | 5-7,24-25\n  headers.ts  |     100 |      100 |     100 |     100 |\n src/metadata |   98.57 |      100 |   98.52 |   98.57 |\n  index.ts    |   98.57 |      100 |   98.52 |   98.57 | 208\n src/schema   |     100 |      100 |     100 |     100 |\n  index.ts    |     100 |      100 |     100 |     100 |\n--------------|---------|----------|---------|---------|-------------------\n```\n\n\nThe main type definition in this project comes directly from the official hasura/graphql-engine/console, in order to keep the future\niterations, I did not modify this file directly, but added a patch file to extend and modify it (yes, there are some bugs in the official\n file), anyway, so I can not achieve 100% coverage, in addition, there is an api in the metadata API that is only available in the\n cloud/enterprise version, I can not test it well.(line 208)\n\n## API\n\nBased on the official sdk grouping, I grouped all the APIs according to their functionality to make the syntax more comfortable to use:\n\n* add - refers to you can add multiple\n* create - refers to there is only one\n\nOfficially there is no distinction between SQL functions, and there are actually two kinds of functions,\nso you will see the subclass \"schemaFunction\"\n\n```\nSchema:/\n├── bulk\n└── sql\n\nMetadata:/\n├── bulk\n├── source/\n│   ├── add\n│   └── drop\n├── schemaFunction/\n│   ├── track\n│   ├── untrack\n│   ├── customize\n│   └── permission/\n│       ├── add\n│       └── drop\n├── table/\n│   ├── track\n│   ├── untrack\n│   ├── customize\n│   ├── setAsEnum\n│   ├── permission/\n│   │   ├── insert/\n│   │   │   ├── add\n│   │   │   └── drop\n│   │   ├── select/\n│   │   │   ├── add\n│   │   │   └── drop\n│   │   ├── update/\n│   │   │   ├── add\n│   │   │   └── drop\n│   │   ├── delete/\n│   │   │   ├── add\n│   │   │   └── drop\n│   │   └── comment\n│   ├── relationship/\n│   │   ├── addObjectRL\n│   │   ├── addArrayRL\n│   │   ├── drop\n│   │   ├── rename\n│   │   └── comment\n│   └── computedField/\n│       ├── add\n│       └── drop\n├── action/\n│   ├── setCustomTypes\n│   ├── add\n│   ├── drop\n│   ├── update\n│   └── permission/\n│       ├── add\n│       └── drop\n├── remoteSchema/\n│   ├── add\n│   ├── update\n│   ├── drop\n│   ├── reload\n│   ├── introspect\n│   └── permission/\n│       ├── add\n│       └── drop\n├── trigger/\n│   ├── event/\n│   │   ├── add\n│   │   ├── redeliver\n│   │   ├── invoke\n│   │   └── drop\n│   ├── cron/\n│   │   ├── add\n│   │   └── drop\n│   └── schedule/\n│       ├── add\n│       └── drop\n├── metadata/\n│   ├── export\n│   ├── replace\n│   ├── reload\n│   ├── clear\n│   └── inconsistent/\n│       ├── get\n│       └── drop\n├── rest/\n│   ├── createCollection\n│   ├── dropCollection\n│   ├── addQueryToCollection\n│   ├── dropQueryFromCollection\n│   ├── addCollectionToAllowlist\n│   ├── dropCollectionFromAllowlist\n│   ├── createRestEndpoint\n│   └── dropRestEndpoint\n└── setting/\n    ├── GraphQL/\n    │   └── setIntrospection\n    ├── TLSallowList/\n    │   ├── addHost\n    │   └── dropHost\n    └── InheritedRole/\n        ├── add\n        └── drop\n```\n\n## Changelog\n1.1.0 - Refactoring with the Factory Pattern, now can use enviroment variables or options, or mixture to config the SDK;\n\n1.0.0 - Cover the full features of the Healthz/Schema/Metadata/PGdump API;\n\n\n## Todo\n1. I have not tested other databases besides postgres, so if anyone is using these databases, I hope they can test them or even submit a\npull request. The project currently supports all database prefixes, but it seems that some databases do not have the same request data\nfields and may need to be modified;\n2. Add some get operations (SQL template) to get some current configuration data, This makes it easy to verify existing configurations\nwhen we write extension projects, whether a table already exists, whether a relationship already exists, etc;\n3. Add some helper functions to make things simple, For example, to add a computed field, it's a sequence of operations,\n\n*Regarding the third point, I have not yet decided whether to write in this project, or most likely will open a new project\n\n\n## Contributing\n\nEveryone is welcome to contribute. Please take a moment to review the [contributing guidelines](Contributing.md).\n\n## Authors and license\n\n[ash0080](Eldarion) and [contributors](/graphs/contributors).\n\nMIT License, see the included [License.md](License.md) file.\n","readmeFilename":"Readme.md"}