From b1b284ec370de620e8cb3df98f4ce98ecd8cbb5b Mon Sep 17 00:00:00 2001 From: Justin Walgran Date: Mon, 8 May 2023 10:33:13 -0700 Subject: [PATCH 1/2] Use the type field to determine if ingest is collection or item The `type` field is required in STAC API 1.0.0 and using that field is preferable to a heuristic based on other field values. Connects #486 --- CHANGELOG.md | 1 + src/lib/ingest.js | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6c68e4ee..53289122 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - Remove node streams-based ingest code to prepare for post-ingest notifications +- Use the type field to determin if ingest is collection or item ## [1.1.0] - 2023-05-02 diff --git a/src/lib/ingest.js b/src/lib/ingest.js index 224f6f63..16f08dc0 100644 --- a/src/lib/ingest.js +++ b/src/lib/ingest.js @@ -6,13 +6,13 @@ const COLLECTIONS_INDEX = process.env['COLLECTIONS_INDEX'] || 'collections' export async function convertIngestObjectToDbObject( // eslint-disable-next-line max-len - /** @type {{ hasOwnProperty: (arg0: string) => any; collection: string; links: any[]; id: any; }} */ data + /** @type {{ hasOwnProperty: (arg0: string) => any; type: string, collection: string; links: any[]; id: any; }} */ data ) { let index = '' logger.debug('data', data) - if (data && data.hasOwnProperty('extent')) { + if (data && data.type === 'Collection') { index = COLLECTIONS_INDEX - } else if (data && data.hasOwnProperty('geometry')) { + } else if (data && data.type === 'Feature') { index = data.collection } else { return null From 0f625edb71beceb3cf55392cd1b5119b8c62854c Mon Sep 17 00:00:00 2001 From: Justin Walgran Date: Mon, 8 May 2023 10:59:56 -0700 Subject: [PATCH 2/2] Update CHANGELOG.md Co-authored-by: Phil Varner --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 53289122..5d94eea6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ### Changed - Remove node streams-based ingest code to prepare for post-ingest notifications -- Use the type field to determin if ingest is collection or item +- Use the `type` field to determine if ingest is a Collection or Item ## [1.1.0] - 2023-05-02