@ministryofjustice/hmpps-mpop-frontend-components-lib 0.0.3 → 0.0.5
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 +12 -4
- package/dist/MPoPComponents.d.ts +3 -0
- package/dist/_all.scss +2 -1
- package/dist/components/pop-header/popHeader.test.d.ts +1 -0
- package/dist/index.cjs.js +46 -0
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.ts +22 -0
- package/dist/index.esm.js +46 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/mpop/components/pop-header/_pop-header.scss +12 -0
- package/dist/mpop/components/pop-header/macro.njk +3 -0
- package/dist/mpop/components/pop-header/template.njk +18 -0
- package/dist/mpop/components/supervision-package/macro.njk +2 -2
- package/dist/mpop/components/supervision-package/template.njk +13 -14
- package/dist/types/MPoPComponentsConfig.d.ts +1 -0
- package/dist/types/PersonalDetails.d.ts +18 -0
- package/dist/utils/dateWithYear.d.ts +3 -0
- package/dist/utils/dateWithYear.test.d.ts +1 -0
- package/dist/utils/govukTime.d.ts +1 -0
- package/dist/utils/govukTime.test.d.ts +1 -0
- package/dist/utils/isBlank.d.ts +1 -0
- package/dist/utils/isBlank.test.d.ts +1 -0
- package/dist/utils/yearsSince.d.ts +1 -0
- package/dist/utils/yearsSince.test.d.ts +1 -0
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -5,14 +5,24 @@ MPoP front-end library
|
|
|
5
5
|
|
|
6
6
|
This package is published to npm using GitHub Releases and npm Trusted Publishing.
|
|
7
7
|
|
|
8
|
+
You can view the npm page for this package here https://www.npmjs.com/package/@ministryofjustice/hmpps-mpop-frontend-components-lib
|
|
9
|
+
|
|
10
|
+
### Pre-requisites
|
|
11
|
+
|
|
12
|
+
- Ensure GitHub CLI (gh) is installed and authenticated
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
gh auth status || gh auth login
|
|
16
|
+
```
|
|
17
|
+
|
|
8
18
|
### Release process
|
|
9
19
|
|
|
10
|
-
1. Create a branch from the latest `main` and update the package version:
|
|
20
|
+
1. Create a unique branch name from the latest `main` and update the package version, such as:
|
|
11
21
|
|
|
12
22
|
```bash
|
|
13
23
|
git checkout main
|
|
14
24
|
git pull
|
|
15
|
-
git checkout -b chore/bump-package-version
|
|
25
|
+
git checkout -b chore/bump-package-version-<version>
|
|
16
26
|
|
|
17
27
|
npm version patch --no-git-tag-version
|
|
18
28
|
```
|
|
@@ -41,8 +51,6 @@ This package is published to npm using GitHub Releases and npm Trusted Publishin
|
|
|
41
51
|
|
|
42
52
|
VERSION=$(node -p "require('./package.json').version")
|
|
43
53
|
|
|
44
|
-
// Add a step to say github cli needs to be installed and you need to login to the github cli
|
|
45
|
-
|
|
46
54
|
gh release create "v$VERSION" \
|
|
47
55
|
--target main \
|
|
48
56
|
--title "v$VERSION" \
|
package/dist/MPoPComponents.d.ts
CHANGED
|
@@ -3,9 +3,12 @@ import type { AuthenticationClient } from '@ministryofjustice/hmpps-auth-clients
|
|
|
3
3
|
import type Logger from 'bunyan';
|
|
4
4
|
import type { MPoPComponentsConfig } from './types/MPoPComponentsConfig';
|
|
5
5
|
import type { LatestTierResponse, TierTag } from './types/TierCalculation';
|
|
6
|
+
import type { PersonalDetailsResponse } from './types/PersonalDetails';
|
|
6
7
|
export declare const tierTags: Record<string, TierTag>;
|
|
7
8
|
export default class MPoPComponents {
|
|
8
9
|
private readonly tierApiRestClient;
|
|
10
|
+
private readonly masApiRestClient;
|
|
9
11
|
constructor(authenticationClient: AuthenticationClient, config: MPoPComponentsConfig, logger?: Logger | Console);
|
|
10
12
|
getTierDetails(authOptions: AuthOptions | string, crn: string): Promise<LatestTierResponse>;
|
|
13
|
+
getPersonalDetails(authOptions: AuthOptions | string, crn: string): Promise<PersonalDetailsResponse>;
|
|
11
14
|
}
|
package/dist/_all.scss
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// MPOP Frontend Components Library
|
|
2
2
|
// Requires govuk-frontend to be imported first
|
|
3
3
|
|
|
4
|
-
@import "./mpop/components/supervision-package/supervision-package";
|
|
4
|
+
@import "./mpop/components/supervision-package/supervision-package";
|
|
5
|
+
@import "./mpop/components/pop-header/pop-header";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.cjs.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var hmppsRestClient = require('@ministryofjustice/hmpps-rest-client');
|
|
4
|
+
var luxon = require('luxon');
|
|
4
5
|
|
|
5
6
|
class SuppressingRestClient {
|
|
6
7
|
constructor(restClient, logger) {
|
|
@@ -21,6 +22,18 @@ class SuppressingRestClient {
|
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
24
|
|
|
25
|
+
const isBlank = (str) => !str || /^\s*$/.test(str);
|
|
26
|
+
|
|
27
|
+
const yearsSince = (datetimeString) => {
|
|
28
|
+
if (!datetimeString || isBlank(datetimeString))
|
|
29
|
+
return null;
|
|
30
|
+
const dt = luxon.DateTime.fromISO(datetimeString, { zone: 'Europe/London' });
|
|
31
|
+
if (!dt.isValid)
|
|
32
|
+
return null;
|
|
33
|
+
const years = Math.trunc(luxon.DateTime.now().diff(dt, ['years', 'months']).years);
|
|
34
|
+
return years.toString();
|
|
35
|
+
};
|
|
36
|
+
|
|
24
37
|
const tierTags = {
|
|
25
38
|
missing: { text: 'Missing', color: 'red' },
|
|
26
39
|
provisional: { text: 'Provisional', color: 'orange' },
|
|
@@ -29,7 +42,9 @@ const tierTags = {
|
|
|
29
42
|
};
|
|
30
43
|
class MPoPComponents {
|
|
31
44
|
constructor(authenticationClient, config, logger = console) {
|
|
45
|
+
var _a;
|
|
32
46
|
this.tierApiRestClient = new SuppressingRestClient(new hmppsRestClient.RestClient('Tier API', config, logger, authenticationClient), logger);
|
|
47
|
+
this.masApiRestClient = new SuppressingRestClient(new hmppsRestClient.RestClient('MAS API', (_a = config.masApiConfig) !== null && _a !== void 0 ? _a : config, logger, authenticationClient), logger);
|
|
33
48
|
}
|
|
34
49
|
async getTierDetails(authOptions, crn) {
|
|
35
50
|
let error = null;
|
|
@@ -86,6 +101,37 @@ class MPoPComponents {
|
|
|
86
101
|
error,
|
|
87
102
|
};
|
|
88
103
|
}
|
|
104
|
+
async getPersonalDetails(authOptions, crn) {
|
|
105
|
+
let error = null;
|
|
106
|
+
let personalDetails;
|
|
107
|
+
try {
|
|
108
|
+
const response = await this.masApiRestClient.get(`/personal-details/${crn}/summary`, authOptions);
|
|
109
|
+
if (!response) {
|
|
110
|
+
personalDetails = {
|
|
111
|
+
personalDetails: null,
|
|
112
|
+
httpStatus: 404,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
personalDetails = {
|
|
117
|
+
personalDetails: { ...response, age: yearsSince(response.dateOfBirth) },
|
|
118
|
+
httpStatus: 200,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
catch (err) {
|
|
123
|
+
error = err instanceof Error ? err : new Error('500 Internal Server Error');
|
|
124
|
+
const responseStatus = err === null || err === void 0 ? void 0 : err.responseStatus;
|
|
125
|
+
personalDetails = {
|
|
126
|
+
personalDetails: null,
|
|
127
|
+
httpStatus: responseStatus !== null && responseStatus !== void 0 ? responseStatus : 500,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
...personalDetails,
|
|
132
|
+
error,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
89
135
|
}
|
|
90
136
|
|
|
91
137
|
exports.MPoPComponents = MPoPComponents;
|
package/dist/index.cjs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs.js","sources":["../src/SuppressingRestClient.ts","../src/MPoPComponents.ts"],"sourcesContent":[null,null],"names":["RestClient"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs.js","sources":["../src/SuppressingRestClient.ts","../src/utils/isBlank.ts","../src/utils/year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enticationClient } from '@ministryofjustice/hmpps-auth-clients';
|
|
|
3
3
|
import Logger from 'bunyan';
|
|
4
4
|
|
|
5
5
|
interface MPoPComponentsConfig extends ApiConfig {
|
|
6
|
+
masApiConfig?: ApiConfig;
|
|
6
7
|
}
|
|
7
8
|
|
|
8
9
|
type TierTag = {
|
|
@@ -25,10 +26,31 @@ type LatestTierResponse = {
|
|
|
25
26
|
error?: Error | null;
|
|
26
27
|
};
|
|
27
28
|
|
|
29
|
+
type PersonalDetailsResponse = {
|
|
30
|
+
personalDetails: PersonalDetailsSummary | null;
|
|
31
|
+
httpStatus: number;
|
|
32
|
+
error?: Error | null;
|
|
33
|
+
};
|
|
34
|
+
type PersonalDetailsSummary = {
|
|
35
|
+
name: {
|
|
36
|
+
forename: string;
|
|
37
|
+
middleName: string;
|
|
38
|
+
surname: string;
|
|
39
|
+
};
|
|
40
|
+
crn: string;
|
|
41
|
+
offenderId: number;
|
|
42
|
+
pnc: string;
|
|
43
|
+
noms: string;
|
|
44
|
+
dateOfBirth: string;
|
|
45
|
+
age: string | null;
|
|
46
|
+
};
|
|
47
|
+
|
|
28
48
|
declare class MPoPComponents {
|
|
29
49
|
private readonly tierApiRestClient;
|
|
50
|
+
private readonly masApiRestClient;
|
|
30
51
|
constructor(authenticationClient: AuthenticationClient, config: MPoPComponentsConfig, logger?: Logger | Console);
|
|
31
52
|
getTierDetails(authOptions: AuthOptions | string, crn: string): Promise<LatestTierResponse>;
|
|
53
|
+
getPersonalDetails(authOptions: AuthOptions | string, crn: string): Promise<PersonalDetailsResponse>;
|
|
32
54
|
}
|
|
33
55
|
|
|
34
56
|
export { MPoPComponents };
|
package/dist/index.esm.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { RestClient } from '@ministryofjustice/hmpps-rest-client';
|
|
2
|
+
import { DateTime } from 'luxon';
|
|
2
3
|
|
|
3
4
|
class SuppressingRestClient {
|
|
4
5
|
constructor(restClient, logger) {
|
|
@@ -19,6 +20,18 @@ class SuppressingRestClient {
|
|
|
19
20
|
}
|
|
20
21
|
}
|
|
21
22
|
|
|
23
|
+
const isBlank = (str) => !str || /^\s*$/.test(str);
|
|
24
|
+
|
|
25
|
+
const yearsSince = (datetimeString) => {
|
|
26
|
+
if (!datetimeString || isBlank(datetimeString))
|
|
27
|
+
return null;
|
|
28
|
+
const dt = DateTime.fromISO(datetimeString, { zone: 'Europe/London' });
|
|
29
|
+
if (!dt.isValid)
|
|
30
|
+
return null;
|
|
31
|
+
const years = Math.trunc(DateTime.now().diff(dt, ['years', 'months']).years);
|
|
32
|
+
return years.toString();
|
|
33
|
+
};
|
|
34
|
+
|
|
22
35
|
const tierTags = {
|
|
23
36
|
missing: { text: 'Missing', color: 'red' },
|
|
24
37
|
provisional: { text: 'Provisional', color: 'orange' },
|
|
@@ -27,7 +40,9 @@ const tierTags = {
|
|
|
27
40
|
};
|
|
28
41
|
class MPoPComponents {
|
|
29
42
|
constructor(authenticationClient, config, logger = console) {
|
|
43
|
+
var _a;
|
|
30
44
|
this.tierApiRestClient = new SuppressingRestClient(new RestClient('Tier API', config, logger, authenticationClient), logger);
|
|
45
|
+
this.masApiRestClient = new SuppressingRestClient(new RestClient('MAS API', (_a = config.masApiConfig) !== null && _a !== void 0 ? _a : config, logger, authenticationClient), logger);
|
|
31
46
|
}
|
|
32
47
|
async getTierDetails(authOptions, crn) {
|
|
33
48
|
let error = null;
|
|
@@ -84,6 +99,37 @@ class MPoPComponents {
|
|
|
84
99
|
error,
|
|
85
100
|
};
|
|
86
101
|
}
|
|
102
|
+
async getPersonalDetails(authOptions, crn) {
|
|
103
|
+
let error = null;
|
|
104
|
+
let personalDetails;
|
|
105
|
+
try {
|
|
106
|
+
const response = await this.masApiRestClient.get(`/personal-details/${crn}/summary`, authOptions);
|
|
107
|
+
if (!response) {
|
|
108
|
+
personalDetails = {
|
|
109
|
+
personalDetails: null,
|
|
110
|
+
httpStatus: 404,
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
personalDetails = {
|
|
115
|
+
personalDetails: { ...response, age: yearsSince(response.dateOfBirth) },
|
|
116
|
+
httpStatus: 200,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
catch (err) {
|
|
121
|
+
error = err instanceof Error ? err : new Error('500 Internal Server Error');
|
|
122
|
+
const responseStatus = err === null || err === void 0 ? void 0 : err.responseStatus;
|
|
123
|
+
personalDetails = {
|
|
124
|
+
personalDetails: null,
|
|
125
|
+
httpStatus: responseStatus !== null && responseStatus !== void 0 ? responseStatus : 500,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return {
|
|
129
|
+
...personalDetails,
|
|
130
|
+
error,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
87
133
|
}
|
|
88
134
|
|
|
89
135
|
export { MPoPComponents };
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/SuppressingRestClient.ts","../src/MPoPComponents.ts"],"sourcesContent":[null,null],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/SuppressingRestClient.ts","../src/utils/isBlank.ts","../src/utils/yearsSince.ts","../src/MPoPComponents.ts"],"sourcesContent":[null,null,null,null],"names":[],"mappings":";;;MAGa,qBAAqB,CAAA;IAChC,WAAA,CACmB,UAAsB,EACtB,MAAwB,EAAA;QADxB,IAAA,CAAA,UAAU,GAAV,UAAU;QACV,IAAA,CAAA,MAAM,GAAN,MAAM;IACtB;AAEH,IAAA,MAAM,GAAG,CAAI,IAAY,EAAE,WAAiC,EAAA;AAC1D,QAAA,OAAO,IAAI,CAAC,UAAU,CAAC,GAAG,CACxB;YACE,IAAI;YACJ,YAAY,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,KAAK,KAAI;AAC3C,gBAAA,IAAI,KAAK,CAAC,cAAc,KAAK,GAAG,EAAE;oBAChC,IAAI,CAAC,MAAM,CAAC,K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IAAI;AACrB,oBAAA,UAAU,EAAE,GAAG;iBAChB;YACH;iBAAO;AACL,gBAAA,eAAe,GAAG;AAChB,oBAAA,eAAe,EAAE,EAAE,GAAG,QAAQ,EAAE,GAAG,EAAE,UAAU,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE;AACvE,oBAAA,UAAU,EAAE,GAAG;iBAChB;YACH;QACF;QAAE,OAAO,GAAG,EAAE;AACZ,YAAA,KAAK,GAAG,GAAG,YAAY,KAAK,GAAG,GAAG,GAAG,IAAI,KAAK,CAAC,2BAA2B,CAAC;YAC3E,MAAM,cAAc,GAAI,GAA0C,KAAA,IAAA,IAA1C,GAAG,KAAA,MAAA,GAAA,MAAA,GAAH,GAAG,CAAyC,cAAc;AAElF,YAAA,eAAe,GAAG;AAChB,gBAAA,eAAe,EAAE,IAAI;AACrB,gBAAA,UAAU,EAAE,cAAc,KAAA,IAAA,IAAd,cAAc,KAAA,MAAA,GAAd,cAAc,GAAI,GAAG;aAClC;QACH;QAEA,OAAO;AACL,YAAA,GAAG,eAAe;YAClB,KAAK;SACN;IACH;AACD;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<div class='pop-header__details'>
|
|
2
|
+
<div>
|
|
3
|
+
<ul class='govuk-list govuk-caption-m inline-list-from-tablet'>
|
|
4
|
+
<li>CRN:
|
|
5
|
+
<span data-qa='crn'>{{ params.crn }}</span>
|
|
6
|
+
<span class='govuk-!-padding-left-3 govuk-!-padding-right-3 hide-mobile'>|</span>
|
|
7
|
+
</li>
|
|
8
|
+
<li>Date of birth:
|
|
9
|
+
<span data-qa='headerDateOfBirthValue'>{{ params.dob }}</span>
|
|
10
|
+
{% if params.age %}(<span data-qa='headerDateOfBirthAge'>{{ params.age }} years old</span>){% endif %}
|
|
11
|
+
<span class='govuk-!-padding-left-3 govuk-!-padding-right-3 hide-mobile'>|</span>
|
|
12
|
+
</li>
|
|
13
|
+
<li>Tier:{{' '}}
|
|
14
|
+
<a href='{{ params.historyHref }}' data-qa='tierLink' class='govuk-link'>{{ params.tierScore }}</a>
|
|
15
|
+
</li>
|
|
16
|
+
</ul>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
{% macro supervisionPackage(params) %}
|
|
2
|
-
{% include
|
|
3
|
-
{% endmacro %}
|
|
2
|
+
{% include './template.njk' %}
|
|
3
|
+
{% endmacro %}
|
|
@@ -1,34 +1,33 @@
|
|
|
1
|
-
<div class=
|
|
2
|
-
<h2 class=
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Tier {{ params.tierScore }}
|
|
1
|
+
<div class='govuk-width-container supervision-package'>
|
|
2
|
+
<h2 class='govuk-heading-m'>{{ params.heading or 'Supervision package' }}</h2>
|
|
3
|
+
<div class='govuk-grid-row'>
|
|
4
|
+
<div class='govuk-grid-column-two-thirds'>
|
|
5
|
+
<div class='app-tier-header'>
|
|
6
|
+
<h3 class='govuk-heading-s govuk-!-margin-bottom-0'>
|
|
7
|
+
Tier {{ '' if params.tierScore == 'MISSING' else params.tierScore }}
|
|
9
8
|
</h3>
|
|
10
9
|
|
|
11
10
|
{% if params.tag.text and params.tag.color %}
|
|
12
|
-
<strong class=
|
|
11
|
+
<strong class='govuk-tag govuk-tag--{{ params.tag.color }}'>{{ params.tag.text }}</strong>
|
|
13
12
|
{% endif %}
|
|
14
13
|
</div>
|
|
15
14
|
|
|
16
15
|
{% if params.tag.text == 'Provisional' %}
|
|
17
|
-
<p class=
|
|
16
|
+
<p class='govuk-body'>
|
|
18
17
|
We will calculate the supervision package once the tier is confirmed.
|
|
19
18
|
</p>
|
|
20
19
|
{% endif %}
|
|
21
20
|
|
|
22
21
|
{% if params.tag.text == 'Unavailable' %}
|
|
23
|
-
<p class=
|
|
22
|
+
<p class='govuk-body'>
|
|
24
23
|
Tier information is currently unavailable.
|
|
25
24
|
</p>
|
|
26
25
|
{% endif %}
|
|
27
26
|
|
|
28
27
|
{% if params.historyHref %}
|
|
29
|
-
<p class=
|
|
30
|
-
<a href=
|
|
31
|
-
{{ params.historyText or
|
|
28
|
+
<p class='govuk-body'>
|
|
29
|
+
<a href='{{ params.historyHref }}' class='govuk-link govuk-link--no-visited-state'>
|
|
30
|
+
{{ params.historyText or 'View tier change history' }}
|
|
32
31
|
</a>
|
|
33
32
|
</p>
|
|
34
33
|
{% endif %}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type PersonalDetailsResponse = {
|
|
2
|
+
personalDetails: PersonalDetailsSummary | null;
|
|
3
|
+
httpStatus: number;
|
|
4
|
+
error?: Error | null;
|
|
5
|
+
};
|
|
6
|
+
export type PersonalDetailsSummary = {
|
|
7
|
+
name: {
|
|
8
|
+
forename: string;
|
|
9
|
+
middleName: string;
|
|
10
|
+
surname: string;
|
|
11
|
+
};
|
|
12
|
+
crn: string;
|
|
13
|
+
offenderId: number;
|
|
14
|
+
pnc: string;
|
|
15
|
+
noms: string;
|
|
16
|
+
dateOfBirth: string;
|
|
17
|
+
age: string | null;
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const govukTime: (datetimeString?: string) => string | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const isBlank: (str: string) => boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const yearsSince: (datetimeString: string) => string | null;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ministryofjustice/hmpps-mpop-frontend-components-lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.5",
|
|
4
4
|
"description": "MPOP front-end components library",
|
|
5
5
|
"main": "./dist/index.cjs.js",
|
|
6
6
|
"module": "./dist/index.esm.js",
|
|
@@ -71,6 +71,7 @@
|
|
|
71
71
|
"@types/bunyan": "^1.8.11",
|
|
72
72
|
"@types/jest": "^30.0.0",
|
|
73
73
|
"@types/jsdom": "^28.0.3",
|
|
74
|
+
"@types/luxon": "3.7.1",
|
|
74
75
|
"@types/node": "25.9.1",
|
|
75
76
|
"@typescript-eslint/eslint-plugin": "8.60.1",
|
|
76
77
|
"babel-jest": "^30.4.1",
|
|
@@ -92,7 +93,8 @@
|
|
|
92
93
|
},
|
|
93
94
|
"type": "commonjs",
|
|
94
95
|
"dependencies": {
|
|
95
|
-
"
|
|
96
|
+
"luxon": "3.7.2",
|
|
97
|
+
"@ministryofjustice/hmpps-auth-clients": "^1.0.1",
|
|
96
98
|
"@ministryofjustice/hmpps-rest-client": "^1.2.1",
|
|
97
99
|
"@types/nunjucks": "3.2.6",
|
|
98
100
|
"sass": "^1.100.0"
|