@redhat-cloud-services/notifications-client 3.1.0 → 3.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/README.md +21 -14
  3. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -2,6 +2,11 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [3.1.1](https://github.com/RedHatInsights/javascript-clients/compare/@redhat-cloud-services/notifications-client-3.1.0...@redhat-cloud-services/notifications-client-3.1.1) (2024-12-09)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `@redhat-cloud-services/javascript-clients-shared` updated to version `1.2.7`
5
10
  ## [3.1.0](https://github.com/RedHatInsights/javascript-clients/compare/@redhat-cloud-services/notifications-client-3.0.1...@redhat-cloud-services/notifications-client-3.1.0) (2024-11-19)
6
11
 
7
12
 
package/README.md CHANGED
@@ -1,5 +1,5 @@
1
- # Javascript client for Notifications API
2
- If you want to use [RedHatInsights/notifications-backend](https://github.com/RedHatInsights/notifications-backend) you shouldn't use get requests directly, but rather use this client to integrate with the service.
1
+ # Javascript client for the notifications API
2
+ If you want to use [RedHatInsights/notifications](https://github.com/RedHatInsights/notifications) you shouldn't use get requests directly, but rather use this client to integrate with this service.
3
3
 
4
4
  ## Install
5
5
  NPM
@@ -15,25 +15,29 @@ yarn add @redhat-cloud-services/notifications-client
15
15
  ### Usage
16
16
  This client is using typescript and axios. Types are distributed with this package, so no need to define or install them separately.
17
17
 
18
- To correctly bootstrap this API you should use this config (no need to define it multiple times, just one config and reimport it anywhere you want to use it).
18
+ This package comes with a client in its `api.ts` already defined with every call available.
19
19
  ```JS
20
- // api.js
21
- import APIFactory from '@redhat-cloud-services/notifications-client/utils';
22
- import createBehaviorGroup from '@redhat-cloud-services/notifications-client/NotificationResourceV1CreateBehaviorGroup';
23
- import updateBehaviorGroup from '@redhat-cloud-services/notifications-client/NotificationResourceV1UpdateBehaviorGroup';
24
- import deleteBehaviorGroup from '@redhat-cloud-services/notifications-client/NotificationResourceV1DeleteBehaviorGroup';
20
+ `import notificationsClient from '@redhat-cloud-services/javascript-clients-shared/utils';
25
21
 
22
+ notificationsClient.someEndpoint();
23
+ ```
24
+
25
+ To bootstrap this API manually, you should create your own client via the `APIFactory` defined in the `@redhat-cloud-services/javascript-clients-shared` package. See below for an example:
26
+ ```JS
27
+ import APIFactory from '@redhat-cloud-services/javascript-clients-shared/utils';
28
+ import exampleEndpoint from '@redhat-cloud-services/notifications-client/ExampleEndpoint';
26
29
 
27
30
  // BASE_PATH should be set in your constants file
28
- const notificationsApi = APIFactory(BASE_PATH, undefined, { createBehaviorGroup, updateBehaviorGroup, deleteBehaviorGroup });
31
+ const notificationsApi = APIFactory(BASE_PATH, undefined, { exampleEndpoint });
29
32
  export notificationsApi;
30
33
  ```
31
34
 
32
35
  If you want to add some interceptors you can use axios build in interceptors
33
36
  ```JS
34
- // api.js
35
37
  import axios from 'axios';
36
- import { NotificationsApi } from '@redhat-cloud-services/notifications-client';
38
+ import APIFactory from '@redhat-cloud-services/javascript-clients-shared/utils';
39
+ import exampleEndpoint from '@redhat-cloud-services/notifications-client/ExampleEndpoint';
40
+
37
41
  const instance = axios.create();
38
42
 
39
43
  // Request interceptor
@@ -52,17 +56,20 @@ instance.interceptors.response.use(null, (error) => {
52
56
  });
53
57
 
54
58
  // BASE_PATH should be set in your constants file
55
- const notificationsApi = APIFactory(BASE_PATH, instance, { createBehaviorGroup, updateBehaviorGroup, deleteBehaviorGroup });
59
+ const notificationsApi = APIFactory(BASE_PATH, instance, { exampleEndpoint });
56
60
  export notificationsApi;
57
61
  ```
62
+ ## Generating
63
+
64
+ Ensure you have the javascript-clients generator built first with `npm run build:generator`. Then, run `nx run @redhat-cloud-services/notifications-client:generate` to generate the package.
58
65
 
59
66
  ## Building
60
67
 
61
- Run `nx build @redhat-cloud-services/notifications-client` to build the library.
68
+ Run `nx run @redhat-cloud-services/notifications-client:build` to build the package. This creates the `dist` for publishing.
62
69
 
63
70
  ## Running unit tests
64
71
 
65
- Run `nx test @redhat-cloud-services/notifications-client` to execute the unit tests via [Jest](https://jestjs.io).
72
+ Run `nx run @redhat-cloud-services/notifications-client:test` to execute the unit tests via [Jest](https://jestjs.io).
66
73
 
67
74
  ## API documentation
68
75
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redhat-cloud-services/notifications-client",
3
- "version": "3.1.0",
3
+ "version": "3.1.1",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "typings": "./dist/index.d.ts",