Skip to content
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
4bca3e4
Refactor datastore package
m-houston Oct 15, 2025
92fa9b6
Clean up tests
m-houston Oct 15, 2025
f1b7f63
Merge branch 'main' into feature/CCM-12352-refactor-helpers-and-datas…
m-houston Oct 17, 2025
cc79105
Make markdownlint config separate for specification docs
m-houston Oct 17, 2025
d977710
Update documentation for run functions
m-houston Oct 17, 2025
afaa067
Merge branch 'main' into feature/CCM-12352-refactor-helpers-and-datas…
m-houston Oct 21, 2025
3fa5a8f
Fixup after merging main
m-houston Oct 21, 2025
e3c8315
Merge branch 'main' into feature/CCM-12352-refactor-helpers-and-datas…
m-houston Oct 21, 2025
7c9a282
Merge branch 'refs/heads/main' into feature/CCM-12352-refactor-helper…
m-houston Oct 22, 2025
1313be5
Update after main merge
m-houston Oct 22, 2025
077a43a
Merge branch 'main' into feature/CCM-12352-refactor-helpers-and-datas…
m-houston Oct 27, 2025
7a6759b
Replace newly introduced cross-package reference
m-houston Oct 27, 2025
b9e18db
Remove generated README.md
m-houston Oct 27, 2025
b1a295f
Restore dataschema diagram generation
m-houston Oct 27, 2025
445f1f2
Add diagram for Supplier datastore schema
m-houston Oct 27, 2025
0563699
Merge branch 'main' into feature/CCM-12352-refactor-helpers-and-datas…
m-houston Oct 27, 2025
de6b428
Update package-lock conflicts
m-houston Oct 27, 2025
b8679a3
Merge branch 'main' into feature/CCM-12352-refactor-helpers-and-datas…
masl2 Oct 29, 2025
62f67c1
update lock
masl2 Oct 29, 2025
5b54f85
CCM-12352: single package lock
masl2 Oct 29, 2025
55baa29
Merge branch 'main' into feature/CCM-12352-refactor-helpers-and-datas…
masl2 Oct 29, 2025
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
11 changes: 11 additions & 0 deletions .markdownlint.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
// SEE: https://github.com/DavidAnson/markdownlint/blob/main/schema/.markdownlint.yaml
{
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md013.md
"MD013": false,
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md024.md
"MD024": {
"siblings_only": true
},
// https://github.com/DavidAnson/markdownlint/blob/main/doc/md033.md
"MD033": false
}
10 changes: 10 additions & 0 deletions .syncpackrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"versionGroups": [
{
"dependencies": ["@internal/**", "@nhsdigital/nhs-notify-event-schemas-supplier-api"],
"specifierTypes": ["*"],
"label": "Internal deps",
"isIgnored": true
}
]
}
5 changes: 5 additions & 0 deletions internal/datastore/jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export const baseJestConfig: Config = {
// Indicates which provider should be used to instrument code for coverage
coverageProvider: 'babel',

// Module name mapper to handle TypeScript path aliases
moduleNameMapper: {
'^@internal/helpers$': '<rootDir>/../helpers/src'
},

coverageThreshold: {
global: {
branches: 100,
Expand Down
9 changes: 5 additions & 4 deletions internal/datastore/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
"dependencies": {
"@aws-sdk/client-dynamodb": "^3.858.0",
"@aws-sdk/lib-dynamodb": "^3.858.0",
"@internal/helpers": "*",
"pino": "^9.7.0",
"zod": "^4.0.14"
"zod": "^4.1.11"
},
"devDependencies": {
"@stylistic/eslint-plugin": "^3.1.0",
Expand All @@ -18,15 +19,15 @@
"testcontainers": "^11.4.0",
"ts-jest": "^29.4.0",
"ts-node": "^10.9.2",
"typescript": "^5.8.2",
"typescript": "^5.8.3",
"zod-mermaid": "^1.0.9"
},
"license": "MIT",
"main": "src/index.ts",
"name": "datastore",
"name": "@internal/datastore",
"private": true,
"scripts": {
"diagrams": "ts-node src/cli/diagrams.ts",
"diagrams": "tsx src/cli/diagrams.ts",
"lint": "eslint .",
"lint:fix": "eslint . --fix",
"test:unit": "jest",
Expand Down
4 changes: 2 additions & 2 deletions internal/datastore/src/cli/diagrams.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { LetterSchema, MISchema } from '../types';
import {LetterSchema, MISchema, SupplierSchema} from '../types';
import { generateMermaidDiagram } from 'zod-mermaid';
import * as fs from 'node:fs';

Expand All @@ -11,7 +11,7 @@ This document contains the mermaid diagrams for the data store schemas used in t
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] })) {
for (const [name, schema] of Object.entries({ Letter: [LetterSchema], MI: [MISchema], Supplier: [SupplierSchema] })) {
const mermaid = generateMermaidDiagram(schema);
fs.writeSync(out, `
## ${name} schema
Expand Down
13 changes: 11 additions & 2 deletions internal/datastore/src/types.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ erDiagram
erDiagram
MI {
string id
string supplierId "ref: Supplier"
Comment thread
masl2 marked this conversation as resolved.
string supplierId
string specificationId
string groupId
string lineItem
Expand All @@ -40,7 +40,16 @@ erDiagram
string createdAt
string updatedAt
}
```

## Supplier schema

```mermaid
erDiagram
Supplier {
string id
string name
string apimId
string status "enum: ENABLED, DISABLED"
}
MI }o--|| Supplier : "supplierId"
```
6 changes: 3 additions & 3 deletions internal/datastore/src/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { z } from 'zod';
import { idRef } from 'zod-mermaid';
import { idRef } from '@internal/helpers';

export const SupplerStatus = z.enum(['ENABLED', 'DISABLED']);

Expand Down Expand Up @@ -29,7 +29,7 @@ export const LetterSchemaBase = z.object({
});

export const LetterSchema = LetterSchemaBase.extend({
supplierId: z.string(),
supplierId: idRef(SupplierSchema, 'id'),
url: z.url(),
createdAt: z.string(),
updatedAt: z.string(),
Expand All @@ -48,7 +48,7 @@ export type LetterBase = z.infer<typeof LetterSchemaBase>;

export const MISchema = z.object({
id: z.string(),
supplierId: idRef(SupplierSchema),
supplierId: idRef(SupplierSchema, 'id'),
specificationId: z.string(),
groupId: z.string(),
lineItem: z.string(),
Expand Down
6 changes: 2 additions & 4 deletions internal/datastore/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
{
"compilerOptions": {
"isolatedModules": true
},
"extends": "@tsconfig/node22/tsconfig.json",
"compilerOptions": {},
"extends": "../../tsconfig.base.json",
"include": [
"src/**/*",
"jest.config.ts"
Expand Down
24 changes: 24 additions & 0 deletions internal/helpers/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Dependency directories
node_modules/

# Built output
dist/

# Coverage directory used by tools like istanbul
coverage/

# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Editor directories and files
.idea/
.vscode/
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
15 changes: 15 additions & 0 deletions internal/helpers/jest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import type { Config } from "jest";

const config: Config = {
preset: "ts-jest",
testEnvironment: "node",
testMatch: ["**/src/__tests__/**/*.ts?(x)", "**/src/?(*.)+(spec|test).ts?(x)"],
collectCoverageFrom: ["src/**/*.ts"],
coveragePathIgnorePatterns: ["/node_modules/", "__tests__"],
testPathIgnorePatterns: ["/node_modules/", "/dist/"],
transform: {
"^.+\\.tsx?$": ["ts-jest", { }]
}
};

export default config;
Loading
Loading