Skip to content

Commit

Permalink
fix: fields alignment according to the definition of the polygon part (
Browse files Browse the repository at this point in the history
…#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
  • Loading branch information
almog8k authored Sep 11, 2024
1 parent 8924434 commit 30931e6
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 57 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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/**
Expand Down
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface IDescribeTsType {
}

/* eslint-disable @typescript-eslint/naming-convention */
export const TsTypes: Record<string, IDescribeTsType> = {
export const TsTypes = {
STRING: {
value: 'string',
type: PropertiesTypes.PRIMITIVE,
Expand Down Expand Up @@ -117,7 +117,8 @@ export const TsTypes: Record<string, IDescribeTsType> = {
value: 'DiscreteOrder',
type: PropertiesTypes.ARRAY,
},
};
} satisfies Record<string, IDescribeTsType>;

/* eslint-enable @typescript-eslint/naming-convention */
export interface ITsTypesMapping {
mappingType: IDescribeTsType;
Expand Down
89 changes: 49 additions & 40 deletions src/models/polygonParts/polygonPartRecord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down Expand Up @@ -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({
Expand All @@ -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({
Expand All @@ -79,29 +79,29 @@ 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({
dataFile: DataFileType.SHAPE_METADATA,
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({
Expand All @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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,
Expand All @@ -264,7 +265,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog {
],
})
//#endregion
public sensors: string[] | undefined = undefined;
public sensors!: string[];

//#region METADATA: countries
@catalogDB({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -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({
Expand Down Expand Up @@ -388,7 +389,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog {
],
})
//#endregion
public resolutionMeter: number | undefined = undefined;
public resolutionMeter!: number;

//#region METADATA: sourceResolutionMeter [READONLY]
@catalogDB({
Expand Down Expand Up @@ -416,7 +417,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog {
],
})
//#endregion
public sourceResolutionMeter: number | undefined = undefined;
public sourceResolutionMeter!: number;

//#region METADATA: geometry
@catalogDB({
Expand Down Expand Up @@ -448,7 +449,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog {
],
})
//#endregion
public geometry: GeoJSON | undefined = undefined;
public geometry!: GeoJSON;

//#region RECORD: id
@catalogDB({
Expand All @@ -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({
Expand All @@ -488,7 +489,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog {
isAutoGenerated: true,
})
//#endregion
public partId: number | undefined;
public partId!: string;

//#region RECORD: catalogId
@catalogDB({
Expand All @@ -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,
Expand All @@ -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({
Expand All @@ -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 [];
Expand Down Expand Up @@ -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;
}
11 changes: 7 additions & 4 deletions src/models/raster/ingestion/ingestionTypes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LayerMetadata, ProductType, Transparency } from '../../layerMetadata';
import { PolygonPartRecord } from '../../polygonParts';
import { IPolygonPart } from '../../polygonParts';

export type IBaseRasterLayerMetadata = Pick<LayerMetadata, 'classification'>;

Expand Down Expand Up @@ -63,7 +63,7 @@ export class NewRasterLayerMetadata extends BaseRasterLayerMetadata implements I
}

export type PolygonPart = Pick<
PolygonPartRecord,
IPolygonPart,
| 'sourceName'
| 'resolutionDegree'
| 'resolutionMeter'
Expand All @@ -73,8 +73,11 @@ export type PolygonPart = Pick<
| 'imagingTimeBeginUTC'
| 'imagingTimeEndUTC'
| 'geometry'
> &
Partial<Pick<PolygonPartRecord, 'sourceId' | 'description' | 'countries' | 'cities'>>;
| 'sourceId'
| 'description'
| 'countries'
| 'cities'
>;

export interface InputFiles {
originDirectory: string;
Expand Down

0 comments on commit 30931e6

Please sign in to comment.