Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
b03c482
Improving device model to use more concise sequelize and better repre…
thanaParis Feb 7, 2024
96e0dee
Adding health check for sql db and depends_on to directus so that dir…
thanaParis Feb 7, 2024
6d23dda
changing default for auto accept to true so that the Pending getBaseR…
thanaParis Feb 7, 2024
253ec1d
removing unused imports, log statements only used for testing; adjust…
thanaParis Feb 7, 2024
f4dc59f
reloading variable attribute to grab associated component and variabl…
thanaParis Feb 7, 2024
db66897
Merge pull request #40 from citrineos/feature/device-model-improvements
joll90 Feb 8, 2024
d4b7a62
moved common server classes to 00_Base and 02_Util where appropriate …
thanaParis Feb 8, 2024
c61acbe
Merge pull request #41 from citrineos/feature/common-server-classes-r…
joll90 Feb 9, 2024
cf00f9e
Added dotenv config with env var parsing
majeeel Feb 9, 2024
45a1601
rename dotenv to envvar
majeeel Feb 15, 2024
db9f060
added build arg to dockerfile
majeeel Feb 15, 2024
95d4e52
feat: Make env keys case-insensitive by forcing them lowercase to pro…
ChrisWeissmann Feb 16, 2024
0b797cc
feat: Adjust for camelcase properties to be picked up by looking up t…
ChrisWeissmann Feb 16, 2024
5474be3
feat: Move merging environment variables from own config class in ser…
ChrisWeissmann Feb 21, 2024
e092465
fix: Swagger url for running server local was not pointing at relativ…
ChrisWeissmann Feb 21, 2024
0107b23
Merge pull request #42 from citrineos/feature/env-var-based-config
thanaParis Feb 21, 2024
1b24c94
fix EVSEType value
majeeel Feb 24, 2024
e4bdab2
Merge pull request #43 from citrineos/bugfix/namespace-evse-type-value
thanaParis Mar 4, 2024
9a294e7
adjusting configs to match new format, fixing calls which reference c…
thanaParis Mar 11, 2024
d569066
fixing typo
thanaParis Mar 11, 2024
e5562b9
adding todo
thanaParis Mar 11, 2024
a4b5122
including env var changes to system config
thanaParis Mar 11, 2024
cc8c7f7
refactored handlers to include boilerplate code at higher level
thanaParis Mar 11, 2024
b2e7d45
exporting websocket config
thanaParis Mar 11, 2024
831bee3
feat: Utilizing npm workspaces to simplify multi npm package local de…
Feb 26, 2024
a847a8a
Merge pull request #44 from citrineos/feature/system-config-refactor
thanaParis Mar 12, 2024
43ca45e
Merge branch 'rc-1.1.0' into feature/workspaces
Mar 12, 2024
c1cff2f
chore: fixing doc
Mar 13, 2024
389f6bb
chore: adding run configs
Mar 13, 2024
92b58fb
chore: fix with latest change
Mar 13, 2024
36b4a45
chore: fix with latest change
Mar 13, 2024
f9aa059
chore: fix formatting to 4 spaces
Mar 13, 2024
07e7f20
chore: fix formatting
Mar 13, 2024
71cd5fe
removing cache from constructor, changing pubsub to rabbitmq
thanaParis Mar 13, 2024
169a43a
fixing logo path. removing memory log.
thanaParis Mar 13, 2024
864aaad
adding handling for all OCPP 2.0.1 messages.
thanaParis Mar 14, 2024
3d3dae8
Update 00_Base/src/interfaces/messages/AbstractMessageHandler.ts
thanaParis Mar 14, 2024
bc32990
Merge pull request #49 from citrineos/feature/module-receiver-refactor
thanaParis Mar 14, 2024
9001d25
correcting boot status import
thanaParis Mar 14, 2024
dd99da3
undoing accidental change
thanaParis Mar 14, 2024
8206294
correcting log format
thanaParis Mar 14, 2024
079c8ad
correcting log format
thanaParis Mar 14, 2024
f87fb11
removing evse include on reload that was unneeded, correcting imports
thanaParis Mar 14, 2024
c326d94
Update 03_Modules/EVDriver/src/module/api.ts
thanaParis Mar 15, 2024
8ea12bb
Update 03_Modules/EVDriver/src/module/api.ts
thanaParis Mar 15, 2024
b579354
adding bugfixes found during plugfest testing
thanaParis Mar 15, 2024
9a8f2aa
adding improvements to example configs to swarm
thanaParis Mar 15, 2024
56365c0
adding NotImplemented error code where appropriate
thanaParis Mar 15, 2024
ba22963
Merge branch 'feature/adding-default-message-handling' of https://git…
thanaParis Mar 15, 2024
c50b61d
Merge pull request #50 from citrineos/feature/adding-default-message-…
thanaParis Mar 15, 2024
76a9f41
Merge pull request #51 from citrineos/bugfix/plugfests
thanaParis Mar 15, 2024
3bfe1f5
refactor to support 'network connection' interface, abstracting away …
thanaParis Mar 15, 2024
e39e3d8
adding OcppMessageRouter to export
thanaParis Mar 15, 2024
fbae81c
Adding a central system module
thanaParis Mar 16, 2024
f0a18c3
moving network connection interface into base, removing unusued clien…
thanaParis Mar 17, 2024
579daf5
moving IAuthenticator to base, updating central system code in swarm
thanaParis Mar 17, 2024
bf64a16
fixing conflicts from catching up to network-connection-refactor bran…
thanaParis Mar 17, 2024
7a72dd4
feat advanced device management
lydiazcheng Mar 18, 2024
6b9afea
Refactoring CentralSystem as a module in order to support an api
thanaParis Mar 18, 2024
204f522
Merge pull request #52 from citrineos/feat/advanced-dm
thanaParis Mar 18, 2024
e61d92d
feature: allow turning off log colors for log collectors like cloudwa…
ChrisWeissmann Mar 19, 2024
9b7f87c
feat:check request size
lydiazcheng Mar 19, 2024
ca54089
PR #53 feedback small changes
thanaParis Mar 19, 2024
bee5e07
Merge pull request #54 from citrineos/fix/disable-logging-colors-for-…
thanaParis Mar 19, 2024
7c53c92
Merge pull request #55 from citrineos/feat/request-size-check
thanaParis Mar 19, 2024
df3e56d
directus config added
thanaParis Mar 19, 2024
239792e
Update 03_Modules/CentralSystem/package.json
thanaParis Mar 20, 2024
9022299
adding directus util for exporting message api flows
thanaParis Mar 20, 2024
c497579
removed linter issues, added directus flow initialization to Server code
thanaParis Mar 20, 2024
18306c4
adding directus username and password to config via env vars
thanaParis Mar 20, 2024
6998e3c
bug with camel case system config fields circumvented with lowercase
thanaParis Mar 20, 2024
51ad537
adding logic for using static token or no auth depending on config
thanaParis Mar 20, 2024
186ff99
improving logging statements
thanaParis Mar 20, 2024
a40a3a6
Improving log placement
thanaParis Mar 20, 2024
5e43484
adding directus message flow support to swarm
thanaParis Mar 20, 2024
da8f266
fix: align engine node version with docs and 01_Data
ChrisWeissmann Mar 21, 2024
d34c196
feature: add a workflow that builds and pushes the server docker imag…
ChrisWeissmann Mar 21, 2024
0cb98cf
feature: add a workflow that runs a build without pushing when a PR i…
ChrisWeissmann Mar 21, 2024
faf9d2d
pr feedback--better comment, removing problematic defaults for direct…
thanaParis Mar 21, 2024
6459944
improved logging and variable management in directus hook
thanaParis Mar 21, 2024
6c87504
improved comment
thanaParis Mar 21, 2024
d105a6c
Merge pull request #58 from citrineos/fix/consistent-node-version
thanaParis Mar 21, 2024
53313f4
Update Swarm/src/index.ts
thanaParis Mar 21, 2024
33e332f
fix: only trigger for a version tag push and set higher version of bu…
ChrisWeissmann Mar 21, 2024
1a0d342
Removing INetworkConnection, combining IMessageRouter and ICentralSystem
thanaParis Mar 21, 2024
65efa3b
adjusting swarm for new class structure
thanaParis Mar 21, 2024
50bd9fa
Merging in changes to network connection class structure
thanaParis Mar 21, 2024
29dac17
adding admin api to swarm
thanaParis Mar 21, 2024
c356fe3
fix: add in no cache to avoid npm issues with the tarballs
ChrisWeissmann Mar 21, 2024
b74ed7a
fix: PR sanity build job with correct path
ChrisWeissmann Mar 21, 2024
dd9338f
fix: Upgrade setup build action due to deprication notice
ChrisWeissmann Mar 21, 2024
84ade62
Update Server/src/index.ts
thanaParis Mar 22, 2024
4854cf4
adding ocpp router to unix install scripts, updating comments to refe…
thanaParis Mar 22, 2024
e1aa10d
Merge pull request #59 from citrineos/feature/add-docker-image-releas…
thanaParis Mar 22, 2024
265ff4b
Merge pull request #56 from citrineos/feature/network-connection-refa…
thanaParis Mar 22, 2024
dfe1099
merged updated rc-1.1.0
thanaParis Mar 22, 2024
4668729
adding Location and ChargingStation entities
thanaParis Mar 22, 2024
d164bc8
expanded authenticator to handle unknown/known chargers and duplicate…
thanaParis Mar 22, 2024
b548e53
added missing relation (Locations have one or more Charging Stations;…
thanaParis Mar 22, 2024
6097fcc
adding locations repository impl
thanaParis Mar 22, 2024
46af30f
adding interfaces for locations repo, exporting interface
thanaParis Mar 22, 2024
f52931f
added missing @Column annotation, added custom Directus endpoint
thanaParis Mar 23, 2024
2529c0c
Merge branch 'feature/admin-api' into feature/evse-connection-status
thanaParis Mar 23, 2024
d05a6c1
adding total true count to show how many stations are connected at a …
thanaParis Mar 24, 2024
ac5ba52
Merge pull request #62 from citrineos/feature/admin-api
thanaParis Mar 25, 2024
5666a8e
Merge pull request #60 from citrineos/feature/adding-locations
thanaParis Mar 25, 2024
9e01012
Merge pull request #61 from citrineos/feature/authenticate-unknown-an…
thanaParis Mar 25, 2024
ba5e992
resolved conflict in import statments
thanaParis Mar 25, 2024
2e8fd42
Merge branch 'rc-1.1.0' into feature/evse-connection-status
thanaParis Mar 25, 2024
30d90e7
setting up new preseeded db for release
thanaParis Mar 25, 2024
b9f197d
Forcing addition of dist/index.js for directus extension so that it c…
thanaParis Mar 25, 2024
c6148b3
Merge pull request #57 from citrineos/feature/directus-message-api-flows
thanaParis Mar 26, 2024
3d58a19
advanced ui display message
lydiazcheng Mar 26, 2024
81af830
feat: reverting changes back by moving docker files into Server and r…
Mar 27, 2024
e67f5aa
Merge branch 'rc-1.1.0' into feature/workspaces
Mar 27, 2024
2ff16ae
directus extension completed, bundled, and added to root
thanaParis Mar 27, 2024
c4edd52
Persistent Subscription model database added
thanaParis Mar 28, 2024
c5e34cb
extending admin api to account for necessary crud operations
thanaParis Mar 28, 2024
bb122c7
advanced-ui left part
lydiazcheng Mar 29, 2024
d1a2032
advanced ui: fixes
lydiazcheng Mar 29, 2024
a42abd7
added better description to SubscriptionRepository.create after fixin…
thanaParis Mar 29, 2024
7ce4a6d
fixed comment typo
thanaParis Mar 29, 2024
2f82fb7
feat: adding latest changes for ocpp router and addressing PR comments
Mar 29, 2024
a2307df
chore: fix path
Mar 29, 2024
2d7c15d
adding config.js to directus to provide more complex values to enviro…
thanaParis Mar 29, 2024
92ab626
advanced ui: optimize get total kwh
lydiazcheng Mar 29, 2024
a35aabd
advanced ui: fix failed build
lydiazcheng Apr 1, 2024
a9f6166
fixed naming inconsistency
thanaParis Apr 2, 2024
2c73f88
added comment explaining issue with persistent subscriptions and hori…
thanaParis Apr 2, 2024
05daa49
making tsconfig for directus extension match the rest of the repository.
thanaParis Apr 2, 2024
0e96089
Merge pull request #66 from citrineos/feature/persistent-admin-api
thanaParis Apr 2, 2024
c1c2d5e
Merge branch 'rc-1.1.0' into feature/station-connection-status
thanaParis Apr 2, 2024
28c4d44
moving files in order to rename top level folder to 'DirectusExtensions'
thanaParis Apr 2, 2024
5c7e4e5
advanced ui: fix according to feedback
lydiazcheng Apr 3, 2024
768b81b
Merge branch 'rc-1.1.0' into feature/advanced-ui
lydiazcheng Apr 3, 2024
0ed0a57
advanced ui: add costUpdatedInterval in other config envs
lydiazcheng Apr 3, 2024
7d9f458
Merge pull request #65 from citrineos/feature/advanced-ui
thanaParis Apr 3, 2024
3e38dec
doc: fix readme path to run via docker
Apr 3, 2024
0a14dcc
fixing message api flows to work with new charging station object
thanaParis Apr 3, 2024
b8a62a8
adding missing @Column annotation
thanaParis Apr 3, 2024
8292bb9
updating postgis image to new preseeded image
thanaParis Apr 3, 2024
ecbafdd
chore: removing intellij run configurations
Apr 3, 2024
e0a21d4
chore: reverting swarm changes
Apr 3, 2024
651e773
merging paths
thanaParis Apr 4, 2024
b25cc67
fixing references to data objects in import statements
thanaParis Apr 4, 2024
980da6d
Merge pull request #63 from citrineos/feature/workspaces
thanaParis Apr 4, 2024
a354a56
Merge pull request #69 from citrineos/bugfix/misc-directus
thanaParis Apr 4, 2024
e340c80
Merge branch 'rc-1.1.0' into feature/station-connection-status
thanaParis Apr 4, 2024
6eae968
fixing directus extension bundle to be built inside dockerfile
thanaParis Apr 4, 2024
f271246
fixing issue with building directus bundle in dockerfile, added healt…
thanaParis Apr 5, 2024
265b229
Update DirectusExtensions/charging-stations-bundle/src/display-true-c…
thanaParis Apr 5, 2024
c9ae76f
merged paths
thanaParis Apr 5, 2024
1f4c7a7
Merge branch 'feature/station-connection-status' of https://github.co…
thanaParis Apr 5, 2024
ee83718
Merge pull request #64 from citrineos/feature/station-connection-status
thanaParis Apr 5, 2024
b26773c
merged paths
thanaParis Apr 5, 2024
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
45 changes: 45 additions & 0 deletions .github/workflows/push-release-tagged-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Push Release Tagged Server

on:
push:
tags:
- "v[0-9]+.[0-9]+.[0-9]+"

env:
IMAGE_NAME: citrineos-server

jobs:
build-and-push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build image
run: docker build . --file ./Server/docker/Dockerfile --tag $IMAGE_NAME

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/${IMAGE_NAME}
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')

VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
VERSION=$(echo $VERSION | sed -e 's/^v//')
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION

docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
20 changes: 20 additions & 0 deletions .github/workflows/test-build-server.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Build Server on Pull Request

on:
pull_request:

env:
IMAGE_NAME: citrineos-server

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Build image
run: docker build . --file ./Server/deploy.Dockerfile --tag $IMAGE_NAME
100 changes: 99 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ dist
# TernJS port file
.tern-port

# Stores VSCode configurations
.vscode

# Stores VSCode versions used for testing VSCode extensions
.vscode-test

Expand Down Expand Up @@ -204,4 +207,99 @@ package-lock.json

# PostgreSQL
/Server/data/postgresql
/Swarm/data/postgresql
/Swarm/data/postgresql

# Created by https://www.toptal.com/developers/gitignore/api/intellij+all
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij+all

### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.

.idea/*

#!.idea/codeStyles // todo potentially comment back in when vscode and intellij configs are supported
#!.idea/runConfigurations // todo potentially comment back in when vscode and intellij configs are supported

# End of https://www.toptal.com/developers/gitignore/api/intellij+all

data
15 changes: 8 additions & 7 deletions 00_Base/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
"name": "@citrineos/base",
"version": "1.0.0",
"description": "The base module for OCPP v2.0.1 including all interfaces. This module is not intended to be used directly, but rather as a dependency for other modules.",
"main": "lib/index.js",
"types": "lib/index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"lib"
"dist"
],
"scripts": {
"prepublish": "npx eslint ./src",
"prepare": "npm run build",
"build": "tsc",
"generate-interfaces": "node json-schema-processor.js",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"compile": "npm run clean && tsc -p tsconfig.json",
"clean": "rm -rf package-lock.json dist node_modules tsconfig.tsbuildinfo"
},
"keywords": [
"ocpp",
Expand All @@ -37,5 +37,6 @@
"tslog": "^4.9.2",
"uuid": "^9.0.0",
"zod": "^3.22.2"
}
},
"workspace": "../"
}
11 changes: 10 additions & 1 deletion 00_Base/src/config/BootConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,13 @@ export interface BootConfig {
* Also declared in SystemConfig. If absent, SystemConfig value is used.
*/
bootWithRejectedVariables?: boolean;
}
}

/**
* Cache boot status is used to keep track of the overall boot process for Rejected or Pending.
* When Accepting a boot, blacklist needs to be cleared if and only if there was a previously
* Rejected or Pending boot. When starting to configure charger, i.e. sending GetBaseReport or
* SetVariables, this should only be done if configuring is not still ongoing from a previous
* BootNotificationRequest. Cache boot status mediates this behavior.
*/
export const BOOT_STATUS = "boot_status";
97 changes: 85 additions & 12 deletions 00_Base/src/config/defineConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,93 @@
//
// SPDX-License-Identifier: Apache 2.0

import { type SystemConfig, systemConfigSchema, SystemConfigInput } from "./types";
import {type SystemConfig, SystemConfigInput, systemConfigSchema} from "./types";

/**
* Defines the application configuration by merging input configuration which is defined in a file with environment variables.
* Takes environment variables over predefined
* @param inputConfig The file defined input configuration.
* @returns The final system configuration.
* @throws Error if required environment variables are not set or if there are parsing errors.
*/
export function defineConfig(inputConfig: SystemConfigInput): SystemConfig {
if (!inputConfig.data.sequelize.username) {
if (process.env.CITRINEOS_DB_USERNAME)
inputConfig.data.sequelize.username = process.env.CITRINEOS_DB_USERNAME;
else
throw new Error('CITRINEOS_DB_USERNAME must be set if username not provided in config');
const appConfig = mergeConfigFromEnvVars<SystemConfigInput>(inputConfig, process.env);

validateFinalConfig(appConfig);

return systemConfigSchema.parse(appConfig);
}

/**
* Finds a case-insensitive match for a key in an object.
* @param obj The object to search.
* @param targetKey The target key.
* @returns The matching key or undefined.
*/
function findCaseInsensitiveMatch<T>(obj: Record<string, T>, targetKey: string): string | undefined {
const lowerTargetKey = targetKey.toLowerCase();
return Object.keys(obj).find(key => key.toLowerCase() === lowerTargetKey);
}

/**
* Merges configuration from environment variables into the default configuration. Allows any to keep it as generic as possible.
* @param defaultConfig The default configuration.
* @param envVars The environment variables.
* @returns The merged configuration.
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function mergeConfigFromEnvVars<T extends Record<string, any>>(defaultConfig: T, envVars: NodeJS.ProcessEnv): T {
const config: T = {...defaultConfig};

const prefix = "citrineos_";

for (const [fullEnvKey, value] of Object.entries(envVars)) {
if (!value) continue;
const lowercaseEnvKey = fullEnvKey.toLowerCase();
console.log(lowercaseEnvKey);
if (lowercaseEnvKey.startsWith(prefix)) {
const envKeyWithoutPrefix = lowercaseEnvKey.substring(prefix.length);
const path = envKeyWithoutPrefix.split('_');

// eslint-disable-next-line @typescript-eslint/no-explicit-any
let currentConfigPart: any = config;

for (let i = 0; i < path.length - 1; i++) {
const part = path[i];
const matchingKey = findCaseInsensitiveMatch(currentConfigPart, part);
if (matchingKey && typeof currentConfigPart[matchingKey] === 'object') {
currentConfigPart = currentConfigPart[matchingKey];
} else {
currentConfigPart[part] = {};
currentConfigPart = currentConfigPart[part];
}
}

const finalPart = path[path.length - 1];
const keyToUse = findCaseInsensitiveMatch(currentConfigPart, finalPart) || finalPart;

try {
currentConfigPart[keyToUse] = JSON.parse(value as string);
} catch {
console.error(`Error parsing value '${value}' for environment variable '${fullEnvKey}'.`);
currentConfigPart[keyToUse] = value;
}
}
}
return config as T;
}


/**
* Validates the system configuration to ensure required properties are set.
* @param finalConfig The final system configuration.
* @throws Error if required properties are not set.
*/
function validateFinalConfig(finalConfig: SystemConfigInput) {
if (!finalConfig.data.sequelize.username) {
throw new Error('CITRINEOS_DATA_SEQUELIZE_USERNAME must be set if username not provided in config');
}
if (!inputConfig.data.sequelize.password) {
if (process.env.CITRINEOS_DB_PASSWORD)
inputConfig.data.sequelize.password = process.env.CITRINEOS_DB_PASSWORD;
else
throw new Error('CITRINEOS_DB_PASSWORD must be set if password not provided in config');
if (!finalConfig.data.sequelize.password) {
throw new Error('CITRINEOS_DATA_SEQUELIZE_PASSWORD must be set if password not provided in config');
}
return systemConfigSchema.parse(inputConfig);
}
Loading