Skip to content

Commit ae5cdd4

Browse files
authored
CCM-12352: letter-status event schemas (#197)
* Add event schemas for supplier-api domain * Update event naming and metadata based on review * Unify envelope with letter-rendering domain events using origin subject prefix * Add group and specification IDs to letter event domain model * Add group and specification IDs to letter event example * Fix missing domain in origin examples * Updates to envelope URIs and source/subject paths * Add more examples for different statuses * Fix linting config * Fix linting config * Add source field back to origin as this scopes the subject * Update package-lock conflicts * Regenerate schemas * Add empty test:unit script for tests package * CCM-12352: Remove unneeded README.md from events package
1 parent 90f9130 commit ae5cdd4

Some content is hidden

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

42 files changed

+10563
-2859
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

.github/workflows/stage-1-commit.yaml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,3 +199,95 @@ jobs:
199199
idp_aws_report_upload_region: "${{ secrets.IDP_AWS_REPORT_UPLOAD_REGION }}"
200200
idp_aws_report_upload_role_name: "${{ secrets.IDP_AWS_REPORT_UPLOAD_ROLE_NAME }}"
201201
idp_aws_report_upload_bucket_endpoint: "${{ secrets.IDP_AWS_REPORT_UPLOAD_BUCKET_ENDPOINT }}"
202+
203+
detect-event-schema-package-changes:
204+
name: "Check for changes to event schema package compared to main branch"
205+
runs-on: ubuntu-latest
206+
permissions:
207+
contents: read
208+
outputs:
209+
changed: ${{ steps.check.outputs.changed }}
210+
main_version: ${{ steps.check.outputs.main_version }}
211+
212+
steps:
213+
- name: "Checkout code"
214+
uses: actions/checkout@v4
215+
with:
216+
fetch-depth: 0
217+
218+
- name: Detect package changes and current version
219+
id: check
220+
run: |
221+
git fetch origin main
222+
223+
if git diff --quiet origin/main...HEAD -- internal/events; then
224+
echo "No changes in event schemas package"
225+
echo "changed=false" >> $GITHUB_OUTPUT
226+
else
227+
echo "Changes detected in event schemas"
228+
echo "changed=true" >> $GITHUB_OUTPUT
229+
fi
230+
231+
if content=$(git show origin/main:internal/events/schemas/package.json 2>/dev/null); then
232+
version=$(jq -r .version <<< $content);
233+
else
234+
version=null;
235+
fi
236+
237+
echo "Detected package version $version in main branch"
238+
echo "main_version=$version" >> $GITHUB_OUTPUT
239+
240+
check-schemas-generated:
241+
name: Check event schemas have been regenerated
242+
needs: detect-event-schema-package-changes
243+
if: needs.detect-event-schema-package-changes.outputs.changed == 'true'
244+
runs-on: ubuntu-latest
245+
permissions:
246+
contents: read
247+
steps:
248+
- name: "Checkout code"
249+
uses: actions/checkout@v4
250+
251+
# Simplified caching - template management has more complex caching of installed modules from another build step
252+
- name: "Cache node_modules"
253+
uses: actions/cache@v4
254+
with:
255+
path: |
256+
**/node_modules
257+
key: ${{ runner.os }}-node-${{ inputs.nodejs_version }}-${{ hashFiles('**/package-lock.json') }}
258+
restore-keys: |
259+
${{ runner.os }}-node-${{ inputs.nodejs_version }}-
260+
261+
- name: "Re-generate schemas"
262+
run: |
263+
npm ci --workspace internal/events
264+
npm --workspace internal/events run gen:jsonschema
265+
266+
- name: Check for schema changes
267+
run: git diff --quiet internal/events/schemas
268+
269+
check-schema-version-change:
270+
name: Check event schema version has been updated
271+
needs: detect-event-schema-package-changes
272+
if: needs.detect-event-schema-package-changes.outputs.changed == 'true'
273+
runs-on: ubuntu-latest
274+
permissions:
275+
contents: read
276+
steps:
277+
- name: Checkout code
278+
uses: actions/checkout@v4
279+
280+
- name: Check schema versions
281+
run: |
282+
source scripts/is_valid_increment.sh
283+
284+
main_version="${{ needs.detect-event-schema-package-changes.outputs.main_version }}"
285+
echo "Main version: ${{ needs.detect-event-schema-package-changes.outputs.main_version }}"
286+
287+
local_version=$(jq -r '.version' internal/events/package.json)
288+
echo "Local version: $local_version"
289+
290+
if ! is_valid_increment "$main_version" "$local_version" ; then
291+
echo "Error: Event Schema package has changed, but new version ($local_version) is not a valid increment from latest version on main branch ($main_version)."
292+
exit 1
293+
fi

eslint.config.mjs

Lines changed: 56 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import unicorn from 'eslint-plugin-unicorn';
1212
import { defineConfig, globalIgnores } from 'eslint/config';
1313
import js from '@eslint/js';
1414
import html from 'eslint-plugin-html';
15-
import tseslint from '@typescript-eslint/parser';
15+
import tseslint from 'typescript-eslint'; // Replace plugin-only import with meta package that includes configs
1616
import sortDestructureKeys from 'eslint-plugin-sort-destructure-keys';
1717
import {
1818
configs as airbnbConfigs,
@@ -40,9 +40,15 @@ export default defineConfig([
4040
'**/test-results',
4141
'**/playwright-report*',
4242
'eslint.config.mjs',
43+
// newly ignored generated/build artifacts
44+
'build/**',
45+
'sdk/**',
46+
'docs/_site/**',
47+
'docs/vendor/**',
48+
'docs/**/*.html',
4349
]),
4450

45-
//imports
51+
// imports
4652
importX.flatConfigs.recommended,
4753
{ rules: { ...airbnbPlugins.importX.rules } },
4854

@@ -66,21 +72,16 @@ export default defineConfig([
6672
},
6773
},
6874
},
69-
70-
{
71-
files: ['**/*.json'],
72-
extends: [tseslint.configs.disableTypeChecked],
73-
},
75+
{ files: ['**/*.json'], extends: [tseslint.configs.disableTypeChecked] },
7476

7577
{
7678
settings: {
7779
'import-x/resolver-next': [
7880
eslintImportResolverTypescript.createTypeScriptImportResolver({
7981
project: [
80-
'frontend/tsconfig.json',
8182
'lambdas/*/tsconfig.json',
8283
'tests/test-team/tsconfig.json',
83-
'utils/*/tsconfig.json',
84+
'internal/*/tsconfig.json',
8485
],
8586
}),
8687
],
@@ -91,10 +92,7 @@ export default defineConfig([
9192
rules: {
9293
'@typescript-eslint/no-unused-vars': [
9394
2,
94-
{
95-
argsIgnorePattern: '^_',
96-
varsIgnorePattern: '^_',
97-
},
95+
{ argsIgnorePattern: '^_', varsIgnorePattern: '^_' },
9896
],
9997
'@typescript-eslint/consistent-type-definitions': 0,
10098
},
@@ -107,22 +105,13 @@ export default defineConfig([
107105
'unicorn/prevent-abbreviations': 0,
108106
'unicorn/filename-case': [
109107
2,
110-
{
111-
case: 'kebabCase',
112-
ignore: ['.tsx'],
113-
},
108+
{ case: 'kebabCase', ignore: ['.tsx'] },
114109
],
115110
'unicorn/no-null': 0,
116111
'unicorn/prefer-module': 0,
117112
'unicorn/import-style': [
118113
2,
119-
{
120-
styles: {
121-
path: {
122-
named: true,
123-
},
124-
},
125-
},
114+
{ styles: { path: { named: true } } },
126115
],
127116
},
128117
},
@@ -145,103 +134,54 @@ export default defineConfig([
145134
// jsxA11y
146135
{
147136
files: ['**/*.{js,mjs,cjs,jsx,mjsx,ts,tsx,mtsx}'],
148-
plugins: {
149-
'jsx-a11y': jsxA11y,
150-
},
151-
languageOptions: {
152-
parserOptions: {
153-
ecmaFeatures: {
154-
jsx: true,
155-
},
156-
},
157-
},
137+
plugins: { 'jsx-a11y': jsxA11y },
138+
languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } },
158139
},
159140

160141
// security
161142
security.configs.recommended,
162-
163143
// sonar
164144
sonarjs.configs.recommended,
165-
166145
// html
167-
{
168-
files: ['**/*.html'],
169-
plugins: { html },
170-
},
171-
172-
// Next.js
173-
...compat.config({
174-
extends: ['next', 'next/core-web-vitals', 'next/typescript'],
175-
settings: {
176-
next: {
177-
rootDir: 'frontend',
178-
},
179-
},
180-
rules: {
181-
// needed because next lint rules look for a pages directory
182-
'@next/next/no-html-link-for-pages': 0,
183-
},
184-
}),
146+
{ files: ['**/*.html'], plugins: { html } },
185147

186148
// json
187-
{
188-
files: ['**/*.json'],
189-
...json.configs['recommended'],
190-
},
149+
{ files: ['**/*.json'], ...json.configs['recommended'] },
191150

192151
// destructure sorting
193152
{
194153
name: 'eslint-plugin-sort-destructure-keys',
195-
plugins: {
196-
'sort-destructure-keys': sortDestructureKeys,
197-
},
198-
rules: {
199-
'sort-destructure-keys/sort-destructure-keys': 2,
200-
},
154+
plugins: { 'sort-destructure-keys': sortDestructureKeys },
155+
rules: { 'sort-destructure-keys/sort-destructure-keys': 2 },
201156
},
202157

203158
// imports
204159
{
205160
rules: {
206-
'sort-imports': [
207-
2,
208-
{
209-
ignoreDeclarationSort: true,
210-
},
211-
],
161+
'sort-imports': [2, { ignoreDeclarationSort: true }],
212162
'import-x/extensions': 0,
213163
},
214164
},
215165
{
216166
files: ['**/*.ts', '**/*.tsx'],
217-
rules: {
218-
'import-x/no-unresolved': 0, // trust the typescript compiler to catch unresolved imports
219-
},
167+
rules: { 'import-x/no-unresolved': 0 },
220168
},
221169
{
222170
files: ['tests/test-team/**'],
223171
rules: {
224172
'import-x/no-extraneous-dependencies': [
225173
2,
226-
{
227-
devDependencies: true,
228-
},
174+
{ devDependencies: true },
229175
],
230176
},
231177
},
232178
{
233179
files: ['**/utils/**', 'tests/test-team/**'],
234-
rules: {
235-
'import-x/prefer-default-export': 0,
236-
},
180+
rules: { 'import-x/prefer-default-export': 0 },
237181
},
238182
{
239-
plugins: {
240-
'no-relative-import-paths': noRelativeImportPaths,
241-
},
242-
rules: {
243-
'no-relative-import-paths/no-relative-import-paths': 2,
244-
},
183+
plugins: { 'no-relative-import-paths': noRelativeImportPaths },
184+
rules: { 'no-relative-import-paths/no-relative-import-paths': 2 },
245185
},
246186
{
247187
files: ['scripts/**'],
@@ -253,14 +193,44 @@ export default defineConfig([
253193
},
254194
},
255195

196+
// js parserOptions override to suppress project service warnings for loose JS files
197+
{
198+
files: ['**/*.js', '**/*.cjs', '**/*.mjs'],
199+
languageOptions: {
200+
parserOptions: {
201+
allowDefaultProject: true,
202+
noWarnOnMultipleProjects: true, // suppress informational warning
203+
},
204+
},
205+
},
206+
// tests: relax package import restriction
207+
{
208+
files: ['**/__test__/**', '**/__tests__/**', '**/*.test.ts', '**/*.test.js'],
209+
rules: {
210+
'import-x/no-relative-packages': 0,
211+
'security/detect-non-literal-fs-filename': 0
212+
},
213+
},
214+
215+
// CLI tools
216+
{
217+
files: ['**/cli/**'],
218+
rules: {
219+
'no-console': 0,
220+
'security/detect-non-literal-fs-filename': 0
221+
},
222+
},
223+
256224
// misc rule overrides
257225
{
258226
rules: {
259227
'no-restricted-syntax': 0,
260228
'no-underscore-dangle': 0,
261229
'no-await-in-loop': 0,
262230
'no-plusplus': [2, { allowForLoopAfterthoughts: true }],
263-
'unicorn/prefer-top-level-await': 0, // top level await is not available in commonjs
231+
'unicorn/prefer-top-level-await': 0,
232+
'import-x/no-relative-packages': 1,
233+
'no-relative-import-paths/no-relative-import-paths': 1
264234
},
265235
},
266236
]);

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+
};

0 commit comments

Comments
 (0)