Nodejs script that handles documents from MinElev
A definition of jobs that should be run for a given document-type. e.g how to handle elevsamtale
See flow dir for current flows and their defined jobs
A single job that can be run in a flow. e.g archive a document Result of the job is stored in flowStatus
See jobs dir for available jobs
Object that is created on a single document. Keeps tracks of which jobs have run, and result from the job If a job is not enabled - it will not be present in flowstatus
Runs ./index.js - which is the main "robot", and does the following:
- Gets ready documents from db. ./robot/get-ready-documents.js
- Readies documents ./robot/index.js
- For each ready document ./robot/handle-document.js
- Get corresponding flow {type}-{variant}
- Run jobs that are enabled in the flow
- Move to finished if everyting ran ok
Creates a status-report and sends it to Teams-channel
Deletes files in 'finished' and 'copies' directories
Creates needed directories based on your .env preferences (see #setup)
Almost all jobs can be tailored to suit a flow's needs (see the flows for examples/mappers)
Fetches info about an ssn from Kontakt og reservasjonsregisteret. Used mainly for getting preferred language for a person.
Fetches info about an ssn from Folkeregisteret. Used mainly for getting parents for a person.
Creates/updates elevmappe in archive.
Creates/updates privatepersons in archive for ssn's parents if ssn is under 18 of age, and if parents are found in folkeregisteret. Used when you need to send copy of document to guardians/parents.
Creates/updates enterprise in archive based on data fetched from Brønnøysundsregisteret (on enterprisenumber). Used when sending document to enterprise (yff-bekreftelse-bedrift)
Creates a pdf and returns it in base64-format. Base64 is saved as a separate txt-file in queue
Special case: If recipient have address block or has svarut exception - addresses are removed from the pdfs
Archives document in archive.
Sends archived document on svarut to recipients defined on archived document.
Special cases: Checks recipients in the following order:
- Does recipient have address block => do not send on Svarut, send internal note to school that letter must be delivered to student manually
- Does recipient exists in SVARUT_EXCEPTIONS => do not send on Svarut, send internal note to school that letter must be delivered to student manually
- Does recipient have illegal zipCode (not 4 digits, set to 9999), or zipPlace set to UKJENT => do not send on Svarut, send internal note to school that letter must be delivered to student manually
- Does student not have registered parents and is under 18 => do not send on Svarut, send internal note to school that letter must be distributed manually to student and parents
Fetches contact-teachers for a student from PIFU-api. Used when you need to send email alerts to students contact teachers.
Sends email to given recipients in the flows job-mapper. Can send any email to any recipent.
Updates status on the document in the DB it was fetched from in the beginning. The statuses are used in frontend for users to see status on the document. Typically "queued - timestamp", "archived - timestamp", "sent - timestamp".
Creates anonymous statistics element in shared statistics database
Makes the flow fail - simply used for testing purposes when you need the flow to fail
- Clone project
npm i
- Create .env with values from .env
- Run
npm run setup
- If production env - Create tasks that trigger different scripts as you like (e.g npm run start, npm run status-alert, npm run delete-files)
MONGODB_CONNECTION_STRING="connection string to Mongodb"
MONGODB_DB="name of database"
MONGODB_COLLECTION="name of collection"
DOCUMENTS_PER_RUN="how many documents to you want to fetch from DB each run"
ENCRYPTION_KEY="super secret key"
RETRY_INTERVALS_MINUTES="5,30,60,60,60" # Intervals between retries for a document in minutes
KRR_URL="url to KRR api"
KRR_KEY="KRR KEEEY"
APPREG_CLIENT_SECRET="client secret from app registration"
APPREG_TENANT_ID="tenant id for app registration"
APPREG_CLIENT_ID="client id for app registration"
FREG_API_SCOPE="skup"
FREG_URL="url to FREG api"
ARCHIVE_URL="url to ARCHIVE api"
ARCHIVE_API_SCOPE="skupi"
PDF_URL="url for pdf-generator api"
PDF_KEY="keyyyy"
PIFU_JWT_SECRET="PIFU secret for signing jwt"
PIFU_URL="url to PIFU api"
MAIL_URL="https://url-to-mail-api.com?subscription-key=subscription-key-for-mail-api"
MAIL_KEY="MAIL kyeyeyey"
MAIL_TEMPLATE_NAME="du vil vel ha en template?"
MINELEV_URL="url to minelev frontend"
STATISTICS_KEY="key for statistics api"
STATISTICS_URL="url for statistics api"
STATISTICS_COMPANY="kortkode for sektor"
TEAMS_WEBHOOK_URL="teams webhook url" # Optional - if you want error and warn to teams channel
TEAMS_STATUS_WEBHOOK_URL="teams webhook url" # Required when running script "status-alert". Where to send status-alert
PAPERTRAIL_HOST="papertrail host url" # Optional - if you want logging to papertrail
PAPERTRAIL_TOKEN="papertrail token" # Optiional - if you want logging to papertrail
SVARUT_EXCEPTIONS="12345678910,12345678911" # comma-separated ssn's that should not receive letter's on svarut
Samtale og notat skal ikke sendes ut (ikke-samtale skal faktisk sendes ut...)