diff --git a/package.json b/package.json index 0fc276d2..0d0a0fe4 100644 --- a/package.json +++ b/package.json @@ -46,14 +46,14 @@ "dependencies": { "@emotion/react": "^11.11.1", "@emotion/styled": "^11.11.0", - "@mui/material": "^5.14.11", + "@mui/material": "^5.14.13", "@types/geojson": "^7946.0.11", "ajv": "^8.12.0", "ajv-formats": "^2.1.1", "copyfiles": "^2.4.1", "docx": "^8.2.3", - "eslint": "^8.50.0", - "fast-xml-parser": "^4.3.1", + "eslint": "^8.51.0", + "fast-xml-parser": "^4.3.2", "graphql": "^16.8.1", "graphql-request": "^6.1.0", "json-schema-to-typescript": "^13.1.1", @@ -72,9 +72,9 @@ "react": "^18.2.0", "react-dom": "^18.2.0", "striptags": "^3.2.0", - "type-fest": "^4.3.3", + "type-fest": "^4.4.0", "uuid": "^9.0.1", - "zod": "^3.22.2" + "zod": "^3.22.4" }, "devDependencies": { "@types/jest": "^29.5.5", @@ -92,8 +92,8 @@ "@types/lodash.startcase": "^4.4.7", "@types/node": "^18.16.19", "@types/react": "^18.2.15", - "@types/react-dom": "^18.2.8", - "@types/uuid": "^9.0.4", + "@types/react-dom": "^18.2.13", + "@types/uuid": "^9.0.5", "@typescript-eslint/eslint-plugin": "^5.62.0", "@typescript-eslint/parser": "^5.62.0", "esbuild": "^0.19.4", @@ -101,8 +101,8 @@ "eslint-plugin-simple-import-sort": "^10.0.0", "husky": "^8.0.3", "jest": "^29.7.0", - "lint-staged": "^14.0.1", - "rimraf": "^5.0.1", + "lint-staged": "^15.0.1", + "rimraf": "^5.0.5", "ts-jest": "^29.1.1", "ts-node": "^10.9.1", "typescript": "^5.2.2" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f2c23eda..4e6286a9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,8 @@ dependencies: specifier: ^11.11.0 version: 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.15)(react@18.2.0) '@mui/material': - specifier: ^5.14.11 - version: 5.14.11(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.15)(react-dom@18.2.0)(react@18.2.0) + specifier: ^5.14.13 + version: 5.14.13(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.15)(react-dom@18.2.0)(react@18.2.0) '@types/geojson': specifier: ^7946.0.11 version: 7946.0.11 @@ -30,11 +30,11 @@ dependencies: specifier: ^8.2.3 version: 8.2.3 eslint: - specifier: ^8.50.0 - version: 8.50.0 + specifier: ^8.51.0 + version: 8.51.0 fast-xml-parser: - specifier: ^4.3.1 - version: 4.3.1 + specifier: ^4.3.2 + version: 4.3.2 graphql: specifier: ^16.8.1 version: 16.8.1 @@ -90,14 +90,14 @@ dependencies: specifier: ^3.2.0 version: 3.2.0 type-fest: - specifier: ^4.3.3 - version: 4.3.3 + specifier: ^4.4.0 + version: 4.4.0 uuid: specifier: ^9.0.1 version: 9.0.1 zod: - specifier: ^3.22.2 - version: 3.22.2 + specifier: ^3.22.4 + version: 3.22.4 devDependencies: '@types/jest': @@ -146,17 +146,17 @@ devDependencies: specifier: ^18.2.15 version: 18.2.15 '@types/react-dom': - specifier: ^18.2.8 - version: 18.2.8 + specifier: ^18.2.13 + version: 18.2.13 '@types/uuid': - specifier: ^9.0.4 - version: 9.0.4 + specifier: ^9.0.5 + version: 9.0.5 '@typescript-eslint/eslint-plugin': specifier: ^5.62.0 - version: 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.50.0)(typescript@5.2.2) + version: 5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.51.0)(typescript@5.2.2) '@typescript-eslint/parser': specifier: ^5.62.0 - version: 5.62.0(eslint@8.50.0)(typescript@5.2.2) + version: 5.62.0(eslint@8.51.0)(typescript@5.2.2) esbuild: specifier: ^0.19.4 version: 0.19.4 @@ -165,7 +165,7 @@ devDependencies: version: 0.5.0(esbuild@0.19.4) eslint-plugin-simple-import-sort: specifier: ^10.0.0 - version: 10.0.0(eslint@8.50.0) + version: 10.0.0(eslint@8.51.0) husky: specifier: ^8.0.3 version: 8.0.3 @@ -173,11 +173,11 @@ devDependencies: specifier: ^29.7.0 version: 29.7.0(@types/node@18.16.19)(ts-node@10.9.1) lint-staged: - specifier: ^14.0.1 - version: 14.0.1 + specifier: ^15.0.1 + version: 15.0.1 rimraf: - specifier: ^5.0.1 - version: 5.0.1 + specifier: ^5.0.5 + version: 5.0.5 ts-jest: specifier: ^29.1.1 version: 29.1.1(@babel/core@7.22.8)(esbuild@0.19.4)(jest@29.7.0)(typescript@5.2.2) @@ -518,6 +518,13 @@ packages: regenerator-runtime: 0.13.11 dev: false + /@babel/runtime@7.23.2: + resolution: {integrity: sha512-mM8eg4yl5D6i3lu2QKPuPH4FArvJ8KhTofbE7jwMUv9KX5mBvwPAqnV3MlyBNqdp9RyRKP6Yck8TrfYrPvX3bg==} + engines: {node: '>=6.9.0'} + dependencies: + regenerator-runtime: 0.14.0 + dev: false + /@babel/template@7.22.5: resolution: {integrity: sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==} engines: {node: '>=6.9.0'} @@ -897,13 +904,13 @@ packages: dev: true optional: true - /@eslint-community/eslint-utils@4.4.0(eslint@8.50.0): + /@eslint-community/eslint-utils@4.4.0(eslint@8.51.0): resolution: {integrity: sha512-1/sA4dwrzBAyeUoQ6oxahHKmrZvsnLCg4RfxW3ZFGGmQkSNQPFNLV9CUEFQP1x9EYXHTo5p6xdhZM1Ne9p/AfA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || >=8.0.0 dependencies: - eslint: 8.50.0 + eslint: 8.51.0 eslint-visitor-keys: 3.4.3 /@eslint-community/regexpp@4.5.1: @@ -931,8 +938,8 @@ packages: transitivePeerDependencies: - supports-color - /@eslint/js@8.50.0: - resolution: {integrity: sha512-NCC3zz2+nvYd+Ckfh87rA47zfu2QsQpvc6k1yzTk+b9KzRj0wkGa8LSoGOXN6Zv4lRf/EIoZ80biDh9HOI+RNQ==} + /@eslint/js@8.51.0: + resolution: {integrity: sha512-HxjQ8Qn+4SI3/AFv6sOrDB+g6PpUTDwSJiQqOrnneEk8L71161srI9gjzzZvYVbzHiVg/BvcH95+cK/zfIt4pg==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} /@floating-ui/core@1.4.1: @@ -1321,8 +1328,8 @@ packages: resolution: {integrity: sha512-4JQNk+3mVzK3xh2rqd6RB4J46qUR19azEHBneZyTZM+c456qOrbbM/5xcR8huNCCcbVt7+UmizG6GuUvPvKUYg==} dev: false - /@mui/base@5.0.0-beta.17(@types/react@18.2.15)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-xNbk7iOXrglNdIxFBN0k3ySsPIFLWCnFxqsAYl7CIcDkD9low4kJ7IUuy6ctwx/HAy2fenrT3KXHr1sGjAMgpQ==} + /@mui/base@5.0.0-beta.19(@types/react@18.2.15)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-maNBgAscddyPNzFZQUJDF/puxM27Li+NqSBsr/lAP8TLns2VvWS2SoL3OKFOIoRnAMKGY/Ic6Aot6gCYeQnssA==} engines: {node: '>=12.0.0'} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 @@ -1332,10 +1339,10 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.2 '@floating-ui/react-dom': 2.0.2(react-dom@18.2.0)(react@18.2.0) - '@mui/types': 7.2.4(@types/react@18.2.15) - '@mui/utils': 5.14.11(@types/react@18.2.15)(react@18.2.0) + '@mui/types': 7.2.6(@types/react@18.2.15) + '@mui/utils': 5.14.13(@types/react@18.2.15)(react@18.2.0) '@popperjs/core': 2.11.8 '@types/react': 18.2.15 clsx: 2.0.0 @@ -1344,12 +1351,12 @@ packages: react-dom: 18.2.0(react@18.2.0) dev: false - /@mui/core-downloads-tracker@5.14.11: - resolution: {integrity: sha512-uY8FLQURhXe3f3O4dS5OSGML9KDm9+IE226cBu78jarVIzdQGPlXwGIlSI9VJR8MvZDA6C0+6XfWDhWCHruC5Q==} + /@mui/core-downloads-tracker@5.14.13: + resolution: {integrity: sha512-3ZUbzcH4yloLKlV6Y+S0Edn2wef9t+EGHSfEkwVCn8E0ULdshifEFgfEroKRegQifDIwcKS/ofccxuZ8njTAYg==} dev: false - /@mui/material@5.14.11(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.15)(react-dom@18.2.0)(react@18.2.0): - resolution: {integrity: sha512-DnSdJzcR7lwG12JA5L2t8JF+RDzMygu5rCNW+logWb/KW2/TRzwLyVWO+CorHTBjBRd38DBxnwOCDiYkDd+N3A==} + /@mui/material@5.14.13(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.15)(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-iPEFwhoVG789UVsXX4gqd1eJUlcLW1oceqwJYQN8Z4MpcAKfL9Lv3fda65AwG7pQ5lf+d7IbHzm4m48SWZxI2g==} engines: {node: '>=12.0.0'} peerDependencies: '@emotion/react': ^11.5.0 @@ -1365,16 +1372,16 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.2 '@emotion/react': 11.11.1(@types/react@18.2.15)(react@18.2.0) '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.15)(react@18.2.0) - '@mui/base': 5.0.0-beta.17(@types/react@18.2.15)(react-dom@18.2.0)(react@18.2.0) - '@mui/core-downloads-tracker': 5.14.11 - '@mui/system': 5.14.11(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.15)(react@18.2.0) - '@mui/types': 7.2.4(@types/react@18.2.15) - '@mui/utils': 5.14.11(@types/react@18.2.15)(react@18.2.0) + '@mui/base': 5.0.0-beta.19(@types/react@18.2.15)(react-dom@18.2.0)(react@18.2.0) + '@mui/core-downloads-tracker': 5.14.13 + '@mui/system': 5.14.13(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.15)(react@18.2.0) + '@mui/types': 7.2.6(@types/react@18.2.15) + '@mui/utils': 5.14.13(@types/react@18.2.15)(react@18.2.0) '@types/react': 18.2.15 - '@types/react-transition-group': 4.4.6 + '@types/react-transition-group': 4.4.7 clsx: 2.0.0 csstype: 3.1.2 prop-types: 15.8.1 @@ -1384,8 +1391,8 @@ packages: react-transition-group: 4.4.5(react-dom@18.2.0)(react@18.2.0) dev: false - /@mui/private-theming@5.14.11(@types/react@18.2.15)(react@18.2.0): - resolution: {integrity: sha512-MSnNNzTu9pfKLCKs1ZAKwOTgE4bz+fQA0fNr8Jm7NDmuWmw0CaN9Vq2/MHsatE7+S0A25IAKby46Uv1u53rKVQ==} + /@mui/private-theming@5.14.13(@types/react@18.2.15)(react@18.2.0): + resolution: {integrity: sha512-5EFqk4tqiSwPguj4NW/6bUf4u1qoUWXy9lrKfNh9H6oAohM+Ijv/7qSxFjnxPGBctj469/Sc5aKAR35ILBKZLQ==} engines: {node: '>=12.0.0'} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 @@ -1394,15 +1401,15 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.15 - '@mui/utils': 5.14.11(@types/react@18.2.15)(react@18.2.0) + '@babel/runtime': 7.23.2 + '@mui/utils': 5.14.13(@types/react@18.2.15)(react@18.2.0) '@types/react': 18.2.15 prop-types: 15.8.1 react: 18.2.0 dev: false - /@mui/styled-engine@5.14.11(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(react@18.2.0): - resolution: {integrity: sha512-jdUlqRgTYQ8RMtPX4MbRZqar6W2OiIb6J5KEFbIu4FqvPrk44Each4ppg/LAqp1qNlBYq5i+7Q10MYLMpDxX9A==} + /@mui/styled-engine@5.14.13(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(react@18.2.0): + resolution: {integrity: sha512-1ff/egFQl26hiwcUtCMKAkp4Sgqpm3qIewmXq+GN27fb44lDIACquehMFBuadOjceOFmbIXbayzbA46ZyqFYzA==} engines: {node: '>=12.0.0'} peerDependencies: '@emotion/react': ^11.4.1 @@ -1414,7 +1421,7 @@ packages: '@emotion/styled': optional: true dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.2 '@emotion/cache': 11.11.0 '@emotion/react': 11.11.1(@types/react@18.2.15)(react@18.2.0) '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.15)(react@18.2.0) @@ -1423,8 +1430,8 @@ packages: react: 18.2.0 dev: false - /@mui/system@5.14.11(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.15)(react@18.2.0): - resolution: {integrity: sha512-yl8xV+y0k7j6dzBsHabKwoShmjqLa8kTxrhUI3JpqLG358VRVMJRW/ES0HhvfcCi4IVXde+Tc2P3K1akGL8zoA==} + /@mui/system@5.14.13(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(@types/react@18.2.15)(react@18.2.0): + resolution: {integrity: sha512-+5+Dx50lG4csbx2sGjrKLozXQJeCpJ4dIBZolyFLkZ+XphD1keQWouLUvJkPQ3MSglLLKuD37pp52YjMncZMEQ==} engines: {node: '>=12.0.0'} peerDependencies: '@emotion/react': ^11.5.0 @@ -1439,13 +1446,13 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.2 '@emotion/react': 11.11.1(@types/react@18.2.15)(react@18.2.0) '@emotion/styled': 11.11.0(@emotion/react@11.11.1)(@types/react@18.2.15)(react@18.2.0) - '@mui/private-theming': 5.14.11(@types/react@18.2.15)(react@18.2.0) - '@mui/styled-engine': 5.14.11(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(react@18.2.0) - '@mui/types': 7.2.4(@types/react@18.2.15) - '@mui/utils': 5.14.11(@types/react@18.2.15)(react@18.2.0) + '@mui/private-theming': 5.14.13(@types/react@18.2.15)(react@18.2.0) + '@mui/styled-engine': 5.14.13(@emotion/react@11.11.1)(@emotion/styled@11.11.0)(react@18.2.0) + '@mui/types': 7.2.6(@types/react@18.2.15) + '@mui/utils': 5.14.13(@types/react@18.2.15)(react@18.2.0) '@types/react': 18.2.15 clsx: 2.0.0 csstype: 3.1.2 @@ -1453,10 +1460,10 @@ packages: react: 18.2.0 dev: false - /@mui/types@7.2.4(@types/react@18.2.15): - resolution: {integrity: sha512-LBcwa8rN84bKF+f5sDyku42w1NTxaPgPyYKODsh01U1fVstTClbUoSA96oyRBnSNyEiAVjKm6Gwx9vjR+xyqHA==} + /@mui/types@7.2.6(@types/react@18.2.15): + resolution: {integrity: sha512-7sjLQrUmBwufm/M7jw/quNiPK/oor2+pGUQP2CULRcFCArYTq78oJ3D5esTaL0UMkXKJvDqXn6Ike69yAOBQng==} peerDependencies: - '@types/react': '*' + '@types/react': ^17.0.0 || ^18.0.0 peerDependenciesMeta: '@types/react': optional: true @@ -1464,8 +1471,8 @@ packages: '@types/react': 18.2.15 dev: false - /@mui/utils@5.14.11(@types/react@18.2.15)(react@18.2.0): - resolution: {integrity: sha512-fmkIiCPKyDssYrJ5qk+dime1nlO3dmWfCtaPY/uVBqCRMBZ11JhddB9m8sjI2mgqQQwRJG5bq3biaosNdU/s4Q==} + /@mui/utils@5.14.13(@types/react@18.2.15)(react@18.2.0): + resolution: {integrity: sha512-2AFpyXWw7uDCIqRu7eU2i/EplZtks5LAMzQvIhC79sPV9IhOZU2qwOWVnPtdctRXiQJOAaXulg+A37pfhEueQw==} engines: {node: '>=12.0.0'} peerDependencies: '@types/react': ^17.0.0 || ^18.0.0 @@ -1474,8 +1481,8 @@ packages: '@types/react': optional: true dependencies: - '@babel/runtime': 7.22.15 - '@types/prop-types': 15.7.5 + '@babel/runtime': 7.23.2 + '@types/prop-types': 15.7.8 '@types/react': 18.2.15 prop-types: 15.8.1 react: 18.2.0 @@ -1711,14 +1718,18 @@ packages: /@types/prop-types@15.7.5: resolution: {integrity: sha512-JCB8C6SnDoQf0cNycqd/35A7MjcnK+ZTqE7judS6o7utxUCg6imJg3QK2qzHKszlTjcj2cn+NwMB2i96ubpj7w==} - /@types/react-dom@18.2.8: - resolution: {integrity: sha512-bAIvO5lN/U8sPGvs1Xm61rlRHHaq5rp5N3kp9C+NJ/Q41P8iqjkXSu0+/qu8POsjH9pNWb0OYabFez7taP7omw==} + /@types/prop-types@15.7.8: + resolution: {integrity: sha512-kMpQpfZKSCBqltAJwskgePRaYRFukDkm1oItcAbC3gNELR20XIBcN9VRgg4+m8DKsTfkWeA4m4Imp4DDuWy7FQ==} + dev: false + + /@types/react-dom@18.2.13: + resolution: {integrity: sha512-eJIUv7rPP+EC45uNYp/ThhSpE16k22VJUknt5OLoH9tbXoi8bMhwLf5xRuWMywamNbWzhrSmU7IBJfPup1+3fw==} dependencies: '@types/react': 18.2.15 dev: true - /@types/react-transition-group@4.4.6: - resolution: {integrity: sha512-VnCdSxfcm08KjsJVQcfBmhEQAPnLB8G08hAxn39azX1qYBQ/5RVQuoHuKIcfKOdncuaUvEpFKFzEvbtIMsfVew==} + /@types/react-transition-group@4.4.7: + resolution: {integrity: sha512-ICCyBl5mvyqYp8Qeq9B5G/fyBSRC0zx3XM3sCC6KkcMsNeAHqXBKkmat4GqdJET5jtYUpZXrxI5flve5qhi2Eg==} dependencies: '@types/react': 18.2.15 dev: false @@ -1741,8 +1752,8 @@ packages: resolution: {integrity: sha512-Hl219/BT5fLAaz6NDkSuhzasy49dwQS/DSdu4MdggFB8zcXv7vflBI3xp7FEmkmdDkBUI2bPUNeMttp2knYdxw==} dev: true - /@types/uuid@9.0.4: - resolution: {integrity: sha512-zAuJWQflfx6dYJM62vna+Sn5aeSWhh3OB+wfUEACNcqUSc0AGc5JKl+ycL1vrH7frGTXhJchYjE1Hak8L819dA==} + /@types/uuid@9.0.5: + resolution: {integrity: sha512-xfHdwa1FMJ082prjSJpoEI57GZITiQz10r3vEJCHa2khEFQjKy91aWKz6+zybzssCvXUwE1LQWgWVwZ4nYUvHQ==} dev: true /@types/yargs-parser@21.0.0: @@ -1761,7 +1772,7 @@ packages: '@types/yargs-parser': 21.0.0 dev: true - /@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.50.0)(typescript@5.2.2): + /@typescript-eslint/eslint-plugin@5.62.0(@typescript-eslint/parser@5.62.0)(eslint@8.51.0)(typescript@5.2.2): resolution: {integrity: sha512-TiZzBSJja/LbhNPvk6yc0JrX9XqhQ0hdh6M2svYfsHGejaKFIAGd9MQ+ERIMzLGlN/kZoYIgdxFV0PuljTKXag==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1773,12 +1784,12 @@ packages: optional: true dependencies: '@eslint-community/regexpp': 4.5.1 - '@typescript-eslint/parser': 5.62.0(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/parser': 5.62.0(eslint@8.51.0)(typescript@5.2.2) '@typescript-eslint/scope-manager': 5.62.0 - '@typescript-eslint/type-utils': 5.62.0(eslint@8.50.0)(typescript@5.2.2) - '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/type-utils': 5.62.0(eslint@8.51.0)(typescript@5.2.2) + '@typescript-eslint/utils': 5.62.0(eslint@8.51.0)(typescript@5.2.2) debug: 4.3.4 - eslint: 8.50.0 + eslint: 8.51.0 graphemer: 1.4.0 ignore: 5.2.4 natural-compare-lite: 1.4.0 @@ -1789,7 +1800,7 @@ packages: - supports-color dev: true - /@typescript-eslint/parser@5.62.0(eslint@8.50.0)(typescript@5.2.2): + /@typescript-eslint/parser@5.62.0(eslint@8.51.0)(typescript@5.2.2): resolution: {integrity: sha512-VlJEV0fOQ7BExOsHYAGrgbEiZoi8D+Bl2+f6V2RrXerRSylnp+ZBHmPvaIa8cz0Ajx7WO7Z5RqfgYg7ED1nRhA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1803,7 +1814,7 @@ packages: '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.2.2) debug: 4.3.4 - eslint: 8.50.0 + eslint: 8.51.0 typescript: 5.2.2 transitivePeerDependencies: - supports-color @@ -1817,7 +1828,7 @@ packages: '@typescript-eslint/visitor-keys': 5.62.0 dev: true - /@typescript-eslint/type-utils@5.62.0(eslint@8.50.0)(typescript@5.2.2): + /@typescript-eslint/type-utils@5.62.0(eslint@8.51.0)(typescript@5.2.2): resolution: {integrity: sha512-xsSQreu+VnfbqQpW5vnCJdq1Z3Q0U31qiWmRhr98ONQmcp/yhiPJFPq8MXiJVLiksmOKSjIldZzkebzHuCGzew==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: @@ -1828,9 +1839,9 @@ packages: optional: true dependencies: '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.2.2) - '@typescript-eslint/utils': 5.62.0(eslint@8.50.0)(typescript@5.2.2) + '@typescript-eslint/utils': 5.62.0(eslint@8.51.0)(typescript@5.2.2) debug: 4.3.4 - eslint: 8.50.0 + eslint: 8.51.0 tsutils: 3.21.0(typescript@5.2.2) typescript: 5.2.2 transitivePeerDependencies: @@ -1863,19 +1874,19 @@ packages: - supports-color dev: true - /@typescript-eslint/utils@5.62.0(eslint@8.50.0)(typescript@5.2.2): + /@typescript-eslint/utils@5.62.0(eslint@8.51.0)(typescript@5.2.2): resolution: {integrity: sha512-n8oxjeb5aIbPFEtmQxQYOLI0i9n5ySBEY/ZEHHZqKQSFnxio1rv6dthascc9dLuwrL0RC5mPCxB7vnAVGAYWAQ==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} peerDependencies: eslint: ^6.0.0 || ^7.0.0 || ^8.0.0 dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.50.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.51.0) '@types/json-schema': 7.0.12 '@types/semver': 7.5.0 '@typescript-eslint/scope-manager': 5.62.0 '@typescript-eslint/types': 5.62.0 '@typescript-eslint/typescript-estree': 5.62.0(typescript@5.2.2) - eslint: 8.50.0 + eslint: 8.51.0 eslint-scope: 5.1.1 semver: 7.5.4 transitivePeerDependencies: @@ -2431,8 +2442,8 @@ packages: resolution: {integrity: sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==} dev: true - /commander@11.0.0: - resolution: {integrity: sha512-9HMlXtt/BNoYr8ooyjjNRdIilOTkVJXB+GhxMTtOKwk0R4j4lS4NpjuqmRxroBfnfTSHQIHQB7wryHhXarNjmQ==} + /commander@11.1.0: + resolution: {integrity: sha512-yPVavfyCcRhmorC7rWlkHn15b4wDVgVmBA7kV4QVBsF7kv/9TKJAbAXVTxvTnwP8HHKjRCJDClKbciiYS7p0DQ==} engines: {node: '>=16'} dev: true @@ -2441,7 +2452,7 @@ packages: dev: true /concat-map@0.0.1: - resolution: {integrity: sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=} + resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} /convert-source-map@1.9.0: resolution: {integrity: sha512-ASFBup0Mz1uyiIjANan1jzLQami9z1PoYSZCiiYW2FczPbenXc45FZdBZLzOT+r6+iciuEModtmCti+hjaAk0A==} @@ -2651,7 +2662,7 @@ packages: /dom-helpers@5.2.1: resolution: {integrity: sha512-nRCa7CK3VTrM2NmGkIy4cbK7IZlgBE/PYMn55rrXefr5xXDP0LdtfPnblFDoVdcAfslJ7or6iqAUnx0CCGIWQA==} dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.2 csstype: 3.1.2 dev: false @@ -2780,12 +2791,12 @@ packages: resolution: {integrity: sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==} engines: {node: '>=10'} - /eslint-plugin-simple-import-sort@10.0.0(eslint@8.50.0): + /eslint-plugin-simple-import-sort@10.0.0(eslint@8.51.0): resolution: {integrity: sha512-AeTvO9UCMSNzIHRkg8S6c3RPy5YEwKWSQPx3DYghLedo2ZQxowPFLGDN1AZ2evfg6r6mjBSZSLxLFsWSu3acsw==} peerDependencies: eslint: '>=5.0.0' dependencies: - eslint: 8.50.0 + eslint: 8.51.0 dev: true /eslint-scope@5.1.1: @@ -2807,15 +2818,15 @@ packages: resolution: {integrity: sha512-wpc+LXeiyiisxPlEkUzU6svyS1frIO3Mgxj1fdy7Pm8Ygzguax2N3Fa/D/ag1WqbOprdI+uY6wMUl8/a2G+iag==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} - /eslint@8.50.0: - resolution: {integrity: sha512-FOnOGSuFuFLv/Sa+FDVRZl4GGVAAFFi8LecRsI5a1tMO5HIE8nCm4ivAlzt4dT3ol/PaaGC0rJEEXQmHJBGoOg==} + /eslint@8.51.0: + resolution: {integrity: sha512-2WuxRZBrlwnXi+/vFSJyjMqrNjtJqiasMzehF0shoLaW7DzS3/9Yvrmq5JiT66+pNjiX4UBnLDiKHcWAr/OInA==} engines: {node: ^12.22.0 || ^14.17.0 || >=16.0.0} hasBin: true dependencies: - '@eslint-community/eslint-utils': 4.4.0(eslint@8.50.0) + '@eslint-community/eslint-utils': 4.4.0(eslint@8.51.0) '@eslint-community/regexpp': 4.6.2 '@eslint/eslintrc': 2.1.2 - '@eslint/js': 8.50.0 + '@eslint/js': 8.51.0 '@humanwhocodes/config-array': 0.11.11 '@humanwhocodes/module-importer': 1.0.1 '@nodelib/fs.walk': 1.2.8 @@ -2934,18 +2945,18 @@ packages: strip-final-newline: 2.0.0 dev: true - /execa@7.2.0: - resolution: {integrity: sha512-UduyVP7TLB5IcAQl+OzLyLcS/l32W/GLg+AhHJ+ow40FOk2U3SAllPwR44v4vmdFwIWqpdwxxpQbF1n5ta9seA==} - engines: {node: ^14.18.0 || ^16.14.0 || >=18.0.0} + /execa@8.0.1: + resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} + engines: {node: '>=16.17'} dependencies: cross-spawn: 7.0.3 - get-stream: 6.0.1 - human-signals: 4.3.1 + get-stream: 8.0.1 + human-signals: 5.0.0 is-stream: 3.0.0 merge-stream: 2.0.0 npm-run-path: 5.1.0 onetime: 6.0.0 - signal-exit: 3.0.7 + signal-exit: 4.1.0 strip-final-newline: 3.0.0 dev: true @@ -3048,8 +3059,8 @@ packages: /fast-levenshtein@2.0.6: resolution: {integrity: sha512-DCXu6Ifhqcks7TZKY3Hxp3y6qphY5SJZmrWMDrKcERSOXWQdMhU9Ig/PYrzyw/ul9jOIyh0N4M0tbC5hodg8dw==} - /fast-xml-parser@4.3.1: - resolution: {integrity: sha512-viVv3xb8D+SiS1W4cv4tva3bni08kAkx0gQnWrykMM8nXPc1FxqZPU00dCEVjkiCg4HoXd2jC4x29Nzg/l2DAA==} + /fast-xml-parser@4.3.2: + resolution: {integrity: sha512-rmrXUXwbJedoXkStenj1kkljNF7ugn5ZjR9FJcwmCfcCbtOMDghPajbc+Tck6vE6F5XsDmx+Pr2le9fw8+pXBg==} hasBin: true dependencies: strnum: 1.0.5 @@ -3183,6 +3194,11 @@ packages: engines: {node: '>=10'} dev: true + /get-stream@8.0.1: + resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} + engines: {node: '>=16'} + dev: true + /get-value@2.0.6: resolution: {integrity: sha512-Ln0UQDlxH1BapMu3GPtf7CuYNwRZf2gwCuPqbyG6pB8WfmFpzqcy4xtAaAMUhnNqjMKTiCPZG2oMT3YSx8U2NA==} engines: {node: '>=0.10.0'} @@ -3211,13 +3227,13 @@ packages: glob: 7.2.3 dev: false - /glob@10.3.3: - resolution: {integrity: sha512-92vPiMb/iqpmEgsOoIDvTjc50wf9CCCvMzsi6W0JLPeUKE8TWP1a73PgqSrqy7iAZxaSD1YdzU7QZR5LF51MJw==} + /glob@10.3.10: + resolution: {integrity: sha512-fa46+tv1Ak0UPK1TOy/pZrIybNNt4HCv7SDzwyfiOZkvZLEbjsZkJBPtDHVshZjbecAoAGSC20MjLDG/qr679g==} engines: {node: '>=16 || 14 >=14.17'} hasBin: true dependencies: foreground-child: 3.1.1 - jackspeak: 2.2.1 + jackspeak: 2.3.6 minimatch: 9.0.3 minipass: 7.0.2 path-scurry: 1.10.1 @@ -3340,9 +3356,9 @@ packages: engines: {node: '>=10.17.0'} dev: true - /human-signals@4.3.1: - resolution: {integrity: sha512-nZXjEF2nbo7lIw3mgYjItAfgQXog3OjJogSbKa2CQIIvSGWcKgeJnQlNXip6NglNzYH45nSRiEVimMvYL8DDqQ==} - engines: {node: '>=14.18.0'} + /human-signals@5.0.0: + resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} + engines: {node: '>=16.17.0'} dev: true /husky@8.0.3: @@ -3621,8 +3637,8 @@ packages: istanbul-lib-report: 3.0.0 dev: true - /jackspeak@2.2.1: - resolution: {integrity: sha512-MXbxovZ/Pm42f6cDIDkl3xpwv1AGwObKwfmjs2nQePiy85tP3fatofl3FC1aBsOtP/6fq5SbtgHwWcMsLP+bDw==} + /jackspeak@2.3.6: + resolution: {integrity: sha512-N3yCS/NegsOBokc8GAdM8UcmfsKiSS8cipheD/nivzr700H+nsMOxJjQnvwOcRYVuFkdH0wGUvW2WbXGmrZGbQ==} engines: {node: '>=14'} dependencies: '@isaacs/cliui': 8.0.2 @@ -4284,34 +4300,28 @@ packages: /lines-and-columns@1.2.4: resolution: {integrity: sha512-7ylylesZQ/PV29jhEDl3Ufjo6ZX7gCqJr5F7PKrqc93v7fzSymt1BpwEU8nAUXs8qzzvqhbjhK5QZg6Mt/HkBg==} - /lint-staged@14.0.1: - resolution: {integrity: sha512-Mw0cL6HXnHN1ag0mN/Dg4g6sr8uf8sn98w2Oc1ECtFto9tvRF7nkXGJRbx8gPlHyoR0pLyBr2lQHbWwmUHe1Sw==} - engines: {node: ^16.14.0 || >=18.0.0} + /lint-staged@15.0.1: + resolution: {integrity: sha512-2IU5OWmCaxch0X0+IBF4/v7sutpB+F3qoXbro43pYjQTOo5wumckjxoxn47pQBqqBsCWrD5HnI2uG/zJA7isew==} + engines: {node: '>=18.12.0'} hasBin: true dependencies: chalk: 5.3.0 - commander: 11.0.0 + commander: 11.1.0 debug: 4.3.4 - execa: 7.2.0 + execa: 8.0.1 lilconfig: 2.1.0 - listr2: 6.6.1 + listr2: 7.0.1 micromatch: 4.0.5 pidtree: 0.6.0 string-argv: 0.3.2 - yaml: 2.3.1 + yaml: 2.3.2 transitivePeerDependencies: - - enquirer - supports-color dev: true - /listr2@6.6.1: - resolution: {integrity: sha512-+rAXGHh0fkEWdXBmX+L6mmfmXmXvDGEKzkjxO+8mP3+nI/r/CWznVBvsibXdxda9Zz0OW2e2ikphN3OwCT/jSg==} + /listr2@7.0.1: + resolution: {integrity: sha512-nz+7hwgbDp8eWNoDgzdl4hA/xDSLrNRzPu1TLgOYs6l5Y+Ma6zVWWy9Oyt9TQFONwKoSPoka3H50D3vD5EuNwg==} engines: {node: '>=16.0.0'} - peerDependencies: - enquirer: '>= 2.3.0 < 3' - peerDependenciesMeta: - enquirer: - optional: true dependencies: cli-truncate: 3.1.0 colorette: 2.0.20 @@ -4952,7 +4962,7 @@ packages: react: '>=16.6.0' react-dom: '>=16.6.0' dependencies: - '@babel/runtime': 7.22.15 + '@babel/runtime': 7.23.2 dom-helpers: 5.2.1 loose-envify: 1.4.0 prop-types: 15.8.1 @@ -5088,12 +5098,12 @@ packages: dependencies: glob: 7.2.3 - /rimraf@5.0.1: - resolution: {integrity: sha512-OfFZdwtd3lZ+XZzYP/6gTACubwFcHdLRqS9UX3UwpU2dnGQYkPFISRwvM3w9IiB2w7bW5qGo/uAwE4SmXXSKvg==} + /rimraf@5.0.5: + resolution: {integrity: sha512-CqDakW+hMe/Bz202FPEymy68P+G50RfMQK+Qo5YUqc9SPipvbGjCGKd0RSKEelbsfQuw3g5NZDSrlZZAJurH1A==} engines: {node: '>=14'} hasBin: true dependencies: - glob: 10.3.3 + glob: 10.3.10 dev: true /rsvp@4.8.5: @@ -5208,6 +5218,11 @@ packages: engines: {node: '>=14'} dev: true + /signal-exit@4.1.0: + resolution: {integrity: sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==} + engines: {node: '>=14'} + dev: true + /sisteransi@1.0.5: resolution: {integrity: sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==} dev: true @@ -5615,8 +5630,8 @@ packages: engines: {node: '>=10'} dev: true - /type-fest@4.3.3: - resolution: {integrity: sha512-bxhiFii6BBv6UiSDq7uKTMyADT9unXEl3ydGefndVLxFeB44LRbT4K7OJGDYSyDrKnklCC1Pre68qT2wbUl2Aw==} + /type-fest@4.4.0: + resolution: {integrity: sha512-HT3RRs7sTfY22KuPQJkD/XjbTbxgP2Je5HPt6H6JEGvcjHd5Lqru75EbrP3tb4FYjNJ+DjLp+MNQTFQU0mhXNw==} engines: {node: '>=16'} dev: false @@ -5812,8 +5827,8 @@ packages: engines: {node: '>= 6'} dev: false - /yaml@2.3.1: - resolution: {integrity: sha512-2eHWfjaoXgTBC2jNM1LRef62VQa0umtvRiDSk6HSzW7RvS5YtkabJrwYLLEKWBc8a5U2PTSCs+dJjUTJdlHsWQ==} + /yaml@2.3.2: + resolution: {integrity: sha512-N/lyzTPaJasoDmfV7YTrYCI0G/3ivm/9wdG0aHuheKowWQwGTsK0Eoiw6utmzAnI6pkJa0DUVygvp3spqqEKXg==} engines: {node: '>= 14'} dev: true @@ -5862,6 +5877,6 @@ packages: resolution: {integrity: sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==} engines: {node: '>=10'} - /zod@3.22.2: - resolution: {integrity: sha512-wvWkphh5WQsJbVk1tbx1l1Ly4yg+XecD+Mq280uBGt9wa5BKSWf4Mhp6GmrkPixhMxmabYY7RbzlwVP32pbGCg==} + /zod@3.22.4: + resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} dev: false diff --git a/src/export/csv/index.ts b/src/export/csv/index.ts index 0f1ec886..bed40ba2 100644 --- a/src/export/csv/index.ts +++ b/src/export/csv/index.ts @@ -1,36 +1,13 @@ import omit from "lodash.omit"; import type { - BOPSExportData, BOPSFullPayload, - ExportData, Passport, QuestionAndResponses, Response, } from "../../types"; export function computeCSVData({ - sessionId, - bopsExportData, - passport, -}: { - sessionId: string; - bopsExportData: BOPSExportData; - passport: Passport; -}): ExportData { - const compute = (input: BOPSFullPayload) => - computeQuestionAndResponses({ - sessionId, - bopsData: input, - passport, - }); - return { - responses: compute(bopsExportData.exportData), - redactedResponses: compute(bopsExportData.redactedExportData), - }; -} - -export function computeQuestionAndResponses({ sessionId, bopsData, passport, diff --git a/src/export/digitalPlanning/index.ts b/src/export/digitalPlanning/index.ts index 9c577b75..1101434d 100644 --- a/src/export/digitalPlanning/index.ts +++ b/src/export/digitalPlanning/index.ts @@ -1,14 +1,13 @@ -import { GraphQLClient } from "graphql-request"; - import { findPublishedFlowBySessionId } from "../../requests/flow"; import { getSessionById, getSessionMetadata } from "../../requests/session"; +import { ExportParams } from ".."; import { DigitalPlanning } from "./model"; import { DigitalPlanningApplication as DigitalPlanningPayload } from "./schema/types"; -export async function generateDigitalPlanningPayload( - client: GraphQLClient, - sessionId: string, -): Promise { +export async function generateDigitalPlanningPayload({ + client, + sessionId, +}: ExportParams): Promise { const session = await getSessionById(client, sessionId); if (!session) throw new Error(`Cannot find session ${sessionId}`); diff --git a/src/export/digitalPlanning/model.ts b/src/export/digitalPlanning/model.ts index 8db77d74..f123f6e6 100644 --- a/src/export/digitalPlanning/model.ts +++ b/src/export/digitalPlanning/model.ts @@ -20,6 +20,7 @@ import jsonSchema from "./schema/schema.json"; import { ApplicationType, DigitalPlanningApplication as Payload, + PlanningConstraint, } from "./schema/types"; interface DigitalPlanningArgs { @@ -59,9 +60,6 @@ export class DigitalPlanning { return this.payload; } - /** - * WIP - */ mapPassportToPayload(): Payload { return { data: { @@ -98,7 +96,7 @@ export class DigitalPlanning { submittedAt: this.metadata.submittedAt, }, schema: { - url: "https://theopensystemslab.github.io/digital-planning-data-schemas/v0.0.1/schema.json", // @todo populate version based on submittedAt + url: `https://theopensystemslab.github.io/digital-planning-data-schemas/${jsonSchema["$id"]}/schema.json`, }, }, }; @@ -131,6 +129,17 @@ export class DigitalPlanning { )[0]?.properties["description"].const; } + /** + * Cast a string to a boolean + */ + private stringToBool(value: string | undefined): boolean { + if (value && typeof value === "string" && value.toLowerCase() === "true") { + return true; + } else { + return false; + } + } + private getApplicantOwnership(): Payload["data"]["applicant"]["ownership"] { if (this.passport.data?.["applicant.interest"][0] === "owner.sole") { return { @@ -139,7 +148,7 @@ export class DigitalPlanning { } else { return { certificate: this.passport.data?.["applicant.ownership.certificate"][0], - noticeGiven: Boolean( + noticeGiven: this.stringToBool( this.passport.data?.["applicant.ownership.noticeGiven"], ), owners: [ @@ -206,6 +215,8 @@ export class DigitalPlanning { siteContact: this.getSiteContact(), }; + // Prior Approval application types don't collect additional ownership info + // @todo translate this to schema type rather than mapping condition if (this.passport.data?.["application.type"][0].startsWith("pa")) { return baseApplicant; } else { @@ -264,25 +275,26 @@ export class DigitalPlanning { } private getPropertyAddress(): Payload["data"]["property"]["address"] { + const address = this.passport.data?._address; const baseAddress = { - latitude: this.passport.data?._address?.["latitude"], - longitude: this.passport.data?._address?.["longitude"], - x: this.passport.data?._address?.["x"], - y: this.passport.data?._address?.["y"], - title: this.passport.data?._address?.["title"], + latitude: address?.["latitude"], + longitude: address?.["longitude"], + x: address?.["x"], + y: address?.["y"], + title: address?.["title"], }; - if (this.passport.data?._address?.source === "os") { + if (address?.source === "os") { return { ...baseAddress, source: "Ordnance Survey", - uprn: this.passport.data?._address?.["uprn"], - usrn: this.passport.data?._address?.["usrn"], - pao: this.passport.data?._address?.["pao"], - street: this.passport.data?._address?.["street"], - town: this.passport.data?._address?.["town"], - postcode: this.passport.data?._address?.["postcode"], - singleLine: this.passport.data?._address?.["single_line_address"], + uprn: address?.["uprn"], + usrn: address?.["usrn"], + pao: address?.["pao"], + street: address?.["street"], + town: address?.["town"], + postcode: address?.["postcode"], + singleLine: address?.["single_line_address"], }; } else { return { @@ -347,6 +359,7 @@ export class DigitalPlanning { } private getPlanningConstraints(): Payload["data"]["property"]["constraints"] { + // @todo remove any and type data as PlanningConstraint[] const data: any = []; const teamSlug: string = this.metadata.flow.team.slug; @@ -410,21 +423,21 @@ export class DigitalPlanning { calculated: this.passport.data?.["application.fee.calculated"], payable: this.passport.data?.["application.fee.payable"], exemption: { - disability: Boolean( + disability: this.stringToBool( this.passport.data?.["application.fee.exemption.disability"][0], ), - resubmission: Boolean( + resubmission: this.stringToBool( this.passport.data?.["application.fee.exemption.resubmission"][0], ), }, reduction: { - sports: Boolean( + sports: this.stringToBool( this.passport.data?.["application.fee.reduction.sports"]?.[0], ), - parishCouncil: Boolean( + parishCouncil: this.stringToBool( this.passport.data?.["application.fee.reduction.parishCouncil"]?.[0], ), - alternative: Boolean( + alternative: this.stringToBool( this.passport.data?.["application.fee.reduction.alternative"]?.[0], ), }, @@ -445,7 +458,7 @@ export class DigitalPlanning { private getApplicationDeclaration(): Payload["data"]["application"]["declaration"] { return { - accurate: Boolean( + accurate: this.stringToBool( this.passport.data?.["application.declaration.accurate"][0], ), connection: { @@ -458,8 +471,9 @@ export class DigitalPlanning { }; } - // @todo support flagsets beyond Planning Permission + // @todo getResult() should support flagsets beyond Planning Permission private getResult(): Payload["result"] { + // Planning Permission application types won't have a Planning Permission result right now if (this.passport.data?.["application.type"][0].startsWith("pp")) { return []; } else { @@ -546,6 +560,7 @@ export class DigitalPlanning { ); if (this.passport.data?.["proposal.vehicleParking"][0] !== "none") { + // @todo infer vehicleTypes & carTypes directly from schema.json ? const vehicleTypes = [ "cars", "vans", @@ -632,6 +647,7 @@ export class DigitalPlanning { } private getFiles(): Payload["files"] { + // @todo remove any and type files as File[] const files: any = []; Object.entries(this.passport.data) diff --git a/src/export/index.ts b/src/export/index.ts index 2b10a670..ac95fdf0 100644 --- a/src/export/index.ts +++ b/src/export/index.ts @@ -1 +1,142 @@ -export * from "./oneApp"; +import { GraphQLClient } from "graphql-request"; + +import { findPublishedFlowBySessionId, getFlowName } from "../requests/flow"; +import { getSessionById, getSessionPassport } from "../requests/session"; +import type { BOPSFullPayload, QuestionAndResponses } from "../types"; +import { computeBOPSParams } from "./bops"; +import { computeCSVData } from "./csv"; +import { generateDigitalPlanningPayload } from "./digitalPlanning"; +import { DigitalPlanningDataSchema } from "./digitalPlanning/schema/types"; +import { generateOneAppXML } from "./oneApp"; + +export type ExportParams = { + client: GraphQLClient; + sessionId: string; +}; + +type RedactionOptions = + | { isRedacted?: false; keysToRedact?: never } + | { isRedacted: true; keysToRedact?: string[] }; + +export type ExportWithRedactionParams = ExportParams & RedactionOptions; + +export class ExportClient { + protected client: GraphQLClient; + + constructor(client: GraphQLClient) { + this.client = client; + } + + csvData(sessionId: string): Promise { + return generateCSVData({ client: this.client, sessionId }); + } + + csvDataRedacted(sessionId: string): Promise { + return generateCSVData({ + client: this.client, + sessionId, + isRedacted: true, + }); + } + + bopsPayload(sessionId: string): Promise { + return generateBOPSPayload({ client: this.client, sessionId }); + } + + bopsPayloadRedacted(sessionId: string): Promise { + return generateBOPSPayload({ + client: this.client, + sessionId, + isRedacted: true, + }); + } + + digitalPlanningDataPayload( + sessionId: string, + ): Promise { + return generateDigitalPlanningPayload({ client: this.client, sessionId }); + } + + async oneAppPayload(sessionId: string): Promise { + return generateOneAppXML({ client: this.client, sessionId }); + } +} + +export async function generateCSVData({ + client, + sessionId, + isRedacted, +}: ExportWithRedactionParams) { + const bopsData = await generateBOPSPayload({ client, sessionId, isRedacted }); + if (!bopsData) { + throw new Error( + `Cannot fetch BOPS data for session ${sessionId} so cannot generate CSV Data`, + ); + } + + const passport = await getSessionPassport(client, sessionId); + if (!passport) { + throw new Error( + `Cannot find passport for session ${sessionId} so cannot generate CSV Data`, + ); + } + + return computeCSVData({ + sessionId, + bopsData, + passport, + }); +} + +export async function generateBOPSPayload({ + client, + sessionId, + isRedacted = false, + keysToRedact, +}: ExportWithRedactionParams): Promise { + try { + const session = await getSessionById(client, sessionId); + if (!session) throw new Error(`Cannot find session ${sessionId}`); + + const flow = await findPublishedFlowBySessionId(client, sessionId); + if (!flow) throw new Error(`Cannot get flow ${session.flowId}`); + + const flowName = await getFlowName(client, session.flowId); + const { breadcrumbs, passport } = session.data; + + if (isRedacted) { + // compute redacted export data + const defaultKeysToRedact = [ + "applicant.phone.primary", + "applicant.phone.secondary", + "applicant.email", + "applicant.agent.phone.primary", + "applicant.agent.phone.secondary", + "applicant.agent.email", + ]; + const redactedExportData = computeBOPSParams({ + sessionId, + flow, + flowName, + breadcrumbs, + passport, + keysToRedact: keysToRedact || defaultKeysToRedact, + }); + + return redactedExportData; + } + + // compute export data + const exportData = computeBOPSParams({ + sessionId, + flow, + flowName, + breadcrumbs, + passport, + }); + + return exportData; + } catch (e) { + throw new Error(`Cannot generate BOPS payload: ${e}`); + } +} diff --git a/src/export/oneApp/index.test.ts b/src/export/oneApp/index.test.ts index 4c40a583..0e7b8113 100644 --- a/src/export/oneApp/index.test.ts +++ b/src/export/oneApp/index.test.ts @@ -51,7 +51,7 @@ describe("generateOneAppXML", () => { .mockImplementationOnce(() => false) .mockImplementationOnce(() => false); - const xml = await generateOneAppXML(client, "abc123"); + const xml = await generateOneAppXML({ client, sessionId: "abc123" }); expect(xml).not.toBeUndefined(); const isValid = XMLValidator.validate(xml!); expect(isValid).toBe(true); diff --git a/src/export/oneApp/index.ts b/src/export/oneApp/index.ts index f682ec48..9b26a3ba 100644 --- a/src/export/oneApp/index.ts +++ b/src/export/oneApp/index.ts @@ -1,16 +1,15 @@ -import { GraphQLClient } from "graphql-request"; - import { Passport } from "../../models/passport"; import { getDocumentTemplateNamesForSession } from "../../requests/document-templates"; import { getSessionById } from "../../requests/session"; import { hasRequiredDataForTemplate } from "../../templates"; import { Passport as IPassport } from "../../types"; +import { ExportParams } from ".."; import { OneAppPayload } from "./model"; -export async function generateOneAppXML( - client: GraphQLClient, - sessionId: string, -): Promise { +export async function generateOneAppXML({ + client, + sessionId, +}: ExportParams): Promise { const session = await getSessionById(client, sessionId); if (!session) throw Error(`No session found matching ID ${sessionId}`); diff --git a/src/requests/index.ts b/src/requests/index.ts index f23faf72..e13dadf6 100644 --- a/src/requests/index.ts +++ b/src/requests/index.ts @@ -1,14 +1,13 @@ import type { GraphQLClient } from "graphql-request"; import slugify from "lodash.kebabcase"; -import { generateOneAppXML } from "../export/oneApp"; +import { ExportClient } from "../export"; import type { KeyPath, PaymentRequest, Session } from "../types"; import { ApplicationClient } from "./application"; import { getDocumentTemplateNamesForFlow, getDocumentTemplateNamesForSession, } from "./document-templates"; -import { ExportClient } from "./export"; import { createFlow, FlowClient, publishFlow } from "./flow"; import { Auth, getGraphQLClient } from "./graphql"; import { createPaymentRequest, PaymentRequestClient } from "./payment-request"; @@ -111,10 +110,6 @@ export class CoreDomainClient { return getDocumentTemplateNamesForSession(this.client, sessionId); } - async generateOneAppXML(sessionId: string): Promise { - return generateOneAppXML(this.client, sessionId); - } - async getSessionById(sessionId: string): Promise { return getSessionById(this.client, sessionId); } diff --git a/src/types/export.ts b/src/types/export.ts index 14a4dfaa..507f5259 100644 --- a/src/types/export.ts +++ b/src/types/export.ts @@ -1,9 +1,4 @@ -import { BOPSFullPayload, QuestionAndResponses } from "./bops"; - -export type BOPSExportData = { - exportData: BOPSFullPayload; - redactedExportData: BOPSFullPayload; -}; +import { QuestionAndResponses } from "./bops"; export type ExportData = { responses: QuestionAndResponses[];