Skip to content

Commit 69dc5e6

Browse files
committed
Initial public release — squashed import from oldrepo@40687d9 (2025-09-09 11:28:40 +0200)
0 parents  commit 69dc5e6

File tree

662 files changed

+106212
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

662 files changed

+106212
-0
lines changed

.github/prompt.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Project Prompt Kainos Core
2+
3+
## Overview
4+
This monorepo contains multiple design system packages, a core deployable Express application, and cloud-native Lambda functions. It supports dynamic selection of design systems and cloud providers (AWS/Azure), with modular architecture and strong TypeScript usage.
5+
6+
## Structure
7+
- **AccelerateDeployable/**: Contains environment configuration
8+
- **CoreDeployable/**: Main Express app with modular architecture
9+
- Entry point: `src/index.ts` (exports `createApp`)
10+
- `src/config/`: Environment and Express configuration
11+
- `src/container/`: Cloud services factory for AWS/Azure abstraction
12+
- `src/middlewares/`: Authentication, SSO, and permissions middleware
13+
- `src/services/`: Cloud provider implementations (AWS/Azure)
14+
- `src/utils/`: Design system utilities and cloud provider abstractions
15+
- `src/interfaces/`: TypeScript interface definitions
16+
- `schemas/`: JSON schemas for form components and validation
17+
- `services/`: Service configuration files (JSON)
18+
- **CoreFCADS, CoreGCDS, CoreGovUK, CoreNhsUK, CoreOUDS, CoreWDS, CoreRuntime/**: Each is a design system or runtime package with its own `package.json`, `tsconfig.json`, `src/`, and `lib/`.
19+
- **CoreKfdApi/**: Serverless app with functions for file operations
20+
- **utils/**: Utility scripts for file and folder operations
21+
- **pipeline_scripts/**: Shell scripts for deployment and build automation
22+
23+
## Key Patterns
24+
- **Modular Architecture**: `CoreDeployable` now has a well-organized structure with separate folders for config, container, middlewares, services, and utilities
25+
- **Renderer Selection**: `createApp` dynamically chooses a renderer (e.g., FCADSRenderer, GCDSRenderer) based on `context.service.designSystem` via `rendererFunc` in `utils/designSystemUtils.ts`
26+
- **Static Paths**: Local static paths are aggregated from each design system if `useLocalStaticPaths` is true, managed through `getStaticPaths` utility
27+
- **Cloud Provider Abstraction**: Supports AWS and Azure via dependency injection container in `container/CloudServicesContainer.ts`
28+
- AWS: `AwsFileService`, `AwsDynamoDbStore`, `AwsBucketService`
29+
- Azure: `AzureFileService`, `AzureCosmosDbStore`, `AzureStorageService`
30+
- **Middleware Stack**:
31+
- `middlewares/authMiddleware.ts`: Authentication middleware
32+
- `middlewares/ssoHandler.ts`: SSO/SAML authentication with Passport
33+
- `middlewares/permissionsPolicy.ts`: Custom permissions policies
34+
- Helmet for security, Express session management
35+
- **Configuration Management**:
36+
- `config/envConfig.ts`: Environment-based configuration
37+
- `config/expressConfiguration.ts`: Express app setup and security headers
38+
- **Schema-Driven**: JSON schemas in `schemas/` for form components and validation
39+
- **TypeScript**: Strong typing throughout, with type definitions and config files
40+
- **Serverless Functions**: Lambda functions for file operations (upload/delete)
41+
42+
## Extending/Integrating
43+
- **Add new design systems**: Create a package and update renderer logic in `CoreDeployable/src/utils/designSystemUtils.ts` (both `rendererMap` and static path functions)
44+
- **Add new cloud providers**: Implement file and store services in `CoreDeployable/src/services/`, then update `container/CloudServicesContainer.ts`
45+
- **Extend middleware**: Add custom middleware in `CoreDeployable/src/middlewares/` and integrate in `config/expressConfiguration.ts`
46+
- **Add new schemas**: Create JSON schemas in `CoreDeployable/schemas/` for new form components
47+
- **Serverless KFD functions**: Add new functions following the pattern in `CoreKfdApi/*` directories
48+
- **Environment configuration**: Update `config/envConfig.ts` and corresponding `.env` files
49+
50+
## Useful Entry Points
51+
- `CoreDeployable/src/index.ts`: Main app logic and configuration entry point
52+
- `CoreDeployable/src/config/`: Environment configuration and Express setup
53+
- `CoreDeployable/src/container/CloudServicesContainer.ts`: Cloud provider dependency injection container
54+
- `CoreDeployable/src/utils/designSystemUtils.ts`: Design system selection and static paths
55+
- `CoreDeployable/src/middlewares/`: Authentication, SSO, and security middleware
56+
- `CoreDeployable/src/interfaces/`: TypeScript interface definitions
57+
- `CoreDeployable/schemas/`: JSON schemas for form components
58+
- `CoreKfdApi/`: Serverless app with functions for file operations
59+
- `pipeline_scripts/`: Deployment and build automation
60+
- `utils/`: File/folder utilities
61+
62+
---
63+
This file is intended to help contributors and AI assistants quickly understand the architecture and integration points of the project.
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
name: Deploy Kainoscore to Dev
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
9+
env:
10+
AWS_REGION: eu-west-2
11+
DEPLOYMENT_ROLE: arn:aws:iam::975050265283:role/GHA-CodeBuild-Service-Role
12+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13+
14+
permissions:
15+
id-token: write
16+
contents: write
17+
18+
jobs:
19+
deploy:
20+
name: Deploy
21+
runs-on: ubuntu-latest
22+
environment: Dev
23+
outputs:
24+
version: ${{ steps.semver.outputs.version }}
25+
26+
steps:
27+
- name: Checkout
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 0
31+
32+
- name: Set up Node.js
33+
uses: actions/setup-node@v3
34+
with:
35+
node-version: '23'
36+
37+
- name: Generate semantic version
38+
id: semver
39+
run: |
40+
npm install -g semantic-release @semantic-release/git @semantic-release/changelog @semantic-release/exec conventional-changelog-conventionalcommits
41+
42+
cat <<EOF > .releaserc.json
43+
{
44+
"branches": ["main"],
45+
"plugins": [
46+
["@semantic-release/commit-analyzer", {
47+
"preset": "conventionalcommits",
48+
"releaseRules": [
49+
{"type": "feat", "release": "minor"},
50+
{"type": "fix", "release": "patch"},
51+
{"type": "docs", "release": "patch"},
52+
{"type": "chore", "release": "patch"},
53+
{"type": "refactor", "release": "patch"},
54+
{"type": "test", "release": "patch"}
55+
]
56+
}],
57+
"@semantic-release/release-notes-generator",
58+
["@semantic-release/exec", {
59+
"successCmd": "echo \\"SEMANTIC_VERSION=\${nextRelease.version}\\" >> \\$GITHUB_ENV"
60+
}]
61+
]
62+
}
63+
EOF
64+
65+
echo "Running semantic-release dry-run to calculate next version..."
66+
semantic-release --dry-run
67+
68+
if [ -z "$SEMANTIC_VERSION" ]; then
69+
echo "No version bump from semantic-release, calculating manual increment..."
70+
# Get latest tag, default to v1.0.0 if none exists
71+
LATEST_TAG=$(git describe --tags --abbrev=0 2>/dev/null || echo "v1.9.0")
72+
echo "Latest tag: $LATEST_TAG"
73+
74+
# Extract version components
75+
VERSION=${LATEST_TAG#v}
76+
IFS='.' read -r MAJOR MINOR PATCH <<< "$VERSION"
77+
78+
# Determine increment based on commit messages since last tag
79+
COMMIT_MSG=$(git log -1 --pretty=%B)
80+
if echo "$COMMIT_MSG" | grep -q "^BREAKING CHANGE:" || echo "$COMMIT_MSG" | grep -q "^[a-zA-Z]\+!:"; then
81+
# Major version bump for breaking changes
82+
echo "Breaking change detected, bumping major version"
83+
MAJOR=$((MAJOR + 1))
84+
MINOR=0
85+
PATCH=0
86+
elif echo "$COMMIT_MSG" | grep -q "^feat"; then
87+
# Minor version bump for features
88+
echo "Feature detected, bumping minor version"
89+
MINOR=$((MINOR + 1))
90+
PATCH=0
91+
else
92+
# Patch version bump for everything else
93+
echo "Fix/chore detected, bumping patch version"
94+
PATCH=$((PATCH + 1))
95+
fi
96+
97+
SEMANTIC_VERSION="$MAJOR.$MINOR.$PATCH"
98+
echo "Calculated version: $SEMANTIC_VERSION"
99+
echo "SEMANTIC_VERSION=$SEMANTIC_VERSION" >> $GITHUB_ENV
100+
fi
101+
102+
echo "Final semantic version: $SEMANTIC_VERSION"
103+
echo "version=$SEMANTIC_VERSION" >> $GITHUB_OUTPUT
104+
105+
- name: Configure AWS credentials via OIDC
106+
uses: aws-actions/[email protected]
107+
with:
108+
role-to-assume: ${{ env.DEPLOYMENT_ROLE }}
109+
aws-region: ${{ env.AWS_REGION }}
110+
111+
- name: Install Typescript and dependencies
112+
run: |
113+
npm install -g typescript
114+
115+
- name: Get Dependency Versions
116+
run: |
117+
echo "NODE.JS version:"
118+
node -v
119+
120+
echo "NPM version:"
121+
npm -v
122+
123+
echo "AWS CLI version:"
124+
aws --version
125+
126+
- name: Application Deployment
127+
id: build-deploy
128+
run: |
129+
echo "Deploying application..."
130+
# make files executable
131+
chmod +x ./pipeline_scripts/application_deploy.sh
132+
chmod +x ./pipeline_scripts/build_core_kfd_api_application.sh
133+
chmod +x ./pipeline_scripts/upload-zip-files.sh
134+
chmod +x ./pipeline_scripts/update-lambda-functions.sh
135+
136+
# Set environment variables directly in this step
137+
export ENVIRONMENT=dev
138+
export SEMANTIC_VERSION=${{ steps.semver.outputs.version }}
139+
140+
# For debugging
141+
echo "Setting ENVIRONMENT=$ENVIRONMENT"
142+
echo "Setting SEMANTIC_VERSION=$SEMANTIC_VERSION"
143+
144+
# run the deployment scripts with version parameter
145+
echo "Running application deployment script...."
146+
./pipeline_scripts/application_deploy.sh "${{ steps.semver.outputs.version }}"
147+
echo "Running KFD api scripts...."
148+
./pipeline_scripts/build_core_kfd_api_application.sh "${{ steps.semver.outputs.version }}"
149+
echo "Running upload-zip-files script...."
150+
./pipeline_scripts/upload-zip-files.sh "${{ steps.semver.outputs.version }}"
151+
echo "Running update-lambda-functions script...."
152+
./pipeline_scripts/update-lambda-functions.sh "${{ steps.semver.outputs.version }}"
153+
154+
# Also add to GITHUB_ENV for subsequent steps
155+
echo "ENVIRONMENT=dev" >> $GITHUB_ENV
156+
echo "SEMANTIC_VERSION=${{ steps.semver.outputs.version }}" >> $GITHUB_ENV
157+
158+
echo "Deployment completed successfully."
159+
160+
- name: Create Git tag
161+
if: success()
162+
run: |
163+
git config user.name "github-actions"
164+
git config user.email "[email protected]"
165+
166+
SEMANTIC_VERSION="${{ steps.semver.outputs.version }}"
167+
if [ -z "$SEMANTIC_VERSION" ]; then
168+
echo "Using version from environment: $SEMANTIC_VERSION"
169+
fi
170+
171+
# Check if tag already exists
172+
if git rev-parse "v$SEMANTIC_VERSION" >/dev/null 2>&1; then
173+
echo "Tag v$SEMANTIC_VERSION already exists. Skipping tag creation."
174+
else
175+
echo "Creating new tag v$SEMANTIC_VERSION"
176+
git tag "v$SEMANTIC_VERSION"
177+
git push https://x-access-token:${GITHUB_TOKEN}@github.com/${{ github.repository }}.git "v$SEMANTIC_VERSION"
178+
fi
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
name: Deploy Kainoscore to Staging
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
version:
7+
description: 'Version to deploy to staging (e.g. 1.10.1)'
8+
required: true
9+
10+
env:
11+
AWS_REGION: eu-west-2
12+
DEPLOYMENT_ROLE: arn:aws:iam::975050265283:role/GHA-CodeBuild-Service-Role
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
ENVIRONMENT: staging
15+
16+
permissions:
17+
id-token: write
18+
contents: write
19+
20+
jobs:
21+
deploy:
22+
name: Deploy to Staging
23+
runs-on: ubuntu-latest
24+
environment: Staging
25+
outputs:
26+
version: ${{ github.event.inputs.version }}
27+
28+
steps:
29+
- name: Checkout
30+
uses: actions/checkout@v4
31+
32+
- name: Configure AWS credentials via OIDC
33+
uses: aws-actions/[email protected]
34+
with:
35+
role-to-assume: ${{ env.DEPLOYMENT_ROLE }}
36+
aws-region: ${{ env.AWS_REGION }}
37+
38+
- name: Install Required Tools
39+
run: |
40+
npm install -g typescript
41+
echo "NODE.JS version: $(node -v)"
42+
echo "NPM version: $(npm -v)"
43+
echo "AWS CLI version: $(aws --version)"
44+
45+
- name: Prepare Scripts
46+
run: |
47+
# Make sure the script file exists before making it executable
48+
if [ ! -f "./pipeline_scripts/deploy-to-staging.sh" ]; then
49+
echo "ERROR: deploy-to-staging.sh not found in pipeline_scripts directory"
50+
ls -la ./pipeline_scripts/
51+
exit 1
52+
fi
53+
54+
chmod +x ./pipeline_scripts/deploy-to-staging.sh
55+
chmod +x ./pipeline_scripts/update-lambda-functions.sh
56+
chmod +x ./pipeline_scripts/functions.sh
57+
chmod +x ./pipeline_scripts/deploy-static-files-staging.sh
58+
ls -la ./pipeline_scripts/
59+
60+
- name: Copy Artifacts and Deploy to Staging
61+
run: |
62+
echo "Starting staging deployment for version ${{ github.event.inputs.version }}"
63+
./pipeline_scripts/deploy-to-staging.sh "${{ github.event.inputs.version }}"
64+
./pipeline_scripts/deploy-static-files-staging.sh "${{ github.event.inputs.version }}"
65+
66+
- name: Deployment Summary
67+
run: |
68+
echo "✅ Successfully deployed version v${{ github.event.inputs.version }} to staging"
69+
echo " • Deployment Time: $(date -u +"%Y-%m-%d %H:%M:%S UTC")"
70+
echo " • Deployed by: ${{ github.actor }}"
71+
72+
# Create an artifact with deployment details for tracking
73+
mkdir -p deployment-info
74+
cat > deployment-info/staging-deployment.txt << EOF
75+
Version: v${{ github.event.inputs.version }}
76+
Time: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
77+
Actor: ${{ github.actor }}
78+
Workflow Run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
79+
EOF
80+
81+
- name: Upload Deployment Info
82+
uses: actions/[email protected]
83+
with:
84+
name: staging-deployment-v${{ github.event.inputs.version }}-${{ github.run_id }}
85+
path: deployment-info
86+
retention-days: 90
87+
88+
create-release:
89+
name: Create GitHub Release
90+
runs-on: ubuntu-latest
91+
needs: deploy
92+
permissions:
93+
contents: write
94+
95+
steps:
96+
- name: Checkout
97+
uses: actions/checkout@v4
98+
with:
99+
fetch-depth: 0
100+
101+
- name: Generate release notes
102+
id: release-notes
103+
run: |
104+
echo "Generating release notes for v${{ needs.deploy.outputs.version }}"
105+
106+
# Extract commits since last release
107+
git fetch --tags
108+
PREV_TAG=$(git describe --tags --abbrev=0 --match "v*" 2>/dev/null || echo "none")
109+
110+
if [ "$PREV_TAG" == "none" ]; then
111+
COMMITS=$(git log --pretty=format:"- %s (%h)" -10)
112+
else
113+
COMMITS=$(git log --pretty=format:"- %s (%h)" ${PREV_TAG}..HEAD)
114+
fi
115+
116+
# Create release notes file
117+
cat > release-notes.md << EOF
118+
# Release v${{ needs.deploy.outputs.version }}
119+
120+
## What's Changed
121+
${COMMITS}
122+
123+
## Deployment Information
124+
- Deployed to: Staging
125+
- Deployment time: $(date -u +"%Y-%m-%d %H:%M:%S UTC")
126+
- Workflow run: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
127+
EOF
128+
129+
cat release-notes.md
130+
131+
- name: Create GitHub Release
132+
uses: softprops/[email protected]
133+
with:
134+
name: "v${{ needs.deploy.outputs.version }} (Staging)"
135+
tag_name: "v${{ needs.deploy.outputs.version }}"
136+
body_path: release-notes.md
137+
draft: false
138+
prerelease: true
139+
token: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)