diff --git a/package-lock.json b/package-lock.json index 643962e7..fc87ca79 100644 --- a/package-lock.json +++ b/package-lock.json @@ -39,6 +39,7 @@ "@types/cookie-parser": "^1.4.3", "@types/cors": "^2.8.12", "@types/express": "^4.17.14", + "@types/lodash": "^4.17.7", "@types/mocha": "^10.0.0", "@types/morgan": "^1.9.3", "@types/node": "^18.11.9", @@ -3234,9 +3235,9 @@ } }, "node_modules/@types/lodash": { - "version": "4.14.191", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.191.tgz", - "integrity": "sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==", + "version": "4.17.7", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.7.tgz", + "integrity": "sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==", "dev": true }, "node_modules/@types/mime": { @@ -15984,9 +15985,9 @@ } }, "@types/lodash": { - "version": "4.14.191", - "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.14.191.tgz", - "integrity": "sha512-BdZ5BCCvho3EIXw6wUCXHe7rS53AIDPLE+JzwgT+OsJk53oBfbSmZZ7CX4VaRoN78N+TJpFi9QPlfIVNmJYWxQ==", + "version": "4.17.7", + "resolved": "https://registry.npmjs.org/@types/lodash/-/lodash-4.17.7.tgz", + "integrity": "sha512-8wTvZawATi/lsmNu10/j2hk1KEP0IvjubqPE3cu1Xz7xfXXt5oCq3SNUz4fMIP4XGF9Ky+Ue2tBA3hcS7LSBlA==", "dev": true }, "@types/mime": { diff --git a/package.json b/package.json index 865204ee..1338e255 100644 --- a/package.json +++ b/package.json @@ -28,6 +28,7 @@ "@types/cookie-parser": "^1.4.3", "@types/cors": "^2.8.12", "@types/express": "^4.17.14", + "@types/lodash": "^4.17.7", "@types/mocha": "^10.0.0", "@types/morgan": "^1.9.3", "@types/node": "^18.11.9", diff --git a/src/domains/__tests__/items.spec.ts b/src/domains/__tests__/items.spec.ts index c8ac8622..178e00b1 100644 --- a/src/domains/__tests__/items.spec.ts +++ b/src/domains/__tests__/items.spec.ts @@ -22,7 +22,7 @@ describe("granuleToStac", () => { type: "Feature", id: baseGranule.title, stac_version: "1.0.0", - stac_extensions: [], + stac_extensions: ["https://stac-extensions.github.io/cmr/v0.0.0/schema.json"], geometry: { type: "Polygon", coordinates: [ @@ -37,6 +37,9 @@ describe("granuleToStac", () => { }, bbox: [-26.1081458, 29.8680955, -11.4859874, 40.0118589], properties: { + "cmr:collection_id": "C123456789-TEST_PROV", + "cmr:concept_id": "G000000000-TEST_PROV", + "cmr:provider": "TEST_PROV", datetime: "2009-09-14T00:00:00.000Z", start_datetime: "2009-09-14T00:00:00.000Z", end_datetime: "2010-09-14T00:00:00.000Z", @@ -110,7 +113,7 @@ describe("granuleToStac", () => { type: "Feature", id: baseGranule.title, stac_version: "1.0.0", - stac_extensions: [], + stac_extensions: ["https://stac-extensions.github.io/cmr/v0.0.0/schema.json"], geometry: { type: "Polygon", coordinates: [ @@ -125,6 +128,9 @@ describe("granuleToStac", () => { }, bbox: [-180, -60, 170, 50], properties: { + "cmr:collection_id": "C123456789-TEST_PROV", + "cmr:concept_id": "G000000000-TEST_PROV", + "cmr:provider": "TEST_PROV", datetime: "2009-09-14T00:00:00.000Z", start_datetime: "2009-09-14T00:00:00.000Z", end_datetime: "2010-09-14T00:00:00.000Z", @@ -197,7 +203,7 @@ describe("granuleToStac", () => { type: "Feature", id: baseGranule.title, stac_version: "1.0.0", - stac_extensions: [], + stac_extensions: ["https://stac-extensions.github.io/cmr/v0.0.0/schema.json"], geometry: { type: "LineString", coordinates: [ @@ -208,6 +214,9 @@ describe("granuleToStac", () => { }, bbox: [-42.915595, 60.477742, 11.618598, 65.941741], properties: { + "cmr:collection_id": "C123456789-TEST_PROV", + "cmr:concept_id": "G000000000-TEST_PROV", + "cmr:provider": "TEST_PROV", datetime: "2009-09-14T00:00:00.000Z", start_datetime: "2009-09-14T00:00:00.000Z", end_datetime: "2010-09-14T00:00:00.000Z", diff --git a/src/domains/items.ts b/src/domains/items.ts index 4132ba6b..7fd00214 100644 --- a/src/domains/items.ts +++ b/src/domains/items.ts @@ -71,6 +71,20 @@ const cloudCoverExtension = (granule: Granule) => { }; }; +/** + * Return the CMR extension schema and properties for a granule. + */ +const cmrGranuleExtension = (granule: Granule) => { + return { + extension: "https://stac-extensions.github.io/cmr/v0.0.0/schema.json", + properties: { + "cmr:provider": granule.collection?.conceptId.split("-")[1], + "cmr:collection_id": granule.collection?.conceptId, + "cmr:concept_id": granule.conceptId, + }, + }; +}; + /** * Returns the self-links for a STACItem. * @@ -166,6 +180,7 @@ export const granuleToStac = (granule: Granule): STACItem => { const { extensions, properties: extensionProperties } = deriveExtensions(granule, [ cloudCoverExtension, + cmrGranuleExtension, ]); const properties: { [key: string]: string } = mergeMaybe(