{"id":16269566,"url":"https://github.com/av/thng-query","last_synced_at":"2025-04-08T15:18:05.071Z","repository":{"id":98551348,"uuid":"121991823","full_name":"av/thng-query","owner":"av","description":null,"archived":false,"fork":false,"pushed_at":"2018-05-22T20:30:39.000Z","size":12,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-02-14T11:33:51.119Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/av.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-02-18T21:21:21.000Z","updated_at":"2023-03-07T07:52:51.000Z","dependencies_parsed_at":"2023-04-25T19:02:08.162Z","dependency_job_id":null,"html_url":"https://github.com/av/thng-query","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/av%2Fthng-query","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/av%2Fthng-query/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/av%2Fthng-query/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/av%2Fthng-query/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/av","download_url":"https://codeload.github.com/av/thng-query/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247867365,"owners_count":21009240,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T18:08:38.918Z","updated_at":"2025-04-08T15:18:05.040Z","avatar_url":"https://github.com/av.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# thng-query\n\nDSL for working with EVRYTHNG Platform API\n```bash\ntq --key $OPERATOR_KEY 'products tagged embedded where photos~gif'\n```\n```javascript\nconst tq = require('tq');\n\ntq.setup({\n  authorization: process.env.OPERATOR_KEY\n});\n\ntq.run('thngs with name Advanced* where identifiers.ser^673')\n    .then(console.log)\n    .catch(console.error);\n```\n## Query syntax\nEach query consist of stages:\n```javascript\n|     fetch stage        |     filter stage         |\n'thngs with name Advanced* where identifiers.ser^673'\n```\nEach stage is independent from the other in terms of data processing. \nThink about it as about stream. That also means independent syntax for each \none of them.\n#### Stages\n##### Fetch\n```javascript\n'target selector'\n'quantifier target selector'\n```\n*quantifier*\n- int string (14, 203, 1)\n*target*:\n- `thng(s)`\n- `product(s)`\n*selector*:\n- `with name` | `named`\n- `with tag` | `tagged`\n##### Filter\n```javascript\n'where filterExpression'\n```\n*filterExpression*\n- `filterField filterOperator filterValue`\n*filterField*\n- string path to a property of entity\n*filterOperator*\n- `=` - exact match\n- `~` - inclusion check\n- `^` - starts with\n- `$` - ends with\n*filterValue*\n- string\n## Interface\n#### As library\n```javascript\nconst tq = require('tq');\n\n/**\n * Runs a given query. Throws if any errors during parsing\n * @param {String} query \n */\ntq.run('query');\n\n/**\n * Consumes global settings for tq\n * @param {Settings} settings   \n */\ntq.setup({})\n```\n#### As CLI app\n```bash\n# To see all available options\ntq --help \n# Will dump output json straight to stdout\ntq -k $OPERATOR_KEY 'thngs where properties.online = true'\n# Could be used with formatters, like jq\ntq -k $OPERATOR_KEY 'products with tag overcomplicated' | jq .\n```\n## Settings\n```javascript\ntq.setup({\n  /**\n   * Defines if tq will produce \n   * debug output\n   * \n   * @type {Boolean}\n   */\n  debug: false,\n  \n  /**\n   * Defines max depth of query pipeline i.e. max amount of \n   * pipeline repetitions attempted to fulfill output.\n   * Imagine, account has 10k thngs, tagged \"connected\"\n   * running a query with settings.perPage=1 against them would attempt\n   * to fulfill settings.maxItems (100 by default) which would be actually \n   * capped at 20 by default.\n   * \n   * @type {Number}\n   */\n  depth: 20,\n  \n  /**\n   * Defines how many entities will be queries by fetch stage\n   * Ends up as a \"perPage\" query param on all outgoing requests\n   * \n   * @type {Number}\n   */\n  perPage: 100,\n  \n  /**\n   * Defines how many results at max pipeline will expect\n   * \n   * @type {Number}\n   */\n  maxResults: 100,\n  \n  /**\n   * API Key to use for queries\n   * \n   * @see https://developers.evrythng.com/docs/api-key-scopes-and-permissions\n   * @type {String} \n   */\n  authorization: '',\n  \n  /**\n   * API Url to use\n   * \n   * @type {String}\n   */\n  apiUrl: 'https://api.evrythng.com',\n});\n```\n## Development\n```bash\n# Will complile current grammar and run nearley-test \n# against given expression\nnpm run debug -- 'thngs where createdAt $ 65'\n\n# Will complile nearley grammar to parser\nnpm run compile\n\n# Will produce a random string which will be valid\n# when feed to the runner\n# i.e. \"PrOdUCTs    with nAMe j where  YG ~pol\"\nnpm run unparse\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fav%2Fthng-query","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fav%2Fthng-query","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fav%2Fthng-query/lists"}