Skip to content

[RELEASE] Dazzling Diamond #149

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

Merged
merged 120 commits into from
May 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
120 commits
Select commit Hold shift + click to select a range
4881bc4
[TM-1861] WIP status state machine support.
roguenet Apr 7, 2025
d7df6cd
[TM-1861] Implement entity status state machine for project.
roguenet Apr 7, 2025
baab788
[TM-1861] Common module depends on database module; move the dependen…
roguenet Apr 7, 2025
605d883
[TM-1861] The user creation service doesn't use JWTs.
roguenet Apr 7, 2025
d8deae8
[TM-1861] Set up an event emitter pattern from the database lib.
roguenet Apr 7, 2025
9aed845
[TM-1861] Wire up BullMQ for email sends.
roguenet Apr 8, 2025
3bd10e0
[TM-1861] Improve i18n template email handling.
roguenet Apr 8, 2025
7d9429b
[TM-1861] Get the entity status email fully wired up.
roguenet Apr 8, 2025
075de90
[TM-1861] Use a single central health module for all services.
roguenet Apr 9, 2025
b543cbf
[TM-1861] Specify the entity update do not email list in github secre…
roguenet Apr 9, 2025
533c20b
[TM-1861] Add a note about ENV configuration.
roguenet Apr 9, 2025
739819f
[TM-1861] WIP generic update endpoint.
roguenet Apr 10, 2025
181c221
[TM-1861] Basic status updates.
roguenet Apr 10, 2025
0313598
[TM-1861] Support for feedback / feedbackFields
roguenet Apr 10, 2025
7db3b82
[TM-1861] Specify the update DTO for each entity type.
roguenet Apr 10, 2025
5069a3e
[TM-1861] Merge remote-tracking branch 'origin/staging' into feat/TM-…
roguenet Apr 10, 2025
b108f37
[TM-1861] Double check the path / payload entity ID as well.
roguenet Apr 10, 2025
0841c37
[TM-1861] Use the updated polymorphic chain scope pattern for Media.
roguenet Apr 10, 2025
ae50eb4
[TM-1861] Generate UUIDs automatically.
roguenet Apr 10, 2025
427ca56
[TM-1861] Spec out the audit statuses DB table.
roguenet Apr 10, 2025
3bacc4d
[TM-1861] Avoid multiple EmailProcessor classes.
roguenet Apr 10, 2025
0386541
[TM-1861] Finish implementing side effects for project status update.
roguenet Apr 10, 2025
f7350e6
[TM-1861] Expose the set of supported entities as a const to the FE.
roguenet Apr 11, 2025
d37a778
[TM-1861] Fix build.
roguenet Apr 11, 2025
55ed532
[TM-1861] Update user creation service spec.
roguenet Apr 11, 2025
7a91bdb
[TM-1861] Update reset password service spec.
roguenet Apr 11, 2025
8f86726
[TM-1711] refactor: simplify job query by removing unnecessary status…
Scriptmatico Apr 16, 2025
8b8db47
[TM-1861] Merge remote-tracking branch 'origin/staging' into feat/TM-…
roguenet Apr 17, 2025
9ace600
[TM-1861] npm audit fix
roguenet Apr 17, 2025
7d207d5
[TM-1861] Provide a built-in option for getting to the shell instead …
roguenet Apr 17, 2025
f9bb163
[TM-1861] Email specs updated.
roguenet Apr 17, 2025
3db370a
[TM-1711] test: update bulkUpdateJobs test to correctly handle pendin…
Scriptmatico Apr 17, 2025
1094f42
[TM-1861] Full coverage for common lib.
roguenet Apr 17, 2025
dec37df
[TM-1861] Cover the new behaviors in entity service.
roguenet Apr 17, 2025
a032071
[TM-1861] Specs for ModelColumnStateMachine
roguenet Apr 18, 2025
1234ca0
[TM-1937] change nothingToReport to nullable
Scriptmatico Apr 18, 2025
422372b
Merge pull request #136 from wri/main
roguenet Apr 18, 2025
996fcaa
[TM-1861] Fix directions for seeing local emails.
roguenet Apr 18, 2025
75007a1
[TM-1937] add nothingToReport to LigthDto
Scriptmatico Apr 18, 2025
3ae4c9c
[TM-1861] Specs for the entity status update event processor.
roguenet Apr 18, 2025
5afae39
[TM-1861] Handle status updates for site and nursery
roguenet Apr 18, 2025
c22fafe
[TM-1861] Merge remote-tracking branch 'origin/staging' into feat/TM-…
roguenet Apr 18, 2025
521775e
[TM-1960] To get a true count, we need to modify with distinct.
roguenet Apr 21, 2025
08d6f8f
[TM-1955] All columns for Task defined.
roguenet Apr 21, 2025
3c4d34e
[TM-1955] Define the state machines for tasks and reports.
roguenet Apr 21, 2025
03e33b6
Merge pull request #135 from wri/feat/TM-1711-notifications-allow-use…
Scriptmatico Apr 21, 2025
41dc299
[TM-1955] Implement task status update when a report is updated.
roguenet Apr 21, 2025
6d79af7
Merge pull request #139 from wri/fix/TM-1960-site-polygon-pagination-…
roguenet Apr 21, 2025
919c03b
Merge pull request #138 from wri/feat/TM-1861-entity-update
roguenet Apr 21, 2025
df98225
[TM-1955] Support update of all six entity types.
roguenet Apr 22, 2025
6227aec
[TM-1955] Support for nothing to report updates on site / nursery rep…
roguenet Apr 22, 2025
1a347a0
[TM-1955] Get coverage back up in entity service.
roguenet Apr 22, 2025
4595e80
[TM-1955] Coverage for checkTaskStatus.
roguenet Apr 22, 2025
bc1fa9d
[TM-1955] Update report policies.
roguenet Apr 23, 2025
db27bcc
[TM-1955] updateRequestStatus needs to be predictable to avoid flaky …
roguenet Apr 23, 2025
efe628b
[TM-1955] Test coverage for update / approve on entities.
roguenet Apr 23, 2025
d58b6f6
[TM-1955] Fix column definition of feedback fields.
roguenet Apr 23, 2025
3c382b1
[TM-1955] Fix replacement of parent entity name for reports.
roguenet Apr 23, 2025
a90fb63
[TM-1955] Fix empty feedback detection.
roguenet Apr 23, 2025
c853c74
[TM-1959] feat: add Disturbance entity support in entity processing a…
Scriptmatico Apr 23, 2025
5a4bb00
[TM-1953] add entities service user to permissions
LimberHope Apr 23, 2025
a9ff19f
[TM-1953] add entities service user to permissions
LimberHope Apr 23, 2025
ed02175
[TM-1953] update site and nursery-report processor spect
LimberHope Apr 23, 2025
17f7f5d
Merge pull request #141 from wri/fix/TM-1953_issues_accessing_site_re…
LimberHope Apr 23, 2025
d43bf2a
Merge pull request #140 from wri/feat/TM-1955-report-status-update
roguenet Apr 23, 2025
9f9aa45
[TM-1922] add sideload for associations
egrojMonroy Apr 23, 2025
bb1b3ac
[TM-1922] Merge Staging
egrojMonroy Apr 23, 2025
2bc8411
[TM-1922]remove unused variables
egrojMonroy Apr 23, 2025
a61bb7c
[TM-1937] remove nothingToReport from fulldto and change data type in…
Scriptmatico Apr 24, 2025
032b1b0
Merge branch 'staging' into feat/TM-1937-Add-nothing-report-column-si…
Scriptmatico Apr 24, 2025
05e7142
[TM-1937] Fx uuidv4 issue
Scriptmatico Apr 24, 2025
d75fade
[TM-1922] add included dto function
egrojMonroy Apr 24, 2025
073dd30
[TM-1922] change any to type
egrojMonroy Apr 24, 2025
01dc0ce
[TM-1937] Fix status check
Scriptmatico Apr 24, 2025
212e42e
[TM-1959] feat: update DisturbancesProcessor to support Disturbance e…
Scriptmatico Apr 24, 2025
76e76f0
[TM-1922] rollback to original test
egrojMonroy Apr 24, 2025
97fa614
[TM-1922] add sideload demographic test
egrojMonroy Apr 24, 2025
f47cd2b
[TM-1922] unify addDtos
egrojMonroy Apr 24, 2025
1abc04d
[TM-1937] Fix logic for status check
Scriptmatico Apr 24, 2025
c6277f4
Merge pull request #142 from wri/feat/TM-1922-sideload-associations
egrojMonroy Apr 24, 2025
ee3a46d
[TM-1922] add attributes to light site
egrojMonroy Apr 24, 2025
f0669c6
Merge pull request #137 from wri/feat/TM-1937-Add-nothing-report-colu…
Scriptmatico Apr 24, 2025
dd43cee
[TM-1959] feat: update Disturbance DTOs and processor to enhance supp…
Scriptmatico Apr 25, 2025
74546ad
[TM-1922] add pctSurvivalToDate to the light resource DTO for project…
cesarLima1 Apr 25, 2025
6505588
[TM-1922] improve query sum
egrojMonroy Apr 25, 2025
f049128
Merge pull request #144 from wri/feat/TM-1922-survival-rate-from-proj…
cesarLima1 Apr 25, 2025
ef767a7
[TM-1922] replace nullish operator
egrojMonroy Apr 25, 2025
db38aec
[TM-1959] feat: enhance Disturbance entity and DTO with additional pr…
Scriptmatico Apr 25, 2025
7237430
[TM-1942] add new fields to fields in projects and site reports
LimberHope Apr 25, 2025
9155b91
[TM-1959] feat: extend Disturbance DTO and entity with new properties…
Scriptmatico Apr 25, 2025
034bc09
[TM-1959] feat: refactor Disturbance processor and DTOs for improved …
Scriptmatico Apr 25, 2025
00215c0
Merge pull request #146 from wri/feat/TM-1942_add_upload_fields_for_p…
LimberHope Apr 25, 2025
c180fa2
[TM-1958] Build our initial Data API integration as its own library.
roguenet Apr 25, 2025
7ea63cc
[TM-1959] feat: refactor Disturbance and Invasive DTOs to extend Asso…
Scriptmatico Apr 25, 2025
0d12828
[TM-1959] feat: add Strata entity and DTO support to entity processin…
Scriptmatico Apr 25, 2025
b87ddf4
[TM-1959] feat: remove Disturbance and Invasive checks from update me…
Scriptmatico Apr 25, 2025
fbd972f
[TM-1959] Merge branch 'staging' into feat/TM-1959-Move-Get-disturban…
Scriptmatico Apr 25, 2025
015e427
[TM-1959] remove unused import for Invasive entity in strata.dto.ts
Scriptmatico Apr 25, 2025
5c582ce
[TM-1959] refactor: clean up imports in entities and stratas.entity f…
Scriptmatico Apr 25, 2025
16b860c
[TM-1958] Use the data API to get the gadm level 0 and level 1 names …
roguenet Apr 25, 2025
60a1a1c
[TM-1959] refactor: remove unused entity references in entities.ts
Scriptmatico Apr 25, 2025
df95a31
[TM-1959] refactor: remove unused Invasive entity import in entities.ts
Scriptmatico Apr 25, 2025
1e02ccb
[TM-1958] Update coverage for the unified database service.
roguenet Apr 25, 2025
b886d33
[TM-1959] Add entities to controller response
Scriptmatico Apr 27, 2025
1e068bc
Merge pull request #143 from wri/feat/TM-1922-update-light-site
egrojMonroy Apr 28, 2025
93552a5
[TM-1958] Data API specs
roguenet Apr 28, 2025
a290e00
[TM-1959] refactor: remove unused properties from disturbance and inv…
Scriptmatico Apr 29, 2025
0f210a8
[TM-1959] refactor: remove unused INTEGER import from disturbance and…
Scriptmatico Apr 29, 2025
9751f0a
[TM-1959] refactor: mark oldId and oldModel as deprecated in Disturba…
Scriptmatico Apr 29, 2025
0a5ea21
Merge pull request #145 from wri/feat/TM-1959-Move-Get-disturbances-s…
Scriptmatico Apr 29, 2025
3af1589
[TM-1958] Merge remote-tracking branch 'origin/staging' into feat/TM-…
roguenet Apr 30, 2025
b452085
Merge pull request #147 from wri/feat/TM-1958-data-api-gadm
roguenet Apr 30, 2025
2fb4a3b
Add TLS strings to the redis config.
roguenet Apr 30, 2025
879d2e6
[TM-1931] Modify configurations for cpu / memory based on AWS recomme…
roguenet Apr 30, 2025
305ed31
[TM-1931] Audit fix
roguenet May 1, 2025
7a05b24
[TM-1931] Fix imports.
roguenet May 1, 2025
86f1387
[TM-2010] fix typo and add subjectKey as parameter for template rende…
pachonjcl May 1, 2025
78e1f30
[TM-2010] improve subject gather from params
pachonjcl May 1, 2025
9ba3304
Merge pull request #151 from wri/fix/TM-2010_unable_sign_up_as_new_user
pachonjcl May 1, 2025
d2033b4
Merge pull request #150 from wri/feat/TM-1931-rightsize-fargate
roguenet May 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions .env.local.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ DB_PASSWORD=wri
REDIS_HOST=localhost
REDIS_PORT=6379

# Shared Data API key that may be used by all devs and AWS environments
DATA_API_KEY=349c85f6-a915-4d3d-b337-0a0dafc0e5db

JWT_SECRET=qu3sep4GKdbg6PiVPCKLKljHukXALorq6nLHDBOCSwvs6BrgE6zb8gPmZfrNspKt

AWS_ENDPOINT==http://minio:9000
Expand All @@ -28,15 +31,17 @@ AIRTABLE_BASE_ID=
SLACK_API_KEY=
UDB_SLACK_CHANNEL=

MAIL_HOST=email-smtp.eu-west-1.amazonaws.com
MAIL_PORT=587
MAIL_USERNAME=
MAIL_PASSWORD=
[email protected]
# Points to the mail catcher running from the PHP docker-compose. Visit localhost:1080 to see "sent" emails.
MAIL_HOST=localhost
MAIL_PORT=1025
[email protected]
# If set, email is redirected from the original recipient to this list of addresses. The original
# recipients are encoded in the X-Original-Recipients header
MAIL_RECIPIENTS=
# If set, email addresses on this list will be exempted from receiving updates to entity statuses
ENTITY_UPDATE_DO_NOT_EMAIL=

TRANSIFEX_TOKEN=1/dada8aab9ed6bba68805fcab6349f2e69d3b1367

EMAIL_IMAGE_BASE_URL=https://api.terramatch.org/images
APP_FRONT_END=http://localhost:3000
1 change: 1 addition & 0 deletions .github/workflows/deploy-service.yml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ jobs:
echo "AIRTABLE_API_KEY=\"${{ secrets.AIRTABLE_API_KEY }}\"" >> .env
echo "SENTRY_DSN=\"${{ secrets.SENTRY_DSN }}\"" >> .env
echo "SLACK_API_KEY=\"${{ secrets.SLACK_API_KEY }}\"" >> .env
echo "ENTITY_UPDATE_DO_NOT_EMAIL=\"${{ secrets.ENTITY_UPDATE_DO_NOT_EMAIL }}\"" >> .env
: # Don't build the base image with NODE_ENV because it'll limit the packages that are installed
docker build -t terramatch-microservices-base:nx-base .
SERVICE_IMAGE=$ECR_REGISTRY/$ECR_REPOSITORY:${{ env.IMAGE_TAG }}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
# First run just the small database test to get the test database synced to the current schema
# in a clean way.
- name: Sync DB Schema
run: npx nx test database --no-cloud --skip-nx-cache
run: npx nx test database --no-cloud --skip-nx-cache libs/database/src/lib/database.module.spec.ts

# All tests are run in band so that wipes of database tables from one test doesn't interfere
# with other tests.
Expand Down
21 changes: 20 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,37 @@ to take effect.
Once this project is live in production, we can explore continuous deployment to at least staging and prod envs on the staging
and main branches.

# Environment

The Environment for a given service deployment is configured in Github Actions secrets / variables. Some are repo-wide, and
some apply only to a given environment. During the build process, the contents of the variables applied to .env are visible
to the general public, so we need to be very careful about what is included there. Nothing sensitive (passwords, email
addresses, API tokens, etc) may be included in Variables, and must instead be in Secrets

- If you need to update a _non-secret_ ENV variable, add / update it in the given environment's ENV variable
- If you need to add a _secret_ ENV variable, create the secret in Github actions, and then add a line to `deploy-service.yml`
to append that secret to the generated `.env` variable.
- The current value of secrets in GitHub actions may not be read by anyone, including repository admins. If you need to
inspect the current value of a configured secret, the recommended approach is to access that deployed service's REPL, and
pull the value using the `ConfigService`:

```
> $(ConfigService).get("SUPER_SECRETE_ENV_VALUE");
```

# Creating a new service

- In the root directory: `nx g @nx/nest:app apps/foo-service`
- Set up the new `main.ts` similarly to existing services.
- Make sure swagger docs and the `/health` endpoint are implemented
- Make sure swagger docs are implemented
- Pick a default local port that is unique from other services
- Make sure the top of `main.ts` has these two lines:
```
// eslint-disable-next-line @nx/enforce-module-boundaries
import "../../../instrument-sentry";
```
- Add the `SentryModule` and `SentryGlobalFilter` to your main `app.module.ts`. See an existing service for an example.
- Add the `HealthModule` to your main `app.module.ts`. You will likely need `CommonModule` as well.
- Set up REPL access:
- Copy `repl.ts` from an existing service (and modify to specify the new service's name)
- Add the `build-repl` target to `project.json`, which an empty definition.
Expand Down
5 changes: 2 additions & 3 deletions apps/entity-service/src/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { Module } from "@nestjs/common";
import { DatabaseModule } from "@terramatch-microservices/database";
import { CommonModule } from "@terramatch-microservices/common";
import { HealthModule } from "./health/health.module";
import { TreesController } from "./trees/trees.controller";
import { TreeService } from "./trees/tree.service";
import { SentryGlobalFilter, SentryModule } from "@sentry/nestjs/setup";
import { APP_FILTER } from "@nestjs/core";
import { EntitiesService } from "./entities/entities.service";
import { EntitiesController } from "./entities/entities.controller";
import { EntityAssociationsController } from "./entities/entity-associations.controller";
import { HealthModule } from "@terramatch-microservices/common/health/health.module";

@Module({
imports: [SentryModule.forRoot(), DatabaseModule, CommonModule, HealthModule],
imports: [SentryModule.forRoot(), CommonModule, HealthModule],
controllers: [EntitiesController, EntityAssociationsController, TreesController],
providers: [
{
Expand Down
30 changes: 30 additions & 0 deletions apps/entity-service/src/entities/dto/disturbance.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { JsonApiDto } from "@terramatch-microservices/common/decorators";
import { pickApiProperties } from "@terramatch-microservices/common/dto/json-api-attributes";
import { ApiProperty } from "@nestjs/swagger";
import { Disturbance } from "@terramatch-microservices/database/entities/disturbance.entity";
import { AssociationDto, AssociationDtoAdditionalProps } from "./association.dto";

@JsonApiDto({ type: "disturbances" })
export class DisturbanceDto extends AssociationDto<DisturbanceDto> {
constructor(disturbance: Disturbance, additional: AssociationDtoAdditionalProps) {
super({
...pickApiProperties(disturbance, DisturbanceDto),
...additional
});
}

@ApiProperty({ nullable: true })
collection: string | null;

@ApiProperty({ nullable: true })
type: string | null;

@ApiProperty({ nullable: true })
intensity: string | null;

@ApiProperty({ nullable: true })
extent: string | null;

@ApiProperty({ nullable: true })
description: string | null;
}
16 changes: 12 additions & 4 deletions apps/entity-service/src/entities/dto/entity-query.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@ import { NumberPage } from "@terramatch-microservices/common/dto/page.dto";
import {
MAX_PAGE_SIZE,
PROCESSABLE_ENTITIES,
ProcessableEntity,
PROCESSABLE_ASSOCIATIONS,
POLYGON_STATUSES_FILTERS,
PolygonStatusFilter
} from "../entities.service";
import { Type } from "class-transformer";

export const VALID_SIDELOAD_TYPES = [...PROCESSABLE_ENTITIES, ...PROCESSABLE_ASSOCIATIONS] as const;

export type SideloadType = (typeof VALID_SIDELOAD_TYPES)[number];

class QuerySort {
@ApiProperty({ name: "sort[field]", required: false })
@IsOptional()
Expand All @@ -22,9 +26,13 @@ class QuerySort {
}

export class EntitySideload {
@IsIn(PROCESSABLE_ENTITIES)
@ApiProperty({ name: "entity", enum: PROCESSABLE_ENTITIES, description: "Entity type to sideload" })
entity: ProcessableEntity;
@IsIn(VALID_SIDELOAD_TYPES)
@ApiProperty({
name: "entity",
enum: VALID_SIDELOAD_TYPES,
description: "Entity or association type to sideload"
})
entity: SideloadType;

@ApiProperty({ name: "pageSize", description: "The page size to include." })
@IsInt()
Expand Down
87 changes: 87 additions & 0 deletions apps/entity-service/src/entities/dto/entity-update.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import { ApiProperty } from "@nestjs/swagger";
import { ENTITY_STATUSES, REPORT_STATUSES, SITE_STATUSES } from "@terramatch-microservices/database/constants/status";
import { IsArray, IsBoolean, IsIn, IsOptional, IsString } from "class-validator";
import { JsonApiDataDto, JsonApiMultiBodyDto } from "@terramatch-microservices/common/util/json-api-update-dto";
import { Type } from "class-transformer";

export class EntityUpdateAttributes {
@IsOptional()
@IsIn(ENTITY_STATUSES)
@ApiProperty({
description: "Request to change to the status of the given entity",
nullable: true,
enum: ENTITY_STATUSES
})
status?: string | null;

@IsOptional()
@IsString()
@ApiProperty({ description: "Specific feedback for the PD", nullable: true })
feedback?: string | null;

@IsOptional()
@IsArray()
@Type(() => String)
@ApiProperty({
isArray: true,
type: String,
description: "The fields in the entity form that need attention from the PD",
nullable: true
})
feedbackFields?: string[] | null;
}

export class ProjectUpdateAttributes extends EntityUpdateAttributes {
@IsOptional()
@IsBoolean()
@ApiProperty({ description: "Update the isTest flag.", nullable: true })
isTest?: boolean;
}

export class SiteUpdateAttributes extends EntityUpdateAttributes {
@IsOptional()
@IsIn(SITE_STATUSES)
@ApiProperty({
description: "Request to change to the status of the given site",
nullable: true,
enum: SITE_STATUSES
})
status?: string | null;
}

export class ReportUpdateAttributes extends EntityUpdateAttributes {
@IsOptional()
@IsIn(REPORT_STATUSES)
@ApiProperty({
description: "Request to change to the status of the given report",
nullable: true,
enum: REPORT_STATUSES
})
status?: string | null;

@IsOptional()
@IsBoolean()
@ApiProperty({ description: "Update the nothingToReport flag.", nullable: true })
nothingToReport?: boolean;
}

export class ProjectUpdateData extends JsonApiDataDto({ type: "projects" }, ProjectUpdateAttributes) {}
export class SiteUpdateData extends JsonApiDataDto({ type: "sites" }, SiteUpdateAttributes) {}
export class NurseryUpdateData extends JsonApiDataDto({ type: "nurseries" }, EntityUpdateAttributes) {}
export class ProjectReportUpdateData extends JsonApiDataDto({ type: "projectReports" }, ReportUpdateAttributes) {}
export class SiteReportUpdateData extends JsonApiDataDto({ type: "siteReports" }, ReportUpdateAttributes) {}
export class NurseryReportUpdateData extends JsonApiDataDto({ type: "nurseryReports" }, ReportUpdateAttributes) {}

export type EntityUpdateData =
| ProjectUpdateAttributes
| SiteUpdateAttributes
| ReportUpdateAttributes
| EntityUpdateAttributes;
export class EntityUpdateBody extends JsonApiMultiBodyDto([
ProjectUpdateData,
SiteUpdateData,
NurseryUpdateData,
ProjectReportUpdateData,
SiteReportUpdateData,
NurseryReportUpdateData
] as const) {}
8 changes: 8 additions & 0 deletions apps/entity-service/src/entities/dto/entity.dto.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { ApiProperty } from "@nestjs/swagger";
import { HybridSupportDto } from "@terramatch-microservices/common/dto/hybrid-support.dto";
import { JsonApiConstants } from "@terramatch-microservices/common/decorators/json-api-constants.decorator";
import { ENTITY_TYPES } from "@terramatch-microservices/database/constants/entities";

/**
* A utility type for constructing the "extra props" type of a DTO based on what's in the dto, the
* base type (e.g. the light DTO & base model for a full DTO)
*/
export type AdditionalProps<DTO, BaseType> = Pick<DTO, keyof Omit<DTO, keyof BaseType>>;

@JsonApiConstants
export class SupportedEntities {
@ApiProperty({ example: ENTITY_TYPES })
ENTITY_TYPES: string[];
}

export abstract class EntityDto extends HybridSupportDto {
/**
* All EntityDtos must include UUID in the attributes for use in the react-admin pagination
Expand Down
21 changes: 21 additions & 0 deletions apps/entity-service/src/entities/dto/invasive.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { JsonApiDto } from "@terramatch-microservices/common/decorators";
import { pickApiProperties } from "@terramatch-microservices/common/dto/json-api-attributes";
import { ApiProperty } from "@nestjs/swagger";
import { Invasive } from "@terramatch-microservices/database/entities/invasive.entity";
import { AssociationDto, AssociationDtoAdditionalProps } from "./association.dto";

@JsonApiDto({ type: "invasives" })
export class InvasiveDto extends AssociationDto<InvasiveDto> {
constructor(invasive: Invasive, additional: AssociationDtoAdditionalProps) {
super({
...pickApiProperties(invasive, InvasiveDto),
...additional
});
}

@ApiProperty({ nullable: true })
type: string | null;

@ApiProperty({ nullable: true })
name: string | null;
}
6 changes: 3 additions & 3 deletions apps/entity-service/src/entities/dto/nursery-report.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ export class NurseryReportLightDto extends EntityDto {

@ApiProperty()
createdAt: Date;

@ApiProperty({ nullable: true })
nothingToReport: boolean | null;
}

export type AdditionalNurseryReportLightProps = Pick<NurseryReportLightDto, "reportTitle">;
Expand Down Expand Up @@ -156,9 +159,6 @@ export class NurseryReportFullDto extends NurseryReportLightDto {
@ApiProperty({ nullable: true })
feedbackFields: string[] | null;

@ApiProperty()
nothingToReport: boolean;

@ApiProperty({ nullable: true })
completion: number | null;

Expand Down
54 changes: 51 additions & 3 deletions apps/entity-service/src/entities/dto/project-report.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ export class ProjectReportLightDto extends EntityDto {

@ApiProperty()
updatedAt: Date;

@ApiProperty({ nullable: true })
pctSurvivalToDate: number | null;
}

export type AdditionalProjectReportFullProps = AdditionalProps<
Expand Down Expand Up @@ -188,9 +191,6 @@ export class ProjectReportFullDto extends ProjectReportLightDto {
@ApiProperty({ nullable: true })
significantChange: string | null;

@ApiProperty({ nullable: true })
pctSurvivalToDate: number | null;

@ApiProperty({ nullable: true })
survivalCalculation: string | null;

Expand Down Expand Up @@ -304,4 +304,52 @@ export class ProjectReportFullDto extends ProjectReportLightDto {

@ApiProperty({ type: () => MediaDto, isArray: true })
photos: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
baselineReportUpload: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
localGovernanceOrderLetterUpload: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
eventsMeetingsPhotos: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
localGovernanceProofOfPartnershipUpload: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
topThreeSuccessesUpload: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
directJobsUpload: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
convergenceJobsUpload: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
convergenceSchemesUpload: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
livelihoodActivitiesUpload: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
directLivelihoodImpactsUpload: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
certifiedDatabaseUpload: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
physicalAssetsPhotos: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
indirectCommunityPartnersUpload: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
trainingCapacityBuildingUpload: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
trainingCapacityBuildingPhotos: MediaDto[];

@ApiProperty({ type: () => MediaDto, isArray: true })
financialReportUpload: MediaDto[];
}
Loading
Loading