{"id":18885951,"url":"https://github.com/studiohyperdrive/hal-tools","last_synced_at":"2025-07-15T16:06:32.851Z","repository":{"id":39996088,"uuid":"321957742","full_name":"studiohyperdrive/hal-tools","owner":"studiohyperdrive","description":null,"archived":false,"fork":false,"pushed_at":"2023-06-29T10:56:47.000Z","size":465,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-31T10:49:43.478Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","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/studiohyperdrive.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":"2020-12-16T11:13:13.000Z","updated_at":"2022-05-13T08:54:36.000Z","dependencies_parsed_at":"2024-11-08T07:37:45.121Z","dependency_job_id":null,"html_url":"https://github.com/studiohyperdrive/hal-tools","commit_stats":null,"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/studiohyperdrive/hal-tools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studiohyperdrive%2Fhal-tools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studiohyperdrive%2Fhal-tools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studiohyperdrive%2Fhal-tools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studiohyperdrive%2Fhal-tools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/studiohyperdrive","download_url":"https://codeload.github.com/studiohyperdrive/hal-tools/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/studiohyperdrive%2Fhal-tools/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265444553,"owners_count":23766431,"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-11-08T07:23:23.050Z","updated_at":"2025-07-15T16:06:32.824Z","avatar_url":"https://github.com/studiohyperdrive.png","language":"TypeScript","readme":"# Studio Hyperdrive HAL Toolset\n\n## General\n\nWARNING: This package has been renamed to [@studiohyperdrive/nodejs-hal-tools](https://www.npmjs.com/package/@studiohyperdrive/nodejs-hal-tools).\n\nThis repo contains a set of tools for working with HAL standards.\n\nIt is build with:\n- node: `v12.20.0` ( ~ `lts/erbium`)\n- npm: `6.14.8`\n\nFor a complete list of packages and version check out the `package.json` file.\n\n## Use\n\n### Install\n\nYou can install this package by doing:\n``` bash\n$ npm install @studiohyperdrive/nodejs-hal-tools\n```\nor if you use Yarn:\n``` bash\n$ yarn add @studiohyperdrive/nodejs-hal-tools\n```\n\n### In your code\nIn your code, you can use this package and it's interfaces like this:\n\n```typescript\nimport { HALFormat } from '@studiohyperdrive/nodejs-hal-tools';\n\nclass DoSomething {\n  public async findAll(page: number, size: number): Promise\u003cIHALFormat\u003cMyEntity\u003e\u003e {\n    const [entities, totalElements] = await this.MyEntitiyRepository.findAndCount(\n      calculateTakeSkip(page, size),\n    );\n    const key = 'my-entities';\n    const path = `https://my-api.com/v1/api/${key}`;\n\n    return HALFormat\u003cMyEntity\u003e({\n      path,\n      key,\n      entities,\n      page,\n      size,\n      totalElements,\n    });\n  }\n}\n```\n\nThis will transform your entities and count to a HAL formatted response which you can return to the client.\n\n#### Parameters\n- `path`: The path parameter is optional, if omitted, the _links section is not added\n- `maxPages`: An optional parameter that limits the maximum number of pages returned. This can be useful in scenario's with lots of items, where querying with limit/offset can be time consuming. To prevent the user from navigating to e.g. page 599, you can limit that number using the `maxPages` parameter.\n\n\n### What's in the package?\nThis package exposes the following functions:\n- `calculateTotalPages`: This function will calculate the total amount of pages based on the pagesize \u0026 total amount of items.\n- `calculatePagination`: This function will calculate and return all pagination properties.\n- `calculateNextPage`: This function will calculate your next page or, when there is none, return your current page.\n- `createHalLinks`: This function will create a set of links required by the HAL Format.\n- `HALFormat`: This function is the main one which will use the above and your input to transform your input to a HAL-formatted object.\n\nAnd the following interfaces:\n- `IHALLink`: An interface for a single HAL link.\n- `IHALLinks`: An interface for the `_links` property.\n- `IHALEntities`: An interface for the `_embedded` property, takes in an optional `T`.\n- `IHALPagination`: An interface for the `_page` property.\n- `IHALFormat`: An interface for the HAL formatted object containing the above properties.\n- `IHALFormatParams`: An interface for the arguments of the `HALFormat` function.\n## Setup for contribution\n\n### Clone and install dependencies\nTo setup this project, clone the repo and run `npm i` to install the dependencies.\n\n### NPM\nThe available commands for building the project are:\n\n| command      | runs                                                                                                      |\n|--------------|-----------------------------------------------------------------------------------------------------------|\n| build        | This script runs tsc to compile and your code (target to the `dist` folder).                              |\n| prepare      | This script runs the `npm run build` command, it is a hook on the npm publish.                            |\n\u003cbr\u003e\n\nThe available commands for testing the project are:\n\n| command      | runs                                                                                                      |\n|--------------|-----------------------------------------------------------------------------------------------------------|\n| lint         | This script will run linting and fix what it can.                                                         |\n| test         | This script will run your Jest tests for the library and create a coverage report.                        |\n| test         | This script will run your Jest tests but with the `--watchAll` flag. It does not create a coverage report.|\n\u003cbr\u003e\n\n## Publish\n\nThis project can be published to the npm registry. To do so follow these steps:\n1. Run `npm version \u003cmajor | minor | patch\u003e` to create a new version and commit + tag it.\n2. Open a Merge Request on Github.\n3. Once your changes have been commited to the main-branch, you can publish to the repo.\n4. Run `npm publish`.\n\n## Team\n\nThis project has been created by:\n- Denis Valcke: denis.valcke@studiohyperdrive.be\n\nIt is currently maintained by:\n- Denis Valcke: denis.valcke@studiohyperdrive.be\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstudiohyperdrive%2Fhal-tools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstudiohyperdrive%2Fhal-tools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstudiohyperdrive%2Fhal-tools/lists"}