Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
a6b1374
feat: add filter extension to conformance
pjhartzell Jan 7, 2025
fb1a000
feat: add cql2 filter extension for POST
pjhartzell Jan 10, 2025
94f6278
fix: remove commented code, get rid of .only in tes
pjhartzell Jan 10, 2025
7306a12
feat: cql2 filter extension for GET
pjhartzell Jan 11, 2025
41ecbf9
fix: use fully qualified property names
pjhartzell Jan 11, 2025
0237061
test: remove redundant test
pjhartzell Jan 12, 2025
9970b68
build: 'npm audit fix' to get CI passing
pjhartzell Jan 13, 2025
647a0a2
feat: check for correct filter-lang and filter-crs
pjhartzell Jan 13, 2025
69d2c3d
feat: Add filter extension to aggregate endpoint
pjhartzell Jan 13, 2025
6cace3a
docs: update CHANGELOG
pjhartzell Jan 14, 2025
5697cf0
test: add test for top level field and property in filter extension f…
pjhartzell Jan 14, 2025
285c994
review: move constants out of function
pjhartzell Jan 14, 2025
80243d4
review: stacQlQuery -> stacqlQuery
pjhartzell Jan 14, 2025
9388cab
review: buildQuery -> buildOpenSearchQuery
pjhartzell Jan 14, 2025
f95a102
review: Add minimum_should_match = 1 for 'should' clauses
pjhartzell Jan 14, 2025
cf61e72
fix: remove .only from test, update a test comment
pjhartzell Jan 16, 2025
dcbf37d
review: remove explicit prefixing of properties object fields
pjhartzell Jan 16, 2025
297d10b
feat: raise error when collection queryables has additionalProperties…
pjhartzell Jan 16, 2025
21cd5a4
style: align existing test format
pjhartzell Jan 16, 2025
b53f3d6
feat: add query and filter extensions to openapi.yaml
pjhartzell Jan 17, 2025
2eb8de1
docs: update README.md
pjhartzell Jan 18, 2025
48e507d
fix: finish adding filters extension to the OpenAPI spec
pjhartzell Jan 19, 2025
a948319
fix: minor changes to query extension in openapi.yaml
pjhartzell Jan 19, 2025
b5b16c6
docs: augument CHANGELOG entry, tweak extension list in README
pjhartzell Jan 19, 2025
74c3d14
review: remove bbox from UNPREFIXED_FIELDS
pjhartzell Jan 23, 2025
dafa26d
review: clarify that fields **must not** be prefixed
pjhartzell Jan 23, 2025
25ee9d3
review: add deprecated note to Context Extension
pjhartzell Jan 23, 2025
b3a8f78
review: Add note about filter expression terms exactly matching Item …
pjhartzell Jan 23, 2025
adc6110
review: add back bbox and note that bbox and geometry are not yet sup…
pjhartzell Jan 23, 2025
5d81274
review: add back bbox
pjhartzell Jan 23, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1017,13 +1017,25 @@ const getGlobalQueryables = async (endpoint = '') => ({
additionalProperties: true
})

const validateAdditionalProperties = (queryables) => {
if ('additionalProperties' in queryables) {
const additionalProperties = queryables.additionalProperties
if (additionalProperties !== true) {
throw new ValidationError(
`Unsupported additionalProperties value: "${additionalProperties}". Must be set to "true".`
)
}
}
}

const getCollectionQueryables = async (collectionId, backend, endpoint = '') => {
const collection = await backend.getCollection(collectionId)

if (collection instanceof Error) {
return collection
}
const queryables = collection.queryables || { ...DEFAULT_QUERYABLES }
validateAdditionalProperties(queryables)
queryables.$id = `${endpoint}/collections/${collectionId}/queryables`
queryables.title = `Queryables for Collection ${collectionId}`
return queryables
Expand Down
41 changes: 41 additions & 0 deletions tests/fixtures/stac/collection-with-incorrect-queryables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"id": "landsat-8-l1-incorrect-queryables",
"type": "Collection",
"stac_version": "1.0.0",
"description": "Landat-8 L1 Collection-1 imagery radiometrically calibrated and orthorectified using gound points and Digital Elevation Model (DEM) data to correct relief displacement.",
"links": [],
"stac_extensions": [],
"title": "Landsat-8 L1 Collection-1",
"extent": {
"spatial": {
"bbox": [
[
-180,
-90,
180,
90
]
]
},
"temporal": {
"interval": [
[
"2013-06-01T00:00:00Z",
null
]
]
}
},
"queryables": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "",
"type": "object",
"title": "",
"properties": {
"eo:cloud_cover": {
"$ref": "https://stac-extensions.github.io/eo/v1.0.0/schema.json#/definitions/fields/properties/eo:cloud_cover"
}
},
"additionalProperties": false
}
}
24 changes: 24 additions & 0 deletions tests/system/test-api-get-collection-queryables.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,27 @@ test('GET /collection/:collectionId/queryables for non-existent collection retur

t.is(response.statusCode, 404)
})

test.only('GET /collection/:collectionId/queryables for collection with unsupported queryables fails', async (t) => {
const collection = await loadFixture(
'stac/collection-with-incorrect-queryables.json',
{ id: t.context.collectionId }
)

await ingestItem({
ingestQueueUrl: t.context.ingestQueueUrl,
ingestTopicArn: t.context.ingestTopicArn,
item: collection
})

const { collectionId } = t.context

const error = await t.throwsAsync(
async () => t.context.api.client.get(`collections/${collectionId}/queryables`,
{ resolveBodyOnly: false })
)

t.is(error.response.statusCode, 400)
t.regex(error.response.body.description,
/.*Unsupported additionalProperties value: "false". Must be set to "true".*/)
})