@ministryofjustice/hmpps-connect-dps-components 2.2.0 → 3.0.0-beta.2
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/dist/allocationService.d.ts +14 -2
- package/dist/allocationService.test.d.ts +1 -0
- package/dist/caseLoadService.d.ts +14 -2
- package/dist/caseLoadService.test.d.ts +1 -0
- package/dist/componentsService.d.ts +24 -2
- package/dist/componentsService.test.d.ts +1 -0
- package/dist/data/allocationsApi/allocationsApiClient.d.ts +6 -6
- package/dist/data/componentApi/componentApiClient.d.ts +6 -6
- package/dist/data/prisonApi/prisonApiClient.d.ts +6 -6
- package/dist/index.cjs +266 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +141 -66
- package/dist/index.esm.js +259 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/middleware/getFrontendComponents.d.ts +3 -0
- package/dist/middleware/retrieveAllocationJobResponsibilities.d.ts +3 -0
- package/dist/middleware/retrieveCaseLoadData.d.ts +3 -0
- package/dist/types/ConnectDpsComponentLogger.d.ts +2 -0
- package/dist/types/public/middleware/index.d.ts +1 -0
- package/dist/types/public/services/index.d.ts +3 -0
- package/dist/utils/fallbacks.d.ts +9 -3
- package/dist/utils/updateCsp.d.ts +1 -1
- package/dist/utils/updateCsp.test.d.ts +1 -0
- package/package.json +34 -47
- package/dist/allocationService.js +0 -48
- package/dist/allocationService.js.map +0 -1
- package/dist/caseLoadService.js +0 -55
- package/dist/caseLoadService.js.map +0 -1
- package/dist/componentsService.js +0 -61
- package/dist/componentsService.js.map +0 -1
- package/dist/config.d.ts +0 -14
- package/dist/config.js +0 -28
- package/dist/config.js.map +0 -1
- package/dist/data/allocationsApi/allocationsApiClient.js +0 -23
- package/dist/data/allocationsApi/allocationsApiClient.js.map +0 -1
- package/dist/data/componentApi/componentApiClient.js +0 -23
- package/dist/data/componentApi/componentApiClient.js.map +0 -1
- package/dist/data/prisonApi/prisonApiClient.js +0 -24
- package/dist/data/prisonApi/prisonApiClient.js.map +0 -1
- package/dist/index.js +0 -72
- package/dist/index.js.map +0 -1
- package/dist/types/AllocationJobResponsibility.js +0 -3
- package/dist/types/AllocationJobResponsibility.js.map +0 -1
- package/dist/types/AvailableComponent.js +0 -3
- package/dist/types/AvailableComponent.js.map +0 -1
- package/dist/types/CaseLoad.js +0 -3
- package/dist/types/CaseLoad.js.map +0 -1
- package/dist/types/CaseLoadOptions.js +0 -3
- package/dist/types/CaseLoadOptions.js.map +0 -1
- package/dist/types/Component.js +0 -3
- package/dist/types/Component.js.map +0 -1
- package/dist/types/HeaderFooterSharedData.js +0 -3
- package/dist/types/HeaderFooterSharedData.js.map +0 -1
- package/dist/types/HmppsUser.js +0 -3
- package/dist/types/HmppsUser.js.map +0 -1
- package/dist/types/RequestOptions.d.ts +0 -12
- package/dist/types/RequestOptions.js +0 -3
- package/dist/types/RequestOptions.js.map +0 -1
- package/dist/types/Service.js +0 -3
- package/dist/types/Service.js.map +0 -1
- package/dist/types/TimeoutOptions.js +0 -3
- package/dist/types/TimeoutOptions.js.map +0 -1
- package/dist/utils/fallbacks.js +0 -36
- package/dist/utils/fallbacks.js.map +0 -1
- package/dist/utils/updateCsp.js +0 -25
- package/dist/utils/updateCsp.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,54 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ministryofjustice/hmpps-connect-dps-components",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-beta.2",
|
|
4
4
|
"description": "A package to allow the inclusion of connect dps micro frontend components within dps applications",
|
|
5
|
-
"main": "./dist/index.
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.esm.js",
|
|
6
7
|
"types": "./dist/index.d.ts",
|
|
7
8
|
"files": [
|
|
8
9
|
"dist/**/*"
|
|
9
10
|
],
|
|
10
11
|
"scripts": {
|
|
11
|
-
"
|
|
12
|
+
"prepare": "hmpps-precommit-hooks-prepare",
|
|
13
|
+
"build": "rollup -c rollup.config.ts --bundleConfigAsCjs && npm run copy:assets",
|
|
12
14
|
"test": "jest",
|
|
13
15
|
"test:ci": "jest --runInBand --passWithNoTests",
|
|
16
|
+
"typecheck": "tsc",
|
|
14
17
|
"lint": "eslint . --cache --max-warnings 0",
|
|
18
|
+
"lint:fix": "eslint . --cache --max-warnings 0 --fix",
|
|
15
19
|
"copy:assets": "rm -rf dist/assets && cp -r src/assets dist/assets",
|
|
16
|
-
"security_audit": "npx audit-ci --config audit-ci.json"
|
|
20
|
+
"security_audit": "npx audit-ci --config audit-ci.json",
|
|
21
|
+
"precommit:secrets": "gitleaks git --pre-commit --redact --staged --verbose --config .gitleaks/config.toml",
|
|
22
|
+
"precommit:lint": "node_modules/.bin/lint-staged",
|
|
23
|
+
"precommit:verify": "npm run typecheck && npm test"
|
|
17
24
|
},
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
{
|
|
23
|
-
"isolatedModules": true
|
|
24
|
-
}
|
|
25
|
-
]
|
|
26
|
-
},
|
|
27
|
-
"testMatch": [
|
|
28
|
-
"<rootDir>/**/**/?(*.)(cy|test).{ts,js,jsx,mjs}"
|
|
25
|
+
"lint-staged": {
|
|
26
|
+
"*.{ts,css}": [
|
|
27
|
+
"prettier --write",
|
|
28
|
+
"eslint --fix"
|
|
29
29
|
],
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
"default",
|
|
33
|
-
[
|
|
34
|
-
"jest-junit",
|
|
35
|
-
{
|
|
36
|
-
"outputDirectory": "test_results/jest/"
|
|
37
|
-
}
|
|
38
|
-
],
|
|
39
|
-
[
|
|
40
|
-
"./node_modules/jest-html-reporter",
|
|
41
|
-
{
|
|
42
|
-
"outputPath": "test_results/unit-test-reports.html"
|
|
43
|
-
}
|
|
44
|
-
]
|
|
45
|
-
],
|
|
46
|
-
"moduleFileExtensions": [
|
|
47
|
-
"web.js",
|
|
48
|
-
"js",
|
|
49
|
-
"json",
|
|
50
|
-
"node",
|
|
51
|
-
"ts"
|
|
30
|
+
"*.json": [
|
|
31
|
+
"prettier --write"
|
|
52
32
|
]
|
|
53
33
|
},
|
|
54
34
|
"repository": {
|
|
@@ -62,32 +42,39 @@
|
|
|
62
42
|
},
|
|
63
43
|
"homepage": "https://github.com/ministryofjustice/hmpps-connect-dps-components#readme",
|
|
64
44
|
"devDependencies": {
|
|
45
|
+
"@ministryofjustice/eslint-config-hmpps": "^0.0.1",
|
|
46
|
+
"@ministryofjustice/hmpps-auth-clients": "^0.0.1",
|
|
47
|
+
"@ministryofjustice/hmpps-precommit-hooks": "^0.0.3",
|
|
48
|
+
"@rollup/plugin-commonjs": "^28.0.6",
|
|
49
|
+
"@rollup/plugin-multi-entry": "^6.0.1",
|
|
50
|
+
"@rollup/plugin-node-resolve": "^16.0.1",
|
|
51
|
+
"@rollup/plugin-typescript": "^12.1.4",
|
|
52
|
+
"@tsconfig/node22": "^22.0.2",
|
|
65
53
|
"@types/bunyan": "^1.8.11",
|
|
66
54
|
"@types/express": "^4.17.22",
|
|
67
55
|
"@types/jest": "^29.5.14",
|
|
68
56
|
"@types/superagent": "^8.1.9",
|
|
69
57
|
"@types/supertest": "^6.0.3",
|
|
70
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
58
|
+
"@typescript-eslint/eslint-plugin": "^8.38.0",
|
|
71
59
|
"cheerio": "^1.0.0",
|
|
72
|
-
"eslint": "^
|
|
73
|
-
"eslint-config-airbnb-base": "^15.0.0",
|
|
74
|
-
"eslint-config-prettier": "^9.1.0",
|
|
75
|
-
"eslint-import-resolver-typescript": "^3.10.1",
|
|
76
|
-
"eslint-plugin-cypress": "^2.15.2",
|
|
77
|
-
"eslint-plugin-import": "^2.31.0",
|
|
60
|
+
"eslint-import-resolver-typescript": "^4.4.4",
|
|
78
61
|
"eslint-plugin-no-only-tests": "^3.3.0",
|
|
79
|
-
"eslint-plugin-prettier": "^5.4.0",
|
|
80
62
|
"express": "^4.21.2",
|
|
81
63
|
"govuk-frontend": "^5.10.1",
|
|
82
64
|
"jest": "^29.7.0",
|
|
83
65
|
"jest-html-reporter": "^3.10.2",
|
|
84
66
|
"jest-junit": "^16.0.0",
|
|
67
|
+
"lint-staged": "^16.1.2",
|
|
85
68
|
"nock": "^13.5.6",
|
|
69
|
+
"rollup": "^4.45.1",
|
|
70
|
+
"rollup-plugin-dts": "^6.2.1",
|
|
86
71
|
"supertest": "^7.1.1",
|
|
87
|
-
"ts-jest": "^29.3.4"
|
|
72
|
+
"ts-jest": "^29.3.4",
|
|
73
|
+
"tslib": "^2.8.1"
|
|
88
74
|
},
|
|
89
75
|
"dependencies": {
|
|
90
|
-
"@
|
|
76
|
+
"@ministryofjustice/hmpps-rest-client": "^0.0.1",
|
|
77
|
+
"@types/node": "22.12.0",
|
|
91
78
|
"@types/nunjucks": "^3.2.6",
|
|
92
79
|
"nunjucks": "^3.2.4",
|
|
93
80
|
"superagent": "^9.0.2"
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const allocationsApiClient_1 = __importDefault(require("./data/allocationsApi/allocationsApiClient"));
|
|
7
|
-
const config_1 = __importDefault(require("./config"));
|
|
8
|
-
const defaultOptions = {
|
|
9
|
-
logger: console,
|
|
10
|
-
timeoutOptions: { response: 2500, deadline: 2500 },
|
|
11
|
-
};
|
|
12
|
-
function retrieveAllocationJobResponsibilities(options) {
|
|
13
|
-
const { logger, timeoutOptions } = {
|
|
14
|
-
...defaultOptions,
|
|
15
|
-
...options,
|
|
16
|
-
};
|
|
17
|
-
if (!config_1.default.apis.allocationsApi.url)
|
|
18
|
-
throw new Error('Environment variable ALLOCATIONS_API_URL must be defined for this middleware to work correctly');
|
|
19
|
-
return async (req, res, next) => {
|
|
20
|
-
if (!req.session)
|
|
21
|
-
throw new Error('User session required in order to cache allocation job responsibilities');
|
|
22
|
-
if (!res.locals.user.token)
|
|
23
|
-
throw new Error('Caseload details needs to be populated before retrieving allocation job responsibilities. Please run retrieveCaseLoadData before retrieveAllocationJobResponsibilities.');
|
|
24
|
-
if (res.locals.user && res.locals.user.authSource === 'nomis') {
|
|
25
|
-
try {
|
|
26
|
-
// Update cache with values from res.feComponents.sharedData if present
|
|
27
|
-
if (res.locals.feComponents && res.locals.feComponents.sharedData) {
|
|
28
|
-
req.session.allocationJobResponsibilities = res.locals.feComponents.sharedData.allocationJobResponsibilities;
|
|
29
|
-
}
|
|
30
|
-
// If cache is empty, fetch data from Prison API
|
|
31
|
-
if (!req.session.allocationJobResponsibilities) {
|
|
32
|
-
logger.info(`Falling back to Allocations API to retrieve job responsibilities for: ${res.locals.user.username}`);
|
|
33
|
-
const allocationPolicies = await allocationsApiClient_1.default.getStaffAllocationPolicies(res.locals.user, timeoutOptions, logger);
|
|
34
|
-
req.session.allocationJobResponsibilities = allocationPolicies.policies;
|
|
35
|
-
}
|
|
36
|
-
// Populate res.locals.user with values from cache
|
|
37
|
-
res.locals.user.allocationJobResponsibilities = req.session.allocationJobResponsibilities;
|
|
38
|
-
}
|
|
39
|
-
catch (error) {
|
|
40
|
-
logger.error(error, `Failed to retrieve allocation job responsibilities for: ${res.locals.user.username}`);
|
|
41
|
-
return next(error);
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return next();
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
exports.default = retrieveAllocationJobResponsibilities;
|
|
48
|
-
//# sourceMappingURL=allocationService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"allocationService.js","sourceRoot":"","sources":["../src/allocationService.ts"],"names":[],"mappings":";;;;;AAEA,sGAA6E;AAC7E,sDAA6B;AAE7B,MAAM,cAAc,GAAoB;IACtC,MAAM,EAAE,OAAO;IACf,cAAc,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cAAc,EACd,MAAM,CACP,CAAA;oBACD,GAAG,CAAC,OAAO,CAAC,6BAA6B,GAAG,kBAAkB,CAAC,QAAQ,CAAA;gBACzE,CAAC;gBAED,kDAAkD;gBAClD,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,6BAA6B,GAAG,GAAG,CAAC,OAAO,CAAC,6BAA6B,CAAA;YAC3F,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,2DAA2D,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;gBAC1G,OAAO,IAAI,CAAC,KAAK,CAAC,CAAA;YACpB,CAAC;QACH,CAAC;QAED,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAA;AACH,CAAC;AA9CD,wDA8CC"}
|
package/dist/caseLoadService.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const prisonApiClient_1 = __importDefault(require("./data/prisonApi/prisonApiClient"));
|
|
7
|
-
const config_1 = __importDefault(require("./config"));
|
|
8
|
-
const defaultOptions = {
|
|
9
|
-
logger: console,
|
|
10
|
-
timeoutOptions: { response: 2500, deadline: 2500 },
|
|
11
|
-
};
|
|
12
|
-
function retrieveCaseLoadData(caseLoadOptions) {
|
|
13
|
-
const { logger, timeoutOptions } = {
|
|
14
|
-
...defaultOptions,
|
|
15
|
-
...caseLoadOptions,
|
|
16
|
-
};
|
|
17
|
-
if (!config_1.default.apis.prisonApi.url)
|
|
18
|
-
throw new Error('Environment variable PRISON_API_URL must be defined for this middleware to work correctly');
|
|
19
|
-
return async (req, res, next) => {
|
|
20
|
-
var _a;
|
|
21
|
-
if (!req.session)
|
|
22
|
-
throw new Error('User session required in order to cache case loads');
|
|
23
|
-
if (res.locals.user && res.locals.user.authSource === 'nomis') {
|
|
24
|
-
try {
|
|
25
|
-
// Update cache with values from res.feComponents.sharedData if present
|
|
26
|
-
if (res.locals.feComponents && res.locals.feComponents.sharedData) {
|
|
27
|
-
req.session.caseLoads = res.locals.feComponents.sharedData.caseLoads;
|
|
28
|
-
req.session.activeCaseLoad = res.locals.feComponents.sharedData.activeCaseLoad;
|
|
29
|
-
req.session.activeCaseLoadId = (_a = res.locals.feComponents.sharedData.activeCaseLoad) === null || _a === void 0 ? void 0 : _a.caseLoadId;
|
|
30
|
-
}
|
|
31
|
-
// If cache is empty, fetch data from Prison API
|
|
32
|
-
if (!req.session.caseLoads) {
|
|
33
|
-
logger.info(`Falling back to Prison API to retrieve case loads for: ${res.locals.user.username}`);
|
|
34
|
-
const userCaseLoads = await prisonApiClient_1.default.getUserCaseLoads(res.locals.user.token, timeoutOptions, logger);
|
|
35
|
-
const caseLoads = userCaseLoads.filter(caseload => caseload.type !== 'APP');
|
|
36
|
-
const activeCaseLoad = caseLoads.find((caseLoad) => caseLoad.currentlyActive);
|
|
37
|
-
req.session.caseLoads = caseLoads;
|
|
38
|
-
req.session.activeCaseLoad = activeCaseLoad;
|
|
39
|
-
req.session.activeCaseLoadId = activeCaseLoad === null || activeCaseLoad === void 0 ? void 0 : activeCaseLoad.caseLoadId;
|
|
40
|
-
}
|
|
41
|
-
// Populate res.locals.user with values from cache
|
|
42
|
-
res.locals.user.caseLoads = req.session.caseLoads;
|
|
43
|
-
res.locals.user.activeCaseLoad = req.session.activeCaseLoad;
|
|
44
|
-
res.locals.user.activeCaseLoadId = req.session.activeCaseLoadId;
|
|
45
|
-
}
|
|
46
|
-
catch (error) {
|
|
47
|
-
logger.error(error, `Failed to retrieve case loads for: ${res.locals.user.username}`);
|
|
48
|
-
return next(error);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return next();
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
exports.default = retrieveCaseLoadData;
|
|
55
|
-
//# sourceMappingURL=caseLoadService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"caseLoadService.js","sourceRoot":"","sources":["../src/caseLoadService.ts"],"names":[],"mappings":";;;;;AAGA,uFAA8D;AAC9D,sDAA6B;AAE7B,MAAM,cAAc,GAAoB;IACtC,MAAM,EAAE,OAAO;IACf,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;CACnD,CAAA;AAED,SAAwB,oBAAoB,CAAC,eAAiC;IAC5E,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,GAAG;QACjC,GAAG,cAAc;QACjB,GAAG,eAAe;KACnB,CAAA;IAED,IAAI,CAAC,gBAAM,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG;QAC5B,MAAM,IAAI,KAAK,CAAC,2FAA2F,CAAC,CAAA;IAE9G,OAAO,KAAK,EAAE,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;;QAC9B,IAAI,CAAC,GAAG,CAAC,OAAO;YAAE,MAAM,IAAI,KAAK,CAAC,oDAAoD,CAAC,CAAA;QAEvF,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,KAAK,OAAO,EAAE,CAAC;YAC9D,IAAI,CAAC;gBACH,uEAAuE;gBACvE,IAAI,GAAG,CAAC,MAAM,CAAC,YAAY,IAAI,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,EAAE,CAAC;oBAClE,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,SAAS,CAAA;oBACpE,GAAG,CAAC,OAAO,CAAC,cAAc,GAAG,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,CAAC,cAAc,CAAA;oBAC9E,GAAG,CAAC,OAAO,CAAC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C,KAAK,CAAC,KAAK,EAAE,sCAAsC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;gBACrF,OAAO,IAAI,CAAC,KAAK,CAAC,CAAA;YACpB,CAAC;QACH,CAAC;QAED,OAAO,IAAI,EAAE,CAAA;IACf,CAAC,CAAA;AACH,CAAC;AA7CD,uCA6CC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const componentApiClient_1 = __importDefault(require("./data/componentApi/componentApiClient"));
|
|
7
|
-
const fallbacks_1 = require("./utils/fallbacks");
|
|
8
|
-
const updateCsp_1 = __importDefault(require("./utils/updateCsp"));
|
|
9
|
-
const defaultOptions = {
|
|
10
|
-
logger: console,
|
|
11
|
-
timeoutOptions: { response: 2500, deadline: 2500 },
|
|
12
|
-
includeSharedData: false,
|
|
13
|
-
useFallbacksByDefault: false,
|
|
14
|
-
};
|
|
15
|
-
function getFrontendComponents(requestOptions) {
|
|
16
|
-
const { logger, timeoutOptions, includeSharedData, useFallbacksByDefault } = {
|
|
17
|
-
...defaultOptions,
|
|
18
|
-
...requestOptions,
|
|
19
|
-
};
|
|
20
|
-
return async (_req, res, next) => {
|
|
21
|
-
const useFallbacks = (user) => {
|
|
22
|
-
res.locals.feComponents = {
|
|
23
|
-
header: (0, fallbacks_1.getFallbackHeader)(user, requestOptions),
|
|
24
|
-
footer: (0, fallbacks_1.getFallbackFooter)(user, requestOptions),
|
|
25
|
-
cssIncludes: [],
|
|
26
|
-
jsIncludes: [],
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
if (!res.locals.user) {
|
|
30
|
-
logger.info('Using fallback frontend components when no user in context');
|
|
31
|
-
useFallbacks(null);
|
|
32
|
-
return next();
|
|
33
|
-
}
|
|
34
|
-
if (useFallbacksByDefault) {
|
|
35
|
-
logger.info('Using fallback frontend components by default');
|
|
36
|
-
useFallbacks(res.locals.user);
|
|
37
|
-
return next();
|
|
38
|
-
}
|
|
39
|
-
try {
|
|
40
|
-
const { header, footer, meta } = await componentApiClient_1.default.getComponents(res.locals.user.token, timeoutOptions, logger);
|
|
41
|
-
res.locals.feComponents = {
|
|
42
|
-
header: header.html,
|
|
43
|
-
footer: footer.html,
|
|
44
|
-
cssIncludes: [...header.css, ...footer.css],
|
|
45
|
-
jsIncludes: [...header.javascript, ...footer.javascript],
|
|
46
|
-
};
|
|
47
|
-
if (includeSharedData) {
|
|
48
|
-
res.locals.feComponents.sharedData = meta;
|
|
49
|
-
}
|
|
50
|
-
(0, updateCsp_1.default)(res);
|
|
51
|
-
return next();
|
|
52
|
-
}
|
|
53
|
-
catch (error) {
|
|
54
|
-
logger.error('Failed to retrieve front end components, using fallbacks');
|
|
55
|
-
useFallbacks(res.locals.user);
|
|
56
|
-
return next();
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
exports.default = getFrontendComponents;
|
|
61
|
-
//# sourceMappingURL=componentsService.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"componentsService.js","sourceRoot":"","sources":["../src/componentsService.ts"],"names":[],"mappings":";;;;;AACA,gGAAuE;AACvE,iDAAwE;AAExE,kEAAyC;AAGzC,MAAM,cAAc,GAA4B;IAC9C,MAAM,EAAE,OAAO;IACf,cAAc,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE;IAClD,iBAAiB,EAAE,KAAK;IACxB,qBAAqB,EAAE,KAAK;CAC7B,CAAA;AAED,SAAwB,qBAAqB,CAAC,cAA+B;IAC3E,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,GAAG;QAC3E,GAAG,cAAc;QACjB,GAAG,cA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AA;YAED,IAAI,iBAAiB,EAAE,CAAC;gBACtB,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,UAAU,GAAG,IAAI,CAAA;YAC3C,CAAC;YAED,IAAA,mBAAS,EAAC,GAAG,CAAC,CAAA;YAEd,OAAO,IAAI,EAAE,CAAA;QACf,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,0DAA0D,CAAC,CAAA;YACxE,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAA;YAC7B,OAAO,IAAI,EAAE,CAAA;QACf,CAAC;IACH,CAAC,CAAA;AACH,CAAC;AAvDD,wCAuDC"}
|
package/dist/config.d.ts
DELETED
package/dist/config.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const production = process.env.NODE_ENV === 'production';
|
|
4
|
-
function get(name, fallback, options = { requireInProduction: false }) {
|
|
5
|
-
const envVarValue = process.env[name];
|
|
6
|
-
if (envVarValue !== undefined) {
|
|
7
|
-
return envVarValue;
|
|
8
|
-
}
|
|
9
|
-
if (fallback !== undefined && (!production || !options.requireInProduction)) {
|
|
10
|
-
return fallback;
|
|
11
|
-
}
|
|
12
|
-
throw new Error(`Missing env var ${name}`);
|
|
13
|
-
}
|
|
14
|
-
const requiredInProduction = { requireInProduction: true };
|
|
15
|
-
exports.default = {
|
|
16
|
-
apis: {
|
|
17
|
-
feComponents: {
|
|
18
|
-
url: get('COMPONENT_API_URL', 'http://fe-components', requiredInProduction),
|
|
19
|
-
},
|
|
20
|
-
prisonApi: {
|
|
21
|
-
url: get('PRISON_API_URL', null),
|
|
22
|
-
},
|
|
23
|
-
allocationsApi: {
|
|
24
|
-
url: get('ALLOCATIONS_API_URL', null),
|
|
25
|
-
},
|
|
26
|
-
},
|
|
27
|
-
};
|
|
28
|
-
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;AAAA,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY,CAAA;AAExD,SAAS,GAAG,CAAC,IAAY,EAAE,QAAgB,EAAE,OAAO,GAAG,EAAE,mBAAmB,EAAE,KAAK,EAAE;IACnF,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACrC,IAAI,WAAW,KAAK,SAAS,EAAE,CAAC;QAC9B,OAAO,WAAW,CAAA;IACpB,CAAC;IACD,IAAI,QAAQ,KAAK,SAAS,IAAI,CAAC,CAAC,UAAU,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,CAAC;QAC5E,OAAO,QAAQ,CAAA;IACjB,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,EAAE,CAAC,CAAA;AAC5C,CAAC;AAED,MAAM,oBAAoB,GAAG,EAAE,mBAAmB,EAAE,IAAI,EAAE,CAAA;AAE1D,kBAAe;IACb,IAAI,EAAE;QACJ,YAAY,EAAE;YACZ,GAAG,EAAE,GAAG,CAAC,mBAAmB,EAAE,sBAAsB,EAAE,oBAAoB,CAAC;SAC5E;QACD,SAAS,EAAE;YACT,GAAG,EAAE,GAAG,CAAC,gBAAgB,EAAE,IAAI,CAAC;SACjC;QACD,cAAc,EAAE;YACd,GAAG,EAAE,GAAG,CAAC,qBAAqB,EAAE,IAAI,CAAC;SACtC;KACF;CACF,CAAA"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const superagent_1 = __importDefault(require("superagent"));
|
|
7
|
-
const config_1 = __importDefault(require("../../config"));
|
|
8
|
-
exports.default = {
|
|
9
|
-
async getStaffAllocationPolicies(user, timeoutOptions, log) {
|
|
10
|
-
const result = await superagent_1.default
|
|
11
|
-
.get(`${config_1.default.apis.allocationsApi.url}/prisons/${user.activeCaseLoadId}/staff/${user.userId}/job-classifications`)
|
|
12
|
-
.agent(this.agent)
|
|
13
|
-
.retry(2, (err, _res) => {
|
|
14
|
-
if (err)
|
|
15
|
-
log.info(`Retry handler found API error with ${err.code} ${err.message}`);
|
|
16
|
-
return undefined; // retry handler only for logging retries, not to influence retry logic
|
|
17
|
-
})
|
|
18
|
-
.auth(user.token, { type: 'bearer' })
|
|
19
|
-
.timeout(timeoutOptions);
|
|
20
|
-
return result.body;
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=allocationsApiClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"allocationsApiClient.js","sourceRoot":"","sources":["../../../src/data/allocationsApi/allocationsApiClient.ts"],"names":[],"mappings":";;;;;AACA,4DAAmC;AAEnC,0DAAiC;AAIjC,kBAAe;IACb,KAAK,CAAC,0BAA0B,CAC9B,IAAgB,EAChB,cAA8B,EAC9B,GAA4B;QAE5B,MAAM,MAAM,GAAG,MAAM,oBAAU;aAC5B,GAAG,CACF,GAAG,gBAAM,CAAC,IAAI,CAAC,cAAc,CAAC,GAAG,YAAY,IAAI,CAAC,gBAAgB,UAAU,IAAI,CAAC,MAAM,sBAAsB,CAC9G;aACA,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;aACjB,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACtB,IAAI,GAAG;gBAAE,GAAG,CAAC,IAAI,CAAC,sCAAsC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;YAClF,OAAO,SAAS,CAAA,CAAC,uEAAuE;QAC1F,CAAC,CAAC;aACD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;aACpC,OAAO,CAAC,cAAc,CAAC,CAAA;QAE1B,OAAO,MAAM,CAAC,IAAI,CAAA;IACpB,CAAC;CACF,CAAA"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const superagent_1 = __importDefault(require("superagent"));
|
|
7
|
-
const config_1 = __importDefault(require("../../config"));
|
|
8
|
-
exports.default = {
|
|
9
|
-
async getComponents(userToken, timeoutOptions, log) {
|
|
10
|
-
const result = await superagent_1.default
|
|
11
|
-
.get(`${config_1.default.apis.feComponents.url}/components`)
|
|
12
|
-
.retry(1, (err, _res) => {
|
|
13
|
-
if (err)
|
|
14
|
-
log.info(`Retry handler found API error with ${err.code} ${err.message}`);
|
|
15
|
-
return undefined; // retry handler only for logging retries, not to influence retry logic
|
|
16
|
-
})
|
|
17
|
-
.query('component=header&component=footer')
|
|
18
|
-
.set({ 'x-user-token': userToken })
|
|
19
|
-
.timeout(timeoutOptions);
|
|
20
|
-
return result.body;
|
|
21
|
-
},
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=componentApiClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"componentApiClient.js","sourceRoot":"","sources":["../../../src/data/componentApi/componentApiClient.ts"],"names":[],"mappings":";;;;;AAAA,4DAAmC;AAGnC,0DAAiC;AASjC,kBAAe;IACb,KAAK,CAAC,aAAa,CACjB,SAAiB,EACjB,cAA8B,EAC9B,GAA4B;QAE5B,MAAM,MAAM,GAAG,MAAM,oBAAU;aAC5B,GAAG,CAAC,GAAG,gBAAM,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,aAAa,CAAC;aACjD,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACtB,IAAI,GAAG;gBAAE,GAAG,CAAC,IAAI,CAAC,sCAAsC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;YAClF,OAAO,SAAS,CAAA,CAAC,uEAAuE;QAC1F,CAAC,CAAC;aACD,KAAK,CAAC,mCAAmC,CAAC;aAC1C,GAAG,CAAC,EAAE,cAAc,EAAE,SAAS,EAAE,CAAC;aAClC,OAAO,CAAC,cAAc,CAAC,CAAA;QAE1B,OAAO,MAAM,CAAC,IAAI,CAAA;IACpB,CAAC;CACF,CAAA"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const superagent_1 = __importDefault(require("superagent"));
|
|
7
|
-
const config_1 = __importDefault(require("../../config"));
|
|
8
|
-
exports.default = {
|
|
9
|
-
async getUserCaseLoads(userToken, timeoutOptions, log) {
|
|
10
|
-
const result = await superagent_1.default
|
|
11
|
-
.get(`${config_1.default.apis.prisonApi.url}/api/users/me/caseLoads`)
|
|
12
|
-
.agent(this.agent)
|
|
13
|
-
.retry(2, (err, _res) => {
|
|
14
|
-
if (err)
|
|
15
|
-
log.info(`Retry handler found API error with ${err.code} ${err.message}`);
|
|
16
|
-
return undefined; // retry handler only for logging retries, not to influence retry logic
|
|
17
|
-
})
|
|
18
|
-
.query('allCaseloads=true')
|
|
19
|
-
.auth(userToken, { type: 'bearer' })
|
|
20
|
-
.timeout(timeoutOptions);
|
|
21
|
-
return result.body;
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
//# sourceMappingURL=prisonApiClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prisonApiClient.js","sourceRoot":"","sources":["../../../src/data/prisonApi/prisonApiClient.ts"],"names":[],"mappings":";;;;;AAAA,4DAAmC;AAEnC,0DAAiC;AAIjC,kBAAe;IACb,KAAK,CAAC,gBAAgB,CACpB,SAAiB,EACjB,cAA8B,EAC9B,GAA4B;QAE5B,MAAM,MAAM,GAAG,MAAM,oBAAU;aAC5B,GAAG,CAAC,GAAG,gBAAM,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,yBAAyB,CAAC;aAC1D,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;aACjB,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE;YACtB,IAAI,GAAG;gBAAE,GAAG,CAAC,IAAI,CAAC,sCAAsC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC,CAAA;YAClF,OAAO,SAAS,CAAA,CAAC,uEAAuE;QAC1F,CAAC,CAAC;aACD,KAAK,CAAC,mBAAmB,CAAC;aAC1B,IAAI,CAAC,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;aACnC,OAAO,CAAC,cAAc,CAAC,CAAA;QAE1B,OAAO,MAAM,CAAC,IAAI,CAAA;IACpB,CAAC;CACF,CAAA"}
|
package/dist/index.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const componentsService_1 = __importDefault(require("./componentsService"));
|
|
7
|
-
const caseLoadService_1 = __importDefault(require("./caseLoadService"));
|
|
8
|
-
const allocationService_1 = __importDefault(require("./allocationService"));
|
|
9
|
-
exports.default = {
|
|
10
|
-
/**
|
|
11
|
-
* Returns a request handler for adding header and footer frontend components to res.locals
|
|
12
|
-
*
|
|
13
|
-
* Adds stringified html for each component along with lists of css javascript links.
|
|
14
|
-
*
|
|
15
|
-
* Expects nunjucks and res.locals.user to be set up inline with the hmpps-template-typescript project
|
|
16
|
-
*
|
|
17
|
-
* @param requestOptions - config object for request
|
|
18
|
-
* @param requestOptions.dpsUrl - url to the dps homepage to be used in the header
|
|
19
|
-
* @param requestOptions.authUrl - if your service has users with non-nomis auth sources, pass in the url to the auth service for the home link
|
|
20
|
-
* @param requestOptions.supportUrl - if your service has users with non-nomis auth sources, pass in the support url for the support link
|
|
21
|
-
* @param requestOptions.environmentName - if you require environment tags on the fallback banner "DEV", "PRE-PRODUCTION" or "PRODUCTION" can be passed in
|
|
22
|
-
* @param requestOptions.logger - pass in the bunyen logger if you want to use it. Falls back to console if not provided
|
|
23
|
-
* @param requestOptions.timeoutOptions - timeout object for superagent. Defaults to 2500ms
|
|
24
|
-
* @param requestOptions.includeSharedData - adds sharedData to res.locals.feComponents if true. Contains data that the components have collected in order to render, including: activeCaseLoad, caseLoads and available services for user
|
|
25
|
-
* @param requestOptions.useFallbacksByDefault - if your service requires only the basic fallback header and footer to be used by default, set this to true, it will not attempt to fetch the components from the frontend components service
|
|
26
|
-
*/
|
|
27
|
-
getPageComponents: componentsService_1.default,
|
|
28
|
-
/**
|
|
29
|
-
* Ensures that:
|
|
30
|
-
* - `res.locals.user.caseLoads`
|
|
31
|
-
* - `res.locals.user.activeCaseLoad`
|
|
32
|
-
* - `res.locals.user.activeCaseLoadId`
|
|
33
|
-
* are set for NOMIS users (or will propagate an error). It will also attempt to cache in `req.session.caseLoads`,
|
|
34
|
-
* `req.session.activeCaseLoad` and `req.session.activeCaseLoadId` (this is so that extra requests to Prison API
|
|
35
|
-
* are not required for routes that do not need frontend components, such as image data, or if the frontend component
|
|
36
|
-
* API errors or is temporarily down).
|
|
37
|
-
*
|
|
38
|
-
* It will do the following in priority order, and will attempt the next if the previous fails:
|
|
39
|
-
*
|
|
40
|
-
* * Use values from `res.feComponents.sharedData` if present (and cache in `req.session`)
|
|
41
|
-
* * Use cached data from `req.session`
|
|
42
|
-
* * Fetch data from Prison API as a fallback and cache in `req.session`
|
|
43
|
-
*
|
|
44
|
-
* Expects res.locals.user to be set up inline with the hmpps-template-typescript project
|
|
45
|
-
*
|
|
46
|
-
* @param caseLoadOptions - config object for request
|
|
47
|
-
* @param caseLoadOptions.logger - pass in the bunyen logger if you want to use it. Falls back to console if not provided
|
|
48
|
-
* @param caseLoadOptions.timeoutOptions - timeout object for superagent. Defaults to 2500ms
|
|
49
|
-
*/
|
|
50
|
-
retrieveCaseLoadData: caseLoadService_1.default,
|
|
51
|
-
/**
|
|
52
|
-
* Ensures that:
|
|
53
|
-
* - `res.locals.user.allocationJobResponsibilities`
|
|
54
|
-
* is set for NOMIS users (or will propagate an error). It will also attempt to cache in `req.session.allocationJobResponsibilities`
|
|
55
|
-
* (this is so that extra requests to Allocations API are not required for routes that do not need frontend components,
|
|
56
|
-
* such as image data, or if the frontend component API errors or is temporarily down).
|
|
57
|
-
*
|
|
58
|
-
* It will do the following in priority order, and will attempt the next if the previous fails:
|
|
59
|
-
*
|
|
60
|
-
* * Use values from `res.feComponents.sharedData` if present (and cache in `req.session`)
|
|
61
|
-
* * Use cached data from `req.session`
|
|
62
|
-
* * Fetch data from Allocations API as a fallback and cache in `req.session`
|
|
63
|
-
*
|
|
64
|
-
* Expects res.locals.user to be set up inline with the hmpps-template-typescript project
|
|
65
|
-
*
|
|
66
|
-
* @param caseLoadOptions - config object for request
|
|
67
|
-
* @param caseLoadOptions.logger - pass in the bunyen logger if you want to use it. Falls back to console if not provided
|
|
68
|
-
* @param caseLoadOptions.timeoutOptions - timeout object for superagent. Defaults to 2500ms
|
|
69
|
-
*/
|
|
70
|
-
retrieveAllocationJobResponsibilities: allocationService_1.default,
|
|
71
|
-
};
|
|
72
|
-
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;AAAA,4EAAmD;AACnD,wEAAoD;AACpD,4EAAuE;AAEvE,kBAAe;IACb;;;;;;;;;;;;;;;;OAgBG;IACH,iBAAiB,EAAjB,2BAAiB;IAEjB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,oBAAoB,EAApB,yBAAoB;IAEpB;;;;;;;;;;;;;;;;;;OAkBG;IACH,qCAAqC,EAArC,2BAAqC;CACtC,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AllocationJobResponsibility.js","sourceRoot":"","sources":["../../src/types/AllocationJobResponsibility.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AvailableComponent.js","sourceRoot":"","sources":["../../src/types/AvailableComponent.ts"],"names":[],"mappings":""}
|
package/dist/types/CaseLoad.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CaseLoad.js","sourceRoot":"","sources":["../../src/types/CaseLoad.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CaseLoadOptions.js","sourceRoot":"","sources":["../../src/types/CaseLoadOptions.ts"],"names":[],"mappings":""}
|
package/dist/types/Component.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Component.js","sourceRoot":"","sources":["../../src/types/Component.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HeaderFooterSharedData.js","sourceRoot":"","sources":["../../src/types/HeaderFooterSharedData.ts"],"names":[],"mappings":""}
|
package/dist/types/HmppsUser.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HmppsUser.js","sourceRoot":"","sources":["../../src/types/HmppsUser.ts"],"names":[],"mappings":""}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import type bunyan from 'bunyan';
|
|
2
|
-
import TimeoutOptions from './TimeoutOptions';
|
|
3
|
-
export default interface RequestOptions {
|
|
4
|
-
dpsUrl: string;
|
|
5
|
-
authUrl?: string;
|
|
6
|
-
supportUrl?: string;
|
|
7
|
-
environmentName?: 'DEV' | 'PRE-PRODUCTION' | 'PRODUCTION';
|
|
8
|
-
logger?: bunyan | typeof console;
|
|
9
|
-
includeSharedData?: boolean;
|
|
10
|
-
useFallbacksByDefault?: boolean;
|
|
11
|
-
timeoutOptions?: TimeoutOptions;
|
|
12
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"RequestOptions.js","sourceRoot":"","sources":["../../src/types/RequestOptions.ts"],"names":[],"mappings":""}
|
package/dist/types/Service.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Service.js","sourceRoot":"","sources":["../../src/types/Service.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TimeoutOptions.js","sourceRoot":"","sources":["../../src/types/TimeoutOptions.ts"],"names":[],"mappings":""}
|