# contract-processor

This lambda processes a batch of sound recording files for an order, deleting or updating files
to ensure that data which is not contractually valid is not delivered.

## Important note when running locally

Because this lambda will delete files in S3, if you run it multiple times you may see different results.

For convenience, you can back up the SR files in S3 for a given `$ORDER_ID` using the following command:

```shell
aws s3 cp --recursive s3://qa-neighbouring-rights/ownership/delivery/orders/$ORDER_ID/order_data/ .
```

and then re-upload files to the `order_data/` subfolder like so:

```shell
for f in *.json; do aws s3 cp "$f" s3://qa-neighbouring-rights/ownership/delivery/orders/$ORDER_ID/order_data/; done
```

### account IDs

the `local-run.ts` script requires the account IDs for a given batch of sound recordings to run. Normally
these would be provided by the previous lambda in the step function (the `template-data-loader`), but fo
local testing we don't have this luxury.

For convenience, you can use the following shell snippet to extract the account IDs from a batch of sound recording
files (which you have fetched using the command in the above section).

```shell
cat *.json | jq '.rules[] | .vendor.id.vendorId' | sort | uniq
```
