Skip to content

refactor: define every metadata field once and build the schemas from named groups (MAPCO-11579) - #41

Open
lirantul123 wants to merge 7 commits into
masterfrom
schema-fields-single-source
Open

lirantul123 wants to merge 7 commits into
masterfrom
schema-fields-single-source

Conversation

@lirantul123

@lirantul123 lirantul123 commented Dec 3, 2026 •

Copy link
Copy Markdown
Collaborator

Why

The same field was defined in up to four places (core/product.schema.ts, catalog/fields.schema.ts, ingestion/common.schema.ts, and twice inside shapeMetadata.schema.ts: once to validate the column and once to rename it). Composite schemas were chains of omit / extend / innerType. The copies had already drifted: the ShapeMetadata limited SEP90 to 250 (absolute) and 100 (relative), while the catalog allowed 999, which is what the CSW page says.

What

One metadata file. schemas/core/metadata.schema.ts defines every field once (validation, limit from INGESTION_VALIDATIONS, message, description, openapi example) and groups them by where they come from:

Group Source
payloadFields the ingestion request
productShapefileFields Product.shp (footprint)
shapeMetadataProductFields ShapeMetadata, same in every row
partsSummaryFields ShapeMetadata, per part, summarized into the record
partFields ShapeMetadata, per part only (parts table)
catalogFields filled by the catalog

Composites are spreads: shapeMetadataFields, jobRecordMetadataFields, catalogRecordResponseFields.

ingestion3DPayloadSchema    = z.object({ modelPath, productShapefilePath, metadataShapefilePath, ...payloadFields })
jobRecordMetadataSchema     = z.object(jobRecordMetadataFields).strict().superRefine(refineRecordRanges)
catalogRecordResponseSchema = z.object(catalogRecordResponseFields).strict().superRefine(refineRecordRanges)

ShapeMetadata from one column map. SHAPE_METADATA_COLUMNS maps each field to its column and cell type (text / number / list / date). The row schema is built from that map and shapeMetadataFields; the compiler fails if a group field has no column or a column has no field. Errors are still reported by column name (minResM must not be greater than maxResM), the same texts as before.

pickFields(source, group) copies a group out of an object, so consumers stop re-listing fields (the trigger builds the job record metadata with it).

File names follow raster-shared: job.schema.ts, task.schema.ts, payload.schema.ts, *.type.ts; the ingestion constants and messages are one constants.ts.

Removed: core/product.schema.ts, ingestion/common.schema.ts, catalog/fields.schema.ts, the unused ingestion3DDeleteJobParamsSchema alias, the commented-out code, and the identity map SHAPE_METADATA_FIELDS (replaced by SHAPE_METADATA_COLUMNS).

Behavior changes

Aligned with the Confluence pages (3D Record CSW Data, 3D Record Parts WFS Data, v1 vs v2 Comparison); where the Parts page disagrees, the CSW page wins.

  • Client fields: productName, srsId, srsName and producerName move to the ingestion payload ("Inserted by client"); productName max 50.
  • classification: required text, a lookup-tables code (was letters and digits only). Codes can be numbers or Hebrew; the consumer checks them against the lookup table, as 3d-gateway and store-trigger do.
  • Ranges: every accuracy, SEP90 included, is 0–999; description has no length limit; footprint coordinates must be within lon -180..180 and lat -90..90.
  • productionDate is per part (the Parts page stores it per part); the record takes the latest one through the parts summary.
  • maxAbsoluteAccuracyCEP90 stays a product field from the ShapeMetadata ("From product (the shapeMetadata)"); the other accuracies are summarized over the parts.
  • ShapeMetadata row: keeps prodName and producer for the parts table, no longer reads srsId, srsName or desc (not on the Parts page).
  • The row returns imagingTimeBeginUTC / imagingTimeEndUTC as ISO strings, like every other date.
  • "imaging end must not be in the future" now applies to the record too.

Tests: 435 pass; tsc, eslint and build are clean. Checked against #40 merged on top: 449 pass, and the trigger (193) and the workers pass against that build.

…amed groups (MAPCO-11579)

fields/fields.schema.ts holds each field rule once; fields/groups.schema.ts names where the
fields come from (payload, product shapefile, metadata shapefile, catalog). The payload, the job
record metadata and the catalog response are spreads of those groups, and the ShapeMetadata row
pipes each column into the same field rule. SEP90 limits now match the ShapeMetadata (250/100).
@github-actions

github-actions Bot commented Dec 3, 2026 •

Copy link
Copy Markdown

🎫 Related Jira Issue: MAPCO-11579

…nies file names (MAPCO-11579)

core/metadata.schema.ts holds every field and the groups (payload, product shapefile,
ShapeMetadata product, parts summary, part, catalog). The ShapeMetadata row is built from
SHAPE_METADATA_COLUMNS and the groups, returns ISO dates, and reports errors by column name.
Files follow raster-shared: job/task/payload .schema.ts and *.type.ts; ingestion constants
are merged into constants.ts. pickFields copies a group from an object.
@lirantul123 lirantul123 changed the title refactor: define every record field once and build the schemas from named groups (MAPCO-11579) refactor: define every metadata field once and build the schemas from named groups (MAPCO-11579) Dec 3, 2026
…1579)

productName, srsId, srsName and producerName are client fields (payload); productName max 50.
classification is Unclassified/Restricted/Confidential/Secret. productType adds 3DPointCloudBest.
SEP90 accuracies are 0-999 like the other accuracies; description has no limit.
Footprint coordinates must be within lon -180..180 and lat -90..90.
The ShapeMetadata row drops srsId, srsName and desc, which the parts table does not store.
…es in place (MAPCO-11579)

No *Rule constants; range errors no longer name another field, so the ShapeMetadata errors
need no text rewriting; the v1 record type file is metadataV1.type.ts, apart from the v2
metadata schema.
…CO-11579)

The lookup-tables value is a code and the UI shows its translation, as in 3d-gateway and
store-trigger, so classification is required text checked against the lookup table.
3DPointCloudBest is not in @map-colonies/types, so it is not accepted.
@@ -25,7 +31,6 @@ components:
description:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check what the product is the limit

example: sample, city
classification:
type: string
pattern: ^[a-zA-Z0-9]+$

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As raster

srsId:
type: string
minLength: 1
maxLength: 120

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Revert

format: date-time
description: Newest imaging date of the parts
example: 2025-02-01T00:00:00.000Z
minResolutionMeter:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep the order

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants