Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 5 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ clean:: # Clean-up project resources (main) @Operations
# (cd src/server && make clean)

guard-%:
@ if [ "${${*}}" = "" ]; then \
@if [ -z "$${$*}" ]; then \
echo "Variable $* not set"; \
echo "Usage: make <target> APIM_ENV=<env>"
echo "Usage: make <target> $*=<env>"; \
exit 1; \
fi
serve:
Expand All @@ -59,6 +59,9 @@ set-security: guard-APIM_ENV
@ SECURITY=security-$$APIM_ENV.yml \
envsubst '$${SECURITY}' \
< specification/api/components/security/security-template.yml > specification/api/components/security/security.yml
@ SECURITY_SCHEMES=security-schemes-$$APIM_ENV.yml \
envsubst '$${SECURITY_SCHEMES}' \
< specification/api/components/security-schemes/security-schemes-template.yml > specification/api/components/security-schemes/security-schemes.yml

construct-spec: guard-APIM_ENV
$(MAKE) set-target APIM_ENV=$$APIM_ENV
Expand Down
32 changes: 23 additions & 9 deletions internal/datastore/src/cli/diagrams.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
import {LetterSchema, MISchema, SupplierSchema} from '../types';
import { generateMermaidDiagram } from 'zod-mermaid';
import * as fs from 'node:fs';
import { generateMermaidDiagram } from "zod-mermaid";
import * as fs from "node:fs";
import {
LetterSchema,
MISchema,
SupplierSchema,
} from "internal/datastore/src/types";

const out = fs.openSync('src/types.md', 'w');
const out = fs.openSync("src/types.md", "w");

fs.writeSync(out, `# Data Store Schemas
fs.writeSync(
out,
`# Data Store Schemas

This document contains the mermaid diagrams for the data store schemas used in the application.

The schemas are generated from Zod definitions and provide a visual representation of the data structure.
`);
`,
);

for (const [name, schema] of Object.entries({ Letter: [LetterSchema], MI: [MISchema], Supplier: [SupplierSchema] })) {
for (const [name, schema] of Object.entries({
Letter: [LetterSchema],
MI: [MISchema],
Supplier: [SupplierSchema],
})) {
const mermaid = generateMermaidDiagram(schema);
fs.writeSync(out, `
fs.writeSync(
out,
`
## ${name} schema

\`\`\`mermaid
${mermaid}
\`\`\`
`);
`,
);
}

fs.closeSync(out);
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$ref: './security-schemes-ptl.yml'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$ref: './security-schemes-ptl.yml'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$ref: './security-schemes-ptl.yml'
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
app-level3:
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/app-level3
app-level0:
$ref: https://proxygen.prod.api.platform.nhs.uk/components/securitySchemes/app-level0
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
app-level3:
$ref: https://proxygen.ptl.api.platform.nhs.uk/components/securitySchemes/app-level3
app-level0:
$ref: https://proxygen.ptl.api.platform.nhs.uk/components/securitySchemes/app-level0
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$ref: './security-schemes-ptl.yml'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$ref: './security-schemes-ptl.yml'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$ref: $SECURITY_SCHEMES
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$ref: security-schemes-prod.yml
5 changes: 1 addition & 4 deletions specification/api/notify-supplier-phase1.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,7 @@ paths:
summary: Health check
components:
securitySchemes:
app-level3:
$ref: https://proxygen.ptl.api.platform.nhs.uk/components/securitySchemes/app-level3
app-level0:
$ref: https://proxygen.ptl.api.platform.nhs.uk/components/securitySchemes/app-level0
$ref: ./components/security-schemes/security-schemes.yml

tags:
- name: letter
Expand Down