From aa60fedf4caefb5ec9f1d641b39c9d0d36bc1add Mon Sep 17 00:00:00 2001 From: Eliav Maimon <135841794+Eliav-Maimon@users.noreply.github.com> Date: Wed, 13 Nov 2024 12:29:58 +0200 Subject: [PATCH 01/24] fix: add isPartial class to ICatalogDBEntityMapping (#229) --- .../decorators/class/catalogDBEntity.decorator.ts | 1 + src/models/polygonParts/polygonPartRecord.ts | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/models/layerMetadata/decorators/class/catalogDBEntity.decorator.ts b/src/models/layerMetadata/decorators/class/catalogDBEntity.decorator.ts index d8fad48a..26626aa2 100644 --- a/src/models/layerMetadata/decorators/class/catalogDBEntity.decorator.ts +++ b/src/models/layerMetadata/decorators/class/catalogDBEntity.decorator.ts @@ -5,6 +5,7 @@ const catalogDbEntityMetadataKey = Symbol('catalogdbentitymapping'); export interface ICatalogDBEntityMapping { table: string; // database table name className: string; + isPartial?: boolean; // if isPartial is true, the Entity decorator will not be generated } export function catalogDBEntity(catalogdbentitymapping: ICatalogDBEntityMapping): ClassDecorator { diff --git a/src/models/polygonParts/polygonPartRecord.ts b/src/models/polygonParts/polygonPartRecord.ts index f9407d62..dfb92a80 100644 --- a/src/models/polygonParts/polygonPartRecord.ts +++ b/src/models/polygonParts/polygonPartRecord.ts @@ -26,8 +26,9 @@ const POLYGON_PARTS_SERVED_KEYS = keys<Omit<IPolygonPart, 'productId' | 'productType' | 'id' | 'catalogId' | 'productVersion' | 'ingestionDateUTC' | 'partId'>>(); @DBEntity({ - table: 'records', + table: '***DUMMY_NOT_RELEVANT***', className: 'Common', + isPartial: true, }) @graphqlClass({ alias: 'PolygonPartRecord', fields: POLYGON_PARTS_KEYS }) export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { From d316873b87f7efc0e198de2c9f213857468854be Mon Sep 17 00:00:00 2001 From: Alex Lebinson <newdarkvirus@gmail.com> Date: Wed, 13 Nov 2024 12:32:00 +0200 Subject: [PATCH 02/24] fix: pp islivecycleenvolved in layerrecord tuning (#230) * fix: layerrecord lifecycle fields tunning * chore: cleanup few remarks --- src/models/layerMetadata/layerMetadata.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/models/layerMetadata/layerMetadata.ts b/src/models/layerMetadata/layerMetadata.ts index f5777ffd..0d197924 100644 --- a/src/models/layerMetadata/layerMetadata.ts +++ b/src/models/layerMetadata/layerMetadata.ts @@ -345,7 +345,7 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { mappingType: TsTypes.DATE, }) @graphql({ - nullable: true, + nullable: false, }) @fieldConfig({ category: FieldCategory.MAIN, @@ -465,7 +465,7 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { mappingType: TsTypes.NUMBER, }) @graphql({ - nullable: false, //keep it true like in min? + nullable: false, }) @fieldConfig({ category: FieldCategory.GEO_INFO, @@ -512,7 +512,7 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { mappingType: TsTypes.NUMBER, }) @graphql({ - nullable: true, + nullable: false, }) @fieldConfig({ category: FieldCategory.GEO_INFO, @@ -883,13 +883,13 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { mappingType: TsTypes.NUMBER, }) @graphql({ - nullable: false, //keep it true like in max? + nullable: false, }) @fieldConfig({ category: FieldCategory.MAIN, infoMsgCode: [ 'info-field-tooltip.minResolutionDeg.tooltip', - 'info-general-tooltip.required', // is it required? + 'info-general-tooltip.required', 'info-field-tooltip.minResolutionDeg.min', 'info-field-tooltip.minResolutionDeg.max', ], @@ -909,6 +909,7 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { max: VALIDATIONS.resolutionDeg.max, }, ], + isLifecycleEnvolved: true, }) //#endregion public minResolutionDeg: number | undefined = undefined; @@ -981,10 +982,10 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { mappingType: TsTypes.NUMBER, }) @graphql({ - nullable: true, + nullable: false, }) @fieldConfig({ - category: FieldCategory.MAIN, // is it required? + category: FieldCategory.MAIN, infoMsgCode: ['info-general-tooltip.required', 'info-field-tooltip.minResolutionMeter.min', 'info-field-tooltip.minResolutionMeter.max'], validation: [ { From 250f9830177a05cb1c4d456c9b10064e24c1f208 Mon Sep 17 00:00:00 2001 From: Alex Lebinson <newdarkvirus@gmail.com> Date: Wed, 13 Nov 2024 13:26:49 +0200 Subject: [PATCH 03/24] fix: cleanup inputmapping decorator not relevant (#231) --- src/models/layerMetadata/layerMetadata.ts | 85 +---------------------- 1 file changed, 1 insertion(+), 84 deletions(-) diff --git a/src/models/layerMetadata/layerMetadata.ts b/src/models/layerMetadata/layerMetadata.ts index 0d197924..64f2bea8 100644 --- a/src/models/layerMetadata/layerMetadata.ts +++ b/src/models/layerMetadata/layerMetadata.ts @@ -14,7 +14,7 @@ import { NewRasterLayerMetadata, UpdateRasterLayerMetadata } from '../raster/ing import { VALIDATIONS } from '../raster/constants'; import { IMetadataCommonModel } from './interfaces/metadataCommonModel'; import { getPyCSWMapping, IPYCSWMapping, pycsw } from './decorators/property/csw.decorator'; -import { getInputDataMapping, IDataMapping, DataFileType, inputDataMapping, IPropSHPMapping } from './decorators/property/shp.decorator'; +import { getInputDataMapping, IDataMapping, IPropSHPMapping } from './decorators/property/shp.decorator'; import { getCatalogDBMapping, ICatalogDBMapping, catalogDB, ORMColumnType } from './decorators/property/catalogDB.decorator'; import { getTsTypesMapping, tsTypes, TsTypes } from './decorators/property/tsTypes.decorator'; import { ProductType, Transparency, TileOutputFormat } from './enums'; @@ -151,10 +151,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { nullable: true, }, }) - @inputDataMapping({ - dataFile: DataFileType.SHAPE_METADATA, - valuePath: 'features[0].properties.SourceName', - }) @tsTypes({ mappingType: TsTypes.STRING, }) @@ -187,10 +183,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { nullable: true, }, }) - @inputDataMapping({ - dataFile: DataFileType.SHAPE_METADATA, - valuePath: 'features[0].properties.Dsc', - }) @tsTypes({ mappingType: TsTypes.STRING, }) @@ -336,11 +328,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { columnType: ORMColumnType.UPDATE_DATE_COLUMN, }, }) - @inputDataMapping({ - isCustomLogic: true, - dataFile: DataFileType.SHAPE_METADATA, - valuePath: '***max(features[].properties.UpdateDate)***', - }) @tsTypes({ mappingType: TsTypes.DATE, }) @@ -370,11 +357,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { nullable: false, }, }) - @inputDataMapping({ - isCustomLogic: true, - dataFile: DataFileType.SHAPE_METADATA, - valuePath: '***min(features[].properties.UpdateDate)***', - }) @tsTypes({ mappingType: TsTypes.DATE, }) @@ -419,11 +401,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { nullable: false, }, }) - @inputDataMapping({ - isCustomLogic: true, - dataFile: DataFileType.SHAPE_METADATA, - valuePath: '***max(features[].properties.UpdateDate)***', - }) @tsTypes({ mappingType: TsTypes.DATE, }) @@ -457,10 +434,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { type: 'real', }, }) - @inputDataMapping({ - dataFile: DataFileType.SHAPE_METADATA, - valuePath: 'features[0].properties.Ep90', - }) @tsTypes({ mappingType: TsTypes.NUMBER, }) @@ -504,10 +477,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { type: 'real', }, }) - @inputDataMapping({ - dataFile: DataFileType.SHAPE_METADATA, - valuePath: 'features[0].properties.Ep90', - }) @tsTypes({ mappingType: TsTypes.NUMBER, }) @@ -554,11 +523,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { overrideType: TsTypes.STRING, }, }) - @inputDataMapping({ - isCustomLogic: true, - dataFile: DataFileType.SHAPE_METADATA, - valuePath: '***features[].properties.SensorType***', - }) @tsTypes({ mappingType: TsTypes.STRING_ARRAY, }) @@ -595,11 +559,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { overrideType: TsTypes.STRING, }, }) - @inputDataMapping({ - isCustomLogic: true, - dataFile: DataFileType.SHAPE_METADATA, - valuePath: '***features[].properties.Countries***', - }) @tsTypes({ mappingType: TsTypes.STRING_ARRAY, }) @@ -637,11 +596,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { nullable: false, }, }) - @inputDataMapping({ - isCustomLogic: true, - dataFile: DataFileType.SHAPE_METADATA, - valuePath: '***features[0].properties.Source.Split(-)[0]***', - }) @tsTypes({ mappingType: TsTypes.STRING, }) @@ -680,11 +634,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { nullable: true, }, }) - @inputDataMapping({ - isCustomLogic: true, - dataFile: DataFileType.SHAPE_METADATA, - valuePath: '***features[0].properties.Source.Split(-)[1]***', - }) @tsTypes({ mappingType: TsTypes.STRING, }) @@ -723,10 +672,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { nullable: false, }, }) - @inputDataMapping({ - dataFile: DataFileType.PRODUCT, - valuePath: 'features[0].properties.Type', - }) @tsTypes({ mappingType: TsTypes.PRODUCTTYPE, }) @@ -823,10 +768,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { type: 'numeric', }, }) - @inputDataMapping({ - dataFile: DataFileType.TFW, - valuePath: '[0]', - }) @tsTypes({ mappingType: TsTypes.NUMBER, }) @@ -875,10 +816,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { type: 'numeric', }, }) - @inputDataMapping({ - dataFile: DataFileType.TFW, - valuePath: '[0]', - }) @tsTypes({ mappingType: TsTypes.NUMBER, }) @@ -927,10 +864,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { type: 'numeric', }, }) - @inputDataMapping({ - dataFile: DataFileType.SHAPE_METADATA, - valuePath: 'features[0].properties.Resolution', - }) @tsTypes({ mappingType: TsTypes.NUMBER, }) @@ -974,10 +907,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { type: 'numeric', }, }) - @inputDataMapping({ - dataFile: DataFileType.SHAPE_METADATA, - valuePath: 'features[0].properties.Resolution', - }) @tsTypes({ mappingType: TsTypes.NUMBER, }) @@ -1022,10 +951,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { nullable: true, }, }) - @inputDataMapping({ - dataFile: DataFileType.SHAPE_METADATA, - valuePath: 'features[0].properties.Rms', - }) @tsTypes({ mappingType: TsTypes.NUMBER, }) @@ -1049,10 +974,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { nullable: true, }, }) - @inputDataMapping({ - dataFile: DataFileType.SHAPE_METADATA, - valuePath: 'features[0].properties.Scale', - }) @tsTypes({ mappingType: TsTypes.NUMBER, }) @@ -1094,10 +1015,6 @@ export class LayerMetadata implements ILayerMetadata, IMetadataCommonModel { nullable: false, }, }) - @inputDataMapping({ - dataFile: DataFileType.PRODUCT, - valuePath: 'features[0].geometry', - }) @tsTypes({ mappingType: TsTypes.OBJECT, }) From 9f6928f5f0d43c45d4003eac50bc63783ad3156e Mon Sep 17 00:00:00 2001 From: alebinson <newdarkvirus@gmail.com> Date: Wed, 13 Nov 2024 13:26:27 +0200 Subject: [PATCH 04/24] chore(release): 17.10.2 --- CHANGELOG.md | 9 +++++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b59e7471..efa7aa27 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,15 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [17.10.2](https://github.com/MapColonies/mc-models/compare/v17.10.1...v17.10.2) (2024-11-13) + + +### Bug Fixes + +* add isPartial class to ICatalogDBEntityMapping ([#229](https://github.com/MapColonies/mc-models/issues/229)) ([aa60fed](https://github.com/MapColonies/mc-models/commit/aa60fedf4caefb5ec9f1d641b39c9d0d36bc1add)) +* cleanup inputmapping decorator not relevant ([#231](https://github.com/MapColonies/mc-models/issues/231)) ([250f983](https://github.com/MapColonies/mc-models/commit/250f9830177a05cb1c4d456c9b10064e24c1f208)) +* pp islivecycleenvolved in layerrecord tuning ([#230](https://github.com/MapColonies/mc-models/issues/230)) ([d316873](https://github.com/MapColonies/mc-models/commit/d316873b87f7efc0e198de2c9f213857468854be)) + ### [17.10.1](https://github.com/MapColonies/mc-models/compare/v17.10.0...v17.10.1) (2024-11-12) ## [17.10.0](https://github.com/MapColonies/mc-models/compare/v17.9.3...v17.10.0) (2024-11-12) diff --git a/package-lock.json b/package-lock.json index 91cc08e5..a15c240e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.10.1", + "version": "17.10.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@map-colonies/mc-model-types", - "version": "17.10.1", + "version": "17.10.2", "license": "MIT", "dependencies": { "@types/geojson": "^7946.0.7", diff --git a/package.json b/package.json index 87bbb015..e8fa5251 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.10.1", + "version": "17.10.2", "description": "json schemas for validations and generated ts models", "author": "", "license": "MIT", From 7dd9dceca1adbb6c1618970075c59ce3f51fa496 Mon Sep 17 00:00:00 2001 From: Dorin-RFL <rutime7@gmail.com> Date: Sun, 17 Nov 2024 13:27:33 +0200 Subject: [PATCH 05/24] Primary generated column catalog db (#232) * fix: add isPartial class to ICatalogDBEntityMapping * feat: add column type of PRIMARY_GENERATED_COLUMN * fix: delete unnecesarry tests * ci: change name of artifacts --------- Co-authored-by: Eliav Maimon <liavma3@gmail.com> --- .github/workflows/pull_request.yaml | 2 +- src/models/polygonParts/polygonPartRecord.ts | 6 +++-- tests/unit/layerMetadata.spec.ts | 28 +------------------- 3 files changed, 6 insertions(+), 30 deletions(-) diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index d4d68b0f..9e246062 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -62,6 +62,6 @@ jobs: - uses: actions/upload-artifact@v4 with: - name: Test Reporters + name: Test Reporters Node-${{ matrix.node }} path: reports/** diff --git a/src/models/polygonParts/polygonPartRecord.ts b/src/models/polygonParts/polygonPartRecord.ts index dfb92a80..1ce1aff7 100644 --- a/src/models/polygonParts/polygonPartRecord.ts +++ b/src/models/polygonParts/polygonPartRecord.ts @@ -594,9 +594,10 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { //#region RECORD: id @catalogDB({ column: { - type: 'text', + name: camelCaseToSnakeCase('id'), + type: 'uuid', + columnType: ORMColumnType.PRIMARY_GENERATED_COLUMN, nullable: false, - primary: true, }, }) @wfs({ @@ -615,6 +616,7 @@ export class PolygonPartRecord implements IPolygonPart, IOrmCatalog { //#region RECORD: partId @catalogDB({ column: { + name: camelCaseToSnakeCase('partId'), type: 'number', nullable: false, }, diff --git a/tests/unit/layerMetadata.spec.ts b/tests/unit/layerMetadata.spec.ts index e39cf70e..43d8490c 100644 --- a/tests/unit/layerMetadata.spec.ts +++ b/tests/unit/layerMetadata.spec.ts @@ -1,6 +1,5 @@ -import { LayerMetadata, IPYCSWMapping, IDataMapping, IPropPYCSWMapping, Pycsw3DCatalogRecord } from '../../src/models'; +import { LayerMetadata, IPYCSWMapping, IPropPYCSWMapping, Pycsw3DCatalogRecord } from '../../src/models'; import { ICatalogDBMapping } from '../../src/models/layerMetadata/decorators/property/catalogDB.decorator'; -import { IPropSHPMapping } from '../../src/models/layerMetadata/decorators/property/shp.decorator'; import { PycswLayerCatalogRecord } from '../../src/models/layerMetadata/pycswLayerCatalogRecord'; describe('LayerMetadata class static methods', () => { @@ -19,21 +18,6 @@ describe('LayerMetadata class static methods', () => { expect(pycswMapping).toBeUndefined(); }); - it('getShpMapping(): mapped to SHAPE prop', () => { - const PROPERTY_NAME = 'footprint'; - const shpMapping: IDataMapping | undefined = LayerMetadata.getShpMapping(PROPERTY_NAME); - - expect(shpMapping).toHaveProperty('dataFile'); - expect(shpMapping).toHaveProperty('valuePath'); - }); - - it('getShpMapping(): NOT mapped to SHAPE prop', () => { - const PROPERTY_NAME = 'dummy_footprint'; - const shpMapping: IDataMapping | undefined = LayerMetadata.getShpMapping(PROPERTY_NAME); - - expect(shpMapping).toBeUndefined(); - }); - it('getPyCSWMappings(): HAS props mapped to PYCSW', () => { const pycswMappings: IPropPYCSWMapping[] = LayerMetadata.getPyCSWMappings(); @@ -44,16 +28,6 @@ describe('LayerMetadata class static methods', () => { expect(pycswMappings[0]).toHaveProperty('queryableField'); }); - it('getShpMappings(): HAS props mapped to SHAPE', () => { - const shpMappings: IPropSHPMapping[] = LayerMetadata.getShpMappings(); - - expect(shpMappings.length).toBeGreaterThan(0); - expect(shpMappings[0]).toHaveProperty('prop'); - expect(shpMappings[0]).toHaveProperty('dataFile'); - expect(shpMappings[0]).toHaveProperty('valuePath'); - expect(shpMappings[0]).toHaveProperty('mappingType'); - }); - it('getCatalogDbMapping(): mapped to DATABASE prop', () => { const PROPERTY_NAME = 'footprint'; const catalogDBMapping: ICatalogDBMapping | undefined = LayerMetadata.getCatalogDBMapping(PROPERTY_NAME); From 52816c8dc3eed532dd6953bf2eb880d1efbc43a7 Mon Sep 17 00:00:00 2001 From: alebinson <newdarkvirus@gmail.com> Date: Sun, 17 Nov 2024 18:19:16 +0200 Subject: [PATCH 06/24] chore(release): 17.10.3 --- CHANGELOG.md | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index efa7aa27..1309791c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [17.10.3](https://github.com/MapColonies/mc-models/compare/v17.10.2...v17.10.3) (2024-11-17) + ### [17.10.2](https://github.com/MapColonies/mc-models/compare/v17.10.1...v17.10.2) (2024-11-13) diff --git a/package-lock.json b/package-lock.json index a15c240e..7fdafda0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.10.2", + "version": "17.10.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@map-colonies/mc-model-types", - "version": "17.10.2", + "version": "17.10.3", "license": "MIT", "dependencies": { "@types/geojson": "^7946.0.7", diff --git a/package.json b/package.json index e8fa5251..de44117d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.10.2", + "version": "17.10.3", "description": "json schemas for validations and generated ts models", "author": "", "license": "MIT", From d65072a7ec8e704124e56fe7560534c7207d6430 Mon Sep 17 00:00:00 2001 From: Ronit Kissis <92728393+RonitKissis@users.noreply.github.com> Date: Sun, 24 Nov 2024 10:54:41 +0200 Subject: [PATCH 07/24] fix: update yaml and types for raster catalog manager bugs (#233) --- .../rasterCatalogUpsertRequest.ts | 8 ++ src/yaml/fullLayerMetadata.yaml | 94 +++++++++++++++++++ src/yaml/rasterCatalog/insertRequest.yaml | 4 + src/yaml/rasterCatalog/updateRequest.yaml | 4 - src/yaml/updateLayerMetadata.yaml | 70 +------------- 5 files changed, 107 insertions(+), 73 deletions(-) diff --git a/src/models/rasterCatalog/rasterCatalogUpsertRequest.ts b/src/models/rasterCatalog/rasterCatalogUpsertRequest.ts index a0c3707d..a783d4f7 100644 --- a/src/models/rasterCatalog/rasterCatalogUpsertRequest.ts +++ b/src/models/rasterCatalog/rasterCatalogUpsertRequest.ts @@ -1,7 +1,15 @@ import { Link } from '../common'; import { LayerMetadata } from '../layerMetadata'; +export type UpdateLayerMetadata = Partial< + Pick<LayerMetadata, 'classification' | 'productName' | 'productSubType' | 'description' | 'producerName' | 'region' | 'scale'> +>; + export interface IRasterCatalogUpsertRequestBody { metadata: LayerMetadata; links?: Link[]; } + +export interface IRasterCatalogUpdateRequestBody { + metadata: UpdateLayerMetadata; +} diff --git a/src/yaml/fullLayerMetadata.yaml b/src/yaml/fullLayerMetadata.yaml index 61133353..416d75f7 100644 --- a/src/yaml/fullLayerMetadata.yaml +++ b/src/yaml/fullLayerMetadata.yaml @@ -50,4 +50,98 @@ components: maximum: 4000 format: double description: minimum Horizontal Accuracy + type: + type: string + description: Layer type raster / 3d / dem + enum: + - RECORD_RASTER + - RECORD_3D + classification: + type: string + description: Permitted roles + pattern: ^[0-9]$|^[1-9][0-9]$|^(100)$ + productId: + type: string + description: Layer's external identifier + pattern: ^[A-Za-z]{1}[A-Za-z0-9_]{0,37}$ + productName: + type: string + description: Layer's external name + productVersion: + type: string + pattern: ^[1-9]\d*(\.(0|[1-9]\d?))?$ + description: layer's version + productType: + $ref: './updateLayerMetadata.yaml#/components/schemas/productType' + productSubType: + type: string + description: Layer's sub type + description: + type: string + description: layer's description + srs: + type: string + description: geo system id + srsName: + type: string + description: geo system name + producerName: + type: string + description: creator name default IDFMU + creationDateUTC: + type: string + description: Creation date + format: date-time + ingestionDate: + type: string + description: Ingestion date + format: date-time + imagingTimeBeginUTC: + type: string + description: Oldest imaging date + format: date-time + imagingTimeEndUTC: + type: string + description: Latest imaging date + format: date-time + maxResolutionDeg: + type: number + minimum: 0.000000167638063430786 + maximum: 0.703125 + format: double + description: max resolution of layer in degrees/pixel + maxResolutionMeter: + type: number + minimum: 0.0185 + maximum: 78271.52 + format: double + description: max (rounded) resolution of layer in meters/pixel + minHorizontalAccuracyCE90: + type: number + minimum: 0.01 + maximum: 4000 + format: double + description: minimum Horizontal Accuracy + sensors: + type: array + items: + type: string + description: Layer sensors list + region: + type: array + items: + type: string + description: regions included in the layer + rms: + type: number + scale: + type: integer + minimum: 0 + maximum: 100000000 + footprint: + $ref: geojson.yaml#/components/schemas/Geometry + productBoundingBox: + type: string + pattern: "^-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?$" + diff --git a/src/yaml/rasterCatalog/insertRequest.yaml b/src/yaml/rasterCatalog/insertRequest.yaml index ab6aecd0..25637246 100644 --- a/src/yaml/rasterCatalog/insertRequest.yaml +++ b/src/yaml/rasterCatalog/insertRequest.yaml @@ -15,6 +15,10 @@ components: - properties: metadata: $ref: ../insertLayerMetadata.yaml#/components/schemas/insertLayerMetadata + links: + type: array + items: + $ref: ../link.yaml#/components/schemas/Link - properties: metadata: required: diff --git a/src/yaml/rasterCatalog/updateRequest.yaml b/src/yaml/rasterCatalog/updateRequest.yaml index f42257d7..2c6dd3f9 100644 --- a/src/yaml/rasterCatalog/updateRequest.yaml +++ b/src/yaml/rasterCatalog/updateRequest.yaml @@ -10,10 +10,6 @@ components: properties: metadata: $ref: ../updateLayerMetadata.yaml#/components/schemas/updateLayerMetadata - links: - type: array - items: - $ref: ../link.yaml#/components/schemas/Link #due to bug in validator additional properties is not compilable with allof #https://github.com/cdimascio/express-openapi-validator/issues/239 diff --git a/src/yaml/updateLayerMetadata.yaml b/src/yaml/updateLayerMetadata.yaml index 147cb53c..e969b70a 100644 --- a/src/yaml/updateLayerMetadata.yaml +++ b/src/yaml/updateLayerMetadata.yaml @@ -19,101 +19,33 @@ components: description: layer's type might be derived from the first letter updateLayerMetadata: type: object - description: layer meta data + description: updatable layer metadata properties: - type: - type: string - description: Layer type raster / 3d / dem - enum: - - RECORD_RASTER - - RECORD_3D classification: type: string description: Permitted roles pattern: ^[0-9]$|^[1-9][0-9]$|^(100)$ - productId: - type: string - description: Layer's external identifier - pattern: ^[A-Za-z]{1}[A-Za-z0-9_]{0,37}$ productName: type: string description: Layer's external name - productVersion: - type: string - pattern: ^[1-9]\d*(\.(0|[1-9]\d?))?$ - description: layer's version - productType: - $ref: '#/components/schemas/productType' productSubType: type: string description: Layer's sub type description: type: string description: layer's description - srs: - type: string - description: geo system id - srsName: - type: string - description: geo system name producerName: type: string description: creator name default IDFMU - creationDateUTC: - type: string - description: Creation date - format: date-time - ingestionDate: - type: string - description: Ingestion date - format: date-time - imagingTimeBeginUTC: - type: string - description: Oldest imaging date - format: date-time - imagingTimeEndUTC: - type: string - description: Latest imaging date - format: date-time - maxResolutionDeg: - type: number - minimum: 0.000000167638063430786 - maximum: 0.703125 - format: double - description: max resolution of layer in degrees/pixel - maxResolutionMeter: - type: number - minimum: 0.0185 - maximum: 78271.52 - format: double - description: max (rounded) resolution of layer in meters/pixel - minHorizontalAccuracyCE90: - type: number - minimum: 0.01 - maximum: 4000 - format: double - description: minimum Horizontal Accuracy - sensors: - type: array - items: - type: string - description: Layer sensors list region: type: array items: type: string description: regions included in the layer - rms: - type: number scale: type: integer minimum: 0 maximum: 100000000 - footprint: - $ref: geojson.yaml#/components/schemas/Geometry - productBoundingBox: - type: string - pattern: "^-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?$" updateStatusLayerMetadata: type: object From e680af33733bfcd1c80881b0ba6474deac2f0e2e Mon Sep 17 00:00:00 2001 From: RonitKissis <ronitkisis1997@gmail.com> Date: Sun, 24 Nov 2024 10:54:54 +0200 Subject: [PATCH 08/24] chore(release): 17.10.4 --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1309791c..77d95f26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [17.10.4](https://github.com/MapColonies/mc-models/compare/v17.10.3...v17.10.4) (2024-11-24) + + +### Bug Fixes + +* update yaml and types for raster catalog manager bugs ([#233](https://github.com/MapColonies/mc-models/issues/233)) ([d65072a](https://github.com/MapColonies/mc-models/commit/d65072a7ec8e704124e56fe7560534c7207d6430)) + ### [17.10.3](https://github.com/MapColonies/mc-models/compare/v17.10.2...v17.10.3) (2024-11-17) ### [17.10.2](https://github.com/MapColonies/mc-models/compare/v17.10.1...v17.10.2) (2024-11-13) diff --git a/package-lock.json b/package-lock.json index 7fdafda0..128c2aa4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.10.3", + "version": "17.10.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@map-colonies/mc-model-types", - "version": "17.10.3", + "version": "17.10.4", "license": "MIT", "dependencies": { "@types/geojson": "^7946.0.7", diff --git a/package.json b/package.json index de44117d..04f4ad2c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.10.3", + "version": "17.10.4", "description": "json schemas for validations and generated ts models", "author": "", "license": "MIT", From 153c12cfa8a611d64becdd5f266d98468766df3a Mon Sep 17 00:00:00 2001 From: vitaligi <54726763+vitaligi@users.noreply.github.com> Date: Mon, 25 Nov 2024 14:11:29 +0200 Subject: [PATCH 09/24] feat: aggregation layer metadata (#234) * feat: aggregation layer metadata * refactor: stricter footprint type * refactor: naming convention --- .../layerMetadata/aggregatedLayerMetadata.ts | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 src/models/layerMetadata/aggregatedLayerMetadata.ts diff --git a/src/models/layerMetadata/aggregatedLayerMetadata.ts b/src/models/layerMetadata/aggregatedLayerMetadata.ts new file mode 100644 index 00000000..f1e4b893 --- /dev/null +++ b/src/models/layerMetadata/aggregatedLayerMetadata.ts @@ -0,0 +1,31 @@ +import type { GeoJSON, MultiPolygon, Polygon } from 'geojson'; +import type { IMetadataCommonModel } from './interfaces/metadataCommonModel'; +import type { ILayerMetadata } from './layerMetadata'; + +type NonNullableRecord<T extends Record<PropertyKey, unknown>> = { + [K in keyof T]-?: NonNullable<T[K]>; +}; + +type FlatArraysInRecord<T extends Record<PropertyKey, unknown>> = { + [K in keyof T]: T[K] extends (infer I)[] ? I : T[K]; +}; + +type MakePolygonalRecord<T, P extends keyof T, Q = GeoJSON> = NonNullable<T[P]> extends Q ? Record<P, Polygon | MultiPolygon> : never; + +export interface AggregationLayerMetadata + extends NonNullableRecord< + Pick< + ILayerMetadata, + | 'imagingTimeBeginUTC' + | 'imagingTimeEndUTC' + | 'maxResolutionDeg' + | 'minResolutionDeg' + | 'maxResolutionMeter' + | 'minResolutionMeter' + | 'maxHorizontalAccuracyCE90' + | 'minHorizontalAccuracyCE90' + | 'productBoundingBox' + > + >, + FlatArraysInRecord<NonNullableRecord<Pick<ILayerMetadata, 'sensors'>>>, + MakePolygonalRecord<IMetadataCommonModel, 'footprint'> {} From 451eba750c4c4dbbfe8a3ea1ee7e1e3603844ed0 Mon Sep 17 00:00:00 2001 From: vitaligi <54726763+vitaligi@users.noreply.github.com> Date: Mon, 25 Nov 2024 14:12:22 +0200 Subject: [PATCH 10/24] chore(release): 17.11.0 --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 77d95f26..a150a272 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [17.11.0](https://github.com/MapColonies/mc-models/compare/v17.10.4...v17.11.0) (2024-11-25) + + +### Features + +* aggregation layer metadata ([#234](https://github.com/MapColonies/mc-models/issues/234)) ([153c12c](https://github.com/MapColonies/mc-models/commit/153c12cfa8a611d64becdd5f266d98468766df3a)) + ### [17.10.4](https://github.com/MapColonies/mc-models/compare/v17.10.3...v17.10.4) (2024-11-24) diff --git a/package-lock.json b/package-lock.json index 128c2aa4..86c9a529 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.10.4", + "version": "17.11.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@map-colonies/mc-model-types", - "version": "17.10.4", + "version": "17.11.0", "license": "MIT", "dependencies": { "@types/geojson": "^7946.0.7", diff --git a/package.json b/package.json index 04f4ad2c..0a1db0fd 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.10.4", + "version": "17.11.0", "description": "json schemas for validations and generated ts models", "author": "", "license": "MIT", From be8fa2ed72c1f070bd463db26f8d8380bcd52fe0 Mon Sep 17 00:00:00 2001 From: vitaligi <54726763+vitaligi@users.noreply.github.com> Date: Mon, 25 Nov 2024 14:25:18 +0200 Subject: [PATCH 11/24] refactor: export aggregation layer metadata (#235) --- .../{aggregatedLayerMetadata.ts => aggregationLayerMetadata.ts} | 0 src/models/layerMetadata/index.ts | 1 + 2 files changed, 1 insertion(+) rename src/models/layerMetadata/{aggregatedLayerMetadata.ts => aggregationLayerMetadata.ts} (100%) diff --git a/src/models/layerMetadata/aggregatedLayerMetadata.ts b/src/models/layerMetadata/aggregationLayerMetadata.ts similarity index 100% rename from src/models/layerMetadata/aggregatedLayerMetadata.ts rename to src/models/layerMetadata/aggregationLayerMetadata.ts diff --git a/src/models/layerMetadata/index.ts b/src/models/layerMetadata/index.ts index e960f762..133256f9 100644 --- a/src/models/layerMetadata/index.ts +++ b/src/models/layerMetadata/index.ts @@ -1,4 +1,5 @@ export * from './layerMetadata'; +export { AggregationLayerMetadata } from './aggregationLayerMetadata'; export { Layer3DMetadata } from './layer3DMetadata'; export { LayerDemMetadata } from './layerDEMMetadata'; export * from './layerMetadata-StatusFields'; From 8396d8d1d34aff331962bf9196d3dea2c9f0666c Mon Sep 17 00:00:00 2001 From: vitaligi <54726763+vitaligi@users.noreply.github.com> Date: Mon, 25 Nov 2024 14:26:01 +0200 Subject: [PATCH 12/24] chore(release): 17.11.1 --- CHANGELOG.md | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a150a272..1c2ecbf2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [17.11.1](https://github.com/MapColonies/mc-models/compare/v17.11.0...v17.11.1) (2024-11-25) + ## [17.11.0](https://github.com/MapColonies/mc-models/compare/v17.10.4...v17.11.0) (2024-11-25) diff --git a/package-lock.json b/package-lock.json index 86c9a529..e1824b97 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.11.0", + "version": "17.11.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@map-colonies/mc-model-types", - "version": "17.11.0", + "version": "17.11.1", "license": "MIT", "dependencies": { "@types/geojson": "^7946.0.7", diff --git a/package.json b/package.json index 0a1db0fd..e4f087a2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.11.0", + "version": "17.11.1", "description": "json schemas for validations and generated ts models", "author": "", "license": "MIT", From 3e3359d57cc075ce61dc9da3a351089840f638e6 Mon Sep 17 00:00:00 2001 From: vitaligi <54726763+vitaligi@users.noreply.github.com> Date: Mon, 25 Nov 2024 15:42:18 +0200 Subject: [PATCH 13/24] refactor: aggregation (#236) * refactor: move to other dir and sensors should be an array * fix: sensors should follow a regex pattern * fix: sensors should have at least 1 item and update descriptions openapi * refactor: remove invalid export --- src/models/layerMetadata/index.ts | 1 - .../aggregationLayerMetadata.ts | 10 +++------- src/models/polygonParts/index.ts | 1 + .../ingestion/zod/schemas/partData.schema.ts | 2 +- .../partData/rasterLayerPartData.yaml | 15 +++++++++------ 5 files changed, 14 insertions(+), 15 deletions(-) rename src/models/{layerMetadata => polygonParts}/aggregationLayerMetadata.ts (69%) diff --git a/src/models/layerMetadata/index.ts b/src/models/layerMetadata/index.ts index 133256f9..e960f762 100644 --- a/src/models/layerMetadata/index.ts +++ b/src/models/layerMetadata/index.ts @@ -1,5 +1,4 @@ export * from './layerMetadata'; -export { AggregationLayerMetadata } from './aggregationLayerMetadata'; export { Layer3DMetadata } from './layer3DMetadata'; export { LayerDemMetadata } from './layerDEMMetadata'; export * from './layerMetadata-StatusFields'; diff --git a/src/models/layerMetadata/aggregationLayerMetadata.ts b/src/models/polygonParts/aggregationLayerMetadata.ts similarity index 69% rename from src/models/layerMetadata/aggregationLayerMetadata.ts rename to src/models/polygonParts/aggregationLayerMetadata.ts index f1e4b893..3d2504d9 100644 --- a/src/models/layerMetadata/aggregationLayerMetadata.ts +++ b/src/models/polygonParts/aggregationLayerMetadata.ts @@ -1,15 +1,11 @@ import type { GeoJSON, MultiPolygon, Polygon } from 'geojson'; -import type { IMetadataCommonModel } from './interfaces/metadataCommonModel'; -import type { ILayerMetadata } from './layerMetadata'; +import type { IMetadataCommonModel } from '../layerMetadata/interfaces/metadataCommonModel'; +import type { ILayerMetadata } from '../layerMetadata/layerMetadata'; type NonNullableRecord<T extends Record<PropertyKey, unknown>> = { [K in keyof T]-?: NonNullable<T[K]>; }; -type FlatArraysInRecord<T extends Record<PropertyKey, unknown>> = { - [K in keyof T]: T[K] extends (infer I)[] ? I : T[K]; -}; - type MakePolygonalRecord<T, P extends keyof T, Q = GeoJSON> = NonNullable<T[P]> extends Q ? Record<P, Polygon | MultiPolygon> : never; export interface AggregationLayerMetadata @@ -27,5 +23,5 @@ export interface AggregationLayerMetadata | 'productBoundingBox' > >, - FlatArraysInRecord<NonNullableRecord<Pick<ILayerMetadata, 'sensors'>>>, + NonNullableRecord<Pick<ILayerMetadata, 'sensors'>>, MakePolygonalRecord<IMetadataCommonModel, 'footprint'> {} diff --git a/src/models/polygonParts/index.ts b/src/models/polygonParts/index.ts index cc8a4f5b..b4c2d04e 100644 --- a/src/models/polygonParts/index.ts +++ b/src/models/polygonParts/index.ts @@ -1 +1,2 @@ +export type { AggregationLayerMetadata } from './aggregationLayerMetadata'; export * from './polygonPartRecord'; diff --git a/src/models/raster/ingestion/zod/schemas/partData.schema.ts b/src/models/raster/ingestion/zod/schemas/partData.schema.ts index ad4e0b58..72325cf3 100644 --- a/src/models/raster/ingestion/zod/schemas/partData.schema.ts +++ b/src/models/raster/ingestion/zod/schemas/partData.schema.ts @@ -23,7 +23,7 @@ export const partSchema = z .min(VALIDATIONS.resolutionMeter.min as number) .max(VALIDATIONS.resolutionMeter.max as number), horizontalAccuracyCE90: z.number().min(VALIDATIONS.horizontalAccuracyCE90.min).max(VALIDATIONS.horizontalAccuracyCE90.max), - sensors: z.array(z.string().min(1)).min(1), + sensors: z.array(z.string().regex(new RegExp('^(?! ).+(?<! )$'))).min(1), countries: z.array(z.string().min(1)).optional(), cities: z.array(z.string().min(1)).optional(), footprint: z.custom<Polygon>(), diff --git a/src/yaml/ingestionTrigger/partData/rasterLayerPartData.yaml b/src/yaml/ingestionTrigger/partData/rasterLayerPartData.yaml index 6068a172..20c0c32d 100644 --- a/src/yaml/ingestionTrigger/partData/rasterLayerPartData.yaml +++ b/src/yaml/ingestionTrigger/partData/rasterLayerPartData.yaml @@ -43,41 +43,44 @@ components: minimum: 1.67638e-7 maximum: 0.703125 format: double - description: min resolution of layer in degrees/pixel + description: Resolution of layer in degrees/pixel resolutionMeter: type: number minimum: 0.0185 maximum: 78271.52 format: double - description: min resolution of layer in meters + description: Resolution of layer in meters sourceResolutionMeter: type: number minimum: 0.0185 maximum: 78271.52 format: double - description: min resolution of layer in meters + description: Resolution of layer in meters horizontalAccuracyCE90: type: number minimum: 0.01 maximum: 4000 format: double - description: minimum Horizontal Accuracy + description: Horizontal accuracy sensors: type: array items: type: string + pattern: ^(?! ).+(?<! )$ + minItems: 1 description: Layer sensors list countries: type: array items: type: string - description: countries included in the layer + description: Countries included in the part cities: type: array items: type: string - description: cities included in the layer + description: Cities included in the part description: type: string footprint: $ref: '../../geojson.yaml#/components/schemas/Polygon' + description: Part polygonal footprint From e371a2f4afb71e4dbcf9a1ed1bb49b401179343d Mon Sep 17 00:00:00 2001 From: vitaligi <54726763+vitaligi@users.noreply.github.com> Date: Mon, 25 Nov 2024 15:42:58 +0200 Subject: [PATCH 14/24] chore(release): 17.11.2 --- CHANGELOG.md | 2 ++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1c2ecbf2..b4c91d2d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [17.11.2](https://github.com/MapColonies/mc-models/compare/v17.11.1...v17.11.2) (2024-11-25) + ### [17.11.1](https://github.com/MapColonies/mc-models/compare/v17.11.0...v17.11.1) (2024-11-25) ## [17.11.0](https://github.com/MapColonies/mc-models/compare/v17.10.4...v17.11.0) (2024-11-25) diff --git a/package-lock.json b/package-lock.json index e1824b97..c6b9c406 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.11.1", + "version": "17.11.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@map-colonies/mc-model-types", - "version": "17.11.1", + "version": "17.11.2", "license": "MIT", "dependencies": { "@types/geojson": "^7946.0.7", diff --git a/package.json b/package.json index e4f087a2..81946c0e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.11.1", + "version": "17.11.2", "description": "json schemas for validations and generated ts models", "author": "", "license": "MIT", From 083aafd56dfd2d925db13c68e594a7eed6cff35e Mon Sep 17 00:00:00 2001 From: vitaligi <54726763+vitaligi@users.noreply.github.com> Date: Mon, 25 Nov 2024 17:36:55 +0200 Subject: [PATCH 15/24] fix: remove description (#237) --- src/yaml/ingestionTrigger/partData/rasterLayerPartData.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/yaml/ingestionTrigger/partData/rasterLayerPartData.yaml b/src/yaml/ingestionTrigger/partData/rasterLayerPartData.yaml index 20c0c32d..149f5044 100644 --- a/src/yaml/ingestionTrigger/partData/rasterLayerPartData.yaml +++ b/src/yaml/ingestionTrigger/partData/rasterLayerPartData.yaml @@ -83,4 +83,3 @@ components: type: string footprint: $ref: '../../geojson.yaml#/components/schemas/Polygon' - description: Part polygonal footprint From ba608ec6bf850c71f1f724f8c53385861092358f Mon Sep 17 00:00:00 2001 From: vitaligi <54726763+vitaligi@users.noreply.github.com> Date: Mon, 25 Nov 2024 17:37:18 +0200 Subject: [PATCH 16/24] chore(release): 17.11.3 --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4c91d2d..9b998450 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [17.11.3](https://github.com/MapColonies/mc-models/compare/v17.11.2...v17.11.3) (2024-11-25) + + +### Bug Fixes + +* remove description ([#237](https://github.com/MapColonies/mc-models/issues/237)) ([083aafd](https://github.com/MapColonies/mc-models/commit/083aafd56dfd2d925db13c68e594a7eed6cff35e)) + ### [17.11.2](https://github.com/MapColonies/mc-models/compare/v17.11.1...v17.11.2) (2024-11-25) ### [17.11.1](https://github.com/MapColonies/mc-models/compare/v17.11.0...v17.11.1) (2024-11-25) diff --git a/package-lock.json b/package-lock.json index c6b9c406..df01694a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.11.2", + "version": "17.11.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@map-colonies/mc-model-types", - "version": "17.11.2", + "version": "17.11.3", "license": "MIT", "dependencies": { "@types/geojson": "^7946.0.7", diff --git a/package.json b/package.json index 81946c0e..eb92e2ef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.11.2", + "version": "17.11.3", "description": "json schemas for validations and generated ts models", "author": "", "license": "MIT", From c9f8a6435cd6e86add2108b01f596669814a5ff1 Mon Sep 17 00:00:00 2001 From: vitaligi <54726763+vitaligi@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:51:34 +0200 Subject: [PATCH 17/24] feat: aggregation validation (#238) * refactor: additional regex patterns and organize props alphabetically * refactor: use validation pattern * feat: aggregation zod schema * refactor: add time validation between begin, end and current timestamp * fix: openapi sensor regex pattern * fix: file name pattern validation * style: remove extra spaces * refactor: improve error messages * refactor: removed prefix of each error message * refactor: error messages for part data zod schema --- src/models/raster/constants.ts | 26 ++++-- .../aggregationLayerMetadata.schema.ts | 92 +++++++++++++++++++ .../raster/ingestion/zod/schemas/index.ts | 3 +- .../ingestion/zod/schemas/partData.schema.ts | 75 +++++++++++---- .../inputFiles/rasterLayerInputFiles.yaml | 2 +- .../partData/rasterLayerPartData.yaml | 2 +- 6 files changed, 168 insertions(+), 32 deletions(-) create mode 100644 src/models/raster/ingestion/zod/schemas/aggregationLayerMetadata.schema.ts diff --git a/src/models/raster/constants.ts b/src/models/raster/constants.ts index 5e0e203f..bf8c7bf4 100644 --- a/src/models/raster/constants.ts +++ b/src/models/raster/constants.ts @@ -2,13 +2,14 @@ import { zoomLevelToResolutionDeg, zoomLevelToResolutionMeter } from '@map-colonies/mc-utils'; export const VALIDATIONS = { - resolutionMeter: { - min: zoomLevelToResolutionMeter(22), - max: zoomLevelToResolutionMeter(0), + boundingBox: { + pattern: '^-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?$', }, - resolutionDeg: { - min: zoomLevelToResolutionDeg(22), - max: zoomLevelToResolutionDeg(0), + classification: { + pattern: '^[0-9]$|^[1-9][0-9]$|^(100)$', + }, + fileNames: { + pattern: '^.+\\.[Gg][Pp][Kk][Gg]$', }, horizontalAccuracyCE90: { min: 0.01, @@ -20,14 +21,19 @@ export const VALIDATIONS = { productVersion: { pattern: '^[1-9]\\d*(\\.(0|[1-9]\\d?))?$', }, - classification: { - pattern: '^[0-9]$|^[1-9][0-9]$|^(100)$', + resolutionDeg: { + min: zoomLevelToResolutionDeg(22), + max: zoomLevelToResolutionDeg(0), + }, + resolutionMeter: { + min: zoomLevelToResolutionMeter(22), + max: zoomLevelToResolutionMeter(0), }, scale: { min: 0, max: 100000000, }, - fileNames: { - pattern: '^.+.[Gg][Pp][Kk][Gg]$', + sensor: { + pattern: '^(?!\\s).+(?<!\\s)$', }, }; diff --git a/src/models/raster/ingestion/zod/schemas/aggregationLayerMetadata.schema.ts b/src/models/raster/ingestion/zod/schemas/aggregationLayerMetadata.schema.ts new file mode 100644 index 00000000..42a14a3c --- /dev/null +++ b/src/models/raster/ingestion/zod/schemas/aggregationLayerMetadata.schema.ts @@ -0,0 +1,92 @@ +import type { MultiPolygon, Polygon } from 'geojson'; +import { z, type ZodType } from 'zod'; +import type { AggregationLayerMetadata } from '../../../../polygonParts/aggregationLayerMetadata'; +import { VALIDATIONS } from '../../../constants'; + +export const aggregationLayerMetadataSchema: ZodType<AggregationLayerMetadata> = z + .object( + { + footprint: z.custom<Polygon | MultiPolygon>(), + imagingTimeBeginUTC: z.coerce.date({ message: 'Imaging time begin UTC should be a datetime' }), + imagingTimeEndUTC: z.coerce.date({ message: 'Imaging time end UTC should be a datetime' }), + maxHorizontalAccuracyCE90: z + .number({ message: 'Max horizontal accuracy CE90 should be a number' }) + .min(VALIDATIONS.horizontalAccuracyCE90.min, { + message: `Max horizontal accuracy CE90 should not be less than ${VALIDATIONS.horizontalAccuracyCE90.min}`, + }) + .max(VALIDATIONS.horizontalAccuracyCE90.max, { + message: `Max horizontal accuracy CE90 should not be larger than ${VALIDATIONS.horizontalAccuracyCE90.max}`, + }), + maxResolutionDeg: z + .number({ message: 'Max resolution degree should be a number' }) + .min(VALIDATIONS.resolutionDeg.min as number, { + message: `Max resolution degree should not be less than ${VALIDATIONS.resolutionDeg.min as number}`, + }) + .max(VALIDATIONS.resolutionDeg.max as number, { + message: `Max resolution degree should not be larger than ${VALIDATIONS.resolutionDeg.max as number}`, + }), + maxResolutionMeter: z + .number({ message: 'Max resolution meter should be a number' }) + .min(VALIDATIONS.resolutionMeter.min as number, { + message: `Max resolution meter should not be less than ${VALIDATIONS.resolutionMeter.min as number}`, + }) + .max(VALIDATIONS.resolutionMeter.max as number, { + message: `Max resolution meter should not be larger than ${VALIDATIONS.resolutionMeter.max as number}`, + }), + minHorizontalAccuracyCE90: z + .number({ message: 'Min horizontal accuracy CE90 should be a number' }) + .min(VALIDATIONS.horizontalAccuracyCE90.min, { + message: `Min horizontal accuracy CE90 should not be less than ${VALIDATIONS.horizontalAccuracyCE90.min}`, + }) + .max(VALIDATIONS.horizontalAccuracyCE90.max, { + message: `Min horizontal accuracy CE90 should not be larger than ${VALIDATIONS.horizontalAccuracyCE90.max}`, + }), + minResolutionDeg: z + .number({ message: 'Min resolution degree should be a number' }) + .min(VALIDATIONS.resolutionDeg.min as number, { + message: `Min resolution degree should not be less than ${VALIDATIONS.resolutionDeg.min as number}`, + }) + .max(VALIDATIONS.resolutionDeg.max as number, { + message: `Min resolution degree should not be larger than ${VALIDATIONS.resolutionDeg.max as number}`, + }), + minResolutionMeter: z + .number({ message: 'Min resolution meter should be a number' }) + .min(VALIDATIONS.resolutionMeter.min as number, { + message: `Min resolution meter should not be less than ${VALIDATIONS.resolutionMeter.min as number}`, + }) + .max(VALIDATIONS.resolutionMeter.max as number, { + message: `Min resolution meter should not be larger than ${VALIDATIONS.resolutionMeter.max as number}`, + }), + productBoundingBox: z.string({ message: 'Product bounding box should be a string' }).regex(new RegExp(VALIDATIONS.boundingBox.pattern), { + message: 'Product bounding box must be of the shape min_x,min_y,max_x,max_y', + }), + sensors: z + .array( + z.string({ message: 'Sensors should be an array of strings' }).regex(new RegExp(VALIDATIONS.sensor.pattern), { + message: 'Sensors should be an array with items not starting or ending with whitespace characters', + }), + { message: 'Sensors should be an array' } + ) + .min(1, { message: 'Sensors should have an array length of at least 1' }), + }, + { message: 'Layer metadata should be an object' } + ) + .strict() + .refine( + (aggregationLayerMetadata) => + aggregationLayerMetadata.imagingTimeBeginUTC <= aggregationLayerMetadata.imagingTimeEndUTC && + aggregationLayerMetadata.imagingTimeEndUTC <= new Date(), + { + message: 'Imaging time begin UTC should be less than or equal to imaging time end UTC and both less than or equal to current timestamp', + } + ) + .refine((aggregationLayerMetadata) => aggregationLayerMetadata.minHorizontalAccuracyCE90 <= aggregationLayerMetadata.maxHorizontalAccuracyCE90, { + message: 'Min horizontal accuracy CE90 should be less than or equal to max horizontal accuracy CE90', + }) + .refine((aggregationLayerMetadata) => aggregationLayerMetadata.minResolutionDeg <= aggregationLayerMetadata.maxResolutionDeg, { + message: 'Min resolution degree should be less than or equal to max resolution degree', + }) + .refine((aggregationLayerMetadata) => aggregationLayerMetadata.minResolutionMeter <= aggregationLayerMetadata.maxResolutionMeter, { + message: 'Min resolution meter should be less than or equal to max resolution meter', + }) + .describe('aggregationLayerMetadataSchema'); diff --git a/src/models/raster/ingestion/zod/schemas/index.ts b/src/models/raster/ingestion/zod/schemas/index.ts index 33dc8103..f09d1692 100644 --- a/src/models/raster/ingestion/zod/schemas/index.ts +++ b/src/models/raster/ingestion/zod/schemas/index.ts @@ -1,3 +1,4 @@ -export * from './partData.schema'; +export * from './aggregationLayerMetadata.schema'; export * from './inputFiles.schema'; export * from './metadata.schema'; +export * from './partData.schema'; diff --git a/src/models/raster/ingestion/zod/schemas/partData.schema.ts b/src/models/raster/ingestion/zod/schemas/partData.schema.ts index 72325cf3..8bdc4bee 100644 --- a/src/models/raster/ingestion/zod/schemas/partData.schema.ts +++ b/src/models/raster/ingestion/zod/schemas/partData.schema.ts @@ -1,31 +1,68 @@ /* eslint-disable @typescript-eslint/no-magic-numbers */ +import type { Polygon } from 'geojson'; import { z } from 'zod'; -import { Polygon } from 'geojson'; import { VALIDATIONS } from '../../../constants'; export const partSchema = z .object({ - sourceId: z.string().optional(), - sourceName: z.string().min(1), - description: z.string().optional(), - imagingTimeBeginUTC: z.coerce.date(), - imagingTimeEndUTC: z.coerce.date(), + sourceId: z.string({ message: 'Source id should be a string' }).optional(), + sourceName: z.string({ message: 'Source name should be a string' }).min(1, { message: 'Source name should have length of at least 1' }), + description: z.string({ message: 'Description should be a string' }).optional(), + imagingTimeBeginUTC: z.coerce.date({ message: 'Imaging time begin UTC should be a datetime' }), + imagingTimeEndUTC: z.coerce.date({ message: 'Imaging time end UTC should be a datetime' }), resolutionDegree: z - .number() - .min(VALIDATIONS.resolutionDeg.min as number) - .max(VALIDATIONS.resolutionDeg.max as number), + .number({ message: 'Resolution degree should be a number' }) + .min(VALIDATIONS.resolutionDeg.min as number, { + message: `Resolution degree should not be less than ${VALIDATIONS.resolutionDeg.min as number}`, + }) + .max(VALIDATIONS.resolutionDeg.max as number, { + message: `Resolution degree should not be larger than ${VALIDATIONS.resolutionDeg.max as number}`, + }), resolutionMeter: z - .number() - .min(VALIDATIONS.resolutionMeter.min as number) - .max(VALIDATIONS.resolutionMeter.max as number), + .number({ message: 'Resolution meter should be a number' }) + .min(VALIDATIONS.resolutionMeter.min as number, { + message: `Resolution meter should not be less than ${VALIDATIONS.resolutionMeter.min as number}`, + }) + .max(VALIDATIONS.resolutionMeter.max as number, { + message: `Resolution meter should not be larger than ${VALIDATIONS.resolutionMeter.max as number}`, + }), sourceResolutionMeter: z - .number() - .min(VALIDATIONS.resolutionMeter.min as number) - .max(VALIDATIONS.resolutionMeter.max as number), - horizontalAccuracyCE90: z.number().min(VALIDATIONS.horizontalAccuracyCE90.min).max(VALIDATIONS.horizontalAccuracyCE90.max), - sensors: z.array(z.string().regex(new RegExp('^(?! ).+(?<! )$'))).min(1), - countries: z.array(z.string().min(1)).optional(), - cities: z.array(z.string().min(1)).optional(), + .number({ message: 'Source resolution meter should be a number' }) + .min(VALIDATIONS.resolutionMeter.min as number, { + message: `Source resolution meter should not be less than ${VALIDATIONS.resolutionMeter.min as number}`, + }) + .max(VALIDATIONS.resolutionMeter.max as number, { + message: `Source resolution meter should not be larger than ${VALIDATIONS.resolutionMeter.max as number}`, + }), + horizontalAccuracyCE90: z + .number({ message: 'Horizontal accuracy CE90 should be a number' }) + .min(VALIDATIONS.horizontalAccuracyCE90.min, { + message: `Horizontal accuracy CE90 should not be less than ${VALIDATIONS.horizontalAccuracyCE90.min}`, + }) + .max(VALIDATIONS.horizontalAccuracyCE90.max, { + message: `Horizontal accuracy CE90 should not be larger than ${VALIDATIONS.horizontalAccuracyCE90.max}`, + }), + sensors: z + .array( + z.string({ message: 'Sensors should be an array of strings' }).regex(new RegExp(VALIDATIONS.sensor.pattern), { + message: 'Sensors should be an array with items not starting or ending with whitespace characters', + }), + { message: 'Sensors should be an array' } + ) + .min(1, { message: 'Sensors should have an array length of at least 1' }), + countries: z + .array(z.string({ message: 'Countries should be an array of strings' }).min(1, { message: 'Countries should have length of at least 1' }), { + message: 'Countries should be an array', + }) + .optional(), + cities: z + .array(z.string({ message: 'Cities should be an array of strings' }).min(1, { message: 'Cities should have length of at least 1' }), { + message: 'Cities should be an array', + }) + .optional(), footprint: z.custom<Polygon>(), }) + .refine((part) => part.imagingTimeBeginUTC <= part.imagingTimeEndUTC && part.imagingTimeEndUTC <= new Date(), { + message: 'Imaging time begin UTC should be less than or equal to imaging time end UTC and both less than or equal to current timestamp', + }) .describe('partSchema'); diff --git a/src/yaml/ingestionTrigger/inputFiles/rasterLayerInputFiles.yaml b/src/yaml/ingestionTrigger/inputFiles/rasterLayerInputFiles.yaml index 127845b0..59a6a627 100644 --- a/src/yaml/ingestionTrigger/inputFiles/rasterLayerInputFiles.yaml +++ b/src/yaml/ingestionTrigger/inputFiles/rasterLayerInputFiles.yaml @@ -21,4 +21,4 @@ components: example: ['example.gpkg'] required: - originDirectory - - fileNames + - fileNames diff --git a/src/yaml/ingestionTrigger/partData/rasterLayerPartData.yaml b/src/yaml/ingestionTrigger/partData/rasterLayerPartData.yaml index 149f5044..6ab59bcb 100644 --- a/src/yaml/ingestionTrigger/partData/rasterLayerPartData.yaml +++ b/src/yaml/ingestionTrigger/partData/rasterLayerPartData.yaml @@ -66,7 +66,7 @@ components: type: array items: type: string - pattern: ^(?! ).+(?<! )$ + pattern: ^(?!\s).+(?<!\s)$ minItems: 1 description: Layer sensors list countries: From f7e23f301826ddcd61ded8ae8d69c293d7c62b30 Mon Sep 17 00:00:00 2001 From: vitaligi <54726763+vitaligi@users.noreply.github.com> Date: Tue, 26 Nov 2024 14:52:11 +0200 Subject: [PATCH 18/24] chore(release): 17.12.0 --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b998450..f6b76f56 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [17.12.0](https://github.com/MapColonies/mc-models/compare/v17.11.3...v17.12.0) (2024-11-26) + + +### Features + +* aggregation validation ([#238](https://github.com/MapColonies/mc-models/issues/238)) ([c9f8a64](https://github.com/MapColonies/mc-models/commit/c9f8a6435cd6e86add2108b01f596669814a5ff1)) + ### [17.11.3](https://github.com/MapColonies/mc-models/compare/v17.11.2...v17.11.3) (2024-11-25) diff --git a/package-lock.json b/package-lock.json index df01694a..ef5389ee 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.11.3", + "version": "17.12.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@map-colonies/mc-model-types", - "version": "17.11.3", + "version": "17.12.0", "license": "MIT", "dependencies": { "@types/geojson": "^7946.0.7", diff --git a/package.json b/package.json index eb92e2ef..8a80112e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.11.3", + "version": "17.12.0", "description": "json schemas for validations and generated ts models", "author": "", "license": "MIT", From 70691175af3b7b33b3de27ff37ad303b3bfa92a4 Mon Sep 17 00:00:00 2001 From: Ronit Kissis <92728393+RonitKissis@users.noreply.github.com> Date: Wed, 27 Nov 2024 16:19:46 +0200 Subject: [PATCH 19/24] fix: revert to old update request and add edit request (#239) * fix: revert to old update request and add edit request * fix: eof --- .../rasterCatalogUpsertRequest.ts | 2 +- src/yaml/editLayerMetadata.yaml | 48 ++++++++++ src/yaml/fullLayerMetadata.yaml | 95 ------------------- .../rasterCatalog/editMetadataRequest.yaml | 16 ++++ src/yaml/rasterCatalog/insertRequest.yaml | 4 - src/yaml/rasterCatalog/updateRequest.yaml | 4 + src/yaml/updateLayerMetadata.yaml | 72 +++++++++++++- 7 files changed, 139 insertions(+), 102 deletions(-) create mode 100644 src/yaml/editLayerMetadata.yaml create mode 100644 src/yaml/rasterCatalog/editMetadataRequest.yaml diff --git a/src/models/rasterCatalog/rasterCatalogUpsertRequest.ts b/src/models/rasterCatalog/rasterCatalogUpsertRequest.ts index a783d4f7..5a37ef22 100644 --- a/src/models/rasterCatalog/rasterCatalogUpsertRequest.ts +++ b/src/models/rasterCatalog/rasterCatalogUpsertRequest.ts @@ -10,6 +10,6 @@ export interface IRasterCatalogUpsertRequestBody { links?: Link[]; } -export interface IRasterCatalogUpdateRequestBody { +export interface IRasterCatalogEditRequestBody { metadata: UpdateLayerMetadata; } diff --git a/src/yaml/editLayerMetadata.yaml b/src/yaml/editLayerMetadata.yaml new file mode 100644 index 00000000..0c13ec53 --- /dev/null +++ b/src/yaml/editLayerMetadata.yaml @@ -0,0 +1,48 @@ +openapi: "3.0.1" +info: + title: Editable layer metadata fields + version: 2.0.0 +components: + schemas: + productType: + type: string + enum: + - Orthophoto + - OrthophotoHistory + - OrthophotoBest + - RasterMap + - RasterMapBest + - RasterAid + - RasterAidBest + - RasterVector + - RasterVectorBest + description: layer's type might be derived from the first letter + editLayerMetadata: + type: object + description: updatable layer metadata + properties: + classification: + type: string + description: Permitted roles + pattern: ^[0-9]$|^[1-9][0-9]$|^(100)$ + productName: + type: string + description: Layer's external name + productSubType: + type: string + description: Layer's sub type + description: + type: string + description: layer's description + producerName: + type: string + description: creator name default IDFMU + region: + type: array + items: + type: string + description: regions included in the layer + scale: + type: integer + minimum: 0 + maximum: 100000000 diff --git a/src/yaml/fullLayerMetadata.yaml b/src/yaml/fullLayerMetadata.yaml index 416d75f7..bcedf88e 100644 --- a/src/yaml/fullLayerMetadata.yaml +++ b/src/yaml/fullLayerMetadata.yaml @@ -50,98 +50,3 @@ components: maximum: 4000 format: double description: minimum Horizontal Accuracy - type: - type: string - description: Layer type raster / 3d / dem - enum: - - RECORD_RASTER - - RECORD_3D - classification: - type: string - description: Permitted roles - pattern: ^[0-9]$|^[1-9][0-9]$|^(100)$ - productId: - type: string - description: Layer's external identifier - pattern: ^[A-Za-z]{1}[A-Za-z0-9_]{0,37}$ - productName: - type: string - description: Layer's external name - productVersion: - type: string - pattern: ^[1-9]\d*(\.(0|[1-9]\d?))?$ - description: layer's version - productType: - $ref: './updateLayerMetadata.yaml#/components/schemas/productType' - productSubType: - type: string - description: Layer's sub type - description: - type: string - description: layer's description - srs: - type: string - description: geo system id - srsName: - type: string - description: geo system name - producerName: - type: string - description: creator name default IDFMU - creationDateUTC: - type: string - description: Creation date - format: date-time - ingestionDate: - type: string - description: Ingestion date - format: date-time - imagingTimeBeginUTC: - type: string - description: Oldest imaging date - format: date-time - imagingTimeEndUTC: - type: string - description: Latest imaging date - format: date-time - maxResolutionDeg: - type: number - minimum: 0.000000167638063430786 - maximum: 0.703125 - format: double - description: max resolution of layer in degrees/pixel - maxResolutionMeter: - type: number - minimum: 0.0185 - maximum: 78271.52 - format: double - description: max (rounded) resolution of layer in meters/pixel - minHorizontalAccuracyCE90: - type: number - minimum: 0.01 - maximum: 4000 - format: double - description: minimum Horizontal Accuracy - sensors: - type: array - items: - type: string - description: Layer sensors list - region: - type: array - items: - type: string - description: regions included in the layer - rms: - type: number - scale: - type: integer - minimum: 0 - maximum: 100000000 - footprint: - $ref: geojson.yaml#/components/schemas/Geometry - productBoundingBox: - type: string - pattern: "^-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?$" - - diff --git a/src/yaml/rasterCatalog/editMetadataRequest.yaml b/src/yaml/rasterCatalog/editMetadataRequest.yaml new file mode 100644 index 00000000..22997be1 --- /dev/null +++ b/src/yaml/rasterCatalog/editMetadataRequest.yaml @@ -0,0 +1,16 @@ +openapi: "3.0.1" +info: + title: raster catalog edit metadata request + version: 1.0.0 +components: + schemas: + EditMetadataRequest: + type: object + description: raster catalog edit request + properties: + metadata: + $ref: ../editLayerMetadata.yaml#/components/schemas/editLayerMetadata + + #due to bug in validator additional properties is not compilable with allof + #https://github.com/cdimascio/express-openapi-validator/issues/239 + #additionalProperties: false diff --git a/src/yaml/rasterCatalog/insertRequest.yaml b/src/yaml/rasterCatalog/insertRequest.yaml index 25637246..ab6aecd0 100644 --- a/src/yaml/rasterCatalog/insertRequest.yaml +++ b/src/yaml/rasterCatalog/insertRequest.yaml @@ -15,10 +15,6 @@ components: - properties: metadata: $ref: ../insertLayerMetadata.yaml#/components/schemas/insertLayerMetadata - links: - type: array - items: - $ref: ../link.yaml#/components/schemas/Link - properties: metadata: required: diff --git a/src/yaml/rasterCatalog/updateRequest.yaml b/src/yaml/rasterCatalog/updateRequest.yaml index 2c6dd3f9..1e249298 100644 --- a/src/yaml/rasterCatalog/updateRequest.yaml +++ b/src/yaml/rasterCatalog/updateRequest.yaml @@ -10,6 +10,10 @@ components: properties: metadata: $ref: ../updateLayerMetadata.yaml#/components/schemas/updateLayerMetadata + links: + type: array + items: + $ref: ../link.yaml#/components/schemas/Link #due to bug in validator additional properties is not compilable with allof #https://github.com/cdimascio/express-openapi-validator/issues/239 diff --git a/src/yaml/updateLayerMetadata.yaml b/src/yaml/updateLayerMetadata.yaml index e969b70a..42945550 100644 --- a/src/yaml/updateLayerMetadata.yaml +++ b/src/yaml/updateLayerMetadata.yaml @@ -19,34 +19,102 @@ components: description: layer's type might be derived from the first letter updateLayerMetadata: type: object - description: updatable layer metadata + description: layer meta data properties: + type: + type: string + description: Layer type raster / 3d / dem + enum: + - RECORD_RASTER + - RECORD_3D classification: type: string description: Permitted roles pattern: ^[0-9]$|^[1-9][0-9]$|^(100)$ + productId: + type: string + description: Layer's external identifier + pattern: ^[A-Za-z]{1}[A-Za-z0-9_]{0,37}$ productName: type: string description: Layer's external name + productVersion: + type: string + pattern: ^[1-9]\d*(\.(0|[1-9]\d?))?$ + description: layer's version + productType: + $ref: '#/components/schemas/productType' productSubType: type: string description: Layer's sub type description: type: string description: layer's description + srs: + type: string + description: geo system id + srsName: + type: string + description: geo system name producerName: type: string description: creator name default IDFMU + creationDateUTC: + type: string + description: Creation date + format: date-time + ingestionDate: + type: string + description: Ingestion date + format: date-time + imagingTimeBeginUTC: + type: string + description: Oldest imaging date + format: date-time + imagingTimeEndUTC: + type: string + description: Latest imaging date + format: date-time + maxResolutionDeg: + type: number + minimum: 0.000000167638063430786 + maximum: 0.703125 + format: double + description: max resolution of layer in degrees/pixel + maxResolutionMeter: + type: number + minimum: 0.0185 + maximum: 78271.52 + format: double + description: max (rounded) resolution of layer in meters/pixel + minHorizontalAccuracyCE90: + type: number + minimum: 0.01 + maximum: 4000 + format: double + description: minimum Horizontal Accuracy + sensors: + type: array + items: + type: string + description: Layer sensors list region: type: array items: type: string description: regions included in the layer + rms: + type: number scale: type: integer minimum: 0 maximum: 100000000 - + footprint: + $ref: geojson.yaml#/components/schemas/Geometry + productBoundingBox: + type: string + pattern: "^-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?$" + updateStatusLayerMetadata: type: object description: Metadata for layer status From 52fe838640b96a6e1c15b1fc5882745281ad8532 Mon Sep 17 00:00:00 2001 From: RonitKissis <ronitkisis1997@gmail.com> Date: Wed, 27 Nov 2024 16:20:23 +0200 Subject: [PATCH 20/24] chore(release): 17.12.1 --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f6b76f56..e6b870a7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [17.12.1](https://github.com/MapColonies/mc-models/compare/v17.12.0...v17.12.1) (2024-11-27) + + +### Bug Fixes + +* revert to old update request and add edit request ([#239](https://github.com/MapColonies/mc-models/issues/239)) ([7069117](https://github.com/MapColonies/mc-models/commit/70691175af3b7b33b3de27ff37ad303b3bfa92a4)) + ## [17.12.0](https://github.com/MapColonies/mc-models/compare/v17.11.3...v17.12.0) (2024-11-26) diff --git a/package-lock.json b/package-lock.json index ef5389ee..11c5f9ad 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.12.0", + "version": "17.12.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@map-colonies/mc-model-types", - "version": "17.12.0", + "version": "17.12.1", "license": "MIT", "dependencies": { "@types/geojson": "^7946.0.7", diff --git a/package.json b/package.json index 8a80112e..f40b2105 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.12.0", + "version": "17.12.1", "description": "json schemas for validations and generated ts models", "author": "", "license": "MIT", From 0370d8622d78808a983c185430745d646e2a0076 Mon Sep 17 00:00:00 2001 From: Ronit Kissis <92728393+RonitKissis@users.noreply.github.com> Date: Thu, 28 Nov 2024 10:59:34 +0200 Subject: [PATCH 21/24] fix: additional properties (#240) --- src/yaml/rasterCatalog/editMetadataRequest.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/yaml/rasterCatalog/editMetadataRequest.yaml b/src/yaml/rasterCatalog/editMetadataRequest.yaml index 22997be1..b8a82e6d 100644 --- a/src/yaml/rasterCatalog/editMetadataRequest.yaml +++ b/src/yaml/rasterCatalog/editMetadataRequest.yaml @@ -10,7 +10,4 @@ components: properties: metadata: $ref: ../editLayerMetadata.yaml#/components/schemas/editLayerMetadata - - #due to bug in validator additional properties is not compilable with allof - #https://github.com/cdimascio/express-openapi-validator/issues/239 - #additionalProperties: false + additionalProperties: false From da246eb72b3c761259e813f533182a555a2d2d57 Mon Sep 17 00:00:00 2001 From: RonitKissis <ronitkisis1997@gmail.com> Date: Thu, 28 Nov 2024 10:59:44 +0200 Subject: [PATCH 22/24] chore(release): 17.12.2 --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e6b870a7..7335c2c1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +### [17.12.2](https://github.com/MapColonies/mc-models/compare/v17.12.1...v17.12.2) (2024-11-28) + + +### Bug Fixes + +* additional properties ([#240](https://github.com/MapColonies/mc-models/issues/240)) ([0370d86](https://github.com/MapColonies/mc-models/commit/0370d8622d78808a983c185430745d646e2a0076)) + ### [17.12.1](https://github.com/MapColonies/mc-models/compare/v17.12.0...v17.12.1) (2024-11-27) diff --git a/package-lock.json b/package-lock.json index 11c5f9ad..ad796a6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.12.1", + "version": "17.12.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@map-colonies/mc-model-types", - "version": "17.12.1", + "version": "17.12.2", "license": "MIT", "dependencies": { "@types/geojson": "^7946.0.7", diff --git a/package.json b/package.json index f40b2105..b71d9aaa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.12.1", + "version": "17.12.2", "description": "json schemas for validations and generated ts models", "author": "", "license": "MIT", From e1f16217088403e7b749c175f786ad28c76bff6b Mon Sep 17 00:00:00 2001 From: almog8k <60139576+almog8k@users.noreply.github.com> Date: Thu, 28 Nov 2024 17:34:35 +0200 Subject: [PATCH 23/24] feat: adding polygon-parts table name type and valdiation (#241) * feat: adding polygon-parts table name type and valdiation * fix: naming adjustments * fix: naming adjustments * fix: naming adjustments * fix: order schemas by relevance * feat: tighten polygonPartsEntityName with rasterProductTypes * feat: ordernig files * fix: productType in lowercase * refactor: infer AggregationLayerMetadata from zod schema * fix: polygonPartsEntity to polygonPartsEntityName in zod schema * feat: new RasterProductTypes type+const --- .../polygonParts/aggregationLayerMetadata.ts | 27 ------ src/models/polygonParts/index.ts | 1 - src/models/polygonParts/polygonPartRecord.ts | 8 +- src/models/raster/constants.ts | 18 ++++ src/models/raster/index.ts | 1 + .../aggregationLayerMetadata.schema.ts | 92 ------------------ .../raster/ingestion/zod/schemas/index.ts | 3 +- .../ingestion/zod/schemas/metadata.schema.ts | 93 ++++++++++++++++++- ...tData.schema.ts => polygonParts.schema.ts} | 17 ++++ src/models/raster/types.ts | 3 + 10 files changed, 133 insertions(+), 130 deletions(-) delete mode 100644 src/models/polygonParts/aggregationLayerMetadata.ts delete mode 100644 src/models/raster/ingestion/zod/schemas/aggregationLayerMetadata.schema.ts rename src/models/raster/ingestion/zod/schemas/{partData.schema.ts => polygonParts.schema.ts} (84%) create mode 100644 src/models/raster/types.ts diff --git a/src/models/polygonParts/aggregationLayerMetadata.ts b/src/models/polygonParts/aggregationLayerMetadata.ts deleted file mode 100644 index 3d2504d9..00000000 --- a/src/models/polygonParts/aggregationLayerMetadata.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { GeoJSON, MultiPolygon, Polygon } from 'geojson'; -import type { IMetadataCommonModel } from '../layerMetadata/interfaces/metadataCommonModel'; -import type { ILayerMetadata } from '../layerMetadata/layerMetadata'; - -type NonNullableRecord<T extends Record<PropertyKey, unknown>> = { - [K in keyof T]-?: NonNullable<T[K]>; -}; - -type MakePolygonalRecord<T, P extends keyof T, Q = GeoJSON> = NonNullable<T[P]> extends Q ? Record<P, Polygon | MultiPolygon> : never; - -export interface AggregationLayerMetadata - extends NonNullableRecord< - Pick< - ILayerMetadata, - | 'imagingTimeBeginUTC' - | 'imagingTimeEndUTC' - | 'maxResolutionDeg' - | 'minResolutionDeg' - | 'maxResolutionMeter' - | 'minResolutionMeter' - | 'maxHorizontalAccuracyCE90' - | 'minHorizontalAccuracyCE90' - | 'productBoundingBox' - > - >, - NonNullableRecord<Pick<ILayerMetadata, 'sensors'>>, - MakePolygonalRecord<IMetadataCommonModel, 'footprint'> {} diff --git a/src/models/polygonParts/index.ts b/src/models/polygonParts/index.ts index b4c2d04e..cc8a4f5b 100644 --- a/src/models/polygonParts/index.ts +++ b/src/models/polygonParts/index.ts @@ -1,2 +1 @@ -export type { AggregationLayerMetadata } from './aggregationLayerMetadata'; export * from './polygonPartRecord'; diff --git a/src/models/polygonParts/polygonPartRecord.ts b/src/models/polygonParts/polygonPartRecord.ts index 1ce1aff7..0a9208d8 100644 --- a/src/models/polygonParts/polygonPartRecord.ts +++ b/src/models/polygonParts/polygonPartRecord.ts @@ -1,13 +1,7 @@ import { Polygon } from 'geojson'; import { keys } from 'ts-transformer-keys'; import { graphql } from '../common/decorators/graphQL/graphql.decorator'; -import { - FieldCategory, - IFieldConfigInfo, - IPropFieldConfigInfo, - fieldConfig, - getFieldConfig, -} from '../common/decorators/fieldConfig/fieldConfig.decorator'; +import { FieldCategory, IPropFieldConfigInfo, fieldConfig, getFieldConfig } from '../common/decorators/fieldConfig/fieldConfig.decorator'; import { DataFileType, IPropSHPMapping, getInputDataMapping, inputDataMapping } from '../layerMetadata/decorators/property/shp.decorator'; import { catalogDB, getCatalogDBMapping, ORMColumnType } from '../layerMetadata/decorators/property/catalogDB.decorator'; import { getTsTypesMapping, tsTypes, TsTypes } from '../layerMetadata/decorators/property/tsTypes.decorator'; diff --git a/src/models/raster/constants.ts b/src/models/raster/constants.ts index bf8c7bf4..1f07025e 100644 --- a/src/models/raster/constants.ts +++ b/src/models/raster/constants.ts @@ -1,6 +1,21 @@ +/* eslint-disable @typescript-eslint/naming-convention */ /* eslint-disable @typescript-eslint/no-magic-numbers */ import { zoomLevelToResolutionDeg, zoomLevelToResolutionMeter } from '@map-colonies/mc-utils'; +export const RasterProductTypes = { + Orthophoto: 'Orthophoto', + OrthophotoHistory: 'OrthophotoHistory', + OrthophotoBest: 'OrthophotoBest', + RasterMap: 'RasterMap', + RasterMapBest: 'RasterMapBest', + RasterAid: 'RasterAid', + RasterAidBest: 'RasterAidBest', + RasterVector: 'RasterVector', + RasterVectorBest: 'RasterVectorBest', +} as const; + +export const RASTER_PRODUCT_TYPES = Object.values(RasterProductTypes); + export const VALIDATIONS = { boundingBox: { pattern: '^-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?,-?(0|[1-9]\\d*)(\\.\\d*)?$', @@ -36,4 +51,7 @@ export const VALIDATIONS = { sensor: { pattern: '^(?!\\s).+(?<!\\s)$', }, + polygonPartsEntityName: { + pattern: '^[a-z][a-z0-9_]{0,61}[a-z0-9]$', + }, }; diff --git a/src/models/raster/index.ts b/src/models/raster/index.ts index c94f80f8..611bfcae 100644 --- a/src/models/raster/index.ts +++ b/src/models/raster/index.ts @@ -1 +1,2 @@ export * from './constants'; +export type { RasterProductTypes } from './types'; diff --git a/src/models/raster/ingestion/zod/schemas/aggregationLayerMetadata.schema.ts b/src/models/raster/ingestion/zod/schemas/aggregationLayerMetadata.schema.ts deleted file mode 100644 index 42a14a3c..00000000 --- a/src/models/raster/ingestion/zod/schemas/aggregationLayerMetadata.schema.ts +++ /dev/null @@ -1,92 +0,0 @@ -import type { MultiPolygon, Polygon } from 'geojson'; -import { z, type ZodType } from 'zod'; -import type { AggregationLayerMetadata } from '../../../../polygonParts/aggregationLayerMetadata'; -import { VALIDATIONS } from '../../../constants'; - -export const aggregationLayerMetadataSchema: ZodType<AggregationLayerMetadata> = z - .object( - { - footprint: z.custom<Polygon | MultiPolygon>(), - imagingTimeBeginUTC: z.coerce.date({ message: 'Imaging time begin UTC should be a datetime' }), - imagingTimeEndUTC: z.coerce.date({ message: 'Imaging time end UTC should be a datetime' }), - maxHorizontalAccuracyCE90: z - .number({ message: 'Max horizontal accuracy CE90 should be a number' }) - .min(VALIDATIONS.horizontalAccuracyCE90.min, { - message: `Max horizontal accuracy CE90 should not be less than ${VALIDATIONS.horizontalAccuracyCE90.min}`, - }) - .max(VALIDATIONS.horizontalAccuracyCE90.max, { - message: `Max horizontal accuracy CE90 should not be larger than ${VALIDATIONS.horizontalAccuracyCE90.max}`, - }), - maxResolutionDeg: z - .number({ message: 'Max resolution degree should be a number' }) - .min(VALIDATIONS.resolutionDeg.min as number, { - message: `Max resolution degree should not be less than ${VALIDATIONS.resolutionDeg.min as number}`, - }) - .max(VALIDATIONS.resolutionDeg.max as number, { - message: `Max resolution degree should not be larger than ${VALIDATIONS.resolutionDeg.max as number}`, - }), - maxResolutionMeter: z - .number({ message: 'Max resolution meter should be a number' }) - .min(VALIDATIONS.resolutionMeter.min as number, { - message: `Max resolution meter should not be less than ${VALIDATIONS.resolutionMeter.min as number}`, - }) - .max(VALIDATIONS.resolutionMeter.max as number, { - message: `Max resolution meter should not be larger than ${VALIDATIONS.resolutionMeter.max as number}`, - }), - minHorizontalAccuracyCE90: z - .number({ message: 'Min horizontal accuracy CE90 should be a number' }) - .min(VALIDATIONS.horizontalAccuracyCE90.min, { - message: `Min horizontal accuracy CE90 should not be less than ${VALIDATIONS.horizontalAccuracyCE90.min}`, - }) - .max(VALIDATIONS.horizontalAccuracyCE90.max, { - message: `Min horizontal accuracy CE90 should not be larger than ${VALIDATIONS.horizontalAccuracyCE90.max}`, - }), - minResolutionDeg: z - .number({ message: 'Min resolution degree should be a number' }) - .min(VALIDATIONS.resolutionDeg.min as number, { - message: `Min resolution degree should not be less than ${VALIDATIONS.resolutionDeg.min as number}`, - }) - .max(VALIDATIONS.resolutionDeg.max as number, { - message: `Min resolution degree should not be larger than ${VALIDATIONS.resolutionDeg.max as number}`, - }), - minResolutionMeter: z - .number({ message: 'Min resolution meter should be a number' }) - .min(VALIDATIONS.resolutionMeter.min as number, { - message: `Min resolution meter should not be less than ${VALIDATIONS.resolutionMeter.min as number}`, - }) - .max(VALIDATIONS.resolutionMeter.max as number, { - message: `Min resolution meter should not be larger than ${VALIDATIONS.resolutionMeter.max as number}`, - }), - productBoundingBox: z.string({ message: 'Product bounding box should be a string' }).regex(new RegExp(VALIDATIONS.boundingBox.pattern), { - message: 'Product bounding box must be of the shape min_x,min_y,max_x,max_y', - }), - sensors: z - .array( - z.string({ message: 'Sensors should be an array of strings' }).regex(new RegExp(VALIDATIONS.sensor.pattern), { - message: 'Sensors should be an array with items not starting or ending with whitespace characters', - }), - { message: 'Sensors should be an array' } - ) - .min(1, { message: 'Sensors should have an array length of at least 1' }), - }, - { message: 'Layer metadata should be an object' } - ) - .strict() - .refine( - (aggregationLayerMetadata) => - aggregationLayerMetadata.imagingTimeBeginUTC <= aggregationLayerMetadata.imagingTimeEndUTC && - aggregationLayerMetadata.imagingTimeEndUTC <= new Date(), - { - message: 'Imaging time begin UTC should be less than or equal to imaging time end UTC and both less than or equal to current timestamp', - } - ) - .refine((aggregationLayerMetadata) => aggregationLayerMetadata.minHorizontalAccuracyCE90 <= aggregationLayerMetadata.maxHorizontalAccuracyCE90, { - message: 'Min horizontal accuracy CE90 should be less than or equal to max horizontal accuracy CE90', - }) - .refine((aggregationLayerMetadata) => aggregationLayerMetadata.minResolutionDeg <= aggregationLayerMetadata.maxResolutionDeg, { - message: 'Min resolution degree should be less than or equal to max resolution degree', - }) - .refine((aggregationLayerMetadata) => aggregationLayerMetadata.minResolutionMeter <= aggregationLayerMetadata.maxResolutionMeter, { - message: 'Min resolution meter should be less than or equal to max resolution meter', - }) - .describe('aggregationLayerMetadataSchema'); diff --git a/src/models/raster/ingestion/zod/schemas/index.ts b/src/models/raster/ingestion/zod/schemas/index.ts index f09d1692..1144e23f 100644 --- a/src/models/raster/ingestion/zod/schemas/index.ts +++ b/src/models/raster/ingestion/zod/schemas/index.ts @@ -1,4 +1,3 @@ -export * from './aggregationLayerMetadata.schema'; export * from './inputFiles.schema'; export * from './metadata.schema'; -export * from './partData.schema'; +export * from './polygonParts.schema'; diff --git a/src/models/raster/ingestion/zod/schemas/metadata.schema.ts b/src/models/raster/ingestion/zod/schemas/metadata.schema.ts index 88945997..7f4dd035 100644 --- a/src/models/raster/ingestion/zod/schemas/metadata.schema.ts +++ b/src/models/raster/ingestion/zod/schemas/metadata.schema.ts @@ -1,5 +1,6 @@ /* eslint-disable @typescript-eslint/no-magic-numbers */ -import { z } from 'zod'; +import { z, ZodType } from 'zod'; +import { MultiPolygon, Polygon } from 'geojson'; import { VALIDATIONS } from '../../../constants'; import { ProductType, Transparency } from '../../../../layerMetadata/enums'; @@ -25,3 +26,93 @@ export const updateMetadataSchema = z classification: z.string().regex(new RegExp(VALIDATIONS.classification.pattern)), }) .describe('updateMetadataSchema'); + +export const aggregationMetadataSchema = z + .object( + { + footprint: z.custom<Polygon | MultiPolygon>(), + imagingTimeBeginUTC: z.coerce.date({ message: 'Imaging time begin UTC should be a datetime' }), + imagingTimeEndUTC: z.coerce.date({ message: 'Imaging time end UTC should be a datetime' }), + maxHorizontalAccuracyCE90: z + .number({ message: 'Max horizontal accuracy CE90 should be a number' }) + .min(VALIDATIONS.horizontalAccuracyCE90.min, { + message: `Max horizontal accuracy CE90 should not be less than ${VALIDATIONS.horizontalAccuracyCE90.min}`, + }) + .max(VALIDATIONS.horizontalAccuracyCE90.max, { + message: `Max horizontal accuracy CE90 should not be larger than ${VALIDATIONS.horizontalAccuracyCE90.max}`, + }), + maxResolutionDeg: z + .number({ message: 'Max resolution degree should be a number' }) + .min(VALIDATIONS.resolutionDeg.min as number, { + message: `Max resolution degree should not be less than ${VALIDATIONS.resolutionDeg.min as number}`, + }) + .max(VALIDATIONS.resolutionDeg.max as number, { + message: `Max resolution degree should not be larger than ${VALIDATIONS.resolutionDeg.max as number}`, + }), + maxResolutionMeter: z + .number({ message: 'Max resolution meter should be a number' }) + .min(VALIDATIONS.resolutionMeter.min as number, { + message: `Max resolution meter should not be less than ${VALIDATIONS.resolutionMeter.min as number}`, + }) + .max(VALIDATIONS.resolutionMeter.max as number, { + message: `Max resolution meter should not be larger than ${VALIDATIONS.resolutionMeter.max as number}`, + }), + minHorizontalAccuracyCE90: z + .number({ message: 'Min horizontal accuracy CE90 should be a number' }) + .min(VALIDATIONS.horizontalAccuracyCE90.min, { + message: `Min horizontal accuracy CE90 should not be less than ${VALIDATIONS.horizontalAccuracyCE90.min}`, + }) + .max(VALIDATIONS.horizontalAccuracyCE90.max, { + message: `Min horizontal accuracy CE90 should not be larger than ${VALIDATIONS.horizontalAccuracyCE90.max}`, + }), + minResolutionDeg: z + .number({ message: 'Min resolution degree should be a number' }) + .min(VALIDATIONS.resolutionDeg.min as number, { + message: `Min resolution degree should not be less than ${VALIDATIONS.resolutionDeg.min as number}`, + }) + .max(VALIDATIONS.resolutionDeg.max as number, { + message: `Min resolution degree should not be larger than ${VALIDATIONS.resolutionDeg.max as number}`, + }), + minResolutionMeter: z + .number({ message: 'Min resolution meter should be a number' }) + .min(VALIDATIONS.resolutionMeter.min as number, { + message: `Min resolution meter should not be less than ${VALIDATIONS.resolutionMeter.min as number}`, + }) + .max(VALIDATIONS.resolutionMeter.max as number, { + message: `Min resolution meter should not be larger than ${VALIDATIONS.resolutionMeter.max as number}`, + }), + productBoundingBox: z.string({ message: 'Product bounding box should be a string' }).regex(new RegExp(VALIDATIONS.boundingBox.pattern), { + message: 'Product bounding box must be of the shape min_x,min_y,max_x,max_y', + }), + sensors: z + .array( + z.string({ message: 'Sensors should be an array of strings' }).regex(new RegExp(VALIDATIONS.sensor.pattern), { + message: 'Sensors should be an array with items not starting or ending with whitespace characters', + }), + { message: 'Sensors should be an array' } + ) + .min(1, { message: 'Sensors should have an array length of at least 1' }), + }, + { message: 'Layer metadata should be an object' } + ) + .strict() + .refine( + (aggregationLayerMetadata) => + aggregationLayerMetadata.imagingTimeBeginUTC <= aggregationLayerMetadata.imagingTimeEndUTC && + aggregationLayerMetadata.imagingTimeEndUTC <= new Date(), + { + message: 'Imaging time begin UTC should be less than or equal to imaging time end UTC and both less than or equal to current timestamp', + } + ) + .refine((aggregationLayerMetadata) => aggregationLayerMetadata.minHorizontalAccuracyCE90 <= aggregationLayerMetadata.maxHorizontalAccuracyCE90, { + message: 'Min horizontal accuracy CE90 should be less than or equal to max horizontal accuracy CE90', + }) + .refine((aggregationLayerMetadata) => aggregationLayerMetadata.minResolutionDeg <= aggregationLayerMetadata.maxResolutionDeg, { + message: 'Min resolution degree should be less than or equal to max resolution degree', + }) + .refine((aggregationLayerMetadata) => aggregationLayerMetadata.minResolutionMeter <= aggregationLayerMetadata.maxResolutionMeter, { + message: 'Min resolution meter should be less than or equal to max resolution meter', + }) + .describe('aggregationLayerMetadataSchema'); + +export type AggregationLayerMetadata = z.infer<typeof aggregationMetadataSchema>; diff --git a/src/models/raster/ingestion/zod/schemas/partData.schema.ts b/src/models/raster/ingestion/zod/schemas/polygonParts.schema.ts similarity index 84% rename from src/models/raster/ingestion/zod/schemas/partData.schema.ts rename to src/models/raster/ingestion/zod/schemas/polygonParts.schema.ts index 8bdc4bee..e8ee0642 100644 --- a/src/models/raster/ingestion/zod/schemas/partData.schema.ts +++ b/src/models/raster/ingestion/zod/schemas/polygonParts.schema.ts @@ -2,6 +2,7 @@ import type { Polygon } from 'geojson'; import { z } from 'zod'; import { VALIDATIONS } from '../../../constants'; +import { RASTER_PRODUCT_TYPES } from '../../../constants'; export const partSchema = z .object({ @@ -66,3 +67,19 @@ export const partSchema = z message: 'Imaging time begin UTC should be less than or equal to imaging time end UTC and both less than or equal to current timestamp', }) .describe('partSchema'); + +export const polygonPartsEntityNameSchema = z + .object({ + polygonPartsEntityName: z + .string() + .regex(new RegExp(VALIDATIONS.polygonPartsEntityName.pattern), { message: 'Polygon parts entity name should valid entity name' }) + .refine( + (value) => { + return RASTER_PRODUCT_TYPES.some((type) => value.endsWith(type.toLowerCase())); + }, + { message: 'Polygon parts entity name should end with one of the valid raster product types' } + ), + }) + .describe('polygonPartsEntityNameSchema'); + +export type PolygonPartsEntityName = z.infer<typeof polygonPartsEntityNameSchema>; diff --git a/src/models/raster/types.ts b/src/models/raster/types.ts new file mode 100644 index 00000000..f3905aa7 --- /dev/null +++ b/src/models/raster/types.ts @@ -0,0 +1,3 @@ +import { RasterProductTypes } from './constants'; + +export type RasterProductTypes = (typeof RasterProductTypes)[keyof typeof RasterProductTypes]; From b2d1bdcc620e9c741647db861fff3f5e83ed85d9 Mon Sep 17 00:00:00 2001 From: almog8k <almog8k@gmail.com> Date: Thu, 28 Nov 2024 17:35:02 +0200 Subject: [PATCH 24/24] chore(release): 17.13.0 --- CHANGELOG.md | 7 +++++++ package-lock.json | 4 ++-- package.json | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7335c2c1..dcc667e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines. +## [17.13.0](https://github.com/MapColonies/mc-models/compare/v17.12.2...v17.13.0) (2024-11-28) + + +### Features + +* adding polygon-parts table name type and valdiation ([#241](https://github.com/MapColonies/mc-models/issues/241)) ([e1f1621](https://github.com/MapColonies/mc-models/commit/e1f16217088403e7b749c175f786ad28c76bff6b)) + ### [17.12.2](https://github.com/MapColonies/mc-models/compare/v17.12.1...v17.12.2) (2024-11-28) diff --git a/package-lock.json b/package-lock.json index ad796a6e..5c0b7853 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.12.2", + "version": "17.13.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@map-colonies/mc-model-types", - "version": "17.12.2", + "version": "17.13.0", "license": "MIT", "dependencies": { "@types/geojson": "^7946.0.7", diff --git a/package.json b/package.json index b71d9aaa..d5b0ac45 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@map-colonies/mc-model-types", - "version": "17.12.2", + "version": "17.13.0", "description": "json schemas for validations and generated ts models", "author": "", "license": "MIT",