@metarisc/metarisc-js 0.0.1-alpha.65 → 0.0.1-alpha.66
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.
- package/README.md +32 -5
- package/lib/api/HealthcheckAPI.d.ts +10 -0
- package/lib/api/HealthcheckAPI.js +23 -0
- package/lib/core.d.ts +6 -0
- package/lib/core.js +13 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/metarisc.d.ts +2 -0
- package/lib/metarisc.js +3 -0
- package/package.json +1 -1
- package/src/api/HealthcheckAPI.ts +25 -0
- package/src/core.ts +16 -0
- package/src/index.ts +2 -0
- package/src/metarisc.ts +7 -0
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ npm i @metarisc/metarisc-js
|
|
|
13
13
|
Pour utiliser la librairie, il suffit de l'importer comme ceci :
|
|
14
14
|
|
|
15
15
|
```ts
|
|
16
|
-
import { Metarisc } from
|
|
16
|
+
import { Metarisc } from "@metarisc/metarisc-js";
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Utilisation
|
|
@@ -24,9 +24,9 @@ Pour effectuer une requête sur Metarisc, il faut tout d'adord initialisé le cl
|
|
|
24
24
|
|
|
25
25
|
```ts
|
|
26
26
|
const m = new Metarisc({
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
metarisc_url: "https://api.metarisc.fr",
|
|
28
|
+
client_id: "CLIENT_ID",
|
|
29
|
+
client_secret: "CLIENT_SECRET"
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
m.dossiers.getDossier("123456");
|
|
@@ -69,4 +69,31 @@ Le type de retour d'une requête paginée est :
|
|
|
69
69
|
AsyncGenerator<T>;
|
|
70
70
|
```
|
|
71
71
|
|
|
72
|
-
(voir la documentation suivante [AsyncGenerator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator))
|
|
72
|
+
(voir la documentation suivante [AsyncGenerator](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncGenerator))
|
|
73
|
+
|
|
74
|
+
#### Écouteur d'événements pour les requêtes
|
|
75
|
+
|
|
76
|
+
Il est possible d'ajouter un écouteur d'événements sur chaque requête effectuée par le client Metarisc. Pour ce faire, vous pouvez utiliser la méthode on() de l'objet core, en spécifiant le nom de l'événement on("request", function)
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
m.on("request", (config: Event): void => {
|
|
80
|
+
//Action à effectuer à chaque requête
|
|
81
|
+
});
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
Cet écouteur est particulièrement utile pour effectuer des vérifications, comme la validation du token d'authentification avant l'envoi de chaque requête.
|
|
85
|
+
|
|
86
|
+
La fonction de rappel (callback) reçoit en paramètre un objet Event. Cet objet contient une propriété detail, où sont stockées toutes les informations relatives à la requête entrante.
|
|
87
|
+
|
|
88
|
+
```ts
|
|
89
|
+
m.on("request", (config: Event): void => {
|
|
90
|
+
console.log(config.detail); // Retourne un objet de type RequestConfig
|
|
91
|
+
//{
|
|
92
|
+
//body?: any;
|
|
93
|
+
//headers?: { [name: string]: string | string[] };
|
|
94
|
+
//params?: { [param: string]: string | string[] };
|
|
95
|
+
//endpoint?: string;
|
|
96
|
+
//method?: string;
|
|
97
|
+
//}
|
|
98
|
+
});
|
|
99
|
+
```
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Core, MetariscConfig } from "../core";
|
|
2
|
+
import type { AxiosResponse } from "axios";
|
|
3
|
+
import { Client } from "../client";
|
|
4
|
+
export declare class HealthcheckAPI extends Core {
|
|
5
|
+
constructor(config: MetariscConfig, client?: Client);
|
|
6
|
+
/**
|
|
7
|
+
* Assurez-vous que tous nos services sont opérationnels en effectuant des appels API vers le point de terminaison de contrôle d'intégrité. Ce point de terminaison exécute des contrôles d'intégrité et renvoie un état qui vous indique si le service Metarisc est fonctionnel ou non.
|
|
8
|
+
*/
|
|
9
|
+
verify(): Promise<AxiosResponse<void>>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HealthcheckAPI = void 0;
|
|
4
|
+
const core_1 = require("../core");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
class HealthcheckAPI extends core_1.Core {
|
|
7
|
+
constructor(config, client) {
|
|
8
|
+
super(config, client);
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Assurez-vous que tous nos services sont opérationnels en effectuant des appels API vers le point de terminaison de contrôle d'intégrité. Ce point de terminaison exécute des contrôles d'intégrité et renvoie un état qui vous indique si le service Metarisc est fonctionnel ou non.
|
|
12
|
+
*/
|
|
13
|
+
async verify() {
|
|
14
|
+
const pathVariable = {};
|
|
15
|
+
return this.request({
|
|
16
|
+
method: 'GET',
|
|
17
|
+
endpoint: utils_1.Utils.constructPath(pathVariable, '/healthcheck'),
|
|
18
|
+
params: {},
|
|
19
|
+
body: utils_1.Utils.payloadFilter({})
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.HealthcheckAPI = HealthcheckAPI;
|
package/lib/core.d.ts
CHANGED
|
@@ -29,8 +29,11 @@ export interface OAuth2Options {
|
|
|
29
29
|
export declare class Core {
|
|
30
30
|
protected client: Client;
|
|
31
31
|
protected config: MetariscConfig;
|
|
32
|
+
protected requestEvent: EventTarget;
|
|
32
33
|
constructor(config: MetariscConfig, client?: Client);
|
|
33
34
|
request<T>(config: RequestConfig): Promise<AxiosResponse<T>>;
|
|
35
|
+
protected emit(eventName: EventEnum, payload: unknown): void;
|
|
36
|
+
on(eventName: EventEnum, callback: (event: Event) => void): void;
|
|
34
37
|
collect<T>(config: RequestConfig): Collection<T>;
|
|
35
38
|
authenticate(auth_method: AuthMethod, options: OAuth2Options): Promise<GrantResponse>;
|
|
36
39
|
refreshToken(): Promise<RefreshResponse>;
|
|
@@ -38,4 +41,7 @@ export declare class Core {
|
|
|
38
41
|
setRefreshToken(refresh_token: string): void;
|
|
39
42
|
setActiveOrganisation(orgId: string): void;
|
|
40
43
|
}
|
|
44
|
+
export declare enum EventEnum {
|
|
45
|
+
request = "request"
|
|
46
|
+
}
|
|
41
47
|
export {};
|
package/lib/core.js
CHANGED
|
@@ -1,16 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Core = void 0;
|
|
3
|
+
exports.EventEnum = exports.Core = void 0;
|
|
4
4
|
const client_1 = require("./client");
|
|
5
5
|
const collection_1 = require("./collection");
|
|
6
6
|
class Core {
|
|
7
7
|
constructor(config, client) {
|
|
8
|
+
this.requestEvent = new EventTarget();
|
|
8
9
|
this.config = config;
|
|
9
10
|
this.client = client ?? new client_1.Client(config);
|
|
10
11
|
}
|
|
11
12
|
async request(config) {
|
|
13
|
+
this.emit(EventEnum.request, config);
|
|
12
14
|
return this.client.request(config);
|
|
13
15
|
}
|
|
16
|
+
emit(eventName, payload) {
|
|
17
|
+
this.requestEvent.dispatchEvent(new CustomEvent(eventName, { detail: payload }));
|
|
18
|
+
}
|
|
19
|
+
on(eventName, callback) {
|
|
20
|
+
this.requestEvent.addEventListener(eventName, callback);
|
|
21
|
+
}
|
|
14
22
|
collect(config) {
|
|
15
23
|
return new collection_1.Collection(this, {
|
|
16
24
|
endpoint: config.endpoint || "/",
|
|
@@ -35,3 +43,7 @@ class Core {
|
|
|
35
43
|
}
|
|
36
44
|
}
|
|
37
45
|
exports.Core = Core;
|
|
46
|
+
var EventEnum;
|
|
47
|
+
(function (EventEnum) {
|
|
48
|
+
EventEnum["request"] = "request";
|
|
49
|
+
})(EventEnum = exports.EventEnum || (exports.EventEnum = {}));
|
package/lib/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { DossiersAPI } from './api/DossiersAPI';
|
|
|
16
16
|
export { ERPAPI } from './api/ERPAPI';
|
|
17
17
|
export { EvenementsAPI } from './api/EvenementsAPI';
|
|
18
18
|
export { FeedAPI } from './api/FeedAPI';
|
|
19
|
+
export { HealthcheckAPI } from './api/HealthcheckAPI';
|
|
19
20
|
export { MoiAPI } from './api/MoiAPI';
|
|
20
21
|
export { NotificationsAPI } from './api/NotificationsAPI';
|
|
21
22
|
export { OrdresDuJourAPI } from './api/OrdresDuJourAPI';
|
package/lib/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WorkflowsAPI = exports.UtilisateursAPI = exports.TournesDECIAPI = exports.PrescriptionsAPI = exports.PingAPI = exports.PEIAPI = exports.OrganisationsAPI = exports.OrdresDuJourAPI = exports.NotificationsAPI = exports.MoiAPI = exports.FeedAPI = exports.EvenementsAPI = exports.ERPAPI = exports.DossiersAPI = exports.DocumentsAPI = exports.DatesPassageCommissionAPI = exports.ControlesPeiAPI = exports.ContactsAPI = exports.CommissionsAPI = exports.AnomaliesAPI = exports.Tus = exports.Utils = exports.Client = exports.AuthMethod = exports.Collection = exports.Core = exports.SessionExpiredError = exports.OAuth2 = exports.Metarisc = void 0;
|
|
3
|
+
exports.WorkflowsAPI = exports.UtilisateursAPI = exports.TournesDECIAPI = exports.PrescriptionsAPI = exports.PingAPI = exports.PEIAPI = exports.OrganisationsAPI = exports.OrdresDuJourAPI = exports.NotificationsAPI = exports.MoiAPI = exports.HealthcheckAPI = exports.FeedAPI = exports.EvenementsAPI = exports.ERPAPI = exports.DossiersAPI = exports.DocumentsAPI = exports.DatesPassageCommissionAPI = exports.ControlesPeiAPI = exports.ContactsAPI = exports.CommissionsAPI = exports.AnomaliesAPI = exports.Tus = exports.Utils = exports.Client = exports.AuthMethod = exports.Collection = exports.Core = exports.SessionExpiredError = exports.OAuth2 = exports.Metarisc = void 0;
|
|
4
4
|
var metarisc_1 = require("./metarisc");
|
|
5
5
|
Object.defineProperty(exports, "Metarisc", { enumerable: true, get: function () { return metarisc_1.Metarisc; } });
|
|
6
6
|
var oauth2_1 = require("./auth/oauth2");
|
|
@@ -38,6 +38,8 @@ var EvenementsAPI_1 = require("./api/EvenementsAPI");
|
|
|
38
38
|
Object.defineProperty(exports, "EvenementsAPI", { enumerable: true, get: function () { return EvenementsAPI_1.EvenementsAPI; } });
|
|
39
39
|
var FeedAPI_1 = require("./api/FeedAPI");
|
|
40
40
|
Object.defineProperty(exports, "FeedAPI", { enumerable: true, get: function () { return FeedAPI_1.FeedAPI; } });
|
|
41
|
+
var HealthcheckAPI_1 = require("./api/HealthcheckAPI");
|
|
42
|
+
Object.defineProperty(exports, "HealthcheckAPI", { enumerable: true, get: function () { return HealthcheckAPI_1.HealthcheckAPI; } });
|
|
41
43
|
var MoiAPI_1 = require("./api/MoiAPI");
|
|
42
44
|
Object.defineProperty(exports, "MoiAPI", { enumerable: true, get: function () { return MoiAPI_1.MoiAPI; } });
|
|
43
45
|
var NotificationsAPI_1 = require("./api/NotificationsAPI");
|
package/lib/metarisc.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { DossiersAPI } from './api/DossiersAPI';
|
|
|
11
11
|
import { ERPAPI } from './api/ERPAPI';
|
|
12
12
|
import { EvenementsAPI } from './api/EvenementsAPI';
|
|
13
13
|
import { FeedAPI } from './api/FeedAPI';
|
|
14
|
+
import { HealthcheckAPI } from './api/HealthcheckAPI';
|
|
14
15
|
import { MoiAPI } from './api/MoiAPI';
|
|
15
16
|
import { NotificationsAPI } from './api/NotificationsAPI';
|
|
16
17
|
import { OrdresDuJourAPI } from './api/OrdresDuJourAPI';
|
|
@@ -33,6 +34,7 @@ export declare class Metarisc extends Core {
|
|
|
33
34
|
anomalies?: AnomaliesAPI;
|
|
34
35
|
supports_reglementaires?: PrescriptionsAPI;
|
|
35
36
|
feed?: FeedAPI;
|
|
37
|
+
healthcheck?: HealthcheckAPI;
|
|
36
38
|
tournees_deci?: TournesDECIAPI;
|
|
37
39
|
organisations?: OrganisationsAPI;
|
|
38
40
|
pei?: PEIAPI;
|
package/lib/metarisc.js
CHANGED
|
@@ -13,6 +13,7 @@ const DossiersAPI_1 = require("./api/DossiersAPI");
|
|
|
13
13
|
const ERPAPI_1 = require("./api/ERPAPI");
|
|
14
14
|
const EvenementsAPI_1 = require("./api/EvenementsAPI");
|
|
15
15
|
const FeedAPI_1 = require("./api/FeedAPI");
|
|
16
|
+
const HealthcheckAPI_1 = require("./api/HealthcheckAPI");
|
|
16
17
|
const MoiAPI_1 = require("./api/MoiAPI");
|
|
17
18
|
const NotificationsAPI_1 = require("./api/NotificationsAPI");
|
|
18
19
|
const OrdresDuJourAPI_1 = require("./api/OrdresDuJourAPI");
|
|
@@ -52,6 +53,8 @@ class Metarisc extends core_1.Core {
|
|
|
52
53
|
return new PrescriptionsAPI_1.PrescriptionsAPI(config, tmpClient);
|
|
53
54
|
case 'feed':
|
|
54
55
|
return new FeedAPI_1.FeedAPI(config, tmpClient);
|
|
56
|
+
case 'healthcheck':
|
|
57
|
+
return new HealthcheckAPI_1.HealthcheckAPI(config, tmpClient);
|
|
55
58
|
case 'tournees_deci':
|
|
56
59
|
return new TournesDECIAPI_1.TournesDECIAPI(config, tmpClient);
|
|
57
60
|
case 'organisations':
|
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Core, MetariscConfig } from "../core";
|
|
2
|
+
import { Utils } from "../utils";
|
|
3
|
+
import type { AxiosResponse } from "axios";
|
|
4
|
+
import { Client } from "../client";
|
|
5
|
+
|
|
6
|
+
export class HealthcheckAPI extends Core {
|
|
7
|
+
constructor(config: MetariscConfig, client?: Client) {
|
|
8
|
+
super(config, client);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Assurez-vous que tous nos services sont opérationnels en effectuant des appels API vers le point de terminaison de contrôle d'intégrité. Ce point de terminaison exécute des contrôles d'intégrité et renvoie un état qui vous indique si le service Metarisc est fonctionnel ou non.
|
|
13
|
+
*/
|
|
14
|
+
async verify(): Promise<AxiosResponse<void>>
|
|
15
|
+
{
|
|
16
|
+
const pathVariable = { };
|
|
17
|
+
return this.request({
|
|
18
|
+
method: 'GET',
|
|
19
|
+
endpoint: Utils.constructPath(pathVariable, '/healthcheck'),
|
|
20
|
+
params: { },
|
|
21
|
+
body: Utils.payloadFilter({})
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
}
|
package/src/core.ts
CHANGED
|
@@ -29,6 +29,7 @@ export interface OAuth2Options {
|
|
|
29
29
|
export class Core {
|
|
30
30
|
protected client: Client;
|
|
31
31
|
protected config: MetariscConfig;
|
|
32
|
+
protected requestEvent = new EventTarget();
|
|
32
33
|
|
|
33
34
|
constructor(config: MetariscConfig, client?: Client) {
|
|
34
35
|
this.config = config;
|
|
@@ -36,9 +37,20 @@ export class Core {
|
|
|
36
37
|
}
|
|
37
38
|
|
|
38
39
|
async request<T>(config: RequestConfig): Promise<AxiosResponse<T>> {
|
|
40
|
+
this.emit(EventEnum.request, config);
|
|
39
41
|
return this.client.request<T>(config);
|
|
40
42
|
}
|
|
41
43
|
|
|
44
|
+
protected emit(eventName: EventEnum, payload: unknown) {
|
|
45
|
+
this.requestEvent.dispatchEvent(
|
|
46
|
+
new CustomEvent(eventName, { detail: payload })
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
on(eventName: EventEnum, callback: (event: Event) => void): void {
|
|
51
|
+
this.requestEvent.addEventListener(eventName, callback);
|
|
52
|
+
}
|
|
53
|
+
|
|
42
54
|
collect<T>(config: RequestConfig): Collection<T> {
|
|
43
55
|
return new Collection<T>(this, {
|
|
44
56
|
endpoint: config.endpoint || "/",
|
|
@@ -70,3 +82,7 @@ export class Core {
|
|
|
70
82
|
this.client.setActiveOrganisation(orgId);
|
|
71
83
|
}
|
|
72
84
|
}
|
|
85
|
+
|
|
86
|
+
export enum EventEnum {
|
|
87
|
+
request = "request"
|
|
88
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -27,6 +27,8 @@ export { EvenementsAPI } from './api/EvenementsAPI';
|
|
|
27
27
|
|
|
28
28
|
export { FeedAPI } from './api/FeedAPI';
|
|
29
29
|
|
|
30
|
+
export { HealthcheckAPI } from './api/HealthcheckAPI';
|
|
31
|
+
|
|
30
32
|
export { MoiAPI } from './api/MoiAPI';
|
|
31
33
|
|
|
32
34
|
export { NotificationsAPI } from './api/NotificationsAPI';
|
package/src/metarisc.ts
CHANGED
|
@@ -22,6 +22,8 @@ import { EvenementsAPI } from './api/EvenementsAPI';
|
|
|
22
22
|
|
|
23
23
|
import { FeedAPI } from './api/FeedAPI';
|
|
24
24
|
|
|
25
|
+
import { HealthcheckAPI } from './api/HealthcheckAPI';
|
|
26
|
+
|
|
25
27
|
import { MoiAPI } from './api/MoiAPI';
|
|
26
28
|
|
|
27
29
|
import { NotificationsAPI } from './api/NotificationsAPI';
|
|
@@ -67,6 +69,8 @@ export class Metarisc extends Core
|
|
|
67
69
|
|
|
68
70
|
public feed?: FeedAPI;
|
|
69
71
|
|
|
72
|
+
public healthcheck?: HealthcheckAPI;
|
|
73
|
+
|
|
70
74
|
public tournees_deci?: TournesDECIAPI;
|
|
71
75
|
|
|
72
76
|
public organisations?: OrganisationsAPI;
|
|
@@ -131,6 +135,9 @@ export class Metarisc extends Core
|
|
|
131
135
|
case 'feed':
|
|
132
136
|
return new FeedAPI(config, tmpClient);
|
|
133
137
|
|
|
138
|
+
case 'healthcheck':
|
|
139
|
+
return new HealthcheckAPI(config, tmpClient);
|
|
140
|
+
|
|
134
141
|
case 'tournees_deci':
|
|
135
142
|
return new TournesDECIAPI(config, tmpClient);
|
|
136
143
|
|