Skip to content

Commit 519916b

Browse files
committed
build(nodejs-hal-tools):v2.0.0
1 parent 7c4ea2c commit 519916b

File tree

2 files changed

+17
-105
lines changed

2 files changed

+17
-105
lines changed

libs/javascript/pagination/README.md

Lines changed: 14 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,25 @@
1-
# Studio Hyperdrive HAL Toolset
1+
# Javascript Tools: Pagination (`@studiohyperdrive/nodejs-hal-tools`)
22

3-
## General
3+
`@studiohyperdrive/nodejs-hal-tools` is light-weight package that contains a set of tools for working with HAL standards.
44

5-
WARNING: This package has been renamed to [@studiohyperdrive/nodejs-hal-tools](https://www.npmjs.com/package/@studiohyperdrive/nodejs-hal-tools).
5+
## Installation
66

7-
This repo contains a set of tools for working with HAL standards.
7+
Install the package first:
88

9-
It is build with:
10-
- node: `v18.x.x` ( ~ `lts/hydrogen`)
11-
- npm: `10.x.x`
12-
13-
For a complete list of packages and version check out the `package.json` file.
14-
15-
## Use
16-
17-
### Install
18-
19-
You can install this package by doing:
20-
``` bash
21-
$ npm install @studiohyperdrive/nodejs-hal-tools
22-
```
23-
or if you use Yarn:
24-
``` bash
25-
$ yarn add @studiohyperdrive/nodejs-hal-tools
26-
```
27-
28-
### In your code
29-
In your code, you can use this package and it's interfaces like this:
30-
31-
```typescript
32-
import { HALFormat } from '@studiohyperdrive/nodejs-hal-tools';
33-
34-
class DoSomething {
35-
public async findAll(page: number, size: number): Promise<IHALFormat<MyEntity>> {
36-
const [entities, totalElements] = await this.MyEntitiyRepository.findAndCount(
37-
calculateTakeSkip(page, size),
38-
);
39-
const key = 'my-entities';
40-
const path = `https://my-api.com/v1/api/${key}`;
41-
42-
return HALFormat<MyEntity>({
43-
path,
44-
key,
45-
entities,
46-
page,
47-
size,
48-
totalElements,
49-
});
50-
}
51-
}
9+
```shell
10+
npm install @studiohyperdrive/nodejs-hal-tools
5211
```
5312

54-
This will transform your entities and count to a HAL formatted response which you can return to the client.
55-
56-
#### Parameters
57-
- `path`: The path parameter is optional, if omitted, the _links section is not added
58-
- `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.
59-
60-
61-
### What's in the package?
62-
This package exposes the following functions:
63-
- `calculateTotalPages`: This function will calculate the total amount of pages based on the pagesize & total amount of items.
64-
- `calculatePagination`: This function will calculate and return all pagination properties.
65-
- `calculateNextPage`: This function will calculate your next page or, when there is none, return your current page.
66-
- `createHalLinks`: This function will create a set of links required by the HAL Format.
67-
- `HALFormat`: This function is the main one which will use the above and your input to transform your input to a HAL-formatted object.
68-
69-
And the following interfaces:
70-
- `IHALLink`: An interface for a single HAL link.
71-
- `IHALLinks`: An interface for the `_links` property.
72-
- `IHALEntities`: An interface for the `_embedded` property, takes in an optional `T`.
73-
- `IHALPagination`: An interface for the `_page` property.
74-
- `IHALFormat`: An interface for the HAL formatted object containing the above properties.
75-
- `IHALFormatParams`: An interface for the arguments of the `HALFormat` function.
76-
## Setup for contribution
77-
78-
### Clone and install dependencies
79-
To setup this project, clone the repo and run `npm i` to install the dependencies.
80-
81-
### NPM
82-
The available commands for building the project are:
83-
84-
| command | runs |
85-
|--------------|-----------------------------------------------------------------------------------------------------------|
86-
| build | This script runs tsc to compile and your code (target to the `dist` folder). |
87-
| prepare | This script runs the `npm run build` command, it is a hook on the npm publish. |
88-
<br>
89-
90-
The available commands for testing the project are:
91-
92-
| command | runs |
93-
|--------------|-----------------------------------------------------------------------------------------------------------|
94-
| lint | This script will run linting and fix what it can. |
95-
| test | This script will run your Jest tests for the library and create a coverage report. |
96-
| test | This script will run your Jest tests but with the `--watchAll` flag. It does not create a coverage report.|
97-
<br>
13+
## Versioning and build information
9814

99-
## Publish
15+
This package will follow a semver-like format, `major.minor.patch`, in which:
10016

101-
This project can be published to the npm registry. To do so follow these steps:
102-
1. Run `npm version <major | minor | patch>` to create a new version and commit + tag it.
103-
2. Open a Merge Request on Github.
104-
3. Once your changes have been commited to the main-branch, you can publish to the repo.
105-
4. Run `npm publish`.
17+
- `major`: Introduces new features or breaking changes
18+
- `minor`: Introduces minor non-breaking changes
19+
- `patch`: Introduces bugfixes
10620

107-
## Team
21+
For more information about the build process, authors, contributions and issues, we refer to the [hyperdrive-opensource](https://github.com/studiohyperdrive/hyperdrive-opensource) repository.
10822

109-
This project has been created by:
110-
- Denis Valcke: [email protected]
23+
## Documentation
11124

112-
It is currently maintained by:
113-
- Denis Valcke: [email protected]
25+
To find more information regarding this package, we refer to [our documentation platform](https://open-source.studiohyperdrive.be/docs/angular/page/introduction).

libs/javascript/pagination/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
{
22
"name": "@studiohyperdrive/nodejs-hal-tools",
3-
"version": "1.2.0",
3+
"version": "2.0.0",
44
"description": "A NodeJs based approach to pagination based on the HAL standards.",
55
"keywords": [
66
"pagination",
77
"hal",
88
"nodejs"
99
],
10-
"homepage": "https://github.com/studiohyperdrive/ngx-tools/tree/master/libs/javascript/pagination",
10+
"homepage": "https://open-source.studiohyperdrive.be/docs/javascript/pagination/introduction",
1111
"author": {
1212
"name": "Studio Hyperdrive",
1313
"url": "https://studiohyperdrive.be/"
1414
},
1515
"repository": {
1616
"type": "git",
17-
"url": "https://github.com/studiohyperdrive/ngx-tools",
17+
"url": "https://github.com/studiohyperdrive/hyperdrive-opensource",
1818
"directory": "libs/javascript/pagination/src"
1919
},
2020
"license": "MIT",

0 commit comments

Comments
 (0)