Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Notification endpoints #19

Merged
merged 20 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 18 commits
Commits
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
25 changes: 16 additions & 9 deletions .env
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
SENTRY_DSN=
PORT=
DATABASE_URL=http://127.0.0.1:5984
DATABASE_USER=admin
DATABASE_PASSWORD=admin
QUERY_URL=http://127.0.0.1:4984
SCHEMA_CONFIG_ID=_design/sqlite:config

CHANGES_POLL_INTERVAL=60000
REPORT_COUCH_SQS_CLIENT_CONFIG_BASIC_AUTH_USER=admin
REPORT_COUCH_SQS_CLIENT_CONFIG_BASIC_AUTH_PASSWORD=docker

REPORT_COUCH_DB_CLIENT_CONFIG_REPORT_BASIC_AUTH_USER=admin
REPORT_COUCH_DB_CLIENT_CONFIG_REPORT_BASIC_AUTH_PASSWORD=docker
tomwwinter marked this conversation as resolved.
Show resolved Hide resolved

REPORT_COUCH_DB_CLIENT_CONFIG_REPORT_CALCULATION_BASIC_AUTH_USER=admin
REPORT_COUCH_DB_CLIENT_CONFIG_REPORT_CALCULATION_BASIC_AUTH_PASSWORD=docker

REPORT_CHANGES_COUCH_DB_CLIENT_CONFIG_BASIC_AUTH_USER=admin
REPORT_CHANGES_COUCH_DB_CLIENT_CONFIG_BASIC_AUTH_PASSWORD=docker

NOTIFICATION_COUCH_DB_CLIENT_CONFIG_BASIC_AUTH_USER=admin
NOTIFICATION_COUCH_DB_CLIENT_CONFIG_BASIC_AUTH_PASSWORD=docker

CRYPTO_ENCRYPTION_SECRET=super-duper-secret
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Query Backend
# Query Back'end

sleidig marked this conversation as resolved.
Show resolved Hide resolved
This service allows to run SQL queries on the database.
In particular, this service allows users with limited permissions to see reports of aggregated statistics across all data (e.g. a supervisor could analyse reports without having access to possibly confidential details of participants or notes).
Expand Down
8 changes: 0 additions & 8 deletions build/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,5 @@ RUN npm ci --no-progress --only=production
COPY --from=builder /app/dist ./dist
COPY --from=builder /app/.env ./

# (optional) The sentry DSN in order to send the error messages to sentry
ENV SENTRY_DSN=""
ENV PORT=""
ENV DATABASE_URL=""
ENV DATABASE_ADMIN="admin"
ENV DATABASE_PASSWORD=""
ENV QUERY_URL=""

CMD ["node", "dist/main"]

75 changes: 53 additions & 22 deletions docs/api-specs/reporting-api-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,19 @@ servers:
default: dev
description: Customer ID assigned by the service provider
tags:
- name: report
- name: reporting
description: Access reports and their results and trigger one-time report calculations.
- name: notification
- name: notifications
description: Subscribe to continuous notification events whenever a report's result data changes due to users changing records in the Aam Digital application.

paths:
/report:
get:
security:
- development:
- reporting_read
- reporting_read
tags:
- report
- reporting
summary: Return list of available Reports
responses:
200:
Expand All @@ -47,9 +47,9 @@ paths:
get:
security:
- development:
- reporting_read
- reporting_read
tags:
- report
- reporting
summary: Return report metadata by ID
parameters:
- in: path
Expand Down Expand Up @@ -81,9 +81,9 @@ paths:
get:
security:
- development:
- reporting_read
- reporting_read
tags:
- report
- reporting
summary: Return all report calculations for a report
parameters:
- in: path
Expand Down Expand Up @@ -114,9 +114,9 @@ paths:
post:
security:
- development:
- reporting_write
- reporting_write
tags:
- report
- reporting
summary: Trigger a new report calculation run.
description: Trigger a new report calculation run. Check status of the asynchronous calculation via the /report-calculation endpoint
As an alternative to triggering a single report calculation, you can subscribe to receive
Expand Down Expand Up @@ -162,9 +162,9 @@ paths:
get:
security:
- development:
- reporting_read
- reporting_read
tags:
- report
- reporting
summary: Return metadata for a report calculation
parameters:
- in: path
Expand Down Expand Up @@ -198,9 +198,9 @@ paths:
get:
security:
- development:
- reporting_read
- reporting_read
tags:
- report
- reporting
summary: Fetch actual report data for a specific calculation
parameters:
- in: path
Expand Down Expand Up @@ -237,9 +237,9 @@ paths:
get:
security:
- development:
- reporting_read
- reporting_read
tags:
- notification
- notifications
summary: Return list of existing Webhooks for your authorized client
responses:
200:
Expand All @@ -262,14 +262,45 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/Error'
post:
security:
- development:
- reporting_write
tags:
- notifications
summary: Subscribe to events for a specific Report
description: Register a webhook to be called for one or more notification subscriptions. To receive events, make calls to your webhookId's /subscribe endpoint.
requestBody:
required: true
content:
application/json:
schema:
$ref: '#/components/schemas/WebhookConfiguration'
responses:
200:
description: Webhook registered successfully, you can now register subscriptions
content:
application/json:
schema:
type: object
properties:
id:
type: string
format: uuid
401:
description: If no valid access token
content:
application/json:
schema:
$ref: '#/components/schemas/Error'

/webhook/{webhookId}:
get:
security:
- development:
- reporting_read
- reporting_read
tags:
- notification
- notifications
summary: Return a specific Webhook
parameters:
- in: path
Expand Down Expand Up @@ -307,9 +338,9 @@ paths:
post:
security:
- development:
- reporting_write
- reporting_write
tags:
- notification
- notifications
summary: Subscribe to events for a specific Report
description: If you subscribe to a reportId, Aam Digital will continuously monitor the changes users
make in the application and check if they affect the results calculated by that report.
Expand Down Expand Up @@ -356,9 +387,9 @@ paths:
delete:
security:
- development:
- reporting_write
- reporting_write
tags:
- notification
- notifications
summary: Remove event subscription for a specific Report
parameters:
- in: path
Expand Down
12 changes: 0 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 22 additions & 2 deletions src/config/app.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
COUCH_SQS_CLIENT_CONFIG:
BASE_URL: http://localhost:4984
NOTIFICATION:
COUCH_DB_CLIENT_CONFIG:
BASE_URL: http://localhost:5984
TARGET_DATABASE: notification-webhook

REPORT:
COUCH_DB_CLIENT_CONFIG:
REPORT:
BASE_URL: http://localhost:5984
TARGET_DATABASE: app
REPORT_CALCULATION:
BASE_URL: http://localhost:5984
TARGET_DATABASE: report-calculation
COUCH_SQS_CLIENT_CONFIG:
BASE_URL: http://localhost:4984
SCHEMA_DESIGN_CONFIG: /app/_design/sqlite:config

REPORT_CHANGES:
COUCH_DB_CLIENT_CONFIG:
BASE_URL: http://localhost:5984
TARGET_DATABASE: app
POLL_INTERVAL: 10000
tomwwinter marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading