Skip to content

Commit 25d1952

Browse files
committed
CCM-12352: add events for letter status changed
1 parent 4b769c4 commit 25d1952

Some content is hidden

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

49 files changed

+5093
-209
lines changed

.editorconfig

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,3 +67,6 @@ trim_trailing_whitespace = unset
6767
indent_style = unset
6868
indent_size = unset
6969
generated_code = true
70+
71+
[/internal/events/**/*.schema.json]
72+
insert_final_newline = unset

.syncpackrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"versionGroups": [
3+
{
4+
"dependencies": ["@internal/**", "@nhsdigital/nhs-notify-event-schemas-supplier-api"],
5+
"specifierTypes": ["*"],
6+
"label": "Internal deps",
7+
"isIgnored": true
8+
}
9+
]
10+
}

internal/datastore/jest.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@ export const baseJestConfig: Config = {
1515
// Indicates which provider should be used to instrument code for coverage
1616
coverageProvider: 'babel',
1717

18+
// Module name mapper to handle TypeScript path aliases
19+
moduleNameMapper: {
20+
'^@internal/helpers$': '<rootDir>/../helpers/src'
21+
},
22+
1823
coverageThreshold: {
1924
global: {
2025
branches: 100,

internal/datastore/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"@aws-sdk/lib-dynamodb": "^3.858.0",
55
"@internal/helpers": "*",
66
"pino": "^9.7.0",
7-
"zod": "^4.0.14"
7+
"zod": "^4.1.11"
88
},
99
"devDependencies": {
1010
"@stylistic/eslint-plugin": "^3.1.0",
@@ -19,7 +19,7 @@
1919
"testcontainers": "^11.4.0",
2020
"ts-jest": "^29.4.0",
2121
"ts-node": "^10.9.2",
22-
"typescript": "^5.8.2"
22+
"typescript": "^5.8.3"
2323
},
2424
"license": "MIT",
2525
"main": "src/index.ts",

internal/datastore/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export const LetterSchemaBase = z.object({
2929
});
3030

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

4949
export const MISchema = z.object({
5050
id: z.string(),
51-
supplierId: idRef(SupplierSchema),
51+
supplierId: idRef(SupplierSchema, 'id'),
5252
specificationId: z.string(),
5353
groupId: z.string(),
5454
lineItem: z.string(),

internal/events/.spectral.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
extends: ["spectral:oas", "spectral:asyncapi", "spectral:arazzo"]

internal/events/jest.config.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
export default {
2+
preset: "ts-jest",
3+
testEnvironment: "node",
4+
testMatch: ["**/__tests__/**/*.ts", "**/?(*.)+(spec|test).ts"],
5+
testPathIgnorePatterns: ["<rootDir>/dist/"],
6+
moduleFileExtensions: ["ts", "js", "json", "node"],
7+
transform: {
8+
"^.+\\.ts$": ["ts-jest", { tsconfig: "<rootDir>/tsconfig.jest.json" }],
9+
},
10+
};

internal/events/package.json

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
{
22
"dependencies": {
3+
"@asyncapi/bundler": "^0.6.4",
34
"@internal/helpers": "*",
4-
"zod": "^4.0.14"
5+
"zod": "^4.1.11"
56
},
67
"description": "Schemas for NHS Notify Supplier API events",
78
"devDependencies": {
9+
"@stoplight/spectral-cli": "^6.15.0",
810
"@stylistic/eslint-plugin": "^3.1.0",
911
"@tsconfig/node22": "^22.0.2",
1012
"@types/jest": "^29.5.14",
@@ -15,21 +17,33 @@
1517
"jest": "^29.7.0",
1618
"ts-jest": "^29.4.0",
1719
"ts-node": "^10.9.2",
18-
"typescript": "^5.8.2",
19-
"zod-mermaid": "^1.0.9"
20+
"typescript": "^5.8.3"
2021
},
2122
"license": "MIT",
2223
"main": "dist/index.js",
23-
"name": "nhs-notify-schemas-supplier-api",
24+
"name": "@nhsdigital/nhs-notify-event-schemas-supplier-api",
2425
"private": true,
26+
"publishConfig": {
27+
"registry": "https://npm.pkg.github.com"
28+
},
29+
"repository": "[email protected]:NHSDigital/nhs-notify-supplier-api.git",
2530
"scripts": {
2631
"build": "tsc",
27-
"generate-diagrams": "ts-node src/cli/generateDiagrams.ts",
28-
"lint": "eslint .",
32+
"dev": "ts-node src/index.ts",
33+
"gen:asyncapi": "mkdir -p ./dist/asyncapi && ts-node src/cli/bundle-asyncapi.ts",
34+
"gen:jsonschema": "ts-node src/cli/generate-json.ts",
35+
"lint": "npm run lint:node && npm run lint:schema",
2936
"lint:fix": "eslint . --fix",
37+
"lint:node": "eslint .",
38+
"lint:schema": "spectral lint client-config/client-config.yaml",
39+
"prebuild": "rm -rf dist && npm run gen:asyncapi",
40+
"pregen:asyncapi": "npm run gen:jsonschema",
41+
"pregen:jsonschema": "rm -rf ./client-config/json",
42+
"prelint:schema": "npm run gen:jsonschema",
43+
"start": "node dist/index.js",
3044
"test": "jest",
31-
"typecheck": "tsc --noEmit"
45+
"test:unit": "jest"
3246
},
3347
"types": "dist/index.d.ts",
34-
"version": "0.1.0"
48+
"version": "1.0.0"
3549
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
{
2+
"type": "object",
3+
"properties": {
4+
"domainId": {
5+
"type": "string"
6+
},
7+
"sourceSubject": {
8+
"type": "string"
9+
},
10+
"status": {
11+
"type": "string",
12+
"enum": [
13+
"PENDING",
14+
"ACCEPTED",
15+
"REJECTED",
16+
"PRINTED",
17+
"ENCLOSED",
18+
"CANCELLED",
19+
"DISPATCHED",
20+
"FAILED",
21+
"RETURNED",
22+
"DESTROYED",
23+
"FORWARDED",
24+
"DELIVERED"
25+
]
26+
},
27+
"reasonCode": {
28+
"type": "string"
29+
},
30+
"reasonText": {
31+
"type": "string"
32+
}
33+
},
34+
"required": [
35+
"domainId",
36+
"sourceSubject",
37+
"status"
38+
]
39+
}

0 commit comments

Comments
 (0)