Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update demo #1196

Merged
merged 242 commits into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
242 commits
Select commit Hold shift + click to select a range
58ab398
removed people; added andres
davidsingal Apr 5, 2024
2edc0ab
Add carto apikey name to api conf and default dotenv
alexeh Feb 21, 2024
74e27c8
Add eudr module scaffold
alexeh Feb 23, 2024
46ac009
Queue for eudr import
alexeh Feb 26, 2024
490f5ee
Bypass queue and parse file
alexeh Feb 26, 2024
cf0faa7
Add wellknown to parse WKT to Geom
alexeh Feb 27, 2024
022a859
Add companyId to supplier entity
alexeh Feb 27, 2024
b6a7596
Add totalArea to georegion entity
alexeh Feb 27, 2024
3d47578
Adds EUDR location type
alexeh Feb 27, 2024
3309bbf
First approach saving eudr ingested data
alexeh Feb 27, 2024
3eb39ee
transactional save
alexeh Feb 27, 2024
0e02a79
Add address for company
alexeh Feb 27, 2024
8383e24
Fallback to intersection when no adminregion found by district name
alexeh Feb 27, 2024
e4c7119
generate fake output csv
alexeh Feb 27, 2024
cd5424c
Add carto tmp carto connector
alexeh Feb 27, 2024
6bba067
retrieve eudr materials
alexeh Feb 27, 2024
ed2d0bd
retrieve eudr suppliers
alexeh Feb 27, 2024
c7c3890
retrieve eudr admin-regions
alexeh Feb 27, 2024
3c0690c
Type EUDR dtos
alexeh Feb 28, 2024
f92f821
Add initial get eudr georegions
alexeh Feb 28, 2024
fd2f86d
Fix pg json equality operator error, add tests
alexeh Feb 28, 2024
a6c3cd4
eudr admin region filter tests
alexeh Feb 29, 2024
36016d8
Improve testing framework, add tests for eudr admin-regions
alexeh Feb 29, 2024
25626eb
Refactor eudr related endpoints to eudr controller
alexeh Feb 29, 2024
59d22c9
add EUDR output shape class
alexeh Feb 29, 2024
46280cc
Add bigquery client
alexeh Mar 2, 2024
580194c
Stream alerts response back
alexeh Mar 3, 2024
1883b4a
Refactor setupUser test utility
alexeh Mar 3, 2024
2bf3c58
Mock eudr repository
alexeh Mar 3, 2024
86ee5dc
Fix regressions, leave legit failing tests until further decisions ab…
alexeh Mar 4, 2024
4e17768
Endpoint to retrieve filtered EUDR Alerts
alexeh Mar 4, 2024
6659248
Dates endpoint
alexeh Mar 5, 2024
4e310ee
Add swagger spec file generation
alexeh Mar 5, 2024
4f35f3d
Adds reverse index to sourcing location georegionid column
alexeh Mar 6, 2024
a642e07
Adds geo-features.service.ts
alexeh Mar 6, 2024
c4bc08d
Get Features and FeatureCollection, update swagger spec
alexeh Mar 6, 2024
06434f0
geo-features tests
alexeh Mar 6, 2024
9c3c5fc
clean-up testing flow
alexeh Mar 6, 2024
09736c7
Add entity filters for geo-features
alexeh Mar 6, 2024
748db66
Add metadata to geo features
alexeh Mar 7, 2024
2843cec
internal param supplier type optional
alexeh Mar 7, 2024
d8de264
wrap eudr alert dates in data prop
alexeh Mar 7, 2024
c5dcc0a
eudr dashboard first version
alexeh Mar 8, 2024
d386814
add filters for dashboard
alexeh Mar 8, 2024
afc3b0a
First working dashboard breakdown version
alexeh Mar 9, 2024
a23971d
stronger type safety
alexeh Mar 10, 2024
f554bb4
eudr dashboard detail
alexeh Mar 11, 2024
db29cb6
eudr dashboard cleanup
alexeh Mar 12, 2024
b5cb22c
remove data root prop from dashboard responses
alexeh Mar 12, 2024
4ad37f2
Save georegions with no name and no geom
alexeh Mar 12, 2024
7c5a222
filter out geoRegions with no geom
alexeh Mar 12, 2024
0d0b2d7
get material and origin descendants for dashboard filters
alexeh Mar 12, 2024
1fff579
Add alert filter by georegion
alexeh Mar 12, 2024
036df58
add isoA3 to table origins and breakdown origins
alexeh Mar 12, 2024
e6eb002
Do not save missing geometries as georegions
alexeh Mar 13, 2024
9c77a4d
Update approach to calculate percentage of missing georegions per sup…
alexeh Mar 13, 2024
fad91aa
Add plotName and id to byVolume dashboard detail
alexeh Mar 13, 2024
7f04901
handle unknown georegions, aggregate volumes to unknown
alexeh Mar 14, 2024
4e2e023
group plots by alert date in eudr dashboard detail alerts
alexeh Mar 14, 2024
fbc0114
bigquery builder unit tests
alexeh Mar 14, 2024
0cd656a
calculate volume percentage by year, fix total plot area sum
alexeh Mar 15, 2024
d784bc5
Refactor approach to calculate alert values
alexeh Mar 17, 2024
9f7b845
Add company address to import
alexeh Mar 18, 2024
1baa121
update field names in bigquerybuilder
alexeh Mar 18, 2024
e9050d5
Add total carbon removals to dashboard and detail
alexeh Mar 18, 2024
cf0a941
migration from Mapbox GL to MapLibre GL
davidsingal Feb 22, 2024
da5d624
eudr page and layout
davidsingal Feb 28, 2024
8bccbfd
added supplier chart
davidsingal Mar 1, 2024
5c8e773
adding filters to eudr page
davidsingal Mar 1, 2024
dc6cb7b
updated test for map
davidsingal Feb 22, 2024
9abb88c
fixed image resolution and zoom compatibility
davidsingal Mar 5, 2024
035f1f8
eudr - suppliers breakdown foundation
andresgnlez Mar 4, 2024
8cf95ed
eudr store setup
andresgnlez Mar 5, 2024
a41010a
eudr - categories breakdown
andresgnlez Mar 5, 2024
81ed535
edur - data table
andresgnlez Mar 6, 2024
6a64b48
added geosjon layer
davidsingal Mar 6, 2024
f1ab5a0
added toogle legend
davidsingal Mar 6, 2024
994645d
added legend styles
davidsingal Mar 7, 2024
96515c7
added plot geometries from api
davidsingal Mar 7, 2024
88ccf68
starts connecting filters and fetching of filters
andresgnlez Mar 7, 2024
acd7e75
minor styling
andresgnlez Mar 8, 2024
377e83f
EUDR: API connection
andresgnlez Mar 12, 2024
a8e2bc8
adds georegions param
andresgnlez Mar 12, 2024
590a52c
moves Date object away from store
andresgnlez Mar 12, 2024
24612ef
updates labels of tooltip
andresgnlez Mar 12, 2024
3e9a301
updates ISO field
andresgnlez Mar 12, 2024
f78213c
EUDR detail page
andresgnlez Mar 12, 2024
161162b
wip
davidsingal Mar 7, 2024
d5041e0
tooltip for plot layer
davidsingal Mar 11, 2024
685fc47
planet and dual view
davidsingal Mar 11, 2024
d36e7ef
added legend, basemap selector
davidsingal Mar 13, 2024
25619aa
basemap selector
davidsingal Mar 13, 2024
45e6521
planet comparison and contextual layers
davidsingal Mar 14, 2024
eddb7af
fixed types for layer
davidsingal Mar 14, 2024
9f0e76c
redirects to eudr page after signin
andresgnlez Mar 14, 2024
581b353
removes old tailwind.config.js
andresgnlez Mar 14, 2024
569bf1a
updates redirect of signin test
andresgnlez Mar 14, 2024
b93ea1c
navigation menu: updates EUDR icon, disables other links
andresgnlez Mar 14, 2024
3776fab
fixes svg properties
andresgnlez Mar 15, 2024
9d9cd4b
adds info buttons to charts
andresgnlez Mar 15, 2024
a4ebd26
fixed bug navigating to detail; removed fitbounsd; added radd layer
davidsingal Mar 15, 2024
9d8ba99
slider range for legend
davidsingal Mar 15, 2024
9d75ef7
ensures x-axis domain is calculated properly in alerts chart
andresgnlez Mar 18, 2024
1f68507
adds CRM column to suppliers table
andresgnlez Mar 18, 2024
7d779be
supplier detail: adds carbon removal info to sourcing information
andresgnlez Mar 18, 2024
e3b16f5
passes filters to plot geometries hook
andresgnlez Mar 18, 2024
2c6ff7c
adds placeholders for feching and no data in charts
andresgnlez Mar 18, 2024
ead9921
fixes client Docker image
andresgnlez Mar 18, 2024
9e48eae
fixed opacity for layers
davidsingal Mar 18, 2024
815f91d
added planet dates
davidsingal Mar 18, 2024
d2b3f7b
fixed total number of suppliers
davidsingal Mar 19, 2024
2421b81
fixed typo
davidsingal Mar 19, 2024
0401aca
retrieves carbon removal data correctly
andresgnlez Mar 19, 2024
1a6a187
passes geoRegionIds parameter correctly
andresgnlez Mar 19, 2024
626397f
makes filters reactive
andresgnlez Mar 19, 2024
d876e3b
triggers map comparison from alerts chart
andresgnlez Mar 19, 2024
aa1bc9c
adds table filters
andresgnlez Mar 19, 2024
fd05f92
add dfs and sda georegionids by supplier
alexeh Mar 19, 2024
2c16f3d
add dfs * sda georegion ids for dashboard detail
alexeh Mar 19, 2024
20c4480
fix swagger doc for dfs sda georegion ids
alexeh Mar 19, 2024
a9468de
skipping tests conditionally
andresgnlez Mar 19, 2024
a8d3cd8
fixes EUDR redirect
andresgnlez Mar 20, 2024
f33fe04
connect real output, remove carbon_removals from query and set value …
alexeh Mar 20, 2024
9466d28
fit plots to bounds when data is fetched or changed
davidsingal Mar 20, 2024
a0db048
display plots based on dfs/sda values
andresgnlez Mar 19, 2024
8afa1b3
filter geometries by category - WIP
andresgnlez Mar 19, 2024
6703608
fixes duplicating content of category collapsible
andresgnlez Mar 20, 2024
a4895de
keeps collapsibles open based on redux values
andresgnlez Mar 20, 2024
b58fca3
max bounds and max zoom for eudr page
davidsingal Mar 20, 2024
2eaa19c
group by month and fill in missing months
alexeh Mar 20, 2024
deb810b
add all plots to all alert dates
alexeh Mar 20, 2024
f7774a4
return full detail result
alexeh Mar 20, 2024
2ea11a5
tracks zero alerts in alerts deforestation chart
andresgnlez Mar 20, 2024
540e2d5
fallback for geometries
andresgnlez Mar 20, 2024
13118da
hides tooltip for deforestation alerts chart
andresgnlez Mar 20, 2024
a0d1bca
changes category names
andresgnlez Mar 20, 2024
2af7ea0
of suppliers
andresgnlez Mar 20, 2024
400b0ca
updates column names
andresgnlez Mar 20, 2024
165f89b
updates legend with plots
andresgnlez Mar 20, 2024
09f340a
updates title of sourcing information chart
andresgnlez Mar 20, 2024
eda5249
updates label
andresgnlez Mar 20, 2024
c6986f6
removes tooltips
andresgnlez Mar 20, 2024
bdc4b85
compare map with maplibre
davidsingal Mar 20, 2024
68bc995
fixed compare for the map
davidsingal Mar 20, 2024
998fe51
fixed 500 after fitbounds
davidsingal Mar 20, 2024
360f664
fixed compare
davidsingal Mar 20, 2024
31041cc
last minute fixes
davidsingal Mar 20, 2024
ddfeb6f
descendant search for material and origin plot geojsons
alexeh Mar 21, 2024
a5bc479
env variables; basemap as react map gl layers; better styles for drag…
davidsingal Mar 21, 2024
855a579
added temporally env variables cc Alex
davidsingal Mar 21, 2024
3fe555e
legend updates
andresgnlez Mar 21, 2024
4b9015e
disabling tree data node in all filters
davidsingal Mar 21, 2024
1dead51
restores redirects to /analysis page
andresgnlez Apr 16, 2024
664a739
enables data and analysis routes from sidebar navigation
andresgnlez Apr 16, 2024
f199f7d
adds NEXT_PUBLIC_ENABLE_EUDR environmental variable
andresgnlez Apr 16, 2024
5d7437e
fixed what slider on the homepage for mobile devices
davidsingal Apr 5, 2024
0d53267
modal for mobile
davidsingal Apr 5, 2024
62b8099
fixed ui mobile
davidsingal Apr 8, 2024
5ed626d
simplifies eslint configuration
andresgnlez Apr 17, 2024
5da8819
adds environmental variable validation
andresgnlez Apr 17, 2024
cc1af22
disables analysis routes when EUDR env var is enabled
andresgnlez Apr 17, 2024
7453d3a
redirects correctly after signing
andresgnlez Apr 17, 2024
ce06b05
WIP websockets/cqrs
alexeh Apr 16, 2024
2d00cb2
Move services to app cqrs module
alexeh Apr 17, 2024
0beb676
Refactor
alexeh Apr 18, 2024
2df0bcb
Add import event start, finished and failed event handling in import …
alexeh Apr 18, 2024
875eca0
Refactor import process validation step
alexeh Apr 18, 2024
9514c3a
update import progress event data shape
alexeh Apr 19, 2024
d818c0c
Improve event status handling
alexeh Apr 19, 2024
27eb8e2
Add tracking for import and impact chunk insert
alexeh Apr 19, 2024
db068b4
fix duplicated events
alexeh Apr 19, 2024
55b81eb
Implement testing endpoint, to be removed
alexeh Apr 19, 2024
3cd4924
Allow cors for websocket gateway
alexeh Apr 19, 2024
eff0446
fix test endpoint
alexeh Apr 19, 2024
e06eeb7
Refactor event system and adds type safety
alexeh Apr 20, 2024
40cbe5e
Wrap geocoding import progress
alexeh Apr 21, 2024
f115830
use factory to create step trackers
alexeh Apr 22, 2024
605518c
Fix record insert starting point
alexeh Apr 22, 2024
71d4678
log socket client handshake
alexeh Apr 22, 2024
2ba40da
stream completed and failure events
alexeh Apr 22, 2024
816bf81
return serialized task after import
alexeh Apr 23, 2024
74b3a15
fix progress step bug
alexeh Apr 23, 2024
03a9314
implement basic ws client connection auth
alexeh Apr 23, 2024
f649f12
adds EUDR pages to middleware
andresgnlez Apr 24, 2024
cf98602
dependencies bump
andresgnlez Apr 24, 2024
4915af7
updates instructions to add environmental variables for testing
andresgnlez Apr 25, 2024
526c644
ensures session on first render
andresgnlez Apr 29, 2024
c9d7299
send import success mail
alexeh Apr 25, 2024
97ba876
Create excel sheet class validators
alexeh Apr 29, 2024
3f4d798
Add custom excel validation error
alexeh Apr 29, 2024
22a63e9
sourcing location group non mandatory
alexeh Apr 29, 2024
641672e
Improve excel validation error handling and report
alexeh Apr 30, 2024
4fdf377
WIP - geocoding error management
alexeh May 1, 2024
ee53486
refactor and cleaning import validation step
alexeh May 2, 2024
5ef71bb
Add geocoding errors to task
alexeh May 2, 2024
28aa9c8
updates sourcing-locations table test
andresgnlez May 6, 2024
b51856d
Improve typing and cleaning
alexeh May 3, 2024
4eb9d66
Comment out eudr import endpoint and eudr location type
alexeh May 3, 2024
aceb842
Delete websocket testing endpoints
alexeh May 3, 2024
f9f97cb
Cleaning
alexeh May 3, 2024
97b2e8b
Remove eudr references from location type enum
alexeh May 4, 2024
09cee62
Refactor import process and testing framework
alexeh May 5, 2024
161451c
Update tests
alexeh May 5, 2024
c093877
skip eudr admin-region geo-region tests
alexeh May 5, 2024
f972d60
Fix db cleaning before import
alexeh May 6, 2024
e170de1
Sourcing data happy case import updated tests
alexeh May 6, 2024
81127d4
Delete old tests
alexeh May 6, 2024
4913519
Add check for imported suppliers and BU
alexeh May 6, 2024
dca52a9
Update validation messages
alexeh May 6, 2024
4c2e78d
add category column to indicator csv
elpamart May 6, 2024
323d917
Adds contextual rasters, fix s3 url in tiler and format tiler style
BielStela Dec 20, 2023
11ee2a4
Adds metadata and fix values ranges for rendering
BielStela Dec 20, 2023
879f4d2
Fix commented out section
BielStela Dec 20, 2023
703cc6e
Remove debug flag
BielStela Dec 20, 2023
061180b
moves pre-commit to root
BielStela Dec 20, 2023
a37f46f
Remove contextual convert-blue-water-contextual
BielStela Jan 30, 2024
2bcaf08
Reset docker compose port map for tiler to use env var
BielStela Jan 30, 2024
63f4d8a
Add indicator category
alexeh May 6, 2024
ade59f6
moves next-auth types to src
andresgnlez May 6, 2024
5537f38
Add geo_region.totalArea to csv missing columns in populate_geo_and_a…
alexeh May 7, 2024
1c9613a
Add totalArea column to gadm csv preprocessing
BielStela May 7, 2024
fd03a09
Move checkusm to correct folder
BielStela May 8, 2024
260169f
implements UI to track data upload
andresgnlez Apr 17, 2024
6f38002
Fix columns and strart port to python script
BielStela May 8, 2024
6ca8886
Fixes python script to match the table schema
BielStela May 13, 2024
b00961e
Fix the incoming columns to avoid sql crashes
BielStela May 13, 2024
9388d8f
Fixes h3ronpy version in h3 import and fixes docstrings and linter pr…
BielStela May 13, 2024
9c5d1d4
remove oldy commented line
BielStela May 15, 2024
e19c12b
Undo h3ronpy update to avoid bug in geodataframe_to_cells that never …
BielStela May 15, 2024
fd7793d
fix obsolet python version and packages
BielStela May 15, 2024
6782790
analysis: grouped categories selector
andresgnlez May 7, 2024
a8590a8
updates tests
andresgnlez May 13, 2024
fdae161
applies feedback
andresgnlez May 14, 2024
13b8733
updates tests
andresgnlez May 14, 2024
0208043
Adds force false isCreatedByUser in geo_region
BielStela May 20, 2024
0b46183
updates indicator names to their short version
andresgnlez May 21, 2024
2b51162
removes unused root .nvmrc
andresgnlez Jun 3, 2024
91f5758
include updated blue and grey indicator coefficient csvs
elpamart May 17, 2024
8a7fdcd
remove duplicates from indicator coefficients csvs
elpamart May 22, 2024
f283c1d
remove duplicated values in csvs and remove duplicates before ingestion
elpamart May 23, 2024
d903bb8
Remove unneded comment in module docstring and drop_duplicates since …
BielStela May 23, 2024
585f57d
remove admins and materials not presents in the ddbb to avoid duplicates
elpamart Jun 4, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
22 changes: 22 additions & 0 deletions .github/workflows/testing-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,28 @@ jobs:
working-directory: api
run: yarn test:integration

testing-api-unit:
name: Unit Tests
runs-on: ubuntu-22.04
timeout-minutes: 30

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Use Node.js 18.16
uses: actions/setup-node@v3
with:
node-version: '18.16'

- name: Install API dependencies
working-directory: api
run: yarn install

- name: Run API tests + coverage
working-directory: api
run: yarn test:unit

# - name: Generate API coverage artifact
# uses: actions/upload-artifact@v2
# with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/testing-client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ jobs:
name: Running client tests
runs-on: ubuntu-22.04
timeout-minutes: 30
if: ${{ github.ref_name != 'test' }}
strategy:
fail-fast: false
defaults:
Expand Down Expand Up @@ -49,7 +50,6 @@ jobs:
command-prefix: yarn dlx
command: "yarn test:e2e"
env:
NEXT_PUBLIC_MAPBOX_API_TOKEN: ${{ secrets.NEXT_PUBLIC_MAPBOX_API_TOKEN }}
NEXT_PUBLIC_API_URL: ${{ secrets.CYPRESS_API_URL }}
NEXT_TELEMETRY_DISABLED: 1
NEXTAUTH_URL: http://localhost:3000
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ node_modules
/api/coverage
.env

## Data
## Data folders (except for root "data" module which contains all the data engineering bits
/data/datasets/**
/data/h3_data_importer/data
/data/**/data

infrastructure/base/vars/*
infrastructure/kubernetes/vars/*
Expand Down
1 change: 0 additions & 1 deletion .nvmrc

This file was deleted.

42 changes: 42 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
repos:
- repo: https://github.com/gitleaks/gitleaks
rev: v8.17.0
hooks:
- id: gitleaks-docker

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.12.1
hooks:
- id: validate-pyproject

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v2.3.0
hooks:
- id: end-of-file-fixer
- id: trailing-whitespace

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.4
hooks:
- id: ruff
args: [--fix]
types_or: [python, pyi, jupyter]

- id: ruff-format
types_or: [python, pyi, jupyter]

# - repo: https://github.com/pre-commit/mirrors-mypy
# rev: v1.3.0
# hooks:
# - id: mypy
# language_version: python
# exclude: tests/.*
# additional_dependencies:
# - types-simplejson
# - types-attrs
# - pydantic~=2.0

- repo: https://github.com/pre-commit/mirrors-prettier
rev: v3.0.3
hooks:
- id: prettier
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ NC :=\033[0m # No Color
start-api:
docker compose --project-name ${COMPOSE_PROJECT_NAME} up --build api

start-tiler:
docker compose --project-name ${COMPOSE_PROJECT_NAME} up --build tiler

# Starts the CLIENT application
start-client:
docker compose --project-name ${COMPOSE_PROJECT_NAME} up --build client
Expand Down
6 changes: 6 additions & 0 deletions api/config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,5 +72,11 @@
"email": {
"sendGridApiKey": "SENDGRID_API_KEY"
}
},
"eudr": {
"apiKey": "CARTO_API_KEY",
"baseUrl": "CARTO_BASE_URL",
"credentials": "EUDR_CREDENTIALS",
"dataset": "EUDR_DATASET"
}
}
6 changes: 6 additions & 0 deletions api/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,11 @@
"email": {
"sendGridApiKey": null
}
},
"eudr": {
"apiKey": null,
"baseUrl": "null",
"credentials": null,
"dataset": null
}
}
6 changes: 6 additions & 0 deletions api/config/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,11 @@
"email": {
"sendGridApiKey": "SG.forSomeReasonSendGridApiKeysNeedToStartWithSG."
}
},
"eudr": {
"apiKey": null,
"baseUrl": "null",
"credentials": null,
"dataset": "test_dataset"
}
}
7 changes: 7 additions & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,26 +20,31 @@
"test:cov": "node --expose-gc ./node_modules/.bin/jest --config test/jest-config.json --coverage --forceExit",
"test:debug": "node --inspect-brk --expose-gc -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --config test/jest-config.json --detectOpenHandles --forceExit",
"test:integration": "node --expose-gc ./node_modules/.bin/jest --config test/jest-config.json --forceExit -i test/integration/",
"test:unit": "node --expose-gc ./node_modules/.bin/jest --config test/jest-config.json --forceExit -i test/unit/",
"test:e2e": "NODE_OPTIONS=\"--max-old-space-size=6144\" node --expose-gc ./node_modules/.bin/jest --config test/jest-config.json --logHeapUsage --forceExit -i test/e2e/"
},
"engines": {
"node": "^18.16"
},
"dependencies": {
"@google-cloud/bigquery": "^7.5.0",
"@googlemaps/google-maps-services-js": "~3.3.2",
"@json2csv/node": "^7.0.1",
"@nestjs/axios": "^3.0.0",
"@nestjs/bull": "^10.0.1",
"@nestjs/cache-manager": "^2.0.1",
"@nestjs/common": "^10.0.5",
"@nestjs/core": "^10.0.5",
"@nestjs/cqrs": "^10.2.7",
"@nestjs/jwt": "^10.1.0",
"@nestjs/microservices": "^10.0.5",
"@nestjs/passport": "^10.0.0",
"@nestjs/platform-express": "^10.0.5",
"@nestjs/platform-socket.io": "^10.3.7",
"@nestjs/swagger": "^7.1.1",
"@nestjs/terminus": "^10.0.1",
"@nestjs/typeorm": "^10.0.0",
"@nestjs/websockets": "^10.3.7",
"@sendgrid/mail": "^7.7.0",
"@types/object-hash": "~3.0.1",
"bcrypt": "~5.1.0",
Expand Down Expand Up @@ -69,6 +74,7 @@
"swagger-ui-express": "~4.6.0",
"typeorm": "0.3.11",
"uuid": "~9.0.0",
"wellknown": "^0.5.0",
"xlsx": "~0.18.5",
"yargs": "^17.3.1"
},
Expand All @@ -85,6 +91,7 @@
"@types/config": "^3.3.0",
"@types/express": "^4.17.13",
"@types/faker": "^6.6.9",
"@types/geojson": "^7946.0.14",
"@types/jest": "^29.5.3",
"@types/jsonapi-serializer": "^3.6.5",
"@types/lodash": "^4.14.177",
Expand Down
6 changes: 6 additions & 0 deletions api/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ import { AuthorizationService } from 'modules/authorization/authorization.servic
import { TasksService } from 'modules/tasks/tasks.service';
import { NotificationsModule } from 'modules/notifications/notifications.module';
import { ReportsModule } from 'modules/reports/reports.module';
import { EudrModule } from 'modules/eudr-alerts/eudr.module';
import { WebSocketsModule } from 'modules/notifications/websockets/websockets.module';
import { AppEventsModule } from 'modules/events/app-events.module';

const queueConfig: any = config.get('queue');

Expand Down Expand Up @@ -84,6 +87,9 @@ const queueConfig: any = config.get('queue');
AuthorizationModule,
NotificationsModule,
ReportsModule,
WebSocketsModule,
EudrModule,
AppEventsModule,
],
providers: [
{
Expand Down
35 changes: 35 additions & 0 deletions api/src/create-swagger-specification.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import * as fs from 'fs';
import * as crypto from 'crypto';
import * as process from 'process';

function hashContent(content: string): string {
return crypto.createHash('sha256').update(content).digest('hex');
}

const active: boolean = false;

export async function createOrUpdateSwaggerSpec(document: any): Promise<void> {
if (active && process.env.NODE_ENV == 'development') {
const documentString: string = JSON.stringify(document);
const currentHash: string = hashContent(documentString);

const specPath: string = './swagger-spec.json';
if (fs.existsSync(specPath)) {
const existingSpec: string = fs.readFileSync(specPath, 'utf8');
const existingHash: string = hashContent(existingSpec);

if (currentHash !== existingHash) {
console.log('Swagger spec has changed. Updating...');
fs.writeFileSync(specPath, documentString);
} else {
console.log('No changes in Swagger spec.');
}
} else {
console.log('Swagger spec does not exist. Creating...');
fs.writeFileSync(specPath, documentString);
}
} else {
console.log('Swagger spec update is not active.');
return;
}
}
9 changes: 9 additions & 0 deletions api/src/guards/sensitive-info.guard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ export class SensitiveInfoGuard implements NestInterceptor {
context: ExecutionContext,
next: CallHandler<any>,
): Observable<any> {
const request = context.switchToHttp().getRequest();
if (this.dataComesFromAStreamEndpoint(request.url)) {
return next.handle();
}

return next.handle().pipe(map((data: any) => instanceToPlain(data)));
}

dataComesFromAStreamEndpoint(url: string): boolean {
return url.includes('eudr');
}
}
3 changes: 3 additions & 0 deletions api/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import * as compression from 'compression';
import { JwtAuthGuard } from 'guards/jwt-auth.guard';
import { useContainer } from 'class-validator';
import { SensitiveInfoGuard } from 'guards/sensitive-info.guard';
import { createOrUpdateSwaggerSpec } from 'create-swagger-specification';

async function bootstrap(): Promise<void> {
const logger: Logger = new Logger('bootstrap');
Expand Down Expand Up @@ -35,6 +36,8 @@ async function bootstrap(): Promise<void> {
);
SwaggerModule.setup('/swagger', app, swaggerDocument);

await createOrUpdateSwaggerSpec(swaggerDocument);

app.useGlobalPipes(
new ValidationPipe({
forbidUnknownValues: true,
Expand Down
5 changes: 4 additions & 1 deletion api/src/modules/admin-regions/admin-regions.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ import { CreateAdminRegionDto } from 'modules/admin-regions/dto/create.admin-reg
import { UpdateAdminRegionDto } from 'modules/admin-regions/dto/update.admin-region.dto';
import { PaginationMeta } from 'utils/app-base.service';
import { ApiOkTreeResponse } from 'decorators/api-tree-response.decorator';
import { GetAdminRegionTreeWithOptionsDto } from 'modules/admin-regions/dto/get-admin-region-tree-with-options.dto';
import {
GetAdminRegionTreeWithOptionsDto,
GetEUDRAdminRegions,
} from 'modules/admin-regions/dto/get-admin-region-tree-with-options.dto';
import { SetScenarioIdsInterceptor } from 'modules/impact/set-scenario-ids.interceptor';

@Controller(`/api/v1/admin-regions`)
Expand Down
4 changes: 0 additions & 4 deletions api/src/modules/admin-regions/admin-regions.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,6 @@ export class AdminRegionsService extends AppBaseService<
return this.findTreesWithOptions({ depth: adminRegionTreeOptions.depth });
}

async getAdminRegionByIds(ids: string[]): Promise<AdminRegion[]> {
return this.adminRegionRepository.findByIds(ids);
}

/**
* @description: Returns an array of all children of given Admin Region's Ids with optional parameters
* @param {string[]} adminRegionIds - The IDs of the admin regions.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import { IsBoolean, IsNumber, IsOptional, IsUUID } from 'class-validator';
import { ApiPropertyOptional } from '@nestjs/swagger';
import { CommonFiltersDto } from 'utils/base.query-builder';
import { ApiPropertyOptional, OmitType } from '@nestjs/swagger';
import {
CommonEUDRFiltersDTO,
CommonFiltersDto,
} from 'utils/base.query-builder';
import { Type } from 'class-transformer';

export class GetAdminRegionTreeWithOptionsDto extends CommonFiltersDto {
Expand All @@ -24,3 +27,7 @@ export class GetAdminRegionTreeWithOptionsDto extends CommonFiltersDto {
@IsUUID('4')
scenarioId?: string;
}

export class GetEUDRAdminRegions extends CommonEUDRFiltersDTO {
withSourcingLocations!: boolean;
}
22 changes: 1 addition & 21 deletions api/src/modules/business-units/business-units.service.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import {
forwardRef,
Inject,
Injectable,
NotFoundException,
} from '@nestjs/common';
import { forwardRef, Inject, Injectable } from '@nestjs/common';
import {
AppBaseService,
JSONAPISerializerConfig,
Expand Down Expand Up @@ -52,17 +47,6 @@ export class BusinessUnitsService extends AppBaseService<
};
}

async getBusinessUnitById(id: string): Promise<BusinessUnit> {
const found: BusinessUnit | null =
await this.businessUnitRepository.findOneBy({ id });

if (!found) {
throw new NotFoundException(`Business Unit with ID "${id}" not found`);
}

return found;
}

async getBusinessUnitsById(ids: string[]): Promise<BusinessUnit[]> {
return this.businessUnitRepository.findBy({ id: In(ids) });
}
Expand All @@ -80,10 +64,6 @@ export class BusinessUnitsService extends AppBaseService<
return this.businessUnitRepository.saveListToTree(importData, 'mpath');
}

async clearTable(): Promise<void> {
await this.businessUnitRepository.delete({});
}

async getTrees(
businessUnitTreeOptions: GetBusinessUnitTreeWithOptionsDto,
): Promise<BusinessUnit[]> {
Expand Down
Loading
Loading