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-799 Add scaffold for purpose-platformstate-writer #969

Merged
merged 435 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
435 commits
Select commit Hold shift + click to select a range
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
4a44eb0
Refactor
taglioni-r Sep 13, 2024
56e1140
Add purpose-platformstate-writer scaffold
shuyec Sep 13, 2024
bb2b9d4
Update pnpm-lock.yaml
shuyec 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
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
a568d93
Merge branch 'IMN-522_client-assertion-validation' into IMN_799-purpo…
shuyec 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
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
272e788
Merge branch 'IMN-522_client-assertion-validation' into IMN_799-purpo…
shuyec 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
5cbba53
Merge branch 'IMN-522_client-assertion-validation' into IMN_799-purpo…
shuyec 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
2d86058
Merge branch 'IMN-522_client-assertion-validation' into IMN_799-purpo…
shuyec 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
d0d2a8d
Merge branch 'IMN-522_client-assertion-validation' into IMN_799-purpo…
shuyec Sep 27, 2024
eb71c07
Update .env + aws.config.local
shuyec 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
d236a2e
Merge branch 'IMN-522_client-assertion-validation' into IMN_799-purpo…
shuyec Sep 30, 2024
5ee83a1
Remove cleanup
shuyec Oct 1, 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
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
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
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
66a4273
Merge branch 'IMN-522_client-assertion-validation' into IMN_799-purpo…
shuyec Oct 2, 2024
147a259
Remove DynamoDBClient parameters
shuyec Oct 2, 2024
11432b7
Add utils
shuyec Oct 2, 2024
ba83402
Remove TODO comment
shuyec Oct 2, 2024
686aa59
Adjust key utils
taglioni-r Oct 3, 2024
a971a87
Change updates to one page at a time
shuyec 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
4b25577
Merge branch 'main' into IMN-796_catalog-platform-state-writer-scaffold
taglioni-r Oct 3, 2024
ac096fa
Merge branch 'IMN-522_client-assertion-validation' into IMN_799-purpo…
shuyec Oct 3, 2024
f46b0af
Clean configs
shuyec Oct 3, 2024
87f632c
Delete utils.ts
shuyec Oct 3, 2024
b7788cb
Move utils to next branch
shuyec Oct 3, 2024
d91995c
Merge branch 'main' into IMN-796_catalog-platform-state-writer-scaffold
taglioni-r Oct 3, 2024
a8fa124
Merge branch 'IMN-796_catalog-platform-state-writer-scaffold' into IM…
taglioni-r Oct 3, 2024
5a36f89
Add typ
taglioni-r Oct 3, 2024
2127e68
Remove todo
taglioni-r Oct 3, 2024
e8dc415
Merge branch 'main' into IMN-798_catalog-platformstate-writer-v2
taglioni-r Oct 3, 2024
8229176
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Oct 3, 2024
f2212d9
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
taglioni-r Oct 3, 2024
a1d56e8
Merge branch 'IMN-522_client-assertion-validation' into IMN_799-purpo…
shuyec Oct 3, 2024
81b1bc6
Remove todo
shuyec Oct 4, 2024
2baf099
Merge branch 'main' into IMN-798_catalog-platformstate-writer-v2
taglioni-r Oct 4, 2024
7c8da7d
Merge branch 'IMN-798_catalog-platformstate-writer-v2' into IMN-797_c…
taglioni-r Oct 4, 2024
ae133dc
Merge branch 'main' into IMN-797_catalog-platformstate-writer-v1
taglioni-r Oct 4, 2024
fccb758
Remove sample test
taglioni-r Oct 4, 2024
f9b7271
Merge branch 'IMN-797_catalog-platformstate-writer-v1' of https://git…
taglioni-r Oct 4, 2024
e215a13
Merge branch 'IMN-797_catalog-platformstate-writer-v1' into IMN-522_c…
shuyec Oct 4, 2024
a53eaa2
Merge branch 'IMN-522_client-assertion-validation' into IMN_799-purpo…
shuyec Oct 4, 2024
9d4d998
Merge branch 'main' into IMN_799-purpose-platformstate-writer-scaffold
shuyec Oct 8, 2024
450504b
Create sample.test.ts
shuyec Oct 8, 2024
7bde0f4
Merge branch 'main' into IMN_799-purpose-platformstate-writer-scaffold
shuyec Oct 10, 2024
8a8800f
Remove testcontainers
shuyec Oct 11, 2024
c632a0c
Merge branch 'main' into IMN_799-purpose-platformstate-writer-scaffold
shuyec Oct 21, 2024
1fb18cf
Add eof
shuyec Oct 21, 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 @@ -19,6 +19,7 @@
"start:notifier-seeder": "turbo start --filter pagopa-interop-notifier-seeder",
"start:purpose": "turbo start --filter pagopa-interop-purpose-process",
"start:purpose-readmodel-writer": "turbo start --filter pagopa-interop-purpose-readmodel-writer",
"start:purpose-platformstate-writer": "turbo start --filter pagopa-interop-purpose-platformstate-writer",
"start:authorization": "turbo start --filter pagopa-interop-authorization-process",
"start:client-readmodel-writer": "turbo start --filter pagopa-interop-client-readmodel-writer",
"start:key-readmodel-writer": "turbo start --filter pagopa-interop-key-readmodel-writer",
Expand Down
12 changes: 12 additions & 0 deletions packages/purpose-platformstate-writer/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
LOG_LEVEL=info

KAFKA_CLIENT_ID="purpose"
KAFKA_GROUP_ID="purpose-group-local"
KAFKA_BROKERS="localhost:9092"
KAFKA_DISABLE_AWS_IAM_AUTH="true"
PURPOSE_TOPIC="event-store.purpose.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-south-1"
44 changes: 44 additions & 0 deletions packages/purpose-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/purpose-platformstate-writer/package.json /app/packages/purpose-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/purpose-platformstate-writer /app/packages/purpose-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/purpose-platformstate-writer/node_modules \
package*.json packages/purpose-platformstate-writer/package*.json \
packages/commons \
packages/models \
packages/kafka-iam-auth \
packages/purpose-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/purpose-platformstate-writer
EXPOSE 3000

CMD ["node", "."]
9 changes: 9 additions & 0 deletions packages/purpose-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/purpose-platformstate-writer/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "pagopa-interop-purpose-platformstate-writer",
"private": true,
"version": "1.0.0",
"description": "PagoPA Interoperability purpose 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/purpose-platformstate-writer/src/config/config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import {
PlatformStateWriterConfig,
PurposeTopicConfig,
} from "pagopa-interop-commons";
import { z } from "zod";

export const PurposePlatformStateWriterConfig =
PlatformStateWriterConfig.and(PurposeTopicConfig);

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

export const config: PurposePlatformStateWriterConfig =
PurposePlatformStateWriterConfig.parse(process.env);
25 changes: 25 additions & 0 deletions packages/purpose-platformstate-writer/src/consumerServiceV1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { match } from "ts-pattern";
import { PurposeEventEnvelopeV1 } from "pagopa-interop-models";
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";

export async function handleMessageV1(
message: PurposeEventEnvelopeV1,
_dynamoDBClient: DynamoDBClient
): Promise<void> {
await match(message)
.with(
{ type: "PurposeCreated" },
{ type: "PurposeVersionCreated" },
{ type: "PurposeUpdated" },
{ type: "PurposeVersionActivated" },
{ type: "PurposeVersionSuspended" },
{ type: "PurposeVersionArchived" },
{ type: "PurposeVersionWaitedForApproval" },
{ type: "PurposeVersionRejected" },
{ type: "PurposeVersionUpdated" },
{ type: "PurposeDeleted" },
{ type: "PurposeVersionDeleted" },
() => Promise.resolve()
)
.exhaustive();
}
32 changes: 32 additions & 0 deletions packages/purpose-platformstate-writer/src/consumerServiceV2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import { DynamoDBClient } from "@aws-sdk/client-dynamodb";
import { PurposeEventEnvelopeV2 } from "pagopa-interop-models";
import { match } from "ts-pattern";

export async function handleMessageV2(
message: PurposeEventEnvelopeV2,
_dynamoDBClient: DynamoDBClient
): Promise<void> {
await match(message)
.with(
{ type: "DraftPurposeDeleted" },
{ type: "WaitingForApprovalPurposeDeleted" },
{ type: "PurposeAdded" },
{ type: "DraftPurposeUpdated" },
{ type: "NewPurposeVersionActivated" },
{ type: "NewPurposeVersionWaitingForApproval" },
{ type: "PurposeActivated" },
{ type: "PurposeArchived" },
{ type: "PurposeVersionOverQuotaUnsuspended" },
{ type: "PurposeVersionRejected" },
{ type: "PurposeVersionSuspendedByConsumer" },
{ type: "PurposeVersionSuspendedByProducer" },
{ type: "PurposeVersionUnsuspendedByConsumer" },
{ type: "PurposeVersionUnsuspendedByProducer" },
{ type: "PurposeWaitingForApproval" },
{ type: "WaitingForApprovalPurposeVersionDeleted" },
{ type: "PurposeVersionActivated" },
{ type: "PurposeCloned" },
() => Promise.resolve()
)
.exhaustive();
}
36 changes: 36 additions & 0 deletions packages/purpose-platformstate-writer/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { EachMessagePayload } from "kafkajs";
import { logger, decodeKafkaMessage } from "pagopa-interop-commons";
import { runConsumer } from "kafka-iam-auth";
import { PurposeEvent } 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, PurposeEvent);

const loggerInstance = logger({
serviceName: "purpose-platformstate-writer",
eventType: decodedMessage.type,
eventVersion: decodedMessage.event_version,
streamId: decodedMessage.stream_id,
correlationId: decodedMessage.correlation_id,
});

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.purposeTopic], processMessage);
128 changes: 128 additions & 0 deletions packages/purpose-platformstate-writer/src/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
import {
DeleteItemCommand,
DeleteItemInput,
DynamoDBClient,
GetItemCommand,
GetItemCommandOutput,
GetItemInput,
PutItemCommand,
PutItemInput,
} from "@aws-sdk/client-dynamodb";
import { unmarshall } from "@aws-sdk/util-dynamodb";
import {
genericInternalError,
PlatformStatesCatalogEntry,
PlatformStatesEServiceDescriptorPK,
PlatformStatesPurposeEntry,
PlatformStatesPurposePK,
} from "pagopa-interop-models";
import { config } from "./config/config.js";

export const writePlatformPurposeEntry = async (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there write, read and delete are almost identical to the ones here would it be beneficial to declare these as generics and move to commons?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moving to commons is being planned, but I wouldn't turn those into functions with generics, because it doesn't seem a straightforward operation, considering the differences between those entries.

dynamoDBClient: DynamoDBClient,
purposeEntry: PlatformStatesPurposeEntry
): Promise<void> => {
const input: PutItemInput = {
ConditionExpression: "attribute_not_exists(PK)",
Item: {
PK: {
S: purposeEntry.PK,
},
state: {
S: purposeEntry.state,
},
purposeVersionId: {
S: purposeEntry.purposeVersionId,
},
purposeEserviceId: {
S: purposeEntry.purposeEserviceId,
},
purposeConsumerId: {
S: purposeEntry.purposeConsumerId,
},
version: {
N: purposeEntry.version.toString(),
},
updatedAt: {
S: purposeEntry.updatedAt,
},
},
TableName: config.tokenGenerationReadModelTableNamePlatform,
};
const command = new PutItemCommand(input);
await dynamoDBClient.send(command);
};

export const readPlatformPurposeEntry = async (
dynamoDBClient: DynamoDBClient,
primaryKey: PlatformStatesPurposePK
): Promise<PlatformStatesPurposeEntry | 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 purposeEntry = PlatformStatesPurposeEntry.safeParse(unmarshalled);

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

export const deletePlatformPurposeEntry = async (
dynamoDBClient: DynamoDBClient,
primaryKey: PlatformStatesPurposePK
): Promise<void> => {
const input: DeleteItemInput = {
Key: {
PK: { S: primaryKey },
},
TableName: config.tokenGenerationReadModelTableNamePlatform,
};
const command = new DeleteItemCommand(input);
await dynamoDBClient.send(command);
};

export const readCatalogEntry = async (
dynamoDBClient: DynamoDBClient,
primaryKey: PlatformStatesEServiceDescriptorPK
): Promise<PlatformStatesCatalogEntry | 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 catalogEntry = PlatformStatesCatalogEntry.safeParse(unmarshalled);

if (!catalogEntry.success) {
throw genericInternalError(
`Unable to parse catalog entry item: result ${JSON.stringify(
catalogEntry
)} - data ${JSON.stringify(data)} `
);
}
return catalogEntry.data;
}
};
7 changes: 7 additions & 0 deletions packages/purpose-platformstate-writer/test/sample.test.ts
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/purpose-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/purpose-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/purpose-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"
]
}
Loading