Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
ea25830
Initial API documentation for tags
keesey Dec 7, 2022
042cfd7
Added tags to CREATE sql script (source)
keesey Dec 8, 2022
fd16054
Added tags to CREATE sql script (entities)
keesey Dec 8, 2022
560383f
Implemented GET /imagetags
keesey Dec 8, 2022
d9d6463
Updated GET /imagetags in api-docs to include build
keesey Dec 8, 2022
1fbadd3
Merge branch 'main' into feature/tags
keesey Feb 2, 2023
e950f76
Merge branch 'main' into feature/tags
keesey Mar 22, 2023
7e3b216
Revised openAPI version
keesey Mar 22, 2023
949720c
Merge branch 'main' into feature/tags
keesey Mar 25, 2023
cc47f36
Merge branch 'main' into feature/tags
keesey Apr 26, 2023
c91d7ff
Merge branch 'main' into feature/tags
keesey Dec 18, 2023
0a19fcf
Merge branch 'main' into feature/tags
keesey Jun 15, 2024
3980780
Merge branch 'main' into feature/tags
keesey Jan 20, 2025
2ad4651
Upgraded @aws-sdk deps
keesey Jan 21, 2025
c68fb94
SQL tweak
keesey Jan 21, 2025
cd97cbb
Added detection and normalization for tags
keesey Jan 21, 2025
dd9c04b
Added "tags" property to:
keesey Jan 22, 2025
de6a1d3
Fix for isSubmission()
keesey Jan 22, 2025
d568e85
Added editor for tags
keesey Jan 23, 2025
2b692b2
CHANGELOG addition
keesey Jan 23, 2025
a043afa
Added /nodes/{uuid}/imagetags endpoint
keesey Jan 23, 2025
aef6888
Added image tags to make process
keesey Jan 23, 2025
fa7aee0
CHANGELOG updates
keesey Jan 23, 2025
d58b4b5
Removed debug statement
keesey Jan 23, 2025
208e0d3
Fixed an issue with passing arrays to Postgres
keesey Jan 24, 2025
89194c9
Further fix for prepareValue()
keesey Jan 24, 2025
3db8ed3
Better fix for prepareValue()
keesey Jan 24, 2025
9a5544b
Removed some old code from edit. CHANGELOG fixes.
keesey Jan 24, 2025
90c6868
Added /imagetags link to API JSON and imagetags links to Node JSON
keesey Jan 25, 2025
213d12e
Fix for inserting images
keesey Jan 25, 2025
63d0d13
Removed debug call, foramtted code
keesey Jan 25, 2025
33b11c9
New api-models type: Tags
keesey Jan 25, 2025
8f01cf2
Initial screen for tags (contribute).
keesey Jan 25, 2025
0d52c19
Fixed a port conflict for dev mode.
keesey Jan 25, 2025
955999f
More work on tags screen.
keesey Jan 25, 2025
516a18e
Completed Tags screen for contribute
keesey Jan 25, 2025
5bbd7c5
Added tag editing for submissions
keesey Jan 25, 2025
c14c124
CHANGELOG correction
keesey Jan 25, 2025
3b07ef1
Implemented filter_tags
keesey Jan 25, 2025
a4e6a37
Added tags to Image Pages (www)
keesey Jan 25, 2025
57b6b56
Loosening restriction on Image.tags for now.
keesey Apr 1, 2025
f7a68c3
Made having too many source images a warning for make
keesey Apr 1, 2025
59c2f63
Fixed a www build issue
keesey Apr 1, 2025
70c0c46
Import cleanup
keesey Apr 1, 2025
2726b3e
Merge branch '@phylopic/www/prod' into feature/tags
keesey Apr 1, 2025
41fce71
Merge branch 'main' into feature/tags
keesey Sep 25, 2025
0be993d
Fixed some build issues
keesey Sep 26, 2025
676838d
Linting/formatting
keesey Sep 26, 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: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ Note that some apps require certain environment variables to be set, which are d

Apps will run on the following ports:

| App Project | Port |
| ------------------------------- | ------ |
| [api](./apps/api) | `3003` |
| [contribute](./apps/contribute) | `3002` |
| [edit](./apps/edit) | `3001` |
| [www](./apps/www) | `3000` |
| App Project | Port |
| ------------------------------- | --------------------------------- |
| [api](./apps/api) | `3003` (HTTP) and `3004` (Lambda) |
| [contribute](./apps/contribute) | `3002` |
| [edit](./apps/edit) | `3001` |
| [www](./apps/www) | `3000` |

## Releasing versions

Expand Down
4 changes: 4 additions & 0 deletions apps/api-docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- New endpoints: `/imagetags`, `/nodes/{uuid}/imagetags`.
- New property: `Image.tags`.
- New query parameter for image list: `filter_tags`.

### Changed

### Deprecated
Expand Down
102 changes: 99 additions & 3 deletions apps/api-docs/public/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ tags:
description: Methods related to phylogenetic nodes.
- name: search
description: Searches for entities (images and nodes).
- name: tags
description: Methods related to tags.
- name: uploads
description: Methods related to file uploads.
servers:
Expand Down Expand Up @@ -193,7 +195,7 @@ components:
description: |
Limits results to entities within the specified collection.

Cannot be used alongside other `filter_*` parameters (except `filter_license_*` for images).
Cannot be used alongside `filter_clade`, `filter_contributor`, `filter_name`, or `filter_node`.
schema:
example: "060f03a9-fafd-4d08-81d1-b8f82080573f"
pattern: '^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$'
Expand Down Expand Up @@ -345,6 +347,16 @@ components:
example: "8f901db5-84c1-4dc0-93ba-2300eeddf4ab"
format: uuid
type: string
filter_tags:
name: filter_tags
in: query
required: false
description: |
Limits results to images associated with one or more tags, comma-separated.
schema:
example: "male,subadult"
format: "^[a-z0-9 -]{2,}(,[a-z0-9 -]{2,})*$"
type: string
namespace:
name: namespace
in: path
Expand Down Expand Up @@ -627,6 +639,7 @@ components:
- modified
- modifiedFile
- sponsor
- tags
type: object
properties:
attribution:
Expand All @@ -649,6 +662,12 @@ components:
type: string
example: "Patron Name"
nullable: true
tags:
type: array
items:
example: "juvenile"
format: "^[a-z0-9 -]{2,}$"
type: string
unlisted:
description: If true, this image will not appear in lists.
type: boolean
Expand Down Expand Up @@ -1342,6 +1361,7 @@ paths:
- $ref: "#/components/parameters/filter_modifiedFile_before"
- $ref: "#/components/parameters/filter_name"
- $ref: "#/components/parameters/filter_node"
- $ref: "#/components/parameters/filter_tags"
- $ref: "#/components/parameters/page"
responses:
"200":
Expand Down Expand Up @@ -1398,6 +1418,49 @@ paths:
$ref: "#/components/responses/406"
"410":
$ref: "#/components/responses/410"
/imagetags:
get:
operationId: getImageTags
summary: Returns a list of all image tags.
tags:
- images
- tags
description:
Returns a list of all tags currently in use for images.
parameters:
- $ref: "#/components/parameters/Accept"
- $ref: "#/components/parameters/build"
responses:
"200":
description: List of tags.
headers:
Content-Type:
$ref: "#/components/headers/Content-Type"
content:
application/vnd.phylopic.v2+json:
schema:
type: object
required:
- build
- tags
properties:
build:
type: number
format: integer
tags:
type: array
items:
example: "colony"
format: "^[a-z0-0 -]{2,}$"
type: string
"307":
$ref: "#/components/responses/307"
"400":
$ref: "#/components/responses/400"
"406":
$ref: "#/components/responses/406"
"410":
$ref: "#/components/responses/410"
/licenses:
get:
operationId: getLicenses
Expand Down Expand Up @@ -1427,8 +1490,6 @@ paths:
$ref: "#/components/responses/307"
"400":
$ref: "#/components/responses/400"
"404":
$ref: "#/components/responses/404"
"406":
$ref: "#/components/responses/406"
"410":
Expand Down Expand Up @@ -1554,6 +1615,41 @@ paths:
$ref: "#/components/responses/406"
"410":
$ref: "#/components/responses/410"
/nodes/{uuid}/imagetags:
get:
operationId: getNodeImageTags
summary: Returns a list of all image tags in use for this clade.
description: |
Returns a list of all tags associated with images associated with this node or any descendant of this node.
tags:
- images
- nodes
- tags
parameters:
- $ref: "#/components/parameters/Accept"
- $ref: "#/components/parameters/build"
responses:
"200":
description: List of tags.
headers:
Content-Type:
$ref: "#/components/headers/Content-Type"
content:
application/vnd.phylopic.v2+json:
schema:
type: array
items:
type: string
"307":
$ref: "#/components/responses/307"
"400":
$ref: "#/components/responses/400"
"404":
$ref: "#/components/responses/404"
"406":
$ref: "#/components/responses/406"
"410":
$ref: "#/components/responses/410"
/nodes/{uuid}/lineage:
get:
operationId: getLineage
Expand Down
9 changes: 9 additions & 0 deletions apps/api/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

- New endpoints: `/imagetags`, `/nodes/{uuid}/imagetags`.
- New property: `Image.tags`.
- New query parameter for image list: `filter_tags`.

### Changed

- Upgraded `@aws-sdk` dependencies.

### Deprecated

### Fixed

- The `build` query parameter was missing in the Serverless configuration for several endpoints.
- In `dev` mode, the lambda process was using the same port as `contribute`.

### Removed

### Security
Expand Down
2 changes: 2 additions & 0 deletions apps/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ To run the API on your local machine, on port `3003`:
yarn dev
```

(This will run the lambda on port `3004`.)

## Deploying

To deploy to `api.phylopic.org` (if you have [AWS Command Line Interface](https://aws.amazon.com/cli/) set up with proper credentials):
Expand Down
6 changes: 3 additions & 3 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"url": "https://github.com/keesey/phylopic/issues"
},
"dependencies": {
"@aws-sdk/client-s3": "^3.675.0",
"@aws-sdk/client-s3": "^3.732.0",
"@phylopic/api-models": "*",
"@phylopic/utils": "*",
"jsonwebtoken": "^9.0.2",
Expand All @@ -34,13 +34,13 @@
"license": "MIT",
"name": "@phylopic/api",
"peerDependencies": {
"@aws-sdk/signature-v4-crt": "^3.674.0"
"@aws-sdk/signature-v4-crt": "^3.731.0"
},
"private": true,
"scripts": {
"clean": "rm -rf .serverless && rm -rf .turbo && rm -rf .webpack && rm -rf node_modules",
"deploy": "sls deploy",
"dev": "sls offline --httpPort 3003",
"dev": "sls offline --httpPort 3003 --lambdaPort 3004",
"lint": "eslint --fix ./**/*.[jt]s"
},
"version": "2.7.1"
Expand Down
47 changes: 47 additions & 0 deletions apps/api/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ functions:
filter_modifiedFile_before: false
filter_name: false
filter_node: false
filter_tags: false
embed_contributor: false
embed_generalNode: false
embed_items: false
Expand Down Expand Up @@ -293,6 +294,26 @@ functions:
embed_generalNode: false
embed_nodes: false
embed_specificNode: false
- http:
cors:
allowCredentials: true
origin: "*"
headers:
- Accept
- Authorization
- Content-Type
- X-Amz-Date
- X-Amz-Security-Token
- X-Amz-User-Agent
- X-Api-Key
path: imagetags
method: get
request:
parameters:
headers:
accept: false
querystrings:
build: false
- http:
cors:
allowCredentials: true
Expand Down Expand Up @@ -360,9 +381,32 @@ functions:
paths:
uuid: true
querystrings:
build: false
embed_childNodes: false
embed_parentNode: false
embed_primaryImage: false
- http:
cors:
allowCredentials: true
origin: "*"
headers:
- Accept
- Authorization
- Content-Type
- X-Amz-Date
- X-Amz-Security-Token
- X-Amz-User-Agent
- X-Api-Key
path: "nodes/{uuid}/imagetags"
method: get
request:
parameters:
headers:
accept: false
paths:
uuid: true
querystrings:
build: false
- http:
cors:
allowCredentials: true
Expand All @@ -384,6 +428,7 @@ functions:
paths:
uuid: true
querystrings:
build: false
embed_childNodes: false
embed_items: false
embed_parentNode: false
Expand Down Expand Up @@ -411,6 +456,7 @@ functions:
namespace: true
objectID: true
querystrings:
build: false
embed_childNodes: false
embed_parentNode: false
embed_primaryImage: false
Expand Down Expand Up @@ -466,6 +512,7 @@ functions:
authority: true
namespace: true
querystrings:
build: false
embed_childNodes: false
embed_parentNode: false
embed_primaryImage: false
Expand Down
16 changes: 16 additions & 0 deletions apps/api/src/entities/image/addFilterToQuery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,21 @@ const addFilterToQuery = (params: ImageListParameters, builder: QueryConfigBuild
if (params.filter_modifiedFile_before !== undefined) {
builder.add("AND modified_file<=$::timestamp without time zone", [params.filter_modifiedFile_before])
}
if (params.filter_tags) {
builder.add("AND ")
const tags = params.filter_tags.split(",")
if (tags.length > 1) {
builder.add("(")
}
tags.forEach((tag, index) => {
if (index > 0) {
builder.add(" OR ")
}
builder.add("$::character varying=ANY(image.tags)", [tag])
})
if (tags.length > 1) {
builder.add(")")
}
}
}
export default addFilterToQuery
Loading