From 30931e6582be7a2e6332c472be577ff85119b4e6 Mon Sep 17 00:00:00 2001 From: almog8k <60139576+almog8k@users.noreply.github.com> Date: Wed, 11 Sep 2024 14:42:03 +0300 Subject: [PATCH] fix: fields alignment according to the definition of the polygon part (#199) * fix: fields alignment according to the definition of the polygon part * fix: update actions/upload-artifact from v2 to v4 * fix: use IpolygonPart interface instead of PolygonPartRecord * fix: delete unused type * fix: use ProductType instead of string --- .github/workflows/pull_request.yaml | 2 +- package-lock.json | 16 ++-- package.json | 4 +- .../decorators/property/tsTypes.decorator.ts | 5 +- src/models/polygonParts/polygonPartRecord.ts | 89 ++++++++++--------- src/models/raster/ingestion/ingestionTypes.ts | 11 ++- 6 files changed, 70 insertions(+), 57 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 80321bec..d4d68b0f 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -60,7 +60,7 @@ jobs: - name: Run tests run: npm run test - - uses: actions/upload-artifact@v2 + - uses: actions/upload-artifact@v4 with: name: Test Reporters path: reports/** diff --git a/package-lock.json b/package-lock.json index 9c5815bb..f3856e88 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,8 +28,8 @@ "jest": "^27.2.5", "jest-create-mock-instance": "^1.1.0", "jest-html-reporters": "^2.1.6", - "prettier": "^2.2.1", - "pretty-quick": "^3.1.0", + "prettier": "^2.8.8", + "pretty-quick": "^3.1.3", "rimraf": "^3.0.2", "standard-version": "^9.0.0", "ts-jest": "^27.0.5", @@ -11555,9 +11555,9 @@ } }, "node_modules/prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", "dev": true, "bin": { "prettier": "bin-prettier.js" @@ -23475,9 +23475,9 @@ "dev": true }, "prettier": { - "version": "2.7.1", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.7.1.tgz", - "integrity": "sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g==", + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.8.tgz", + "integrity": "sha512-tdN8qQGvNjw4CHbY+XXk0JgCXn9QiF21a55rBe5LJAU+kDyC4WQn4+awm2Xfk2lQMk5fKup9XgzTZtGkjBdP9Q==", "dev": true }, "pretty-format": { diff --git a/package.json b/package.json index 819097ee..7cbcd1c7 100644 --- a/package.json +++ b/package.json @@ -60,8 +60,8 @@ "jest": "^27.2.5", "jest-create-mock-instance": "^1.1.0", "jest-html-reporters": "^2.1.6", - "prettier": "^2.2.1", - "pretty-quick": "^3.1.0", + "prettier": "^2.8.8", + "pretty-quick": "^3.1.3", "rimraf": "^3.0.2", "standard-version": "^9.0.0", "ts-jest": "^27.0.5", diff --git a/src/models/layerMetadata/decorators/property/tsTypes.decorator.ts b/src/models/layerMetadata/decorators/property/tsTypes.decorator.ts index 7d7431d9..3c18be0c 100644 --- a/src/models/layerMetadata/decorators/property/tsTypes.decorator.ts +++ b/src/models/layerMetadata/decorators/property/tsTypes.decorator.ts @@ -17,7 +17,7 @@ export interface IDescribeTsType { } /* eslint-disable @typescript-eslint/naming-convention */ -export const TsTypes: Record = { +export const TsTypes = { STRING: { value: 'string', type: PropertiesTypes.PRIMITIVE, @@ -117,7 +117,8 @@ export const TsTypes: Record = { value: 'DiscreteOrder', type: PropertiesTypes.ARRAY, }, -}; +} satisfies Record; + /* eslint-enable @typescript-eslint/naming-convention */ export interface ITsTypesMapping { mappingType: IDescribeTsType; diff --git a/src/models/polygonParts/polygonPartRecord.ts b/src/models/polygonParts/polygonPartRecord.ts index 38e6ecff..e2686ce3 100644 --- a/src/models/polygonParts/polygonPartRecord.ts +++ b/src/models/polygonParts/polygonPartRecord.ts @@ -5,7 +5,7 @@ import { FieldCategory, IPropFieldConfigInfo, fieldConfig, getFieldConfig } from import { DataFileType, IPropSHPMapping, getInputDataMapping, inputDataMapping } from '../layerMetadata/decorators/property/shp.decorator'; import { catalogDB, getCatalogDBMapping } from '../layerMetadata/decorators/property/catalogDB.decorator'; import { getTsTypesMapping, tsTypes, TsTypes } from '../layerMetadata/decorators/property/tsTypes.decorator'; -import { ICatalogDBEntityMapping, IOrmCatalog, IPYCSWMapping, horizontalAccuracyValidation } from '../layerMetadata'; +import { ICatalogDBEntityMapping, IOrmCatalog, IPYCSWMapping, ProductType, horizontalAccuracyValidation } from '../layerMetadata'; import { graphqlClass, IPropCatalogDBMapping } from '../common'; import { getCatalogDBEntityMapping } from '../layerMetadata/decorators/class/catalogDBEntity.decorator'; @@ -35,14 +35,14 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { category: FieldCategory.MAIN, }) //#endregion - public sourceId: string | undefined = undefined; + public sourceId?: string; //#region METADATA: sourceName @catalogDB({ column: { name: 'source_name', type: 'text', - nullable: true, + nullable: false, }, }) @inputDataMapping({ @@ -57,14 +57,14 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { category: FieldCategory.MAIN, }) //#endregion - public sourceName: string | undefined = undefined; + public sourceName!: string; //#region METADATA: productId @catalogDB({ column: { name: 'product_id', type: 'text', - nullable: true, + nullable: false, }, }) @inputDataMapping({ @@ -79,14 +79,14 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { category: FieldCategory.MAIN, }) //#endregion - public productId: string | undefined = undefined; + public productId!: string; //#region METADATA: productType @catalogDB({ column: { name: 'product_type', type: 'text', - nullable: true, + nullable: false, }, }) @inputDataMapping({ @@ -94,14 +94,14 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { valuePath: 'properties.SourceName', }) @tsTypes({ - mappingType: TsTypes.STRING, + mappingType: TsTypes.PRODUCTTYPE, }) @graphql() @fieldConfig({ category: FieldCategory.MAIN, }) //#endregion - public productType: string | undefined = undefined; + public productType!: ProductType; //#region METADATA: description @catalogDB({ @@ -125,7 +125,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { category: FieldCategory.GENERAL, }) //#endregion - public description: string | undefined = undefined; + public description?: string; //#region METADATA: imagingTimeBeginUTC @catalogDB({ @@ -161,7 +161,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { isLifecycleEnvolved: true, }) //#endregion - public imagingTimeBeginUTC: Date | undefined = undefined; + public imagingTimeBeginUTC!: Date; //#region METADATA: imagingTimeEndUTC @catalogDB({ @@ -192,7 +192,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { isLifecycleEnvolved: true, }) //#endregion - public imagingTimeEndUTC: Date | undefined = undefined; + public imagingTimeEndUTC!: Date; //#region METADATA: horizontalAccuracyCE90 @catalogDB({ @@ -231,13 +231,14 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { isLifecycleEnvolved: true, }) //#endregion - public horizontalAccuracyCE90: number | undefined = undefined; + public horizontalAccuracyCE90!: number; //#region METADATA: sensors @catalogDB({ column: { name: 'sensors', type: 'text', + nullable: false, }, field: { overrideType: TsTypes.STRING, @@ -264,7 +265,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { ], }) //#endregion - public sensors: string[] | undefined = undefined; + public sensors!: string[]; //#region METADATA: countries @catalogDB({ @@ -293,7 +294,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { infoMsgCode: ['info-field-tooltip.region.tooltip'], }) //#endregion - public countries: string[] | undefined = undefined; + public countries?: string[]; //#region **TO_VERIFY_CITIES?** METADATA: cities @catalogDB({ @@ -321,7 +322,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { category: FieldCategory.GENERAL, }) //#endregion - public cities: string[] | undefined = undefined; + public cities?: string[]; //#region METADATA: resolutionDegree??? [from INGESTION PARAMS] @catalogDB({ @@ -357,7 +358,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { ], }) //#endregion - public resolutionDegree: number | undefined = undefined; + public resolutionDegree!: number; //#region METADATA: resolutionMeter [from INGESTION PARAMS] @catalogDB({ @@ -388,7 +389,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { ], }) //#endregion - public resolutionMeter: number | undefined = undefined; + public resolutionMeter!: number; //#region METADATA: sourceResolutionMeter [READONLY] @catalogDB({ @@ -416,7 +417,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { ], }) //#endregion - public sourceResolutionMeter: number | undefined = undefined; + public sourceResolutionMeter!: number; //#region METADATA: geometry @catalogDB({ @@ -448,7 +449,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { ], }) //#endregion - public geometry: GeoJSON | undefined = undefined; + public geometry!: GeoJSON; //#region RECORD: id @catalogDB({ @@ -469,7 +470,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { }) //#endregion // eslint-disable-next-line @typescript-eslint/naming-convention - public id: string | undefined; + public id!: string; //#region RECORD: partId @catalogDB({ @@ -488,7 +489,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { isAutoGenerated: true, }) //#endregion - public partId: number | undefined; + public partId!: string; //#region RECORD: catalogId @catalogDB({ @@ -507,21 +508,21 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { isAutoGenerated: true, }) //#endregion - public catalogId: string | undefined = 'UNKNOWN'; + public catalogId!: string; //#region RECORD: productVersion [Version number of the best layer when it was updated] @catalogDB({ column: { name: 'product_version', type: 'text', - nullable: true, + nullable: false, }, }) @tsTypes({ mappingType: TsTypes.STRING, }) @graphql({ - nullable: true, + nullable: false, }) @fieldConfig({ category: FieldCategory.MAIN, @@ -536,13 +537,14 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { ], }) //#endregion - public productVersion: string | undefined = undefined; + public productVersion!: string; //#region RECORD: ingestionDateUTC @catalogDB({ column: { name: 'ingestion_date_utc', type: 'timestamp with time zone', + nullable: false, }, }) @tsTypes({ @@ -554,7 +556,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { isAutoGenerated: true, }) //#endregion - public ingestionDateUTC: Date | undefined = undefined; + public ingestionDateUTC!: Date; public static getPyCSWMappings(): IPropPYCSWMapping[] { return []; @@ -615,17 +617,24 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { } export interface IPolygonPart { - sourceId: string | undefined; - sourceName: string | undefined; - description: string | undefined; - resolutionDegree: number | undefined; - resolutionMeter: number | undefined; - sourceResolutionMeter: number | undefined; - horizontalAccuracyCE90: number | undefined; - countries: string[] | undefined; - cities: string[] | undefined; - sensors: string[] | undefined; - imagingTimeBeginUTC: Date | undefined; - imagingTimeEndUTC: Date | undefined; - geometry: GeoJSON | undefined; + id: string; + partId: string; + catalogId: string; + productId: string; + productVersion: string; + productType: ProductType; + sourceId?: string; + sourceName: string; + description?: string; + resolutionDegree: number; + resolutionMeter: number; + sourceResolutionMeter: number; + horizontalAccuracyCE90: number; + countries?: string[]; + cities?: string[]; + sensors: string[]; + imagingTimeBeginUTC: Date; + imagingTimeEndUTC: Date; + ingestionDateUTC: Date; + geometry: GeoJSON; } diff --git a/src/models/raster/ingestion/ingestionTypes.ts b/src/models/raster/ingestion/ingestionTypes.ts index ee48d8a8..78c37562 100644 --- a/src/models/raster/ingestion/ingestionTypes.ts +++ b/src/models/raster/ingestion/ingestionTypes.ts @@ -1,5 +1,5 @@ import { LayerMetadata, ProductType, Transparency } from '../../layerMetadata'; -import { PolygonPartRecord } from '../../polygonParts'; +import { IPolygonPart } from '../../polygonParts'; export type IBaseRasterLayerMetadata = Pick; @@ -63,7 +63,7 @@ export class NewRasterLayerMetadata extends BaseRasterLayerMetadata implements I } export type PolygonPart = Pick< - PolygonPartRecord, + IPolygonPart, | 'sourceName' | 'resolutionDegree' | 'resolutionMeter' @@ -73,8 +73,11 @@ export type PolygonPart = Pick< | 'imagingTimeBeginUTC' | 'imagingTimeEndUTC' | 'geometry' -> & - Partial>; + | 'sourceId' + | 'description' + | 'countries' + | 'cities' +>; export interface InputFiles { originDirectory: string;