Skip to content

Commit 222ec82

Browse files
committed
add behavior to allow for deleting items out of collections in bulk
1 parent f22552b commit 222ec82

18 files changed

+412
-232
lines changed

.c8rc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"reporter": [
3+
"html",
4+
"text"
5+
]
6+
}

.github/workflows/push.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ jobs:
3838
- name: Audit
3939
run: npm run audit-prod
4040
- name: Unit tests
41-
run: npm run test:coverage
41+
run: npm run test:unit:coverage
4242
- name: Wait for OpenSearch
4343
run: ./bin/wait-for-opensearch/run.sh
4444
- name: System tests
45-
run: npm run test:system
45+
run: npm run test:system:coverage
4646
- name: Run build
4747
run: npm run build

CHANGELOG.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

8+
## [4.2.0] - unreleased
9+
10+
### Added
11+
12+
- Added support for ingest actions, specifically "truncate collection". This is enabled
13+
by setting `ENABLE_INGEST_ACTION_TRUNCATE` to `true`.
14+
15+
### Changed
16+
17+
- When being ingested, Items and Collection without a `links` array will not be rejected,
18+
but will have the field added.
19+
20+
### Removed
21+
22+
- From ingest.js, removed combineDbObjectsIntoBulkOperations and writeRecordsInBulkToDb
23+
functions, as they have not been used since version 2.0.0.
24+
825
## [4.1.0] - 2024-04-22
926

1027
### Changed

README.md

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
- [Aggregation](#aggregation)
5656
- [Hidden collections filter for authorization](#hidden-collections-filter-for-authorization)
5757
- [Ingesting Data](#ingesting-data)
58+
- [Ingest actions](#ingest-actions)
5859
- [Ingesting large items](#ingesting-large-items)
5960
- [Subscribing to SNS Topics](#subscribing-to-sns-topics)
6061
- [Ingest Errors](#ingest-errors)
@@ -608,8 +609,9 @@ There are some settings that should be reviewed and updated as needeed in the se
608609
| CORS_CREDENTIALS | Configure whether or not to send the `Access-Control-Allow-Credentials` CORS header. Header will be sent if set to `true`. | none |
609610
| CORS_METHODS | Configure whether or not to send the `Access-Control-Allow-Methods` CORS header. Expects a comma-delimited string, e.g., `GET,PUT,POST`. | `GET,HEAD,PUT,PATCH,POST,DELETE` |
610611
| CORS_HEADERS | Configure whether or not to send the `Access-Control-Allow-Headers` CORS header. Expects a comma-delimited string, e.g., `Content-Type,Authorization`. If not specified, defaults to reflecting the headers specified in the request’s `Access-Control-Request-Headers` header. | none |
611-
| ENABLE_COLLECTIONS_AUTHX | Enables support for hidden `_collections` query parameter / field when set to `true`. | none |
612-
| ENABLE_THUMBNAILS | Enables support for presigned thumnails. | none |
612+
| ENABLE_COLLECTIONS_AUTHX | Enables support for hidden `_collections` query parameter / field when set to `true`. | none (not enabled) |
613+
| ENABLE_THUMBNAILS | Enables support for presigned thumnails. | none (not enabled) |
614+
| ENABLE_INGEST_ACTION_TRUNCATE | Enables support for ingest action "truncate". | none (not enabled) |
613615

614616
Additionally, the credential for OpenSearch must be configured, as decribed in the
615617
section [Populating and accessing credentials](#populating-and-accessing-credentials).
@@ -1152,7 +1154,8 @@ STAC Collections and Items are ingested by the `ingest` Lambda function, however
11521154
**STAC Collections must be ingested before Items that belong to that Collection.** Items should have the `collection` field populated with the ID of an existing Collection. If an Item is ingested before ingestion of the Collection it contains,
11531155
ingestion will either fail (in the case of a single Item ingest) or if auto-creation of indexes is enabled (default) and multiple Items are ingested in bulk, the auto-created index will have incorrect mappings.
11541156

1155-
If a collection or item is ingested, and an item with that id already exists in STAC, the new item will completely replace the old item.
1157+
If a collection or item is ingested, and an item with that id already exists in STAC, the new item will completely replace the old item, except the `created` property will be retained and the `updated` property updated
1158+
to match the time of the new update.
11561159

11571160
After a collection or item is ingested, the status of the ingest (success or failure) along with details of the collection or item are sent to a post-ingest SNS topic. To take action on items after they are ingested subscribe an endpoint to this topic.
11581161

@@ -1164,6 +1167,27 @@ Messages published to the post-ingest SNS topic include the following atributes
11641167
| ingestStatus | String | `successful` or `failed` |
11651168
| collection | String | |
11661169

1170+
### Ingest actions
1171+
1172+
In addition to ingesting Item and Collection JSON, the ingestion pipeline can also execute
1173+
actions. This is useful when the Transaction Extension is turned off, but data modification
1174+
still needs to occur.
1175+
1176+
There is currently only one action implemented, `truncate`. This action will delete all
1177+
of the Items in the specified Collection, but keep the Collection.
1178+
1179+
This action is enabled by setting `ENABLE_INGEST_ACTION_TRUNCATE` to `true`.
1180+
1181+
The form of this message is:
1182+
1183+
```json
1184+
{
1185+
"type": "action",
1186+
"command": "truncate",
1187+
"collection": "my_collection_1"
1188+
}
1189+
```
1190+
11671191
### Ingesting large items
11681192

11691193
There is a 256 KB limit on the size of SQS messages. Larger items can by publishing a message to the `stac-server-<stage>-ingest` SNS topic in with the format:
@@ -1367,7 +1391,7 @@ npm test
13671391
npm run test:unit
13681392
13691393
# run unit tests with coverage
1370-
npm run test:coverage
1394+
npm run test:unit:coverage
13711395
13721396
# run tests from a single test file whose titles match 'foobar*'
13731397
npx ava tests/test-es.js --match='foobar*'
@@ -1401,6 +1425,12 @@ Once OpenSearch has been started, run the system tests:
14011425
npm run test:system
14021426
```
14031427

1428+
With coverage:
1429+
1430+
```shell
1431+
npm run test:system:coverage
1432+
```
1433+
14041434
A subset of system tests may be run by providing a glob matching the test files to run:
14051435

14061436
```shell

0 commit comments

Comments
 (0)