Skip to content

Commit

Permalink
Merge pull request #266 from zazuko/next
Browse files Browse the repository at this point in the history
Trifid v5
  • Loading branch information
ludovicm67 authored Mar 6, 2024
2 parents 8fcc928 + 3f765ad commit 23dcbf8
Show file tree
Hide file tree
Showing 199 changed files with 13,941 additions and 16,238 deletions.
5 changes: 5 additions & 0 deletions .changeset/calm-turkeys-boil.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid-core": minor
---

Expose a `query` function that can be used in all plugins to perform a SPARQL query
7 changes: 7 additions & 0 deletions .changeset/funny-jobs-occur.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"trifid-plugin-graph-explorer": major
---

The plugin is now using the new Trifid factory, which is a breaking change.

Assets are served under `/graph-explorer/assets/` and `/graph-explorer/static/` instead of `/graph-explorer-assets/` and `/graph-explorer-static/`.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-points-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid-core": patch
---

Add support for JSON-encoded and URL-encoded bodies by default
8 changes: 8 additions & 0 deletions .changeset/happy-suns-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@zazuko/trifid-markdown-content": patch
"trifid-handler-fetch": patch
"@zazuko/trifid-plugin-ckan": patch
"trifid-core": patch
---

Improve included TypeScript types.
5 changes: 5 additions & 0 deletions .changeset/little-beans-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zazuko/trifid-plugin-ckan": minor
---

The SPARQL query that is made to get all datasets is now querying all graphs by default
5 changes: 5 additions & 0 deletions .changeset/lucky-dingos-hear.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid": major
---

Remove the `trifid-handler-sparql` package
5 changes: 5 additions & 0 deletions .changeset/mean-glasses-eat.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zazuko/trifid-plugin-sparql-proxy": major
---

The plugin is now using the new Trifid factory, which is a breaking change.
5 changes: 5 additions & 0 deletions .changeset/neat-fireants-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zazuko/trifid-entity-renderer": major
---

The plugin is now using the new Trifid factory, which is a breaking change.
5 changes: 5 additions & 0 deletions .changeset/ninety-socks-kiss.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid-core": major
---

Health check is now exposed at `/healthz` instead of `/health`
5 changes: 5 additions & 0 deletions .changeset/old-houses-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zazuko/trifid-markdown-content": major
---

The plugin is now using the new Trifid factory, which is a breaking change.
5 changes: 5 additions & 0 deletions .changeset/pretty-days-whisper.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zazuko/trifid-entity-renderer": minor
---

Remove the use of hijackresponse
16 changes: 16 additions & 0 deletions .changeset/purple-deers-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
"@zazuko/trifid-markdown-content": major
"@zazuko/trifid-entity-renderer": major
"trifid-plugin-graph-explorer": major
"trifid-handler-fetch": major
"@zazuko/trifid-plugin-sparql-proxy": major
"trifid": major
"trifid-plugin-yasgui": major
"@zazuko/trifid-plugin-ckan": major
"trifid-core": major
"trifid-plugin-i18n": major
"@zazuko/trifid-plugin-iiif": major
"trifid-plugin-spex": major
---

Use 'plugins' instead of 'middlewares'
5 changes: 5 additions & 0 deletions .changeset/quick-dancers-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid": minor
---

Allow to start Trifid using the CLI without requiring a path to a configuration file.
42 changes: 42 additions & 0 deletions .changeset/rich-parents-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
"trifid-core": major
---

Trifid Plugins should return an object:

```js
/** @type {import('trifid-core/types/index.js').TrifidPlugin} */
const factory = async (trifid) => {
return {
defaultConfiguration: async () => {
return {
methods: ["GET"],
paths: ["/hello"],
// ...
};
},
routeHandler: async () => {
/**
* Route handler.
* @param {import('fastify').FastifyRequest} _request Request.
* @param {import('fastify').FastifyReply} reply Reply.
*/
const handler = async (_request, reply) => {
reply.send("Hello, world!");
};
return handler;
},
};
};

export default factory;
```

The factory should also be a promise.

Previously, the factory was a function that returned an Express middleware.
Since the move to Fastify, we are now returning an object with two methods: `defaultConfiguration` and `routeHandler`.
The `routeHandler` method should return a route handler function.
The `defaultConfiguration` method should return the default configuration for the plugin.
This allows the user to use the plugin with the default configuration or to override it.
This can be useful to simplify the Trifid configuration files.
5 changes: 5 additions & 0 deletions .changeset/shaggy-papayas-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid-core": major
---

Remove the `rewrite` middleware
5 changes: 5 additions & 0 deletions .changeset/shiny-colts-drive.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zazuko/trifid-plugin-ckan": major
---

The plugin is now using the new Trifid factory, which is a breaking change.
12 changes: 12 additions & 0 deletions .changeset/shiny-weeks-do.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"trifid-handler-fetch": major
---

Completely change the way it is working.

Instead of being an handler that is made to be called only when dereferencing, it is now a Trifid plugin that is exposing a new endpoint `/query` (for example) that can be used to perform SPARQL queries against the dataset.

This means that it is now possible to perform SPARQL queries against a dataset that is loaded from a URL, which was not possible before.
This also means that it is possible to use all other Trifid plugins that were only working with a SPARQL endpoint and not with a dataset coming from a simple file.

Please take a look on how to use it in the documentation here: https://github.com/zazuko/trifid/tree/main/packages/handler-fetch#readme
5 changes: 5 additions & 0 deletions .changeset/silent-meals-mate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid-plugin-i18n": major
---

The plugin is now using the new Trifid factory, which is a breaking change.
5 changes: 5 additions & 0 deletions .changeset/silver-knives-smell.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid-plugin-spex": major
---

The plugin is now using the new Trifid factory, which is a breaking change.
5 changes: 5 additions & 0 deletions .changeset/smooth-grapes-return.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid-plugin-yasgui": major
---

The plugin is now using the new Trifid factory, which is a breaking change.
5 changes: 5 additions & 0 deletions .changeset/spicy-needles-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zazuko/trifid-entity-renderer": minor
---

Add support for redirects.
5 changes: 5 additions & 0 deletions .changeset/stale-oranges-deny.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zazuko/trifid-entity-renderer": minor
---

Support for multiple serializations
5 changes: 5 additions & 0 deletions .changeset/tall-coins-bow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid": major
---

Remove morgan logger.
5 changes: 5 additions & 0 deletions .changeset/thin-pugs-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid-handler-fetch": patch
---

Support `unionDefaultGraph` configuration
5 changes: 5 additions & 0 deletions .changeset/three-rocks-knock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zazuko/trifid-plugin-sparql-proxy": major
---

The plugin was completely restructured to remove extra complexity.
5 changes: 5 additions & 0 deletions .changeset/tough-insects-clap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid-core": minor
---

Allow listening on a random port by using port `0`.
5 changes: 5 additions & 0 deletions .changeset/tough-pens-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zazuko/trifid-plugin-sparql-proxy": patch
---

Upgrade proxy-agent to 6.4.0
5 changes: 5 additions & 0 deletions .changeset/unlucky-bats-behave.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"trifid-handler-fetch": major
---

The plugin is now using the new Trifid factory, which is a breaking change.
5 changes: 5 additions & 0 deletions .changeset/weak-windows-count.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zazuko/trifid-plugin-iiif": minor
---

The plugin is now using the new Trifid factory, which is a breaking change.
2 changes: 2 additions & 0 deletions packages/trifid/.dockerignore → .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ node_modules
npm-debug.log
.git
Dockerfile
.changeset
.github
4 changes: 2 additions & 2 deletions .github/workflows/docker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ jobs:
id: docker_build
uses: docker/build-push-action@v5
with:
context: ./packages/trifid
file: ./packages/trifid/Dockerfile
context: .
file: ./Dockerfile
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ jobs:
- uses: actions/setup-node@v4
with:
node-version: 20
cache: npm

- name: Install Dependencies
run: npm ci
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm

- name: Install dependencies
run: npm ci
Expand All @@ -37,8 +38,12 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
- name: Set up NodeJS
uses: actions/setup-node@v4
with:
node-version: 20
- run: npm ci
- run: npx wsrun --report -mc prepack
cache: npm
- name: Install dependencies
run: npm ci
- name: Run build of each package (prepack script, mostly for typings)
run: npm run build
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,12 @@ yarn.lock
npm-debug.log*
yarn-debug.log*
yarn-error.log*

*.d.ts
*.d.ts.map
*.d.cts
*.d.cts.map
*.d.mts
*.d.mts.map

dist/
21 changes: 11 additions & 10 deletions packages/trifid/Dockerfile → Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,31 @@ FROM docker.io/library/node:20-alpine

EXPOSE 8080

# configure some default values
# Configure some default values
ENV TRIFID_CONFIG="instances/docker-sparql/config.yaml"
ENV SPARQL_ENDPOINT_USERNAME="public"
ENV SPARQL_ENDPOINT_PASSWORD="public"
ENV SPARQL_PROXY_CACHE_PREFIX="default"
ENV SPARQL_PROXY_CACHE_CLEAR_AT_STARTUP="false"

# some default values for the 'docker-fetch' instance
# Some default values for the 'docker-fetch' instance
ENV FETCH_HANDLER_FILE="https://raw.githubusercontent.com/zazuko/tbbt-ld/master/dist/tbbt.nt"
ENV FETCH_HANDLER_FILE_TYPE="application/n-triples"

# use tini for PID1
# Use tini for PID1
# https://github.com/krallin/tini
RUN apk add --no-cache tini

# run as node user
# Run as node user
USER 1000:1000
WORKDIR /app

# copy package.json and install dependencies
COPY package.json ./
RUN npm install --omit=dev && npm cache clean --force
COPY . .
# Copy everything, so that it uses local dependencies
COPY --chown=1000:1000 . .
RUN npm install && npm cache clean --force

ENTRYPOINT ["tini", "--", "/app/server.js"]
WORKDIR /app/packages/trifid

HEALTHCHECK CMD wget -q -O- http://localhost:8080/health
ENTRYPOINT ["tini", "--", "/app/packages/trifid/server.js"]

HEALTHCHECK CMD wget -q -O- http://localhost:8080/healthz
Loading

0 comments on commit 23dcbf8

Please sign in to comment.