diff --git a/db/migration/0017_safe_satana.sql b/db/migration/0017_safe_satana.sql new file mode 100644 index 00000000..521c23e6 --- /dev/null +++ b/db/migration/0017_safe_satana.sql @@ -0,0 +1 @@ +ALTER TABLE "capital_commitment_type" ALTER COLUMN "description" SET NOT NULL; \ No newline at end of file diff --git a/db/migration/meta/0017_snapshot.json b/db/migration/meta/0017_snapshot.json new file mode 100644 index 00000000..b62ace86 --- /dev/null +++ b/db/migration/meta/0017_snapshot.json @@ -0,0 +1,1096 @@ +{ + "id": "ab42fd5b-0a1f-4bb2-adc4-141f0925e934", + "prevId": "020de926-04a7-4e40-97eb-c75945b26ef1", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.agency_budget": { + "name": "agency_budget", + "schema": "", + "columns": { + "code": { + "name": "code", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "sponsor": { + "name": "sponsor", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "agency_budget_sponsor_agency_initials_fk": { + "name": "agency_budget_sponsor_agency_initials_fk", + "tableFrom": "agency_budget", + "tableTo": "agency", + "columnsFrom": [ + "sponsor" + ], + "columnsTo": [ + "initials" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.agency": { + "name": "agency", + "schema": "", + "columns": { + "initials": { + "name": "initials", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.borough": { + "name": "borough", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "char(1)", + "primaryKey": true, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "abbr": { + "name": "abbr", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.budget_line": { + "name": "budget_line", + "schema": "", + "columns": { + "code": { + "name": "code", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "budget_line_code_agency_budget_code_fk": { + "name": "budget_line_code_agency_budget_code_fk", + "tableFrom": "budget_line", + "tableTo": "agency_budget", + "columnsFrom": [ + "code" + ], + "columnsTo": [ + "code" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "budget_line_code_id_pk": { + "name": "budget_line_code_id_pk", + "columns": [ + "code", + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.capital_commitment_fund": { + "name": "capital_commitment_fund", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "capital_commitment_id": { + "name": "capital_commitment_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "capital_fund_category": { + "name": "capital_fund_category", + "type": "capital_fund_category", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "numeric", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "capital_commitment_fund_capital_commitment_id_capital_commitment_id_fk": { + "name": "capital_commitment_fund_capital_commitment_id_capital_commitment_id_fk", + "tableFrom": "capital_commitment_fund", + "tableTo": "capital_commitment", + "columnsFrom": [ + "capital_commitment_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.capital_commitment_type": { + "name": "capital_commitment_type", + "schema": "", + "columns": { + "code": { + "name": "code", + "type": "char(4)", + "primaryKey": true, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.capital_commitment": { + "name": "capital_commitment", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "type": { + "name": "type", + "type": "char(4)", + "primaryKey": false, + "notNull": true + }, + "planned_date": { + "name": "planned_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "managing_code": { + "name": "managing_code", + "type": "char(3)", + "primaryKey": false, + "notNull": false + }, + "capital_project_id": { + "name": "capital_project_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "budget_line_code": { + "name": "budget_line_code", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "budget_line_id": { + "name": "budget_line_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "capital_commitment_type_capital_commitment_type_code_fk": { + "name": "capital_commitment_type_capital_commitment_type_code_fk", + "tableFrom": "capital_commitment", + "tableTo": "capital_commitment_type", + "columnsFrom": [ + "type" + ], + "columnsTo": [ + "code" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "capital_commitment_managing_code_capital_project_id_capital_project_managing_code_id_fk": { + "name": "capital_commitment_managing_code_capital_project_id_capital_project_managing_code_id_fk", + "tableFrom": "capital_commitment", + "tableTo": "capital_project", + "columnsFrom": [ + "managing_code", + "capital_project_id" + ], + "columnsTo": [ + "managing_code", + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "capital_commitment_budget_line_code_budget_line_id_budget_line_code_id_fk": { + "name": "capital_commitment_budget_line_code_budget_line_id_budget_line_code_id_fk", + "tableFrom": "capital_commitment", + "tableTo": "budget_line", + "columnsFrom": [ + "budget_line_code", + "budget_line_id" + ], + "columnsTo": [ + "code", + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.capital_project_checkbook": { + "name": "capital_project_checkbook", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "managing_code": { + "name": "managing_code", + "type": "char(3)", + "primaryKey": false, + "notNull": false + }, + "capital_project_id": { + "name": "capital_project_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "numeric", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "custom_fk": { + "name": "custom_fk", + "tableFrom": "capital_project_checkbook", + "tableTo": "capital_project", + "columnsFrom": [ + "managing_code", + "capital_project_id" + ], + "columnsTo": [ + "managing_code", + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.capital_project_fund": { + "name": "capital_project_fund", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "managing_code": { + "name": "managing_code", + "type": "char(3)", + "primaryKey": false, + "notNull": false + }, + "capital_project_id": { + "name": "capital_project_id", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "capital_fund_category": { + "name": "capital_fund_category", + "type": "capital_fund_category", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "stage": { + "name": "stage", + "type": "capital_project_fund_stage", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "value": { + "name": "value", + "type": "numeric", + "primaryKey": false, + "notNull": false + } + }, + "indexes": {}, + "foreignKeys": { + "custom_fk": { + "name": "custom_fk", + "tableFrom": "capital_project_fund", + "tableTo": "capital_project", + "columnsFrom": [ + "managing_code", + "capital_project_id" + ], + "columnsTo": [ + "managing_code", + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.capital_project": { + "name": "capital_project", + "schema": "", + "columns": { + "managing_code": { + "name": "managing_code", + "type": "char(3)", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "managing_agency": { + "name": "managing_agency", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "min_date": { + "name": "min_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "max_date": { + "name": "max_date", + "type": "date", + "primaryKey": false, + "notNull": true + }, + "category": { + "name": "category", + "type": "capital_project_category", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "li_ft_m_pnt": { + "name": "li_ft_m_pnt", + "type": "geometry(multiPoint,2263)", + "primaryKey": false, + "notNull": false + }, + "li_ft_m_poly": { + "name": "li_ft_m_poly", + "type": "geometry(multiPolygon,2263)", + "primaryKey": false, + "notNull": false + }, + "mercator_label": { + "name": "mercator_label", + "type": "geometry(point,3857)", + "primaryKey": false, + "notNull": false + }, + "mercator_fill_m_pnt": { + "name": "mercator_fill_m_pnt", + "type": "geometry(multiPoint,3857)", + "primaryKey": false, + "notNull": false + }, + "mercator_fill_m_poly": { + "name": "mercator_fill_m_poly", + "type": "geometry(multiPolygon,3857)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "capital_project_mercator_fill_m_poly_index": { + "name": "capital_project_mercator_fill_m_poly_index", + "columns": [ + { + "expression": "mercator_fill_m_poly", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + }, + "capital_project_mercator_fill_m_pnt_index": { + "name": "capital_project_mercator_fill_m_pnt_index", + "columns": [ + { + "expression": "mercator_fill_m_pnt", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + }, + "capital_project_li_ft_m_pnt_index": { + "name": "capital_project_li_ft_m_pnt_index", + "columns": [ + { + "expression": "li_ft_m_pnt", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + }, + "capital_project_li_ft_m_poly_index": { + "name": "capital_project_li_ft_m_poly_index", + "columns": [ + { + "expression": "li_ft_m_poly", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + } + }, + "foreignKeys": { + "capital_project_managing_code_managing_code_id_fk": { + "name": "capital_project_managing_code_managing_code_id_fk", + "tableFrom": "capital_project", + "tableTo": "managing_code", + "columnsFrom": [ + "managing_code" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "capital_project_managing_agency_agency_initials_fk": { + "name": "capital_project_managing_agency_agency_initials_fk", + "tableFrom": "capital_project", + "tableTo": "agency", + "columnsFrom": [ + "managing_agency" + ], + "columnsTo": [ + "initials" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "capital_project_managing_code_id_pk": { + "name": "capital_project_managing_code_id_pk", + "columns": [ + "managing_code", + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.city_council_district": { + "name": "city_council_district", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "li_ft": { + "name": "li_ft", + "type": "geometry(multiPolygon,2263)", + "primaryKey": false, + "notNull": false + }, + "mercator_fill": { + "name": "mercator_fill", + "type": "geometry(multiPolygon,3857)", + "primaryKey": false, + "notNull": false + }, + "mercator_label": { + "name": "mercator_label", + "type": "geometry(point,3857)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "city_council_district_mercator_fill_index": { + "name": "city_council_district_mercator_fill_index", + "columns": [ + { + "expression": "mercator_fill", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + }, + "city_council_district_mercator_label_index": { + "name": "city_council_district_mercator_label_index", + "columns": [ + { + "expression": "mercator_label", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + }, + "city_council_district_li_ft_index": { + "name": "city_council_district_li_ft_index", + "columns": [ + { + "expression": "li_ft", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.community_district": { + "name": "community_district", + "schema": "", + "columns": { + "borough_id": { + "name": "borough_id", + "type": "char(1)", + "primaryKey": false, + "notNull": true + }, + "id": { + "name": "id", + "type": "char(2)", + "primaryKey": false, + "notNull": true + }, + "li_ft": { + "name": "li_ft", + "type": "geometry(multiPolygon,2263)", + "primaryKey": false, + "notNull": false + }, + "mercator_fill": { + "name": "mercator_fill", + "type": "geometry(multiPolygon,3857)", + "primaryKey": false, + "notNull": false + }, + "mercator_label": { + "name": "mercator_label", + "type": "geometry(point,3857)", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "community_district_li_ft_index": { + "name": "community_district_li_ft_index", + "columns": [ + { + "expression": "li_ft", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + }, + "community_district_mercator_fill_index": { + "name": "community_district_mercator_fill_index", + "columns": [ + { + "expression": "mercator_fill", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + }, + "community_district_mercator_label_index": { + "name": "community_district_mercator_label_index", + "columns": [ + { + "expression": "mercator_label", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "GIST", + "with": {} + } + }, + "foreignKeys": { + "community_district_borough_id_borough_id_fk": { + "name": "community_district_borough_id_borough_id_fk", + "tableFrom": "community_district", + "tableTo": "borough", + "columnsFrom": [ + "borough_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "community_district_borough_id_id_pk": { + "name": "community_district_borough_id_id_pk", + "columns": [ + "borough_id", + "id" + ] + } + }, + "uniqueConstraints": {} + }, + "public.land_use": { + "name": "land_use", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "char(2)", + "primaryKey": true, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "color": { + "name": "color", + "type": "char(9)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.managing_code": { + "name": "managing_code", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "char(3)", + "primaryKey": true, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.tax_lot": { + "name": "tax_lot", + "schema": "", + "columns": { + "bbl": { + "name": "bbl", + "type": "char(10)", + "primaryKey": true, + "notNull": true + }, + "borough_id": { + "name": "borough_id", + "type": "char(1)", + "primaryKey": false, + "notNull": true + }, + "block": { + "name": "block", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "lot": { + "name": "lot", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "address": { + "name": "address", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "land_use_id": { + "name": "land_use_id", + "type": "char(2)", + "primaryKey": false, + "notNull": false + }, + "wgs84": { + "name": "wgs84", + "type": "geography(multiPolygon, 4326)", + "primaryKey": false, + "notNull": true + }, + "li_ft": { + "name": "li_ft", + "type": "geometry(multiPolygon,2263)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "tax_lot_borough_id_borough_id_fk": { + "name": "tax_lot_borough_id_borough_id_fk", + "tableFrom": "tax_lot", + "tableTo": "borough", + "columnsFrom": [ + "borough_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "tax_lot_land_use_id_land_use_id_fk": { + "name": "tax_lot_land_use_id_land_use_id_fk", + "tableFrom": "tax_lot", + "tableTo": "land_use", + "columnsFrom": [ + "land_use_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.zoning_district": { + "name": "zoning_district", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "label": { + "name": "label", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "wgs84": { + "name": "wgs84", + "type": "geography(multiPolygon, 4326)", + "primaryKey": false, + "notNull": true + }, + "li_ft": { + "name": "li_ft", + "type": "geometry(multiPolygon,2263)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.zoning_district_class": { + "name": "zoning_district_class", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "category": { + "name": "category", + "type": "category", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "url": { + "name": "url", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "color": { + "name": "color", + "type": "char(9)", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + }, + "public.zoning_district_zoning_district_class": { + "name": "zoning_district_zoning_district_class", + "schema": "", + "columns": { + "zoning_district_id": { + "name": "zoning_district_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "zoning_district_class_id": { + "name": "zoning_district_class_id", + "type": "text", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "zoning_district_zoning_district_class_zoning_district_id_zoning_district_id_fk": { + "name": "zoning_district_zoning_district_class_zoning_district_id_zoning_district_id_fk", + "tableFrom": "zoning_district_zoning_district_class", + "tableTo": "zoning_district", + "columnsFrom": [ + "zoning_district_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + }, + "zoning_district_zoning_district_class_zoning_district_class_id_zoning_district_class_id_fk": { + "name": "zoning_district_zoning_district_class_zoning_district_class_id_zoning_district_class_id_fk", + "tableFrom": "zoning_district_zoning_district_class", + "tableTo": "zoning_district_class", + "columnsFrom": [ + "zoning_district_class_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "no action", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {} + } + }, + "enums": { + "public.capital_fund_category": { + "name": "capital_fund_category", + "schema": "public", + "values": [ + "city-non-exempt", + "city-exempt", + "city-cost", + "non-city-state", + "non-city-federal", + "non-city-other", + "non-city-cost", + "total" + ] + }, + "public.capital_project_fund_stage": { + "name": "capital_project_fund_stage", + "schema": "public", + "values": [ + "adopt", + "allocate", + "commit", + "spent" + ] + }, + "public.capital_project_category": { + "name": "capital_project_category", + "schema": "public", + "values": [ + "Fixed Asset", + "Lump Sum", + "ITT, Vehicles and Equipment" + ] + }, + "public.category": { + "name": "category", + "schema": "public", + "values": [ + "Residential", + "Commercial", + "Manufacturing" + ] + } + }, + "schemas": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/db/migration/meta/_journal.json b/db/migration/meta/_journal.json index d434e56f..bcce35b5 100644 --- a/db/migration/meta/_journal.json +++ b/db/migration/meta/_journal.json @@ -120,6 +120,13 @@ "when": 1720791763826, "tag": "0016_condemned_hammerhead", "breakpoints": true + }, + { + "idx": 17, + "version": "7", + "when": 1722619351595, + "tag": "0017_safe_satana", + "breakpoints": true } ] } \ No newline at end of file diff --git a/openapi/openapi.yaml b/openapi/openapi.yaml index 12ebe77f..39d4cfea 100644 --- a/openapi/openapi.yaml +++ b/openapi/openapi.yaml @@ -158,7 +158,7 @@ paths: $ref: "#/components/responses/InternalServerError" /capital-commitment-types: get: - summary: 🚧 Capital Commitment Types + summary: Capital Commitment Types operationId: findCapitalCommitmentTypes tags: - Capital Commitment Types diff --git a/src/app.module.ts b/src/app.module.ts index 66d3f572..9aba16c6 100644 --- a/src/app.module.ts +++ b/src/app.module.ts @@ -16,6 +16,7 @@ import { AgencyModule } from "./agency/agency.module"; import { CityCouncilDistrictModule } from "./city-council-district/city-council-district.module"; import { CapitalProjectModule } from "./capital-project/capital-project.module"; import { CommunityDistrictModule } from "./community-district/community-district.module"; +import { CapitalCommitmentTypeModule } from "./capital-commitment-type/capital-commitment-type.module"; @Module({ imports: [ @@ -43,6 +44,7 @@ import { CommunityDistrictModule } from "./community-district/community-district AgencyModule, BoroughModule, CityCouncilDistrictModule, + CapitalCommitmentTypeModule, CapitalProjectModule, CommunityDistrictModule, LandUseModule, diff --git a/src/capital-commitment-type/capital-commitment-type.controller.ts b/src/capital-commitment-type/capital-commitment-type.controller.ts new file mode 100644 index 00000000..3054a262 --- /dev/null +++ b/src/capital-commitment-type/capital-commitment-type.controller.ts @@ -0,0 +1,16 @@ +import { Controller, Get, UseFilters } from "@nestjs/common"; +import { CapitalCommitmentTypeService } from "./capital-commitment.service"; +import { InternalServerErrorExceptionFilter } from "src/filter"; + +@UseFilters(InternalServerErrorExceptionFilter) +@Controller("capital-commitment-types") +export class CapitalCommitmentTypeController { + constructor( + private readonly capitalCommitmentType: CapitalCommitmentTypeService, + ) {} + + @Get() + async findMany() { + return this.capitalCommitmentType.findMany(); + } +} diff --git a/src/capital-commitment-type/capital-commitment-type.module.ts b/src/capital-commitment-type/capital-commitment-type.module.ts new file mode 100644 index 00000000..6f89151b --- /dev/null +++ b/src/capital-commitment-type/capital-commitment-type.module.ts @@ -0,0 +1,11 @@ +import { Module } from "@nestjs/common"; +import { CapitalCommitmentTypeRepository } from "./capital-commitment-type.repository"; +import { CapitalCommitmentTypeService } from "./capital-commitment.service"; +import { CapitalCommitmentTypeController } from "./capital-commitment-type.controller"; + +@Module({ + exports: [CapitalCommitmentTypeService], + providers: [CapitalCommitmentTypeService, CapitalCommitmentTypeRepository], + controllers: [CapitalCommitmentTypeController], +}) +export class CapitalCommitmentTypeModule {} diff --git a/src/capital-commitment-type/capital-commitment-type.repository.schema.ts b/src/capital-commitment-type/capital-commitment-type.repository.schema.ts new file mode 100644 index 00000000..1c0a142a --- /dev/null +++ b/src/capital-commitment-type/capital-commitment-type.repository.schema.ts @@ -0,0 +1,6 @@ +import { capitalCommitmentTypeEntitySchema } from "src/schema"; +import { z } from "zod"; + +export const findManyRepoSchema = z.array(capitalCommitmentTypeEntitySchema); + +export type FindManyRepo = z.infer; diff --git a/src/capital-commitment-type/capital-commitment-type.repository.ts b/src/capital-commitment-type/capital-commitment-type.repository.ts new file mode 100644 index 00000000..ef6d1c9b --- /dev/null +++ b/src/capital-commitment-type/capital-commitment-type.repository.ts @@ -0,0 +1,19 @@ +import { Inject } from "@nestjs/common"; +import { DB, DbType } from "src/global/providers/db.provider"; +import { DataRetrievalException } from "src/exception"; +import { FindManyRepo } from "./capital-commitment-type.repository.schema"; + +export class CapitalCommitmentTypeRepository { + constructor( + @Inject(DB) + private readonly db: DbType, + ) {} + + async findMany(): Promise { + try { + return await this.db.query.capitalCommitmentType.findMany(); + } catch { + throw new DataRetrievalException(); + } + } +} diff --git a/src/capital-commitment-type/capital-commitment-type.service.spec.ts b/src/capital-commitment-type/capital-commitment-type.service.spec.ts new file mode 100644 index 00000000..f26b0359 --- /dev/null +++ b/src/capital-commitment-type/capital-commitment-type.service.spec.ts @@ -0,0 +1,38 @@ +import { Test } from "@nestjs/testing"; +import { CapitalCommitmentTypeService } from "./capital-commitment.service"; +import { findCapitalCommitmentTypesQueryResponseSchema } from "src/gen"; +import { CapitalCommitmentTypeRepository } from "./capital-commitment-type.repository"; +import { CapitalCommitmentTypeRepositoryMock } from "test/capital-commitment-type/capital-commitment-type.repository.mock"; + +describe("Capital commitment type service unit", () => { + let capitalCommitmentTypeService: CapitalCommitmentTypeService; + + beforeEach(async () => { + const capitalCommitmentTypeRepositoryMock = + new CapitalCommitmentTypeRepositoryMock(); + + const moduleRef = await Test.createTestingModule({ + providers: [ + CapitalCommitmentTypeService, + CapitalCommitmentTypeRepository, + ], + }) + .overrideProvider(CapitalCommitmentTypeRepository) + .useValue(capitalCommitmentTypeRepositoryMock) + .compile(); + + capitalCommitmentTypeService = moduleRef.get( + CapitalCommitmentTypeService, + ); + }); + + it("service should return a findCapitalCommitmentTypesQueryResponseSchema compliant object", async () => { + const capitalCommitmentTypes = + await capitalCommitmentTypeService.findMany(); + expect(() => + findCapitalCommitmentTypesQueryResponseSchema.parse( + capitalCommitmentTypes, + ), + ).not.toThrow(); + }); +}); diff --git a/src/capital-commitment-type/capital-commitment.service.ts b/src/capital-commitment-type/capital-commitment.service.ts new file mode 100644 index 00000000..f931343e --- /dev/null +++ b/src/capital-commitment-type/capital-commitment.service.ts @@ -0,0 +1,17 @@ +import { Inject, Injectable } from "@nestjs/common"; +import { CapitalCommitmentTypeRepository } from "./capital-commitment-type.repository"; +@Injectable() +export class CapitalCommitmentTypeService { + constructor( + @Inject(CapitalCommitmentTypeRepository) + private readonly capitalCommitmentRepository: CapitalCommitmentTypeRepository, + ) {} + + async findMany() { + const capitalCommitmentTypes = + await this.capitalCommitmentRepository.findMany(); + return { + capitalCommitmentTypes, + }; + } +} diff --git a/src/gen/schemas/CapitalCommitmentType.json b/src/gen/schemas/CapitalCommitmentType.json new file mode 100644 index 00000000..502039a2 --- /dev/null +++ b/src/gen/schemas/CapitalCommitmentType.json @@ -0,0 +1,19 @@ +{ + "type": "object", + "properties": { + "code": { + "description": "The four character code to represent the capital commitment type", + "type": "string", + "example": "CONS", + "maxLength": 4, + "minLength": 4 + }, + "description": { + "description": "The description of the capital commitment type.", + "type": "string", + "example": "CONSTRUCTION" + } + }, + "required": ["code", "description"], + "x-readme-ref-name": "CapitalCommitmentType" +} diff --git a/src/gen/types/CapitalCommitmentType.ts b/src/gen/types/CapitalCommitmentType.ts new file mode 100644 index 00000000..816c36d8 --- /dev/null +++ b/src/gen/types/CapitalCommitmentType.ts @@ -0,0 +1,12 @@ +export type CapitalCommitmentType = { + /** + * @description The four character code to represent the capital commitment type + * @type string + */ + code: string; + /** + * @description The description of the capital commitment type. + * @type string + */ + description: string; +}; diff --git a/src/gen/types/FindCapitalCommitmentTypes.ts b/src/gen/types/FindCapitalCommitmentTypes.ts new file mode 100644 index 00000000..b67cad12 --- /dev/null +++ b/src/gen/types/FindCapitalCommitmentTypes.ts @@ -0,0 +1,33 @@ +import type { Error } from "./Error"; +import type { CapitalCommitmentType } from "./CapitalCommitmentType"; + +/** + * @description An object containing all capital commitment types. + */ +export type FindCapitalCommitmentTypes200 = { + /** + * @type array + */ + capitalCommitmentTypes: CapitalCommitmentType[]; +}; +/** + * @description Invalid client request + */ +export type FindCapitalCommitmentTypes400 = Error; +/** + * @description Server side error + */ +export type FindCapitalCommitmentTypes500 = Error; +/** + * @description An object containing all capital commitment types. + */ +export type FindCapitalCommitmentTypesQueryResponse = { + /** + * @type array + */ + capitalCommitmentTypes: CapitalCommitmentType[]; +}; +export type FindCapitalCommitmentTypesQuery = { + Response: FindCapitalCommitmentTypesQueryResponse; + Errors: FindCapitalCommitmentTypes400 | FindCapitalCommitmentTypes500; +}; diff --git a/src/gen/types/index.ts b/src/gen/types/index.ts index 1d23f0c7..c2de845e 100644 --- a/src/gen/types/index.ts +++ b/src/gen/types/index.ts @@ -2,6 +2,7 @@ export * from "./Agency"; export * from "./BadRequest"; export * from "./Borough"; export * from "./CapitalCommitment"; +export * from "./CapitalCommitmentType"; export * from "./CapitalProject"; export * from "./CapitalProjectBudgeted"; export * from "./CapitalProjectBudgetedGeoJson"; @@ -14,6 +15,7 @@ export * from "./CommunityDistrictGeoJson"; export * from "./Error"; export * from "./FindAgencies"; export * from "./FindBoroughs"; +export * from "./FindCapitalCommitmentTypes"; export * from "./FindCapitalCommitmentsByManagingCodeCapitalProjectId"; export * from "./FindCapitalProjectByManagingCodeCapitalProjectId"; export * from "./FindCapitalProjectGeoJsonByManagingCodeCapitalProjectId"; diff --git a/src/gen/zod/capitalCommitmentTypeSchema.ts b/src/gen/zod/capitalCommitmentTypeSchema.ts new file mode 100644 index 00000000..075a6999 --- /dev/null +++ b/src/gen/zod/capitalCommitmentTypeSchema.ts @@ -0,0 +1,14 @@ +import { z } from "zod"; + +export const capitalCommitmentTypeSchema = z.object({ + code: z.coerce + .string() + .min(4) + .max(4) + .describe( + "The four character code to represent the capital commitment type", + ), + description: z.coerce + .string() + .describe("The description of the capital commitment type."), +}); diff --git a/src/gen/zod/findCapitalCommitmentTypesSchema.ts b/src/gen/zod/findCapitalCommitmentTypesSchema.ts new file mode 100644 index 00000000..e1ba494d --- /dev/null +++ b/src/gen/zod/findCapitalCommitmentTypesSchema.ts @@ -0,0 +1,24 @@ +import { z } from "zod"; +import { capitalCommitmentTypeSchema } from "./capitalCommitmentTypeSchema"; +import { errorSchema } from "./errorSchema"; + +/** + * @description An object containing all capital commitment types. + */ +export const findCapitalCommitmentTypes200Schema = z.object({ + capitalCommitmentTypes: z.array(z.lazy(() => capitalCommitmentTypeSchema)), +}); +/** + * @description Invalid client request + */ +export const findCapitalCommitmentTypes400Schema = z.lazy(() => errorSchema); +/** + * @description Server side error + */ +export const findCapitalCommitmentTypes500Schema = z.lazy(() => errorSchema); +/** + * @description An object containing all capital commitment types. + */ +export const findCapitalCommitmentTypesQueryResponseSchema = z.object({ + capitalCommitmentTypes: z.array(z.lazy(() => capitalCommitmentTypeSchema)), +}); diff --git a/src/gen/zod/index.ts b/src/gen/zod/index.ts index 11f7488d..a0f4125d 100644 --- a/src/gen/zod/index.ts +++ b/src/gen/zod/index.ts @@ -2,6 +2,7 @@ export * from "./agencySchema"; export * from "./badRequestSchema"; export * from "./boroughSchema"; export * from "./capitalCommitmentSchema"; +export * from "./capitalCommitmentTypeSchema"; export * from "./capitalProjectBudgetedGeoJsonSchema"; export * from "./capitalProjectBudgetedSchema"; export * from "./capitalProjectCategorySchema"; @@ -14,6 +15,7 @@ export * from "./communityDistrictSchema"; export * from "./errorSchema"; export * from "./findAgenciesSchema"; export * from "./findBoroughsSchema"; +export * from "./findCapitalCommitmentTypesSchema"; export * from "./findCapitalCommitmentsByManagingCodeCapitalProjectIdSchema"; export * from "./findCapitalProjectByManagingCodeCapitalProjectIdSchema"; export * from "./findCapitalProjectGeoJsonByManagingCodeCapitalProjectIdSchema"; diff --git a/src/gen/zod/operations.ts b/src/gen/zod/operations.ts index f4bd1cdb..4e7c160f 100644 --- a/src/gen/zod/operations.ts +++ b/src/gen/zod/operations.ts @@ -30,6 +30,11 @@ import { findCapitalProjectsByBoroughIdCommunityDistrictIdPathParamsSchema, findCapitalProjectsByBoroughIdCommunityDistrictIdQueryParamsSchema, } from "./findCapitalProjectsByBoroughIdCommunityDistrictIdSchema"; +import { + findCapitalCommitmentTypesQueryResponseSchema, + findCapitalCommitmentTypes400Schema, + findCapitalCommitmentTypes500Schema, +} from "./findCapitalCommitmentTypesSchema"; import { findCapitalCommitmentsByManagingCodeCapitalProjectIdQueryResponseSchema, findCapitalCommitmentsByManagingCodeCapitalProjectId400Schema, @@ -259,6 +264,24 @@ export const operations = { 500: findCapitalProjectsByBoroughIdCommunityDistrictId500Schema, }, }, + findCapitalCommitmentTypes: { + request: undefined, + parameters: { + path: undefined, + query: undefined, + header: undefined, + }, + responses: { + 200: findCapitalCommitmentTypesQueryResponseSchema, + 400: findCapitalCommitmentTypes400Schema, + 500: findCapitalCommitmentTypes500Schema, + default: findCapitalCommitmentTypesQueryResponseSchema, + }, + errors: { + 400: findCapitalCommitmentTypes400Schema, + 500: findCapitalCommitmentTypes500Schema, + }, + }, findCapitalCommitmentsByManagingCodeCapitalProjectId: { request: undefined, parameters: { @@ -668,6 +691,9 @@ export const paths = { { get: operations["findCapitalProjectsByBoroughIdCommunityDistrictId"], }, + "/capital-commitment-types": { + get: operations["findCapitalCommitmentTypes"], + }, "/capital-projects/{managingCode}/{capitalProjectId}/capital-commitments": { get: operations["findCapitalCommitmentsByManagingCodeCapitalProjectId"], }, diff --git a/src/schema/capital-commitment-type.ts b/src/schema/capital-commitment-type.ts index 7521898d..a12458f1 100644 --- a/src/schema/capital-commitment-type.ts +++ b/src/schema/capital-commitment-type.ts @@ -3,7 +3,7 @@ import { z } from "zod"; export const capitalCommitmentType = pgTable("capital_commitment_type", { code: char("code", { length: 4 }).primaryKey(), - description: text("description"), + description: text("description").notNull(), }); export const capitalCommitmentTypeEntitySchema = z.object({ @@ -11,6 +11,6 @@ export const capitalCommitmentTypeEntitySchema = z.object({ description: z.string(), }); -export type CaptialCommitmentTypeEntitySchema = z.infer< +export type CapitalCommitmentTypeEntitySchema = z.infer< typeof capitalCommitmentTypeEntitySchema >; diff --git a/test/capital-commitment-type/capital-commitment-type.e2e-spec.ts b/test/capital-commitment-type/capital-commitment-type.e2e-spec.ts new file mode 100644 index 00000000..2402177d --- /dev/null +++ b/test/capital-commitment-type/capital-commitment-type.e2e-spec.ts @@ -0,0 +1,57 @@ +import * as request from "supertest"; +import { INestApplication } from "@nestjs/common"; +import { Test } from "@nestjs/testing"; +import { DataRetrievalException } from "src/exception"; +import { HttpName } from "src/filter"; +import { CapitalCommitmentTypeRepositoryMock } from "./capital-commitment-type.repository.mock"; +import { findCapitalCommitmentTypesQueryResponseSchema } from "src/gen"; +import { CapitalCommitmentTypeModule } from "src/capital-commitment-type/capital-commitment-type.module"; +import { CapitalCommitmentTypeRepository } from "src/capital-commitment-type/capital-commitment-type.repository"; + +describe("Capital commitment types e2e", () => { + let app: INestApplication; + + const capitalCommitmentTypeRepositoryMock = + new CapitalCommitmentTypeRepositoryMock(); + + beforeAll(async () => { + const moduleRef = await Test.createTestingModule({ + imports: [CapitalCommitmentTypeModule], + }) + .overrideProvider(CapitalCommitmentTypeRepository) + .useValue(capitalCommitmentTypeRepositoryMock) + .compile(); + app = moduleRef.createNestApplication(); + await app.init(); + }); + + describe("findCapitalCommitmentTypes", () => { + it("should 200 and return a list of all land uses", async () => { + const response = await request(app.getHttpServer()) + .get(`/capital-commitment-types`) + .expect(200); + expect(() => + findCapitalCommitmentTypesQueryResponseSchema.parse(response.body), + ).not.toThrow(); + }); + + it("should 500 and return a list of all capital commitment types", async () => { + const dataRetrievalException = new DataRetrievalException(); + jest + .spyOn(capitalCommitmentTypeRepositoryMock, "findMany") + .mockImplementationOnce(() => { + throw dataRetrievalException; + }); + + const response = await request(app.getHttpServer()) + .get(`/capital-commitment-types`) + .expect(500); + expect(response.body.message).toBe(dataRetrievalException.message); + expect(response.body.error).toBe(HttpName.INTERNAL_SEVER_ERROR); + }); + }); + + afterAll(async () => { + await app.close(); + }); +}); diff --git a/test/capital-commitment-type/capital-commitment-type.repository.mock.ts b/test/capital-commitment-type/capital-commitment-type.repository.mock.ts new file mode 100644 index 00000000..f78c9b50 --- /dev/null +++ b/test/capital-commitment-type/capital-commitment-type.repository.mock.ts @@ -0,0 +1,10 @@ +import { findManyRepoSchema } from "src/capital-commitment-type/capital-commitment-type.repository.schema"; +import { generateMock } from "@anatine/zod-mock"; + +export class CapitalCommitmentTypeRepositoryMock { + findAllMocks = generateMock(findManyRepoSchema); + + async findMany() { + return this.findAllMocks; + } +}