Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IMN-790 Add scaffold for agreement-platformstate-writer #967

Merged
merged 427 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
427 commits
Select commit Hold shift + click to select a range
7a17057
Fix
taglioni-r Sep 6, 2024
a938106
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Sep 6, 2024
1e6d50a
Remove comment
taglioni-r Sep 6, 2024
f891ff1
Renaming
taglioni-r Sep 6, 2024
b046603
Fix
taglioni-r Sep 6, 2024
f7c21e1
Fix logic
taglioni-r Sep 6, 2024
6d009cf
Add tests
taglioni-r Sep 6, 2024
77d55d2
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 6, 2024
72a6177
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 6, 2024
5312b34
Draft
taglioni-r Sep 6, 2024
9c9bf27
Refactor tables setup
taglioni-r Sep 6, 2024
6fa4866
Add pagination
shuyec Sep 9, 2024
ba70501
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
shuyec Sep 9, 2024
135b036
WIP: add errors
shuyec Sep 9, 2024
ecc1093
Update package imports
shuyec Sep 9, 2024
1eb3762
Draft
taglioni-r Sep 10, 2024
a26f95d
WIP: add errors
shuyec Sep 10, 2024
e22b041
Update errors
taglioni-r Sep 10, 2024
b34ed35
Update utils
taglioni-r Sep 10, 2024
3c5ad7c
Draft test
taglioni-r Sep 10, 2024
02eeeb4
Add placeholders for tests
taglioni-r Sep 10, 2024
8562a57
Add type
taglioni-r Sep 10, 2024
060e2b7
Refactor
taglioni-r Sep 10, 2024
43d252a
Update tests
taglioni-r Sep 10, 2024
d09d7a2
Update comment
taglioni-r Sep 10, 2024
3bf72b3
Fix errors data
shuyec Sep 11, 2024
facb19c
Refactor
taglioni-r Sep 11, 2024
331b6b1
Merge branch 'IMN-522_client-assertion-validation' of https://github.…
taglioni-r Sep 11, 2024
59f0aa5
Update comment
taglioni-r Sep 11, 2024
c1c4c3e
Fix checks
taglioni-r Sep 11, 2024
b72c5dc
Update test utils
taglioni-r Sep 11, 2024
9ba64f6
Draft tests
taglioni-r Sep 11, 2024
feddfe6
Add errors
shuyec Sep 11, 2024
659d4d1
Fix algorithm error
shuyec Sep 11, 2024
8f774eb
Refactor validateSub
taglioni-r Sep 11, 2024
3991d66
Fix mock
taglioni-r Sep 11, 2024
c97619f
Update tests
taglioni-r Sep 11, 2024
5a49356
Remove printed errors
taglioni-r Sep 11, 2024
b12a6ea
Add errors
shuyec Sep 11, 2024
2060029
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 12, 2024
e2d2de3
Fix tests
shuyec Sep 12, 2024
c73ddf5
Merge branch 'IMN-522_client-assertion-validation' of https://github.…
shuyec Sep 12, 2024
0105452
Improvements
shuyec Sep 12, 2024
98784fc
Improvements
shuyec Sep 12, 2024
04c7aa4
Fix
taglioni-r Sep 12, 2024
762d65b
Fix import
taglioni-r Sep 12, 2024
8ea2212
Refactor
taglioni-r Sep 12, 2024
2fa65e0
Add check
taglioni-r Sep 12, 2024
1f8aa0e
Fix test
taglioni-r Sep 12, 2024
4784b7c
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Sep 12, 2024
c3814e1
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 12, 2024
edcfd79
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 12, 2024
9a19717
Fix
taglioni-r Sep 12, 2024
6a08e96
Merge branch 'IMN-522_client-assertion-validation' of https://github.…
taglioni-r Sep 12, 2024
d212b09
Refactor
taglioni-r Sep 12, 2024
e2e50a3
Add tests
taglioni-r Sep 12, 2024
8b16304
Remove comment
taglioni-r Sep 12, 2024
608f19b
Add scaffold for new package
taglioni-r Sep 12, 2024
4a44eb0
Refactor
taglioni-r Sep 13, 2024
8519e60
Refactor
taglioni-r Sep 13, 2024
9a72065
Add util tests
taglioni-r Sep 13, 2024
f4e37aa
Add test
taglioni-r Sep 13, 2024
7a8205f
Fix
taglioni-r Sep 13, 2024
5f62de0
Remove hardcoded string
taglioni-r Sep 13, 2024
46546ec
Merge branch 'IMN-522_client-assertion-validation' into IMN-790_agree…
taglioni-r Sep 13, 2024
baa6246
Add indexes
taglioni-r Sep 13, 2024
50a5b51
Add script
taglioni-r Sep 13, 2024
66e73b1
Move protobufConverterToV1
taglioni-r Sep 13, 2024
53c3cf0
Update type
taglioni-r Sep 13, 2024
3153988
Add utils
taglioni-r Sep 13, 2024
7788383
Update comments
taglioni-r Sep 16, 2024
c27e3ad
Fix
taglioni-r Sep 16, 2024
ba9609f
Refactor
taglioni-r Sep 16, 2024
f9ba9db
Refactor
taglioni-r Sep 16, 2024
9bdea36
Renaming
taglioni-r Sep 17, 2024
7d5e486
Refactor
taglioni-r Sep 18, 2024
519870b
Fix tests
taglioni-r Sep 18, 2024
bf36128
Refactor
taglioni-r Sep 18, 2024
d8a2dcc
Comment function
taglioni-r Sep 18, 2024
7724295
Fix GSIPK_agreementTimestamp typo
shuyec Sep 20, 2024
97872cd
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
shuyec Sep 20, 2024
db0de47
Revert "Fix GSIPK_agreementTimestamp typo"
shuyec Sep 20, 2024
fd04e3b
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
shuyec Sep 20, 2024
ab92c54
Remove unused line
taglioni-r Sep 24, 2024
2ed47eb
Refactor
taglioni-r Sep 24, 2024
bb0ee8d
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Sep 24, 2024
1860616
Refactor tables setup
taglioni-r Sep 24, 2024
f6e9a08
Update model
taglioni-r Sep 24, 2024
5dbf0bd
Update platform-states table
taglioni-r Sep 24, 2024
3d9664b
Fix
taglioni-r Sep 24, 2024
4f9904a
Update token-generation-states table
taglioni-r Sep 24, 2024
abc158a
Update aws config
taglioni-r Sep 24, 2024
8b6db83
Rename descriptorStateToItemState function
shuyec Sep 24, 2024
3d12bff
Update key types usage
taglioni-r Sep 24, 2024
fda73c2
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Sep 24, 2024
7a3fc3e
Merge branch 'IMN-798_catalog-platformstate-writer-v2' of https://git…
taglioni-r Sep 24, 2024
6ad6e6f
Fix
taglioni-r Sep 24, 2024
b9b3c4b
Fix test split
taglioni-r Sep 24, 2024
80fd523
Remove describe utils in test file
shuyec Sep 24, 2024
2061be8
Merge branch 'IMN-798_catalog-platformstate-writer-v2' of https://git…
shuyec Sep 24, 2024
ddd4bdc
Minor fix
taglioni-r Sep 24, 2024
8e58388
Fix test structure
taglioni-r Sep 24, 2024
ab04510
Fix tests
taglioni-r Sep 24, 2024
3e3769f
Fix
taglioni-r Sep 24, 2024
daddb4b
Improve tests
taglioni-r Sep 24, 2024
c875827
Refactor
taglioni-r Sep 24, 2024
b2fe9a8
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 24, 2024
0b27fbe
Refactor test
taglioni-r Sep 24, 2024
d8a6f37
Rename test file for events V2
shuyec Sep 24, 2024
3d8d605
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 24, 2024
4c4d753
Fix typo
shuyec Sep 24, 2024
609b392
Fix
taglioni-r Sep 24, 2024
0f51a67
Update tests
taglioni-r Sep 24, 2024
ca4eac5
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 24, 2024
b0a0be9
Remove api spec
taglioni-r Sep 24, 2024
1b8b684
Refactor
taglioni-r Sep 24, 2024
0a046dc
Remove comment
taglioni-r Sep 24, 2024
b39d50f
Remove commented code
taglioni-r Sep 24, 2024
2780594
Fix comments
taglioni-r Sep 24, 2024
4bfcfd7
Revert string literal
taglioni-r Sep 24, 2024
6c445ed
Add env var
taglioni-r Sep 24, 2024
6917d52
WIP, broken commit
Carminepo2 Sep 24, 2024
09e27ea
Fix types
Carminepo2 Sep 25, 2024
1bbe00c
Revert "Fix types"
taglioni-r Sep 25, 2024
2b59066
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 25, 2024
ebb6db9
Revert "WIP, broken commit"
taglioni-r Sep 25, 2024
c745838
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 25, 2024
ee86ce3
Merge branch 'IMN-522_client-assertion-validation' into IMN-790_agree…
taglioni-r Sep 25, 2024
f05c1c7
Fix model
taglioni-r Sep 25, 2024
386639f
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Sep 25, 2024
460fc94
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 25, 2024
f0a2a87
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 25, 2024
12cc203
Merge branch 'IMN-522_client-assertion-validation' into IMN-790_agree…
taglioni-r Sep 25, 2024
905aa06
Fix agreementDescriptorId type
shuyec Sep 25, 2024
b2810da
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
shuyec Sep 25, 2024
03426ba
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
shuyec Sep 25, 2024
ed4cb24
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
shuyec Sep 25, 2024
b6687e3
Merge branch 'IMN-522_client-assertion-validation' into IMN-790_agree…
taglioni-r Sep 25, 2024
c3f442d
Update tables setup
taglioni-r Sep 25, 2024
121fdb8
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 25, 2024
fbb1c7c
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 25, 2024
a4b4be6
Merge branch 'IMN-522_client-assertion-validation' into IMN-790_agree…
taglioni-r Sep 25, 2024
b492bcf
Merge branch 'feature/IMN-517_authorization-server' into IMN-796_cata…
taglioni-r Sep 26, 2024
0ddcd8e
Move tables definition
taglioni-r Sep 26, 2024
c5ea4c1
Update test utils
taglioni-r Sep 26, 2024
5acb0f4
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Sep 26, 2024
a38d762
Remove unused error
taglioni-r Sep 26, 2024
ad1dac8
Fix digest type
taglioni-r Sep 26, 2024
fcdb6c0
Fix types in validation request
taglioni-r Sep 26, 2024
4a5c9d6
Remove comments
taglioni-r Sep 26, 2024
ac9b00f
Fix validateSub
taglioni-r Sep 26, 2024
74b2612
Fix check on digest
taglioni-r Sep 26, 2024
1a394e4
Partial revert
taglioni-r Sep 26, 2024
0609f35
Fix digest errors
taglioni-r Sep 26, 2024
b37c400
Remove comment
taglioni-r Sep 26, 2024
7c4e32c
Fix check on strings
taglioni-r Sep 26, 2024
92972b5
Fix checks
taglioni-r Sep 26, 2024
a02f448
Renaming
taglioni-r Sep 26, 2024
207b048
Remove digest from mock
taglioni-r Sep 26, 2024
8edfd7f
Add tests
taglioni-r Sep 26, 2024
d4662d4
Update kid regex
taglioni-r Sep 27, 2024
ea45031
Add type checks
taglioni-r Sep 27, 2024
8e84a58
Add comment
taglioni-r Sep 27, 2024
58dd973
Add tests
taglioni-r Sep 27, 2024
2896889
Merge similar tests
taglioni-r Sep 27, 2024
263e59c
Update test title
taglioni-r Sep 27, 2024
f369a39
Renaming
taglioni-r Sep 27, 2024
20e5711
Renaming
taglioni-r Sep 27, 2024
98a5387
Renaming
taglioni-r Sep 27, 2024
0e24d73
Improve error
taglioni-r Sep 27, 2024
db141fe
Update error message
taglioni-r Sep 27, 2024
ba8178b
Update signature errors
taglioni-r Sep 27, 2024
294c349
Refactor branded ids
taglioni-r Sep 27, 2024
ce476f0
Fix import
taglioni-r Sep 27, 2024
7d9ca9c
Fix typos
shuyec Sep 27, 2024
c032bcd
Fix GSI names
taglioni-r Sep 27, 2024
28402dc
Update aws region
taglioni-r Sep 27, 2024
86f08e3
Update aws region
taglioni-r Sep 27, 2024
fa46fd7
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Sep 27, 2024
d5a28bd
Refactor
taglioni-r Sep 27, 2024
7040666
Merge branch 'IMN-798_catalog-platformstate-writer-v2' of https://git…
taglioni-r Sep 27, 2024
7a84286
Fix GSI name
taglioni-r Sep 27, 2024
149a7ec
Remove commented code
taglioni-r Sep 27, 2024
178296c
Fix GSI names
taglioni-r Sep 27, 2024
ccc27d2
Minor improvement
taglioni-r Sep 27, 2024
fd81ebb
Fix mock
taglioni-r Sep 27, 2024
44cc824
Rename tests
taglioni-r Sep 27, 2024
df2b57b
Update aws region
taglioni-r Sep 27, 2024
6dc781a
Update descriptor audience
taglioni-r Sep 27, 2024
3015935
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Sep 30, 2024
aa2cbfa
Fix
taglioni-r Sep 30, 2024
b52c801
Refactor
taglioni-r Sep 30, 2024
cc0ea48
Rename tests
taglioni-r Sep 30, 2024
f76e677
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Sep 30, 2024
97fb884
Refactor
taglioni-r Sep 30, 2024
d84473f
Refactor
taglioni-r Sep 30, 2024
b7467cd
Remove types check
taglioni-r Sep 30, 2024
33b1014
Add check
taglioni-r Sep 30, 2024
ca6b288
Add test
taglioni-r Sep 30, 2024
f2192dd
Merge branch 'IMN-522_client-assertion-validation' into IMN-790_agree…
taglioni-r Sep 30, 2024
cee7db9
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Oct 1, 2024
3122d67
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Oct 1, 2024
2621cfe
Merge branch 'IMN-522_client-assertion-validation' into IMN-790_agree…
taglioni-r Oct 1, 2024
0cfd319
Fix
taglioni-r Oct 1, 2024
abf77f0
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Oct 1, 2024
72df606
Merge branch 'IMN-522_client-assertion-validation' into IMN-790_agree…
taglioni-r Oct 1, 2024
4e3b338
Remove env vars
taglioni-r Oct 1, 2024
865c4c8
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Oct 1, 2024
6135980
Fix
taglioni-r Oct 1, 2024
bac370e
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Oct 1, 2024
e6bbca3
Fix
taglioni-r Oct 1, 2024
6c3d128
Fix
taglioni-r Oct 1, 2024
cc1dccd
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Oct 1, 2024
f4e3ca0
Remove not needed params
taglioni-r Oct 1, 2024
6b2643e
Rename container
taglioni-r Oct 1, 2024
573ed39
Refactor
taglioni-r Oct 1, 2024
5adc54b
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Oct 1, 2024
ba7233f
Fix import
taglioni-r Oct 1, 2024
0e8f1b5
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Oct 1, 2024
f5376ce
Refactor
taglioni-r Oct 1, 2024
c191fd8
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Oct 1, 2024
2078571
Update error
taglioni-r Oct 1, 2024
497ce62
Improve test
taglioni-r Oct 1, 2024
a0bfaa8
Merge branch 'IMN-522_client-assertion-validation' into IMN-790_agree…
taglioni-r Oct 1, 2024
82ca754
Fix
taglioni-r Oct 1, 2024
b71eec3
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Oct 1, 2024
6353335
Fix
taglioni-r Oct 1, 2024
c23596a
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Oct 1, 2024
efc1408
Merge branch 'IMN-522_client-assertion-validation' into IMN-790_agree…
taglioni-r Oct 1, 2024
5f06c56
Fix
taglioni-r Oct 1, 2024
686aa59
Adjust key utils
taglioni-r Oct 3, 2024
059e489
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Oct 3, 2024
f5dbec0
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Oct 3, 2024
f6cb113
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Oct 3, 2024
01d014d
Merge branch 'IMN-522_client-assertion-validation' into IMN-790_agree…
taglioni-r Oct 3, 2024
5710920
Merge branch 'main' into IMN-790_agreement-platform-state-writer-scaf…
taglioni-r Oct 4, 2024
91e1fb5
Merge branch 'main' into IMN-790_agreement-platform-state-writer-scaf…
taglioni-r Oct 8, 2024
b9e3172
Remove utils test placeholder
taglioni-r Oct 8, 2024
ce83959
Merge branch 'main' into IMN-790_agreement-platform-state-writer-scaf…
taglioni-r Oct 8, 2024
42a4b3a
Fix
taglioni-r Oct 8, 2024
3b01b9d
Merge branch 'IMN-790_agreement-platform-state-writer-scaffold' of ht…
taglioni-r Oct 8, 2024
7ed15fe
Remove not needed dependency
taglioni-r Oct 10, 2024
00573af
Merge branch 'main' into IMN-790_agreement-platform-state-writer-scaf…
taglioni-r Oct 10, 2024
95b5ed2
Merge branch 'main' into IMN-790_agreement-platform-state-writer-scaf…
taglioni-r Oct 11, 2024
2ff3ed1
Merge branch 'main' into IMN-790_agreement-platform-state-writer-scaf…
taglioni-r Oct 11, 2024
2589132
Merge branch 'main' into IMN-790_agreement-platform-state-writer-scaf…
taglioni-r Oct 16, 2024
1dc7860
Merge branch 'main' into IMN-790_agreement-platform-state-writer-scaf…
taglioni-r Oct 21, 2024
d60ef78
Merge branch 'main' into IMN-790_agreement-platform-state-writer-scaf…
taglioni-r Oct 24, 2024
83ab8ad
Fix correlationId
taglioni-r Oct 24, 2024
e1beee0
Fix types
taglioni-r Oct 24, 2024
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"start:catalog-platformstate-writer": "turbo start --filter pagopa-interop-catalog-platformstate-writer",
"start:agreement": "turbo start --filter pagopa-interop-agreement-process",
"start:agreement-readmodel-writer": "turbo start --filter pagopa-interop-agreement-readmodel-writer",
"start:agreement-platformstate-writer": "turbo start --filter pagopa-interop-agreement-platformstate-writer",
"start:agreement-email-sender": "turbo start --filter pagopa-interop-agreement-email-sender",
"start:attribute": "turbo start --filter pagopa-interop-attribute-registry-process",
"start:attribute-readmodel-writer": "turbo start --filter pagopa-interop-attribute-registry-readmodel-writer",
Expand Down
12 changes: 12 additions & 0 deletions packages/agreement-platformstate-writer/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
LOG_LEVEL=info

KAFKA_CLIENT_ID="agreement"
KAFKA_GROUP_ID="agreement-group-local"
KAFKA_BROKERS="localhost:9092"
KAFKA_DISABLE_AWS_IAM_AUTH="true"
AGREEMENT_TOPIC="event-store.agreement.events"
AWS_CONFIG_FILE=aws.config.local
TOKEN_GENERATION_READMODEL_TABLE_NAME_PLATFORM="platform-states"
TOKEN_GENERATION_READMODEL_TABLE_NAME_TOKEN_GENERATION="token-generation-states"

AWS_REGION="eu-central-1"
44 changes: 44 additions & 0 deletions packages/agreement-platformstate-writer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM node:20.14.0-slim@sha256:5e8ac65a0231d76a388683d07ca36a9769ab019a85d85169fe28e206f7a3208e as build

RUN corepack enable

WORKDIR /app
COPY package.json /app/
COPY pnpm-lock.yaml /app/
COPY pnpm-workspace.yaml /app/

COPY ./packages/agreement-platformstate-writer/package.json /app/packages/agreement-platformstate-writer/package.json
COPY ./packages/commons/package.json /app/packages/commons/package.json
COPY ./packages/models/package.json /app/packages/models/package.json
COPY ./packages/kafka-iam-auth/package.json /app/packages/kafka-iam-auth/package.json

RUN --mount=type=cache,id=pnpm,target=/pnpm/store pnpm install --frozen-lockfile

COPY tsconfig.json /app/
COPY turbo.json /app/
COPY ./packages/agreement-platformstate-writer /app/packages/agreement-platformstate-writer
COPY ./packages/commons /app/packages/commons
COPY ./packages/models /app/packages/models
COPY ./packages/kafka-iam-auth /app/packages/kafka-iam-auth

RUN pnpm build && \
rm -rf /app/node_modules/.modules.yaml && \
rm -rf /app/node_modules/.cache && \
mkdir /out && \
cp -a --parents -t /out \
node_modules packages/agreement-platformstate-writer/node_modules \
package*.json packages/agreement-platformstate-writer/package*.json \
packages/commons \
packages/models \
packages/kafka-iam-auth \
packages/agreement-platformstate-writer/dist && \
find /out -exec touch -h --date=@0 {} \;

FROM node:20.14.0-slim@sha256:5e8ac65a0231d76a388683d07ca36a9769ab019a85d85169fe28e206f7a3208e as final

COPY --from=build /out /app

WORKDIR /app/packages/agreement-platformstate-writer
EXPOSE 3000

CMD ["node", "."]
9 changes: 9 additions & 0 deletions packages/agreement-platformstate-writer/aws.config.local
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[default]
aws_access_key_id=key
aws_secret_access_key=secret
region=eu-south-1
services=local

[services local]
dynamodb=
endpoint_url=http://localhost:8085
47 changes: 47 additions & 0 deletions packages/agreement-platformstate-writer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "pagopa-interop-agreement-platformstate-writer",
"private": true,
"version": "1.0.0",
"description": "PagoPA Interoperability agreement consumer service that updates the token-generation-read-model",
"main": "dist",
"type": "module",
"scripts": {
"test": "vitest",
"test:it": "vitest integration",
"lint": "eslint . --ext .ts,.tsx",
"lint:autofix": "eslint . --ext .ts,.tsx --fix",
"format:check": "prettier --check src",
"format:write": "prettier --write src",
"start": "node --loader ts-node/esm -r 'dotenv-flow/config' --watch ./src/index.ts",
"build": "tsc",
"check": "tsc --project tsconfig.check.json"
},
"keywords": [],
"author": "",
"license": "Apache-2.0",
"devDependencies": {
"@pagopa/eslint-config": "3.0.0",
"@types/node": "20.14.6",
"@types/uuid": "9.0.8",
"date-fns": "3.6.0",
"pagopa-interop-commons-test": "workspace:*",
"prettier": "2.8.8",
"ts-node": "10.9.2",
"typescript": "5.4.5",
"uuid": "10.0.0",
"vitest": "1.6.0"
},
"dependencies": {
"@aws-sdk/client-dynamodb": "3.637.0",
"@aws-sdk/util-dynamodb": "3.637.0",
"@protobuf-ts/runtime": "2.9.4",
"connection-string": "4.4.0",
"dotenv-flow": "4.1.0",
"kafka-iam-auth": "workspace:*",
"kafkajs": "2.2.4",
"pagopa-interop-commons": "workspace:*",
"pagopa-interop-models": "workspace:*",
"ts-pattern": "5.2.0",
"zod": "3.23.8"
}
}
15 changes: 15 additions & 0 deletions packages/agreement-platformstate-writer/src/config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {
AgreementTopicConfig,
PlatformStateWriterConfig,
} from "pagopa-interop-commons";
import { z } from "zod";

export const AgreementPlatformStateWriterConfig =
PlatformStateWriterConfig.and(AgreementTopicConfig);

export type AgreementPlatformStateWriterConfig = z.infer<
typeof AgreementPlatformStateWriterConfig
>;

export const config: AgreementPlatformStateWriterConfig =
AgreementPlatformStateWriterConfig.parse(process.env);
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { match } from "ts-pattern";
import { AgreementEventEnvelopeV1 } from "pagopa-interop-models";
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";

export async function handleMessageV1(
message: AgreementEventEnvelopeV1,
_dynamoDBClient: DynamoDBClient
): Promise<void> {
await match(message)
.with(
{ type: "AgreementAdded" },
{ type: "AgreementActivated" },
{ type: "AgreementSuspended" },
{ type: "AgreementDeactivated" },
{ type: "AgreementDeleted" },
{ type: "VerifiedAttributeUpdated" },
{ type: "AgreementUpdated" },
{ type: "AgreementConsumerDocumentAdded" },
{ type: "AgreementConsumerDocumentRemoved" },
{ type: "AgreementContractAdded" },
async () => Promise.resolve()
)
.exhaustive();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { AgreementEventEnvelopeV2 } from "pagopa-interop-models";
import { match } from "ts-pattern";

export async function handleMessageV2(
message: AgreementEventEnvelopeV2,
_dynamoDBClient: DynamoDBClient
): Promise<void> {
await match(message)
.with(
{ type: "AgreementAdded" },
{ type: "AgreementDeleted" },
{ type: "DraftAgreementUpdated" },
{ type: "AgreementSubmitted" },
{ type: "AgreementActivated" },
{ type: "AgreementUnsuspendedByProducer" },
{ type: "AgreementUnsuspendedByConsumer" },
{ type: "AgreementUnsuspendedByPlatform" },
{ type: "AgreementArchivedByConsumer" },
{ type: "AgreementArchivedByUpgrade" },
{ type: "AgreementUpgraded" },
{ type: "AgreementSuspendedByProducer" },
{ type: "AgreementSuspendedByConsumer" },
{ type: "AgreementSuspendedByPlatform" },
{ type: "AgreementRejected" },
{ type: "AgreementConsumerDocumentAdded" },
{ type: "AgreementConsumerDocumentRemoved" },
{ type: "AgreementSetDraftByPlatform" },
{ type: "AgreementSetMissingCertifiedAttributesByPlatform" },
() => Promise.resolve()
)
.exhaustive();
}
43 changes: 43 additions & 0 deletions packages/agreement-platformstate-writer/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import { EachMessagePayload } from "kafkajs";
import { logger, decodeKafkaMessage } from "pagopa-interop-commons";
import { runConsumer } from "kafka-iam-auth";
import {
AgreementEvent,
CorrelationId,
generateId,
unsafeBrandId,
} from "pagopa-interop-models";
import { match } from "ts-pattern";
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { handleMessageV1 } from "./consumerServiceV1.js";
import { handleMessageV2 } from "./consumerServiceV2.js";
import { config } from "./config/config.js";

const dynamoDBClient = new DynamoDBClient({});
async function processMessage({
message,
partition,
}: EachMessagePayload): Promise<void> {
const decodedMessage = decodeKafkaMessage(message, AgreementEvent);

const loggerInstance = logger({
serviceName: "agreement-platformstate-writer",
eventType: decodedMessage.type,
eventVersion: decodedMessage.event_version,
streamId: decodedMessage.stream_id,
correlationId: decodedMessage.correlation_id
? unsafeBrandId<CorrelationId>(decodedMessage.correlation_id)
: generateId<CorrelationId>(),
});

await match(decodedMessage)
.with({ event_version: 1 }, (msg) => handleMessageV1(msg, dynamoDBClient))
.with({ event_version: 2 }, (msg) => handleMessageV2(msg, dynamoDBClient))
.exhaustive();

loggerInstance.info(
`Token-generation read model was updated. Partition number: ${partition}. Offset: ${message.offset}`
);
}

await runConsumer(config, [config.agreementTopic], processMessage);
95 changes: 95 additions & 0 deletions packages/agreement-platformstate-writer/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import {
genericInternalError,
PlatformStatesAgreementEntry,
PlatformStatesAgreementPK,
} from "pagopa-interop-models";
import {
DeleteItemCommand,
DeleteItemInput,
DynamoDBClient,
GetItemCommand,
GetItemCommandOutput,
GetItemInput,
PutItemCommand,
PutItemInput,
} from "@aws-sdk/client-dynamodb";
import { unmarshall } from "@aws-sdk/util-dynamodb";
import { config } from "./config/config.js";

export const writeAgreementEntry = async (
agreementEntry: PlatformStatesAgreementEntry,
dynamoDBClient: DynamoDBClient
): Promise<void> => {
const input: PutItemInput = {
Item: {
PK: {
S: agreementEntry.PK,
},
state: {
S: agreementEntry.state,
},
version: {
N: agreementEntry.version.toString(),
},
updatedAt: {
S: agreementEntry.updatedAt,
},
GSIPK_consumerId_eserviceId: {
S: agreementEntry.GSIPK_consumerId_eserviceId,
},
GSI_agreementTimestamp: {
S: agreementEntry.GSISK_agreementTimestamp,
},
agreementDescriptorId: {
S: agreementEntry.agreementDescriptorId,
},
},
TableName: config.tokenGenerationReadModelTableNamePlatform,
};
const command = new PutItemCommand(input);
await dynamoDBClient.send(command);
};

export const readAgreementEntry = async (
primaryKey: PlatformStatesAgreementPK,
dynamoDBClient: DynamoDBClient
): Promise<PlatformStatesAgreementEntry | undefined> => {
const input: GetItemInput = {
Key: {
PK: { S: primaryKey },
},
TableName: config.tokenGenerationReadModelTableNamePlatform,
};
const command = new GetItemCommand(input);
const data: GetItemCommandOutput = await dynamoDBClient.send(command);

if (!data.Item) {
return undefined;
} else {
const unmarshalled = unmarshall(data.Item);
const agreementEntry = PlatformStatesAgreementEntry.safeParse(unmarshalled);

if (!agreementEntry.success) {
throw genericInternalError(
`Unable to parse agreement entry item: result ${JSON.stringify(
agreementEntry
)} - data ${JSON.stringify(data)} `
);
}
return agreementEntry.data;
}
};

export const deleteAgreementEntry = async (
primaryKey: PlatformStatesAgreementPK,
dynamoDBClient: DynamoDBClient
): Promise<void> => {
const input: DeleteItemInput = {
Key: {
PK: { S: primaryKey },
},
TableName: config.tokenGenerationReadModelTableNamePlatform,
};
const command = new DeleteItemCommand(input);
await dynamoDBClient.send(command);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { describe, expect, it } from "vitest";

describe("sample", () => {
it("test", () => {
expect(1).toBe(1);
});
});
4 changes: 4 additions & 0 deletions packages/agreement-platformstate-writer/test/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../tsconfig.json",
"include": ["."]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { setupTestContainersVitestGlobal } from "pagopa-interop-commons-test/index.js";

export default setupTestContainersVitestGlobal();
7 changes: 7 additions & 0 deletions packages/agreement-platformstate-writer/tsconfig.check.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"noEmit": true,
},
"include": ["src", "test"]
}
9 changes: 9 additions & 0 deletions packages/agreement-platformstate-writer/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist"
},
"include": [
"src"
]
}
11 changes: 11 additions & 0 deletions packages/agreement-platformstate-writer/vitest.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
test: {
globalSetup: ["./test/vitestGlobalSetup.ts"],
testTimeout: 60000,
hookTimeout: 60000,
fileParallelism: false,
pool: "forks",
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,11 @@ import {
toReadModelAgreement,
} from "pagopa-interop-models";
import { describe, expect, it } from "vitest";
import { handleMessageV1 } from "../src/consumerServiceV1.js";
import {
toAgreementDocumentV1,
toAgreementV1,
} from "./protobufConverterToV1.js";
} from "pagopa-interop-commons-test";
import { handleMessageV1 } from "../src/consumerServiceV1.js";
import { agreements } from "./utils.js";

describe("events V1", async () => {
Expand Down
Loading