diff --git a/Development/v4.x/backend/configuration/jobconfig.md b/Development/v4.x/backend/configuration/jobconfig.md index e637bc94..bf2e2f8f 100644 --- a/Development/v4.x/backend/configuration/jobconfig.md +++ b/Development/v4.x/backend/configuration/jobconfig.md @@ -1,5 +1,30 @@ # Job Configuration +- [Overview](#overview) +- [Quick-start](#quick-start) +- [Details](#details) + - [Job lifecycle](#job-lifecycle) + - [Referencing datasets](#referencing-datasets) + - [Status Codes](#status-codes) + - [Actions](#actions) + - [Migration Notes](#migration-notes) +- [Configuration](#configuration) + - [Configuration overview](#configuration-overview) + - [Authorization](#authorization) + - [Templates](#templates) + - [Actions Configuration](#actions-configuration) + - [URLAction](#urlaction) + - [Validate](#validate) + - [Example 1: Require extra template data](#example-1-require-extra-template-data) + - [Example 2: Enforce datasetLifecycle state](#example-2-enforce-datasetlifecycle-state) + - [Example 3: Define statusCodes](#example-3-define-statuscodes) + - [Email](#email) + - [RabbitMQ](#rabbitmq) + - [Switch](#switch) + - [Error](#error) + - [Log](#log) + + ## Overview The SciCat job system is used for any interactions between SciCat and external services. @@ -22,7 +47,7 @@ false`) and retrieval should be disabled. To start using jobs: 1. Copy - [jobConfig.recommended.yaml](https://github.com/SciCatProject/scicat-backend-next/blob/master/jobConfig.recommended.yaml) + [`jobConfig.recommended.yaml`](https://github.com/SciCatProject/scicat-backend-next/blob/master/jobConfig.recommended.yaml) to `jobConfig.yaml` 2. Update the configuration. See [jobConfig.example.yaml](https://github.com/SciCatProject/scicat-backend-next/blob/master/jobConfig.example.yaml) @@ -220,17 +245,44 @@ Template strings use [Handlebars](https://handlebarsjs.com/) syntax. The followi top-level variables are availabe in the handlebars context: {% raw %} -| Top-level variable | Type | Examples | Description | -|---|---|---|---| -| `request` | `CreateJobDto` or
`UpdateJobDto` | `{{request.type}}`
`{{request.jobParams}}` | HTTP Request body | -| `job` | `JobClass` | `{{job.id}}` | The job, as stored in the database. Not available for validate actions. | -| `datasets` | `DatasetClass[]` | `{{#each datasets}}{{pid}}{{/each}}` | All datasets referenced in `job.jobParams.datasetsList`. | -| `env` | `object` | `{{env.SECRET_TOKEN}}` | Access environmental variables | +| Top-level variable | Type | Examples | Description | +| ------------------ | ------------------------------------ | ---------------------------------------------- | ----------------------------------------------------------------------- | +| `request` | `CreateJobDto` or
`UpdateJobDto` | `{{{request.type}}}`
`{{{request.jobParams}}}` | HTTP Request body | +| `job` | `JobClass` | `{{{job.id}}}` | The job. During the validate phase this is the previous job values (if any); during the perform phase it will be the current database value. | +| `datasets` | `DatasetClass[]` | `{{#each datasets}}{{{pid}}}{{/each}}` | Array of all datasets referenced in `job.jobParams.datasetsList`. | +| `env` | `object` | `{{{env.SECRET_TOKEN}}}` | Access environmental variables | {% endraw %} Environmental variables are particularly useful for secrets that should not be stored in the config file. +{% raw %} +Most variables should use handlebars "triple-stash" (`{{{ var }}}`) to disable html +escaping. Use double-brackets (`{{ var }}`) for HTML email bodies where special +characters should be escaped. Templates that expect JSON should use `{{{ jsonify var +}}}` to ensure correct quoting. In addition to the built-in handlebars functions, the +following additional helpers are defined: +{% endraw %} + +- `unwrapJSON`: convert a json object to HTML (arrays become `