diff --git a/.npmrc b/.npmrc index a35fb5cc..25d6c94f 100644 --- a/.npmrc +++ b/.npmrc @@ -1 +1,2 @@ -min-release-age=2 \ No newline at end of file +min-release-age=2 +min-release-age-exclude=jitar,@jitar/plugin-vite,@jitar-plugins/authentication,@jitar-plugins/database,@jitar-plugins/events,@theshelf/events-driver-kafka,@jitar-plugins/files,@jitar-plugins/http,@jitar-plugins/notification,@maskingtech/designsystem,@maskingtech/react-toolkit,@theshelf/authentication,@theshelf/authentication-driver-openid,@theshelf/connection,@theshelf/database,@theshelf/database-driver-mongodb,@theshelf/events,@theshelf/files,@theshelf/files-driver-s3,@theshelf/http,@theshelf/logging,@theshelf/logging-driver-database,@theshelf/notification,@theshelf/validation,@theshelf/validation-driver-zod \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 20375e92..1177c53b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -11,6 +11,6 @@ "js/ts.preferences.quoteStyle": "single", "js/ts.format.semicolons": "insert", "editor.codeActionsOnSave": { - "source.organizeImports": "explicit" + "source.fixAll.eslint": "explicit" } } \ No newline at end of file diff --git a/deployment/docker/keycloak/comify-realm.json b/deployment/docker/keycloak/comify-realm.json index 58516fe7..265ed188 100644 --- a/deployment/docker/keycloak/comify-realm.json +++ b/deployment/docker/keycloak/comify-realm.json @@ -666,8 +666,8 @@ "alwaysDisplayInConsole": false, "clientAuthenticatorType": "client-secret", "redirectUris": [ - "http://localhost:3000/rpc/social/domain/authentication/login", - "http://localhost:5173/rpc/social/domain/authentication/login" + "http://localhost:3000/rpc/social/security/authentication/login", + "http://localhost:5173/rpc/social/security/authentication/login" ], "webOrigins": [ "https://www.keycloak.org" diff --git a/deployment/segments/common.bff.json b/deployment/segments/common.bff.json index d85acbfc..67240455 100644 --- a/deployment/segments/common.bff.json +++ b/deployment/segments/common.bff.json @@ -1,3 +1,3 @@ { - "./common/domain/tenant/getByOriginConverted": { "default": { "access": "public" } } + "./common/domain/tenant/getByOrigin": { "default": { "access": "public" } } } \ No newline at end of file diff --git a/deployment/segments/common.errors.json b/deployment/segments/common.errors.json new file mode 100644 index 00000000..95022799 --- /dev/null +++ b/deployment/segments/common.errors.json @@ -0,0 +1,4 @@ +{ + "./common/domain/tenant/getByOrigin/InvalidOrigin": { "default": {} }, + "./common/domain/tenant/getByOrigin/TenantNotFound": { "default": {} } +} \ No newline at end of file diff --git a/deployment/segments/common.reads.json b/deployment/segments/common.reads.json index d2157492..36207be9 100644 --- a/deployment/segments/common.reads.json +++ b/deployment/segments/common.reads.json @@ -1,3 +1,3 @@ { - "./common/domain/tenant/getByOrigin": { "default": { "access": "protected" }, "TenantNotFound": { } } + "./common/domain/tenant/getByOrigin/retrieve": { "default": { "access": "protected" } } } \ No newline at end of file diff --git a/deployment/segments/social.bff.json b/deployment/segments/social.bff.json index 1b61bd4f..34d2d6ba 100644 --- a/deployment/segments/social.bff.json +++ b/deployment/segments/social.bff.json @@ -1,46 +1,35 @@ { - "./social/domain/authentication/getLoginUrl": { "default": { "access": "public" } }, - "./social/domain/authentication/login": { "default": { "access": "public" } }, - "./social/domain/authentication/logout": { "default": { "access": "public" } }, + "./social/security/authentication/getLoginUrl": { "default": { "access": "public" } }, + "./social/security/authentication/login": { "default": { "access": "public" } }, + "./social/security/authentication/logout": { "default": { "access": "public" } }, - "./social/domain/creator/aggregate": { "default": { "access": "private" }}, - "./social/domain/creator/getByIdAggregated": { "default": { "access": "private" } }, - "./social/domain/creator/getByNicknameAggregated": { "default": { "access": "public" } }, - "./social/domain/creator/getMeAggregated": { "default": { "access": "public" } }, + "./social/domain/creator/getById": { "default": { "access": "public" } }, + "./social/domain/creator/getByNickname": { "default": { "access": "public" } }, + "./social/domain/creator/getMe": { "default": { "access": "public" } }, "./social/domain/creator/updateFullName": { "default": { "access": "public" } }, - "./social/domain/creator/updateNickname": { "default": { "access": "public" } }, + "./social/domain/creator/updateNickname": { "default": { "access": "public" }}, - "./social/domain/creator.metrics/create": { "subscriptions": { "access": "private" } }, - "./social/domain/creator.metrics/updateFollowers": { "subscriptions": { "access": "private" } }, - "./social/domain/creator.metrics/updateFollowing": { "subscriptions": { "access": "private" } }, - "./social/domain/creator.metrics/updatePosts": { "subscriptions": { "access": "private" } }, + "./social/domain/creator.metrics/subscriptions": { "default": { "access": "private" } }, - "./social/domain/notification/aggregate": { "default": { "access": "private" } }, - "./social/domain/notification/notify": { "subscriptions": { "access": "private" } }, - "./social/domain/notification/getRecentAggregated": { "default": { "access": "public" } }, + "./social/domain/notification/getRecent": { "default": { "access": "public" } }, - "./social/domain/post/aggregate": { "default": { "access": "private" } }, - "./social/domain/post/create": { "default": { "access": "private" }, "subscribe": { "access": "private" } }, "./social/domain/post/createWithComic": { "default": { "access": "public" } }, "./social/domain/post/createWithComment": { "default": { "access": "public" } }, - "./social/domain/post/getByCreatorAggregated": { "default": { "access": "public" } }, - "./social/domain/post/getByFollowingAggregated": { "default": { "access": "public" } }, - "./social/domain/post/exploreAggregated": { "default": { "access": "public" } }, - "./social/domain/post/getByIdAggregated": { "default": { "access": "public" } }, - "./social/domain/post/getByParentAggregated": { "default": { "access": "public" } }, - "./social/domain/post/getRecommendedAggregated": { "default": { "access": "public"}}, - "./social/domain/post/remove": { "default": { "access": "public" }, "subscribe": { "access": "private" } }, + "./social/domain/post/getByCreator": { "default": { "access": "public" } }, + "./social/domain/post/getByFollowing": { "default": { "access": "public" } }, + "./social/domain/post/explore": { "default": { "access": "public" } }, + "./social/domain/post/getById": { "default": { "access": "public" } }, + "./social/domain/post/getByParent": { "default": { "access": "public" } }, + "./social/domain/post/getRecommended": { "default": { "access": "public"}}, + "./social/domain/post/remove": { "default": { "access": "public" } }, - "./social/domain/post.metrics/create": { "subscriptions": { "access": "private" } }, - "./social/domain/post.metrics/updateRatings": { "subscriptions": { "access": "private" } }, - "./social/domain/post.metrics/updateReactions": { "subscriptions": { "access": "private" } }, + "./social/domain/post.metrics/subscriptions": { "default": { "access": "private" } }, - "./social/domain/rating/toggle": { "default": { "access": "public" }, "subscribe": { "access": "private" } }, + "./social/domain/post.rating/toggle": { "default": { "access": "public" } }, - "./social/domain/relation/aggregate": { "default": { "access": "private" }}, - "./social/domain/relation/exploreAggregated": { "default": { "access": "public" } }, - "./social/domain/relation/establish": { "default": { "access": "public" }, "subscribe": { "access": "private" } }, - "./social/domain/relation/getAggregated": { "default": { "access": "public" } }, - "./social/domain/relation/getFollowersAggregated": { "default": { "access": "public" } }, - "./social/domain/relation/getFollowingAggregated": { "default": { "access": "public" } } + "./social/domain/relation/explore": { "default": { "access": "public" } }, + "./social/domain/relation/establish": { "default": { "access": "public" } }, + "./social/domain/relation/get": { "default": { "access": "public" } }, + "./social/domain/relation/getFollowers": { "default": { "access": "public" } }, + "./social/domain/relation/getFollowing": { "default": { "access": "public" } } } \ No newline at end of file diff --git a/deployment/segments/social.errors.json b/deployment/segments/social.errors.json new file mode 100644 index 00000000..eaf8cdd7 --- /dev/null +++ b/deployment/segments/social.errors.json @@ -0,0 +1,31 @@ +{ + "./social/domain/creator/create/makeNickname/TooManySimilarNicknames": { "default": { }}, + "./social/domain/creator/create/InvalidCreator": { "default": { }}, + "./social/domain/creator/getById/CreatorNotFound": { "default": { }}, + "./social/domain/creator/getByNickname/NicknameNotFound": { "default": { }}, + "./social/domain/creator/updateFullName/InvalidFullName": { "default": { }}, + "./social/domain/creator/updateNickname/InvalidNickname": { "default": { }}, + "./social/domain/creator/updateNickname/NicknameAlreadyExists": { "default": { }}, + + "./social/domain/creator.metrics/_retrieveByCreator/CreatorMetricsNotFound": { "default": {} }, + + "./social/domain/image/create/InvalidDataURL": { "default": {} }, + "./social/domain/image/download/ImageNotDownloaded": { "default": {} }, + "./social/domain/image/getById/ImageNotFound": { "default": {} }, + + "./social/domain/post/_create/InvalidPost": { "default": {} }, + "./social/domain/post/_retrieveById/PostNotFound": { "default": {} }, + + "./social/domain/post.comic/_retrieveById/ComicNotFound": { "default": {} }, + "./social/domain/post.comic/create/InvalidComic": { "default": {} }, + + "./social/domain/post.comment/create/InvalidComment": { "default": {} }, + "./social/domain/post.comment/getById/CommentNotFound": { "default": {} }, + + "./social/domain/post.metrics/_retrieveByPost/PostMetricsNotFound": { "default": {} }, + + "./social/domain/post.rating/toggle/create/InvalidRating": { "default": {} }, + + "./social/domain/relation/establish/create/InvalidRelation": { "default": {} }, + "./social/domain/relation/establish/RelationAlreadyExists": { "default": {} } +} \ No newline at end of file diff --git a/deployment/segments/social.notification.json b/deployment/segments/social.notification.json index 02806337..63b97db7 100644 --- a/deployment/segments/social.notification.json +++ b/deployment/segments/social.notification.json @@ -1,6 +1,3 @@ { - "./social/domain/notification/create": { "default": { "access": "protected" } }, - "./social/domain/notification/getByPostId": { "default": { "access": "protected" } }, - "./social/domain/notification/getRecent": { "default": { "access": "protected" } }, - "./social/domain/notification/remove": { "default": { "access": "protected" } } + "./social/domain/notification/subscriptions": { "default": { "access": "private" } } } \ No newline at end of file diff --git a/deployment/segments/social.reads.json b/deployment/segments/social.reads.json index 865e5b94..bed86d93 100644 --- a/deployment/segments/social.reads.json +++ b/deployment/segments/social.reads.json @@ -1,36 +1,33 @@ { - "./social/domain/comic/getById": { "default": { "access": "protected" } }, - - "./social/domain/comment/getById": { "default": { "access": "protected" } }, - - "./social/domain/creator/generateNickname/retrieveByNickname": { "default": { "access": "protected" } }, - "./social/domain/creator/generateNickname/retrieveByStartNickname": { "default": { "access": "protected" } }, - "./social/domain/creator/getByEmail": { "default": { "access": "protected" } }, - "./social/domain/creator/getById": { "default": { "access": "protected" } }, - "./social/domain/creator/getByNickname": { "default": { "access": "protected" } }, - "./social/domain/creator/getMe": { "default": { "access": "protected" } }, - "./social/domain/creator/getOthers": { "default": { "access": "private" }}, + "./social/domain/creator/create/makeNickname/retrieveByNickname": { "default": { "access": "protected" } }, + "./social/domain/creator/create/makeNickname/retrieveByStartNickname": { "default": { "access": "protected" } }, + "./social/domain/creator/getByNickname/retrieve": { "default": { "access": "protected" } }, + "./social/domain/creator/getIdByEmail/retrieve": { "default": { "access": "protected" } }, + "./social/domain/creator/getOtherIds/retrieve": { "default": { "access": "protected" } }, "./social/domain/creator/updateNickname/retrieveByNickname": { "default": { "access": "protected" } }, - "./social/domain/creator.metrics/getByCreator": { "default": { "access": "protected" } }, + "./social/domain/creator.metrics/_retrieveByCreator": { "default": { "access": "protected" } }, "./social/domain/image/getById": { "default": { "access": "protected" } }, - "./social/domain/post/explore": { "default": { "access": "protected" } }, - "./social/domain/post/getByCreator": { "default": { "access": "protected" } }, - "./social/domain/post/getByFollowing": { "default": { "access": "protected" } }, - "./social/domain/post/getById": { "default": { "access": "protected" } }, - "./social/domain/post/getByParent": { "default": { "access": "protected" } }, - "./social/domain/post/getRecommended": { "default": { "access": "protected" } }, + "./social/domain/post/_retrieveById": { "default": { "access": "protected" } }, + "./social/domain/post/explore/retrieve": { "default": { "access": "protected" } }, + "./social/domain/post/getByCreator/retrieve": { "default": { "access": "protected" } }, + "./social/domain/post/getByFollowing/retrieve": { "default": { "access": "protected" } }, + "./social/domain/post/getByParent/retrieve": { "default": { "access": "protected" } }, + "./social/domain/post/getRecommended/retrieve": { "default": { "access": "protected" } }, + + "./social/domain/post.comic/_retrieveById": { "default": { "access": "protected" } }, + + "./social/domain/post.comment/getById/retrieve": { "default": { "access": "protected" } }, - "./social/domain/post.metrics/getByPost": { "default": { "access": "protected" } }, + "./social/domain/post.metrics/_retrieveByPost": { "default": { "access": "protected" } }, - "./social/domain/rating/exists": { "default": { "access": "protected" } }, - "./social/domain/rating/toggle/getData": { "default": { "access": "protected" } }, + "./social/domain/post.rating/exists/retrieve": { "default": { "access": "protected" } }, + "./social/domain/post.rating/toggle/retrieve": { "default": { "access": "protected" } }, - "./social/domain/relation/exists": { "default": { "access": "protected" } }, - "./social/domain/relation/explore": { "default": { "access": "protected" } }, - "./social/domain/relation/get": { "default": { "access": "protected" } }, - "./social/domain/relation/getFollowers": { "default": { "access": "protected" } }, - "./social/domain/relation/getFollowing": { "default": { "access": "protected" } } + "./social/domain/relation/_retrieve": { "default": { "access": "protected" } }, + "./social/domain/relation/_retrieveFollowing": { "default": { "access": "protected" } }, + "./social/domain/relation/establish/exists": { "default": { "access": "protected" } }, + "./social/domain/relation/getFollowers/retrieve": { "default": { "access": "protected" } } } \ No newline at end of file diff --git a/deployment/segments/social.writes.json b/deployment/segments/social.writes.json index 37c8b288..5de3ef70 100644 --- a/deployment/segments/social.writes.json +++ b/deployment/segments/social.writes.json @@ -1,32 +1,35 @@ { - "./social/domain/comic/create/insertData": { "default": { "access": "protected" } }, - "./social/domain/comic/erase": { "default": { "access": "protected" } }, + "./social/domain/creator/create/persist": { "default": { "access": "protected" } }, + "./social/domain/creator/create/remove": { "default": { "access": "protected" } }, + "./social/domain/creator/updateFullName/persist": { "default": { "access": "protected" } }, + "./social/domain/creator/updateNickname/persist": { "default": { "access": "protected" } }, - "./social/domain/comment/create": { "default": { "access": "protected" } }, - "./social/domain/comment/erase": { "default": { "access": "protected" } }, + "./social/domain/creator.metrics/create/persist": { "default": { "access": "protected" } }, + "./social/domain/creator.metrics/updateFollowers/persist": { "default": { "access": "protected" } }, + "./social/domain/creator.metrics/updateFollowing/persist": { "default": { "access": "protected" } }, + "./social/domain/creator.metrics/updatePosts/persist": { "default": { "access": "protected" } }, - "./social/domain/creator/create": { "default": { "access": "protected" } }, - "./social/domain/creator/erase": { "default": { "access": "protected" } }, - "./social/domain/creator/update": { "default": { "access": "protected" } }, + "./social/domain/image/_save": { "default": { "access": "protected" } }, + "./social/domain/image/remove": { "default": { "access": "protected" } }, - "./social/domain/creator.metrics/create/insertData": { "default": { "access": "protected" } }, - "./social/domain/creator.metrics/update": { "default": { "access": "protected" } }, + "./social/domain/post/_create/persist": { "default": { "access": "protected" } }, + "./social/domain/post/_create/remove": { "default": { "access": "protected" } }, + "./social/domain/post/remove/markDeleted": { "default": { "access": "protected" }}, + "./social/domain/post/remove/markUndeleted": { "default": { "access": "protected" }}, - "./social/domain/image/erase": { "default": { "access": "protected" } }, - "./social/domain/image/save": { "default": { "access": "protected" } }, + "./social/domain/post.comic/create/persist": { "default": { "access": "protected" } }, + "./social/domain/post.comic/remove/erase": { "default": { "access": "protected" } }, - "./social/domain/post/create/insertData": { "default": { "access": "protected" } }, - "./social/domain/post/erase": { "default": { "access": "protected" } }, - "./social/domain/post/remove/deleteData": { "default": { "access": "protected" }}, - "./social/domain/post/remove/undeleteData": { "default": { "access": "protected" }}, - "./social/domain/post/update": { "default": { "access": "protected" } }, + "./social/domain/post.comment/create/persist": { "default": { "access": "protected" } }, + "./social/domain/post.comment/remove": { "default": { "access": "protected" } }, - "./social/domain/post.metrics/create/insertData": { "default": { "access": "protected" } }, - "./social/domain/post.metrics/update": { "default": { "access": "protected" } }, + "./social/domain/post.metrics/create/persist": { "default": { "access": "protected" } }, + "./social/domain/post.metrics/updateRatings/persist": { "default": { "access": "protected" } }, + "./social/domain/post.metrics/updateReactions/persist": { "default": { "access": "protected" } }, - "./social/domain/rating/create": { "default": { "access": "protected" } }, - "./social/domain/rating/erase": { "default": { "access": "protected" } }, + "./social/domain/post.rating/toggle/create/persist": { "default": { "access": "protected" } }, + "./social/domain/post.rating/toggle/remove": { "default": { "access": "protected" } }, - "./social/domain/relation/create": { "default": { "access": "protected" } }, - "./social/domain/relation/erase": { "default": { "access": "protected" } } + "./social/domain/relation/establish/create/persist": { "default": { "access": "protected" } }, + "./social/domain/relation/establish/remove": { "default": { "access": "protected" } } } \ No newline at end of file diff --git a/deployment/services/demonstration/social.json b/deployment/services/demonstration/social.json index 6d3ef2da..731654ae 100644 --- a/deployment/services/demonstration/social.json +++ b/deployment/services/demonstration/social.json @@ -3,19 +3,19 @@ "setUp": [ "./common/integrations/authentication/setUp", "./common/integrations/database/setUp", - "./common/integrations/fileStore/setUp", - "./common/integrations/eventBroker/setUp" + "./common/integrations/files/setUp", + "./common/integrations/events/setUp" ], "tearDown": [ "./common/integrations/authentication/tearDown", "./common/integrations/database/tearDown", - "./common/integrations/fileStore/tearDown", - "./common/integrations/eventBroker/tearDown" + "./common/integrations/files/tearDown", + "./common/integrations/events/tearDown" ], "healthChecks": [ "./common/integrations/database/healthCheck", - "./common/integrations/fileStore/healthCheck", - "./common/integrations/eventBroker/healthCheck" + "./common/integrations/files/healthCheck", + "./common/integrations/events/healthCheck" ], "middleware": [ "./common/integrations/authentication/originMiddleware", @@ -26,8 +26,10 @@ { "segments": [ "common.bff", + "common.errors", "common.reads", "social.bff", + "social.errors", "social.notification", "social.reads", "social.writes" @@ -35,6 +37,6 @@ "serveIndexOnNotFound": true, "assetRoot": "./social/app", - "assets": ["index.html", "assets/**/*", "registerSW.js", "sw.js", "workbox-*.js", "manifest.webmanifest" ] + "assets": ["index.html", "assets/**/*", "registerSW.js", "sw.js", "workbox-*.js", "manifest.webmanifest"] } } \ No newline at end of file diff --git a/deployment/services/development/worker.json b/deployment/services/development/worker.json index a598ba4f..2619445c 100644 --- a/deployment/services/development/worker.json +++ b/deployment/services/development/worker.json @@ -3,19 +3,19 @@ "setUp": [ "./common/integrations/authentication/setUp", "./common/integrations/database/setUp", - "./common/integrations/fileStore/setUp", - "./common/integrations/eventBroker/setUp" + "./common/integrations/files/setUp", + "./common/integrations/events/setUp" ], "tearDown": [ "./common/integrations/authentication/tearDown", "./common/integrations/database/tearDown", - "./common/integrations/fileStore/tearDown", - "./common/integrations/eventBroker/tearDown" + "./common/integrations/files/tearDown", + "./common/integrations/events/tearDown" ], "healthChecks": [ "./common/integrations/database/healthCheck", - "./common/integrations/fileStore/healthCheck", - "./common/integrations/eventBroker/healthCheck" + "./common/integrations/files/healthCheck", + "./common/integrations/events/healthCheck" ], "middleware": [ "./common/integrations/authentication/originMiddleware", @@ -26,8 +26,10 @@ { "segments": [ "common.bff", + "common.errors", "common.reads", "social.bff", + "social.errors", "social.notification", "social.reads", "social.writes" diff --git a/deployment/services/production/bff.json b/deployment/services/production/bff.json index 0c09bd56..3a83ef98 100644 --- a/deployment/services/production/bff.json +++ b/deployment/services/production/bff.json @@ -2,14 +2,14 @@ "url": "http://127.0.0.1:4000", "setUp": [ "./common/integrations/authentication/setUp", - "./common/integrations/eventBroker/setUp" + "./common/integrations/events/setUp" ], "tearDown": [ "./common/integrations/authentication/tearDown", - "./common/integrations/eventBroker/tearDown" + "./common/integrations/events/tearDown" ], "healthChecks": [ - "./common/integrations/eventBroker/healthCheck" + "./common/integrations/events/healthCheck" ], "middleware": [ "./common/integrations/authentication/originMiddleware", @@ -20,6 +20,6 @@ { "gateway": "http://127.0.0.1:2000", "trustKey": "${JITAR_TRUST_KEY}", - "segments": ["common.bff", "social.bff"] + "segments": ["common.bff", "common.errors", "social.bff", "social.errors"] } } \ No newline at end of file diff --git a/deployment/services/production/reads.json b/deployment/services/production/reads.json index 64e5f547..d95d22e0 100644 --- a/deployment/services/production/reads.json +++ b/deployment/services/production/reads.json @@ -2,15 +2,15 @@ "url": "http://127.0.0.1:4002", "setUp": [ "./common/integrations/database/setUp", - "./common/integrations/fileStore/setUp" + "./common/integrations/files/setUp" ], "tearDown": [ "./common/integrations/database/tearDown", - "./common/integrations/fileStore/tearDown" + "./common/integrations/files/tearDown" ], "healthChecks": [ "./common/integrations/database/healthCheck", - "./common/integrations/fileStore/healthCheck" + "./common/integrations/files/healthCheck" ], "worker": { diff --git a/deployment/services/production/reads2.json b/deployment/services/production/reads2.json index 6fa08551..e2950ada 100644 --- a/deployment/services/production/reads2.json +++ b/deployment/services/production/reads2.json @@ -2,15 +2,15 @@ "url": "http://127.0.0.1:4003", "setUp": [ "./common/integrations/database/setUp", - "./common/integrations/fileStore/setUp" + "./common/integrations/files/setUp" ], "tearDown": [ "./common/integrations/database/tearDown", - "./common/integrations/fileStore/tearDown" + "./common/integrations/files/tearDown" ], "healthChecks": [ "./common/integrations/database/healthCheck", - "./common/integrations/fileStore/healthCheck" + "./common/integrations/files/healthCheck" ], "worker": { diff --git a/deployment/services/production/writes.json b/deployment/services/production/writes.json index 66c7bd18..55c5085a 100644 --- a/deployment/services/production/writes.json +++ b/deployment/services/production/writes.json @@ -2,15 +2,15 @@ "url": "http://127.0.0.1:4004", "setUp": [ "./common/integrations/database/setUp", - "./common/integrations/fileStore/setUp" + "./common/integrations/files/setUp" ], "tearDown": [ "./common/integrations/database/tearDown", - "./common/integrations/fileStore/tearDown" + "./common/integrations/files/tearDown" ], "healthChecks": [ "./common/integrations/database/healthCheck", - "./common/integrations/fileStore/healthCheck" + "./common/integrations/files/healthCheck" ], "worker": { diff --git a/development/common/domain/creator/added/definitions.ts b/development/common/domain/creator/added/definitions.ts new file mode 100644 index 00000000..c7e91958 --- /dev/null +++ b/development/common/domain/creator/added/definitions.ts @@ -0,0 +1,2 @@ + +export const EVENT_NAME = 'added'; diff --git a/development/social/domain/creator/register/index.ts b/development/common/domain/creator/added/index.ts similarity index 52% rename from development/social/domain/creator/register/index.ts rename to development/common/domain/creator/added/index.ts index faddeac1..ff1eb4ef 100644 --- a/development/social/domain/creator/register/index.ts +++ b/development/common/domain/creator/added/index.ts @@ -1,4 +1,3 @@ -export { default } from './register'; - +export { default as publish } from './publish'; export { default as subscribe } from './subscribe'; diff --git a/development/common/domain/creator/added/publish.ts b/development/common/domain/creator/added/publish.ts new file mode 100644 index 00000000..e4d65e05 --- /dev/null +++ b/development/common/domain/creator/added/publish.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (data: EventData): Promise +{ + return eventBroker.publish({ topic: EVENT_TOPIC, name: EVENT_NAME, data }); +} diff --git a/development/common/domain/creator/added/subscribe.ts b/development/common/domain/creator/added/subscribe.ts new file mode 100644 index 00000000..f7cbe15a --- /dev/null +++ b/development/common/domain/creator/added/subscribe.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData, type EventHandler } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (handler: EventHandler): Promise +{ + return eventBroker.subscribe({ topic: EVENT_TOPIC, name: EVENT_NAME, handler }); +} diff --git a/development/common/domain/creator/definitions.ts b/development/common/domain/creator/definitions.ts new file mode 100644 index 00000000..9221f839 --- /dev/null +++ b/development/common/domain/creator/definitions.ts @@ -0,0 +1,12 @@ + +import { type Identifier } from '^/primitives/identifier'; + +import { type BaseEventData, type BaseEventHandler } from '../definitions'; + +export type EventData = BaseEventData & { + readonly creatorId: Identifier; +}; + +export type EventHandler = BaseEventHandler; + +export const EVENT_TOPIC = 'common.creator'; diff --git a/development/social/domain/post/remove/definitions.ts b/development/common/domain/creator/removed/definitions.ts similarity index 100% rename from development/social/domain/post/remove/definitions.ts rename to development/common/domain/creator/removed/definitions.ts diff --git a/development/social/domain/rating/toggle/index.ts b/development/common/domain/creator/removed/index.ts similarity index 52% rename from development/social/domain/rating/toggle/index.ts rename to development/common/domain/creator/removed/index.ts index a084544a..ff1eb4ef 100644 --- a/development/social/domain/rating/toggle/index.ts +++ b/development/common/domain/creator/removed/index.ts @@ -1,4 +1,3 @@ -export { default } from './toggle'; - +export { default as publish } from './publish'; export { default as subscribe } from './subscribe'; diff --git a/development/common/domain/creator/removed/publish.ts b/development/common/domain/creator/removed/publish.ts new file mode 100644 index 00000000..e4d65e05 --- /dev/null +++ b/development/common/domain/creator/removed/publish.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (data: EventData): Promise +{ + return eventBroker.publish({ topic: EVENT_TOPIC, name: EVENT_NAME, data }); +} diff --git a/development/common/domain/creator/removed/subscribe.ts b/development/common/domain/creator/removed/subscribe.ts new file mode 100644 index 00000000..f7cbe15a --- /dev/null +++ b/development/common/domain/creator/removed/subscribe.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData, type EventHandler } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (handler: EventHandler): Promise +{ + return eventBroker.subscribe({ topic: EVENT_TOPIC, name: EVENT_NAME, handler }); +} diff --git a/development/common/domain/creator/updated/definitions.ts b/development/common/domain/creator/updated/definitions.ts new file mode 100644 index 00000000..969884be --- /dev/null +++ b/development/common/domain/creator/updated/definitions.ts @@ -0,0 +1,2 @@ + +export const EVENT_NAME = 'updated'; diff --git a/development/common/domain/creator/updated/index.ts b/development/common/domain/creator/updated/index.ts new file mode 100644 index 00000000..ff1eb4ef --- /dev/null +++ b/development/common/domain/creator/updated/index.ts @@ -0,0 +1,3 @@ + +export { default as publish } from './publish'; +export { default as subscribe } from './subscribe'; diff --git a/development/common/domain/creator/updated/publish.ts b/development/common/domain/creator/updated/publish.ts new file mode 100644 index 00000000..e4d65e05 --- /dev/null +++ b/development/common/domain/creator/updated/publish.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (data: EventData): Promise +{ + return eventBroker.publish({ topic: EVENT_TOPIC, name: EVENT_NAME, data }); +} diff --git a/development/common/domain/creator/updated/subscribe.ts b/development/common/domain/creator/updated/subscribe.ts new file mode 100644 index 00000000..f7cbe15a --- /dev/null +++ b/development/common/domain/creator/updated/subscribe.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData, type EventHandler } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (handler: EventHandler): Promise +{ + return eventBroker.subscribe({ topic: EVENT_TOPIC, name: EVENT_NAME, handler }); +} diff --git a/development/common/domain/definitions.ts b/development/common/domain/definitions.ts new file mode 100644 index 00000000..924fedea --- /dev/null +++ b/development/common/domain/definitions.ts @@ -0,0 +1,18 @@ + +import { type EventHandler as BaseEventHandler } from '@theshelf/events'; + +import { type TenantId } from '^/domain/tenant'; +import { type ContextId } from '^/primitives/context'; +import { type Identifier } from '^/primitives/identifier'; + +export { type BaseEventHandler }; + +export type BaseEventData = { + readonly contextId: ContextId; + readonly tenantId: TenantId; + readonly principalId: Identifier; +}; + +export type BaseRecord = { + readonly id: Identifier; +}; diff --git a/development/common/domain/post.rating/added/definitions.ts b/development/common/domain/post.rating/added/definitions.ts new file mode 100644 index 00000000..c7e91958 --- /dev/null +++ b/development/common/domain/post.rating/added/definitions.ts @@ -0,0 +1,2 @@ + +export const EVENT_NAME = 'added'; diff --git a/development/common/domain/post.rating/added/index.ts b/development/common/domain/post.rating/added/index.ts new file mode 100644 index 00000000..ff1eb4ef --- /dev/null +++ b/development/common/domain/post.rating/added/index.ts @@ -0,0 +1,3 @@ + +export { default as publish } from './publish'; +export { default as subscribe } from './subscribe'; diff --git a/development/common/domain/post.rating/added/publish.ts b/development/common/domain/post.rating/added/publish.ts new file mode 100644 index 00000000..e4d65e05 --- /dev/null +++ b/development/common/domain/post.rating/added/publish.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (data: EventData): Promise +{ + return eventBroker.publish({ topic: EVENT_TOPIC, name: EVENT_NAME, data }); +} diff --git a/development/common/domain/post.rating/added/subscribe.ts b/development/common/domain/post.rating/added/subscribe.ts new file mode 100644 index 00000000..f7cbe15a --- /dev/null +++ b/development/common/domain/post.rating/added/subscribe.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData, type EventHandler } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (handler: EventHandler): Promise +{ + return eventBroker.subscribe({ topic: EVENT_TOPIC, name: EVENT_NAME, handler }); +} diff --git a/development/common/domain/post.rating/definitions.ts b/development/common/domain/post.rating/definitions.ts new file mode 100644 index 00000000..b1de5068 --- /dev/null +++ b/development/common/domain/post.rating/definitions.ts @@ -0,0 +1,13 @@ + +import { type Identifier } from '^/primitives/identifier'; + +import { type BaseEventData, type BaseEventHandler } from '../definitions'; + +export type EventData = BaseEventData & { + readonly creatorId: Identifier; + readonly postId: Identifier; +}; + +export type EventHandler = BaseEventHandler; + +export const EVENT_TOPIC = 'common.post.rating'; diff --git a/development/common/domain/post.rating/removed/definitions.ts b/development/common/domain/post.rating/removed/definitions.ts new file mode 100644 index 00000000..9bb3ca4a --- /dev/null +++ b/development/common/domain/post.rating/removed/definitions.ts @@ -0,0 +1,2 @@ + +export const EVENT_NAME = 'removed'; diff --git a/development/common/domain/post.rating/removed/index.ts b/development/common/domain/post.rating/removed/index.ts new file mode 100644 index 00000000..ff1eb4ef --- /dev/null +++ b/development/common/domain/post.rating/removed/index.ts @@ -0,0 +1,3 @@ + +export { default as publish } from './publish'; +export { default as subscribe } from './subscribe'; diff --git a/development/common/domain/post.rating/removed/publish.ts b/development/common/domain/post.rating/removed/publish.ts new file mode 100644 index 00000000..e4d65e05 --- /dev/null +++ b/development/common/domain/post.rating/removed/publish.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (data: EventData): Promise +{ + return eventBroker.publish({ topic: EVENT_TOPIC, name: EVENT_NAME, data }); +} diff --git a/development/common/domain/post.rating/removed/subscribe.ts b/development/common/domain/post.rating/removed/subscribe.ts new file mode 100644 index 00000000..f7cbe15a --- /dev/null +++ b/development/common/domain/post.rating/removed/subscribe.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData, type EventHandler } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (handler: EventHandler): Promise +{ + return eventBroker.subscribe({ topic: EVENT_TOPIC, name: EVENT_NAME, handler }); +} diff --git a/development/common/domain/post/added/definitions.ts b/development/common/domain/post/added/definitions.ts new file mode 100644 index 00000000..c7e91958 --- /dev/null +++ b/development/common/domain/post/added/definitions.ts @@ -0,0 +1,2 @@ + +export const EVENT_NAME = 'added'; diff --git a/development/common/domain/post/added/index.ts b/development/common/domain/post/added/index.ts new file mode 100644 index 00000000..ff1eb4ef --- /dev/null +++ b/development/common/domain/post/added/index.ts @@ -0,0 +1,3 @@ + +export { default as publish } from './publish'; +export { default as subscribe } from './subscribe'; diff --git a/development/common/domain/post/added/publish.ts b/development/common/domain/post/added/publish.ts new file mode 100644 index 00000000..e4d65e05 --- /dev/null +++ b/development/common/domain/post/added/publish.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (data: EventData): Promise +{ + return eventBroker.publish({ topic: EVENT_TOPIC, name: EVENT_NAME, data }); +} diff --git a/development/common/domain/post/added/subscribe.ts b/development/common/domain/post/added/subscribe.ts new file mode 100644 index 00000000..f7cbe15a --- /dev/null +++ b/development/common/domain/post/added/subscribe.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData, type EventHandler } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (handler: EventHandler): Promise +{ + return eventBroker.subscribe({ topic: EVENT_TOPIC, name: EVENT_NAME, handler }); +} diff --git a/development/common/domain/post/definitions.ts b/development/common/domain/post/definitions.ts new file mode 100644 index 00000000..e212d07f --- /dev/null +++ b/development/common/domain/post/definitions.ts @@ -0,0 +1,13 @@ + +import { type Identifier } from '^/primitives/identifier'; + +import { type BaseEventData, type BaseEventHandler } from '../definitions'; + +export type EventData = BaseEventData & { + readonly postId: Identifier; + readonly parentId?: Identifier; +}; + +export type EventHandler = BaseEventHandler; + +export const EVENT_TOPIC = 'common.post'; diff --git a/development/common/domain/post/removed/definitions.ts b/development/common/domain/post/removed/definitions.ts new file mode 100644 index 00000000..9bb3ca4a --- /dev/null +++ b/development/common/domain/post/removed/definitions.ts @@ -0,0 +1,2 @@ + +export const EVENT_NAME = 'removed'; diff --git a/development/common/domain/post/removed/index.ts b/development/common/domain/post/removed/index.ts new file mode 100644 index 00000000..ff1eb4ef --- /dev/null +++ b/development/common/domain/post/removed/index.ts @@ -0,0 +1,3 @@ + +export { default as publish } from './publish'; +export { default as subscribe } from './subscribe'; diff --git a/development/common/domain/post/removed/publish.ts b/development/common/domain/post/removed/publish.ts new file mode 100644 index 00000000..e4d65e05 --- /dev/null +++ b/development/common/domain/post/removed/publish.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (data: EventData): Promise +{ + return eventBroker.publish({ topic: EVENT_TOPIC, name: EVENT_NAME, data }); +} diff --git a/development/common/domain/post/removed/subscribe.ts b/development/common/domain/post/removed/subscribe.ts new file mode 100644 index 00000000..f7cbe15a --- /dev/null +++ b/development/common/domain/post/removed/subscribe.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData, type EventHandler } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (handler: EventHandler): Promise +{ + return eventBroker.subscribe({ topic: EVENT_TOPIC, name: EVENT_NAME, handler }); +} diff --git a/development/common/domain/relation/definitions.ts b/development/common/domain/relation/definitions.ts new file mode 100644 index 00000000..cdb00e71 --- /dev/null +++ b/development/common/domain/relation/definitions.ts @@ -0,0 +1,13 @@ + +import { type Identifier } from '^/primitives/identifier'; + +import { type BaseEventData, type BaseEventHandler } from '../definitions'; + +export type EventData = BaseEventData & { + readonly followerId: Identifier; + readonly followingId: Identifier; +}; + +export type EventHandler = BaseEventHandler; + +export const EVENT_TOPIC = 'common.relation'; diff --git a/development/social/domain/relation/establish/definitions.ts b/development/common/domain/relation/established/definitions.ts similarity index 100% rename from development/social/domain/relation/establish/definitions.ts rename to development/common/domain/relation/established/definitions.ts diff --git a/development/common/domain/relation/established/index.ts b/development/common/domain/relation/established/index.ts new file mode 100644 index 00000000..ff1eb4ef --- /dev/null +++ b/development/common/domain/relation/established/index.ts @@ -0,0 +1,3 @@ + +export { default as publish } from './publish'; +export { default as subscribe } from './subscribe'; diff --git a/development/common/domain/relation/established/publish.ts b/development/common/domain/relation/established/publish.ts new file mode 100644 index 00000000..e4d65e05 --- /dev/null +++ b/development/common/domain/relation/established/publish.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (data: EventData): Promise +{ + return eventBroker.publish({ topic: EVENT_TOPIC, name: EVENT_NAME, data }); +} diff --git a/development/common/domain/relation/established/subscribe.ts b/development/common/domain/relation/established/subscribe.ts new file mode 100644 index 00000000..f7cbe15a --- /dev/null +++ b/development/common/domain/relation/established/subscribe.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData, type EventHandler } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (handler: EventHandler): Promise +{ + return eventBroker.subscribe({ topic: EVENT_TOPIC, name: EVENT_NAME, handler }); +} diff --git a/development/common/domain/relation/unestablished/definitions.ts b/development/common/domain/relation/unestablished/definitions.ts new file mode 100644 index 00000000..20e25308 --- /dev/null +++ b/development/common/domain/relation/unestablished/definitions.ts @@ -0,0 +1,2 @@ + +export const EVENT_NAME = 'unestablished'; diff --git a/development/common/domain/relation/unestablished/index.ts b/development/common/domain/relation/unestablished/index.ts new file mode 100644 index 00000000..ff1eb4ef --- /dev/null +++ b/development/common/domain/relation/unestablished/index.ts @@ -0,0 +1,3 @@ + +export { default as publish } from './publish'; +export { default as subscribe } from './subscribe'; diff --git a/development/common/domain/relation/unestablished/publish.ts b/development/common/domain/relation/unestablished/publish.ts new file mode 100644 index 00000000..e4d65e05 --- /dev/null +++ b/development/common/domain/relation/unestablished/publish.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (data: EventData): Promise +{ + return eventBroker.publish({ topic: EVENT_TOPIC, name: EVENT_NAME, data }); +} diff --git a/development/common/domain/relation/unestablished/subscribe.ts b/development/common/domain/relation/unestablished/subscribe.ts new file mode 100644 index 00000000..f7cbe15a --- /dev/null +++ b/development/common/domain/relation/unestablished/subscribe.ts @@ -0,0 +1,11 @@ + +import eventBroker from '^/integrations/events'; + +import { EVENT_TOPIC, type EventData, type EventHandler } from '../definitions'; + +import { EVENT_NAME } from './definitions'; + +export default async function (handler: EventHandler): Promise +{ + return eventBroker.subscribe({ topic: EVENT_TOPIC, name: EVENT_NAME, handler }); +} diff --git a/development/common/domain/tenant/definitions.ts b/development/common/domain/tenant/definitions.ts index 3d7c927c..5c1e5999 100644 --- a/development/common/domain/tenant/definitions.ts +++ b/development/common/domain/tenant/definitions.ts @@ -1,2 +1,33 @@ +import { type Validation } from '@theshelf/validation'; + +import { type BaseRecord } from '../definitions'; + +export type Record = BaseRecord & { + readonly origins: string[]; +}; + +export type TenantId = string; +export type Origin = string; + +export type Tenant = { + readonly id: TenantId; + readonly origin: Origin; +}; + +export const tenantIdValidation: Validation = { + message: 'Invalid origin', + STRING: {} +}; + +export const originValidation: Validation = { + message: 'Invalid origin', + URL_STRING: {} +}; + +export const tenant: Tenant = { + id: 'default', + origin: 'localhost' +}; + export const RECORD_TYPE = 'tenant'; diff --git a/development/common/domain/tenant/getByOriginConverted/InvalidOrigin.ts b/development/common/domain/tenant/getByOrigin/InvalidOrigin.ts similarity index 100% rename from development/common/domain/tenant/getByOriginConverted/InvalidOrigin.ts rename to development/common/domain/tenant/getByOrigin/InvalidOrigin.ts diff --git a/development/common/domain/tenant/getByOrigin/getByOrigin.ts b/development/common/domain/tenant/getByOrigin/getByOrigin.ts deleted file mode 100644 index b750020c..00000000 --- a/development/common/domain/tenant/getByOrigin/getByOrigin.ts +++ /dev/null @@ -1,29 +0,0 @@ - -import type { RecordQuery } from '@theshelf/database'; - -import database from '^/integrations/database'; -import logger from '^/integrations/logging'; - -import { RECORD_TYPE } from '../definitions'; -import type { DataModel } from '../types'; - -import TenantNotFound from './TenantNotFound'; - -export default async function getByOrigin(origin: string): Promise -{ - const query: RecordQuery = - { - origins: { CONTAINS: origin } - }; - - const record = await database.readRecord(RECORD_TYPE, query); - - if (record === undefined) - { - logger.warn(`Tenant with origin '${origin}' could not be found.`); - - throw new TenantNotFound(); - } - - return record as DataModel; -} diff --git a/development/common/domain/tenant/getByOrigin/index.ts b/development/common/domain/tenant/getByOrigin/index.ts index f940e37a..ae86e911 100644 --- a/development/common/domain/tenant/getByOrigin/index.ts +++ b/development/common/domain/tenant/getByOrigin/index.ts @@ -1,3 +1,16 @@ -export { default } from './getByOrigin'; +import { type Tenant } from '../definitions'; + +import retrieve from './retrieve'; +import validate from './validate'; + +export default async function (origin: string): Promise +{ + validate(origin); + + const record = await retrieve(origin); + + return { id: record.id, origin: origin }; +} + export { default as TenantNotFound } from './TenantNotFound'; diff --git a/development/common/domain/tenant/getByOrigin/retrieve.ts b/development/common/domain/tenant/getByOrigin/retrieve.ts new file mode 100644 index 00000000..0286b67f --- /dev/null +++ b/development/common/domain/tenant/getByOrigin/retrieve.ts @@ -0,0 +1,21 @@ + +import database from '^/integrations/database'; +import logger from '^/integrations/logging'; + +import { RECORD_TYPE, type Record } from '../definitions'; + +import TenantNotFound from './TenantNotFound'; + +export default async function (origin: string): Promise +{ + const result = await database.readRecord(RECORD_TYPE, { origins: { CONTAINS: origin } }); + + if (result.notFound) + { + logger.warn(`Tenant with origin '${origin}' could not be found.`); + + throw new TenantNotFound(); + } + + return result.record!; +} diff --git a/development/common/domain/tenant/getByOrigin/validate.ts b/development/common/domain/tenant/getByOrigin/validate.ts new file mode 100644 index 00000000..cc61c677 --- /dev/null +++ b/development/common/domain/tenant/getByOrigin/validate.ts @@ -0,0 +1,18 @@ + +import validator from '^/integrations/validation'; + +import { type Origin, originValidation } from '../definitions'; + +import InvalidOrigin from './InvalidOrigin'; + +export default function (origin: string): void +{ + const result = validator.validate<{origin: Origin}>({ origin }, { + origin: originValidation + }); + + if (result.invalid) + { + throw new InvalidOrigin(result.messages); + } +} diff --git a/development/common/domain/tenant/getByOriginConverted/getByOriginConverted.ts b/development/common/domain/tenant/getByOriginConverted/getByOriginConverted.ts deleted file mode 100644 index 7f8cc791..00000000 --- a/development/common/domain/tenant/getByOriginConverted/getByOriginConverted.ts +++ /dev/null @@ -1,16 +0,0 @@ - -import getByOrigin from '../getByOrigin'; -import type { Tenant } from '../types'; -import validateData from './validateData'; - -export default async function getByOriginConverted(origin: string): Promise -{ - validateData({ origin }); - - const tenant = await getByOrigin(origin); - - return { - id: tenant.id, - origin: origin - }; -} diff --git a/development/common/domain/tenant/getByOriginConverted/index.ts b/development/common/domain/tenant/getByOriginConverted/index.ts deleted file mode 100644 index db225e15..00000000 --- a/development/common/domain/tenant/getByOriginConverted/index.ts +++ /dev/null @@ -1,2 +0,0 @@ - -export { default } from './getByOriginConverted'; diff --git a/development/common/domain/tenant/getByOriginConverted/types.ts b/development/common/domain/tenant/getByOriginConverted/types.ts deleted file mode 100644 index 1739df5a..00000000 --- a/development/common/domain/tenant/getByOriginConverted/types.ts +++ /dev/null @@ -1,4 +0,0 @@ - -import type { Tenant } from '../types'; - -export type ValidationModel = Pick; diff --git a/development/common/domain/tenant/getByOriginConverted/validateData.ts b/development/common/domain/tenant/getByOriginConverted/validateData.ts deleted file mode 100644 index 8012d0c0..00000000 --- a/development/common/domain/tenant/getByOriginConverted/validateData.ts +++ /dev/null @@ -1,29 +0,0 @@ - -import type { ValidationSchema } from '@theshelf/validation'; - -import validator from '^/integrations/validation'; - -import InvalidOrigin from './InvalidOrigin'; -import type { ValidationModel } from './types'; - -const schema: ValidationSchema = -{ - origin: - { - message: 'Invalid origin', - URL: - { - required: true - } - } -}; - -export default function validateData({ origin }: ValidationModel): void -{ - const result = validator.validate({ origin }, schema); - - if (result.invalid) - { - throw new InvalidOrigin(result.messages); - } -} diff --git a/development/common/domain/tenant/index.ts b/development/common/domain/tenant/index.ts index 7504bb46..b257c9ea 100644 --- a/development/common/domain/tenant/index.ts +++ b/development/common/domain/tenant/index.ts @@ -1,6 +1,2 @@ -export { RECORD_TYPE } from './definitions'; - -export type { DataModel, Tenant } from './types'; - -export { default as tenant } from './tenant'; +export { RECORD_TYPE, tenant, tenantIdValidation, type TenantId, type Origin, type Tenant, type Record } from './definitions'; diff --git a/development/common/domain/tenant/tenant.ts b/development/common/domain/tenant/tenant.ts deleted file mode 100644 index 664fe246..00000000 --- a/development/common/domain/tenant/tenant.ts +++ /dev/null @@ -1,9 +0,0 @@ - -import type { Tenant } from './types'; - -const tenant: Tenant = { - id: 'default', - origin: 'localhost' -}; - -export default tenant; diff --git a/development/common/domain/tenant/types.ts b/development/common/domain/tenant/types.ts deleted file mode 100644 index 7f74c576..00000000 --- a/development/common/domain/tenant/types.ts +++ /dev/null @@ -1,13 +0,0 @@ - -import type { BaseDataModel } from '../types'; - -type DataModel = BaseDataModel & { - readonly origins: string[]; -}; - -type Tenant = { - readonly id: string; - readonly origin: string; -}; - -export type { DataModel, Tenant }; diff --git a/development/common/domain/types.ts b/development/common/domain/types.ts deleted file mode 100644 index 0ba2f92b..00000000 --- a/development/common/domain/types.ts +++ /dev/null @@ -1,6 +0,0 @@ - -type BaseDataModel = { - readonly id: string; -}; - -export type { BaseDataModel }; diff --git a/development/common/integrations/authentication/authenticationMiddleware.ts b/development/common/integrations/authentication/authenticationMiddleware.ts index 67bb3b64..83dcb1b7 100644 --- a/development/common/integrations/authentication/authenticationMiddleware.ts +++ b/development/common/integrations/authentication/authenticationMiddleware.ts @@ -4,15 +4,15 @@ import { AuthenticationMiddleware } from '@jitar-plugins/authentication'; import identityProvider from './identityProvider'; const authProcedures = { - loginUrl: 'social/domain/authentication/getLoginUrl', - login: 'social/domain/authentication/login', - logout: 'social/domain/authentication/logout' + loginUrl: 'social/security/authentication/getLoginUrl', + login: 'social/security/authentication/login', + logout: 'social/security/authentication/logout' }; const redirectPath = process.env.AUTHENTICATION_CLIENT_PATH ?? ''; const whiteList: string[] = [ - 'common/domain/tenant/getByOriginConverted' + 'common/domain/tenant/getByOrigin' ]; export default new AuthenticationMiddleware(identityProvider, authProcedures, redirectPath, whiteList); diff --git a/development/common/integrations/authentication/identityProvider.ts b/development/common/integrations/authentication/identityProvider.ts index b6c56f1d..2533e449 100644 --- a/development/common/integrations/authentication/identityProvider.ts +++ b/development/common/integrations/authentication/identityProvider.ts @@ -25,7 +25,7 @@ export const driver = setUpOpenID(); const identityProvider = new IdentityProvider(driver, shelfLogger); const connectionManager = new ConnectionManager({ - name: 'Identity provider', + name: 'IdentityProvider', connectable: identityProvider }, shelfLogger); diff --git a/development/common/integrations/database/database.ts b/development/common/integrations/database/database.ts index e1237719..15d4e854 100644 --- a/development/common/integrations/database/database.ts +++ b/development/common/integrations/database/database.ts @@ -1,7 +1,7 @@ +import ConnectionManager from '@theshelf/connection'; import Database, { MemoryDriver } from '@theshelf/database'; import { MongoDBDriver } from '@theshelf/database-driver-mongodb'; -import ConnectionManager from '@theshelf/connection'; import { shelfLogger } from '^/integrations/logging'; diff --git a/development/common/integrations/database/healthCheck.ts b/development/common/integrations/database/healthCheck.ts index 63125845..db7b90d4 100644 --- a/development/common/integrations/database/healthCheck.ts +++ b/development/common/integrations/database/healthCheck.ts @@ -1,5 +1,6 @@ -import database from './database'; import { DatabaseHealthCheck } from '@jitar-plugins/database'; +import database from './database'; + export default new DatabaseHealthCheck(database); diff --git a/development/common/integrations/eventBroker/eventBroker.ts b/development/common/integrations/eventBroker/eventBroker.ts deleted file mode 100644 index 60017936..00000000 --- a/development/common/integrations/eventBroker/eventBroker.ts +++ /dev/null @@ -1,16 +0,0 @@ - -import EventBroker, { MemoryDriver } from '@theshelf/eventbroker'; -import ConnectionManager from '@theshelf/connection'; - -import { shelfLogger } from '^/integrations/logging'; - -export const driver = new MemoryDriver(); - -const eventBroker = new EventBroker(driver, shelfLogger); - -const connectionManager = new ConnectionManager({ - name: 'Event broker', - connectable: eventBroker -}, shelfLogger); - -export { eventBroker as default, connectionManager }; diff --git a/development/common/integrations/events/eventBroker.ts b/development/common/integrations/events/eventBroker.ts new file mode 100644 index 00000000..8b1f61a6 --- /dev/null +++ b/development/common/integrations/events/eventBroker.ts @@ -0,0 +1,34 @@ + +import ConnectionManager from '@theshelf/connection'; +import EventBroker, { MemoryDriver } from '@theshelf/events'; +import { KafkaDriver } from '@theshelf/events-driver-kafka'; + +import { shelfLogger } from '^/integrations/logging'; + +function setUpMemory(): MemoryDriver +{ + return new MemoryDriver(); +} + +function setUpKafka(): KafkaDriver +{ + return new KafkaDriver({ + brokers: [process.env.KAFKA_BROKER ?? ''], + groupId: process.env.KAFKA_GROUP_ID ?? '', + clientId: process.env.KAFKA_CLIENT_ID ?? '', + autocreateTopics: process.env.KAFKA_AUTOCREATE_TOPICS === 'true' + }); +} + +export const driver = process.env.EVENT_BROKER_DRIVER === 'kafka' + ? setUpKafka() + : setUpMemory(); + +const eventBroker = new EventBroker(driver, shelfLogger); + +const connectionManager = new ConnectionManager({ + name: 'EventBroker', + connectable: eventBroker +}, shelfLogger); + +export { eventBroker as default, connectionManager }; diff --git a/development/common/integrations/eventBroker/healthCheck.ts b/development/common/integrations/events/healthCheck.ts similarity index 59% rename from development/common/integrations/eventBroker/healthCheck.ts rename to development/common/integrations/events/healthCheck.ts index 142319ff..b8b5a372 100644 --- a/development/common/integrations/eventBroker/healthCheck.ts +++ b/development/common/integrations/events/healthCheck.ts @@ -1,6 +1,6 @@ -import eventBroker from './eventBroker'; +import { EventBrokerHealthCheck } from '@jitar-plugins/events'; -import { EventBrokerHealthCheck } from '@jitar-plugins/eventbroker'; +import eventBroker from './eventBroker'; export default new EventBrokerHealthCheck(eventBroker); diff --git a/development/common/integrations/eventBroker/index.ts b/development/common/integrations/events/index.ts similarity index 100% rename from development/common/integrations/eventBroker/index.ts rename to development/common/integrations/events/index.ts diff --git a/development/common/integrations/eventBroker/setUp.ts b/development/common/integrations/events/setUp.ts similarity index 100% rename from development/common/integrations/eventBroker/setUp.ts rename to development/common/integrations/events/setUp.ts diff --git a/development/common/integrations/eventBroker/tearDown.ts b/development/common/integrations/events/tearDown.ts similarity index 100% rename from development/common/integrations/eventBroker/tearDown.ts rename to development/common/integrations/events/tearDown.ts diff --git a/development/common/integrations/fileStore/fileStore.ts b/development/common/integrations/files/fileStore.ts similarity index 82% rename from development/common/integrations/fileStore/fileStore.ts rename to development/common/integrations/files/fileStore.ts index ed65f527..1d090b9a 100644 --- a/development/common/integrations/fileStore/fileStore.ts +++ b/development/common/integrations/files/fileStore.ts @@ -1,7 +1,7 @@ -import FileStore, { MemoryDriver } from '@theshelf/filestore'; -import { S3Driver } from '@theshelf/filestore-driver-s3'; import ConnectionManager from '@theshelf/connection'; +import FileStore, { MemoryDriver } from '@theshelf/files'; +import { S3Driver } from '@theshelf/files-driver-s3'; import { shelfLogger } from '^/integrations/logging'; @@ -13,7 +13,7 @@ function setUpMemory(): MemoryDriver function setUpS3(): S3Driver { const config = { - bucketName: process.env.S3_BUCKET_NAME ?? '', + bucketName: process.env.S3_BUCKET_NAME ?? '', clientConfig: { region: process.env.S3_REGION ?? 'local', credentials: { @@ -35,7 +35,7 @@ export const driver = process.env.FILE_STORE_DRIVER === 's3' const fileStore = new FileStore(driver, shelfLogger); const connectionManager = new ConnectionManager({ - name: 'File store', + name: 'FileStore', connectable: fileStore }, shelfLogger); diff --git a/development/common/integrations/fileStore/healthCheck.ts b/development/common/integrations/files/healthCheck.ts similarity index 58% rename from development/common/integrations/fileStore/healthCheck.ts rename to development/common/integrations/files/healthCheck.ts index 8be35ef0..470156d7 100644 --- a/development/common/integrations/fileStore/healthCheck.ts +++ b/development/common/integrations/files/healthCheck.ts @@ -1,6 +1,6 @@ -import fileStore from './fileStore'; +import { FileStoreHealthCheck } from '@jitar-plugins/files'; -import { FileStoreHealthCheck } from '@jitar-plugins/filestore'; +import fileStore from './fileStore'; export default new FileStoreHealthCheck(fileStore); diff --git a/development/common/integrations/fileStore/index.ts b/development/common/integrations/files/index.ts similarity index 100% rename from development/common/integrations/fileStore/index.ts rename to development/common/integrations/files/index.ts diff --git a/development/common/integrations/fileStore/setUp.ts b/development/common/integrations/files/setUp.ts similarity index 100% rename from development/common/integrations/fileStore/setUp.ts rename to development/common/integrations/files/setUp.ts diff --git a/development/common/integrations/fileStore/tearDown.ts b/development/common/integrations/files/tearDown.ts similarity index 100% rename from development/common/integrations/fileStore/tearDown.ts rename to development/common/integrations/files/tearDown.ts diff --git a/development/common/integrations/notification/notificationHealthCheck.ts b/development/common/integrations/notification/healthCheck.ts similarity index 100% rename from development/common/integrations/notification/notificationHealthCheck.ts rename to development/common/integrations/notification/healthCheck.ts diff --git a/development/common/integrations/notification/notificationService.ts b/development/common/integrations/notification/notificationService.ts index eb907a47..edecf49a 100644 --- a/development/common/integrations/notification/notificationService.ts +++ b/development/common/integrations/notification/notificationService.ts @@ -1,6 +1,6 @@ -import NotificationService, { MemoryDriver } from '@theshelf/notification'; import ConnectionManager from '@theshelf/connection'; +import NotificationService, { MemoryDriver } from '@theshelf/notification'; import { shelfLogger } from '^/integrations/logging'; diff --git a/development/common/integrations/tenancy/middleware/MultiTenantMiddleware.ts b/development/common/integrations/tenancy/middleware/MultiTenantMiddleware.ts index 572693e3..e2586226 100644 --- a/development/common/integrations/tenancy/middleware/MultiTenantMiddleware.ts +++ b/development/common/integrations/tenancy/middleware/MultiTenantMiddleware.ts @@ -1,11 +1,10 @@ -import type { Middleware, NextHandler, Request } from 'jitar'; -import { Response } from 'jitar'; +import { type Middleware, type NextHandler, type Request, Response } from 'jitar'; -import type { Tenant } from '^/domain/tenant'; -import getByOrigin from '^/domain/tenant/getByOriginConverted'; +import { type Tenant } from '^/domain/tenant'; +import getByOrigin from '^/domain/tenant/getByOrigin'; -const GEY_BY_ORIGIN_FQN = 'common/domain/tenant/getByOriginConverted'; +const GEY_BY_ORIGIN_FQN = 'common/domain/tenant/getByOrigin'; const TENANT_PARAMETER = '*tenant'; export default class MultiTenantMiddleware implements Middleware diff --git a/development/common/integrations/utilities/crypto.ts b/development/common/integrations/utilities/crypto.ts index ffcbd783..6f36d0fd 100644 --- a/development/common/integrations/utilities/crypto.ts +++ b/development/common/integrations/utilities/crypto.ts @@ -1,24 +1,14 @@ import crypto from 'node:crypto'; -function generateUUID(): string +export function generateUUID(): string { return crypto.randomUUID(); } -function hashFast(input: string): string -{ - return crypto.createHash('sha512').update(input, 'utf8').digest('hex'); -} - export function generateHash(input: string): string { - return hashFast(input); -} - -export function generateId(): string -{ - return generateUUID(); + return crypto.createHash('sha512').update(input, 'utf8').digest('hex'); } export function generateKey(): string @@ -28,5 +18,5 @@ export function generateKey(): string const id3 = generateUUID(); const id4 = generateUUID(); - return hashFast(id1 + id2 + id3 + id4); + return generateHash(id1 + id2 + id3 + id4); } diff --git a/development/common/integrations/utilities/dates.ts b/development/common/integrations/utilities/dates.ts index a9b7b7e7..bf86c063 100644 --- a/development/common/integrations/utilities/dates.ts +++ b/development/common/integrations/utilities/dates.ts @@ -4,7 +4,7 @@ import relativeTime from 'dayjs/plugin/relativeTime'; daysjs.extend(relativeTime); -export function timeElapsed(date: string): string +export function timeElapsed(date: Date): string { return daysjs(date).fromNow(); } diff --git a/development/common/package.json b/development/common/package.json index 1bcfc493..83dff0f1 100644 --- a/development/common/package.json +++ b/development/common/package.json @@ -5,8 +5,8 @@ "type": "module", "scripts": { "dev": "vite --config app/vite.config.js", - "build": "npm run clean && npm run build-domain", - "build-domain": "tsc && tsc-alias", + "build": "npm run clean && npm run build-logic", + "build-logic": "tsc && tsc-alias", "clean": "rimraf ../../artifacts/build/common", "lint": "eslint" } diff --git a/development/common/primitives/context/definitions.ts b/development/common/primitives/context/definitions.ts new file mode 100644 index 00000000..a3788005 --- /dev/null +++ b/development/common/primitives/context/definitions.ts @@ -0,0 +1,2 @@ + +export type ContextId = string; diff --git a/development/common/primitives/context/index.ts b/development/common/primitives/context/index.ts new file mode 100644 index 00000000..01ea8b2c --- /dev/null +++ b/development/common/primitives/context/index.ts @@ -0,0 +1,2 @@ + +export type { ContextId } from './definitions'; diff --git a/development/common/primitives/count/definitions.ts b/development/common/primitives/count/definitions.ts new file mode 100644 index 00000000..662fc3c8 --- /dev/null +++ b/development/common/primitives/count/definitions.ts @@ -0,0 +1,4 @@ + +export type Count = number; + +export type CountOperation = 'increase' | 'decrease'; diff --git a/development/common/primitives/count/index.ts b/development/common/primitives/count/index.ts new file mode 100644 index 00000000..d0ad2a71 --- /dev/null +++ b/development/common/primitives/count/index.ts @@ -0,0 +1,2 @@ + +export type { Count, CountOperation } from './definitions'; diff --git a/development/common/primitives/identifier/definitions.ts b/development/common/primitives/identifier/definitions.ts new file mode 100644 index 00000000..723c9d4d --- /dev/null +++ b/development/common/primitives/identifier/definitions.ts @@ -0,0 +1,9 @@ + +import { type Validation } from '@theshelf/validation'; + +export type Identifier = string; + +export const identifierValidation: Validation = { + message: 'Value is not a valid identifier', + UUID: {} +} as const; diff --git a/development/common/primitives/identifier/generate/index.ts b/development/common/primitives/identifier/generate/index.ts new file mode 100644 index 00000000..3717e546 --- /dev/null +++ b/development/common/primitives/identifier/generate/index.ts @@ -0,0 +1,9 @@ + +import { generateUUID } from '^/integrations/utilities/crypto'; + +import { type Identifier } from '../definitions'; + +export default function (): Identifier +{ + return generateUUID(); +} diff --git a/development/common/primitives/identifier/index.ts b/development/common/primitives/identifier/index.ts new file mode 100644 index 00000000..bab4f615 --- /dev/null +++ b/development/common/primitives/identifier/index.ts @@ -0,0 +1,2 @@ + +export { identifierValidation, type Identifier } from './definitions'; diff --git a/development/common/primitives/range/definitions.ts b/development/common/primitives/range/definitions.ts new file mode 100644 index 00000000..34d2c4c5 --- /dev/null +++ b/development/common/primitives/range/definitions.ts @@ -0,0 +1,18 @@ + +import { type Validation } from '@theshelf/validation'; + +export type Range = { + offset: number; + limit: number; +}; + +export const offsetValidation: Validation = { + message: 'Value is not a valid offset', + NUMBER: { minValue: 0 } +}; + +export const limitValidation: Validation = { + message: 'Value is not a valid limit', + required: true, + NUMBER: { minValue: 1, maxValue: 30 } +}; diff --git a/development/common/primitives/range/index.ts b/development/common/primitives/range/index.ts new file mode 100644 index 00000000..c5a54147 --- /dev/null +++ b/development/common/primitives/range/index.ts @@ -0,0 +1,2 @@ + +export { type Range } from './definitions'; diff --git a/development/common/primitives/range/validate/InvalidRange.ts b/development/common/primitives/range/validate/InvalidRange.ts new file mode 100644 index 00000000..ef602844 --- /dev/null +++ b/development/common/primitives/range/validate/InvalidRange.ts @@ -0,0 +1,7 @@ + +import { ValidationError } from '^/integrations/errors'; + +export default class InvalidRange extends ValidationError +{ + +} diff --git a/development/common/primitives/range/validate/index.ts b/development/common/primitives/range/validate/index.ts new file mode 100644 index 00000000..267ef08d --- /dev/null +++ b/development/common/primitives/range/validate/index.ts @@ -0,0 +1,21 @@ + +import validator from '^/integrations/validation'; + +import { type Range, offsetValidation, limitValidation } from '../definitions'; + +import InvalidRange from './InvalidRange'; + +export default function (range: Range): void +{ + const result = validator.validate(range, { + offset: offsetValidation, + limit: limitValidation + }); + + if (result.invalid) + { + throw new InvalidRange(result.messages); + } +} + +export { InvalidRange }; diff --git a/development/common/security/definitions.ts b/development/common/security/definitions.ts new file mode 100644 index 00000000..b61ba83c --- /dev/null +++ b/development/common/security/definitions.ts @@ -0,0 +1,13 @@ + +import { type TenantId } from '^/domain/tenant'; +import { type Identifier } from '^/primitives/identifier'; + +export type Requester = { + readonly principalId: Identifier; + readonly tenantId: TenantId; +}; + +export const requester: Requester = { + principalId: 'principal', + tenantId: 'tenant' +}; diff --git a/development/common/security/index.ts b/development/common/security/index.ts new file mode 100644 index 00000000..1053e417 --- /dev/null +++ b/development/common/security/index.ts @@ -0,0 +1,2 @@ + +export { type Requester, requester } from './definitions'; diff --git a/development/common/tsconfig.json b/development/common/tsconfig.json index 2153ea77..ab8a4df4 100644 --- a/development/common/tsconfig.json +++ b/development/common/tsconfig.json @@ -8,5 +8,5 @@ "^/*": ["./*"], } }, - "include": ["./domain", "./integrations"] + "include": ["./domain", "./integrations", "./primitives", "./security"] } \ No newline at end of file diff --git a/development/insights/app/vite.config.ts b/development/insights/app/vite.config.ts index a5c0f76a..273e95b4 100644 --- a/development/insights/app/vite.config.ts +++ b/development/insights/app/vite.config.ts @@ -2,7 +2,6 @@ import jitar, { JitarConfig } from '@jitar/plugin-vite'; import react from '@vitejs/plugin-react'; import { defineConfig } from 'vite'; -import tsconfigPaths from 'vite-tsconfig-paths'; const JITAR_URL = 'http://localhost:3000'; const JITAR_SEGMENTS: string[] = []; @@ -26,10 +25,10 @@ export default defineConfig({ }, resolve: { dedupe: ['react', 'react-dom'], + tsconfigPaths: true }, plugins: [ react(), - tsconfigPaths(), jitar(jitarConfig) ] }); \ No newline at end of file diff --git a/development/insights/domain/types.ts b/development/insights/domain/types.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/development/insights/package.json b/development/insights/package.json index 60effa42..2904456b 100644 --- a/development/insights/package.json +++ b/development/insights/package.json @@ -5,9 +5,9 @@ "type": "module", "scripts": { "dev": "vite --config app/vite.config.js", - "build": "npm run clean && npm run build-domain && npm run build-app", + "build": "npm run clean && npm run build-logic && npm run build-app", "build-app": "vite build --config app/vite.config.js", - "build-domain": "tsc && tsc-alias", + "build-logic": "tsc && tsc-alias", "clean": "rimraf ../../artifacts/build/insights", "lint": "eslint" } diff --git a/development/insights/tsconfig.json b/development/insights/tsconfig.json index 86a26e91..7e8ce18c 100644 --- a/development/insights/tsconfig.json +++ b/development/insights/tsconfig.json @@ -5,6 +5,7 @@ "rootDir": "./", "outDir": "../../artifacts/build/insights", "paths": { + "~/*": ["./domain/*"], "^/*": ["./*"], "@comify/common/*": ["../common/*"] } diff --git a/development/moderation/app/vite.config.ts b/development/moderation/app/vite.config.ts index 5e1f4588..5f404640 100644 --- a/development/moderation/app/vite.config.ts +++ b/development/moderation/app/vite.config.ts @@ -2,7 +2,6 @@ import jitar, { JitarConfig } from '@jitar/plugin-vite'; import react from '@vitejs/plugin-react'; import { defineConfig } from 'vite'; -import tsconfigPaths from 'vite-tsconfig-paths'; const JITAR_URL = 'http://localhost:3000'; const JITAR_SEGMENTS: string[] = []; @@ -26,10 +25,10 @@ export default defineConfig({ }, resolve: { dedupe: ['react', 'react-dom'], + tsconfigPaths: true }, plugins: [ react(), - tsconfigPaths(), jitar(jitarConfig) ] }); \ No newline at end of file diff --git a/development/moderation/domain/types.ts b/development/moderation/domain/types.ts deleted file mode 100644 index e69de29b..00000000 diff --git a/development/moderation/package.json b/development/moderation/package.json index 734a8d03..c4264a93 100644 --- a/development/moderation/package.json +++ b/development/moderation/package.json @@ -5,9 +5,9 @@ "type": "module", "scripts": { "dev": "vite --config app/vite.config.js", - "build": "npm run clean && npm run build-domain && npm run build-app", + "build": "npm run clean && npm run build-logic && npm run build-app", "build-app": "vite build --config app/vite.config.js", - "build-domain": "tsc && tsc-alias", + "build-logic": "tsc && tsc-alias", "clean": "rimraf ../../artifacts/build/moderation", "lint": "eslint" } diff --git a/development/moderation/tsconfig.json b/development/moderation/tsconfig.json index 7cca0e3e..57fbf781 100644 --- a/development/moderation/tsconfig.json +++ b/development/moderation/tsconfig.json @@ -5,6 +5,7 @@ "rootDir": "./", "outDir": "../../artifacts/build/moderation", "paths": { + "~/*": ["./domain/*"], "^/*": ["./*"], "@comify/common/*": ["../common/*"] } diff --git a/development/social/app/components/App.tsx b/development/social/app/components/App.tsx index 225af907..9a3804ed 100644 --- a/development/social/app/components/App.tsx +++ b/development/social/app/components/App.tsx @@ -1,13 +1,11 @@ -import { BrowserRouter } from 'react-router-dom'; - import { ErrorBoundary } from '@maskingtech/react-toolkit'; +import { BrowserRouter } from 'react-router-dom'; import { AppContextProvider, ErrorHandler } from './application'; - import Routes from './Routes'; -export default function App() +export default function () { return diff --git a/development/social/app/components/Routes.tsx b/development/social/app/components/Routes.tsx index 243a7e3e..4a4e5620 100644 --- a/development/social/app/components/Routes.tsx +++ b/development/social/app/components/Routes.tsx @@ -1,15 +1,15 @@ import { Route, Routes } from 'react-router-dom'; -import accountRoutes from './account'; import { legalRoutes, guestRoutes, appRoutes, ApplicationLayout, GuestLayout, LegalLayout, ProtectedRoute } from './application'; -import timelineRoutes from './timeline'; +import accountRoutes from './creator.account'; +import profileRoutes from './creator.profile'; import exploreRoutes from './explore'; import notificationRoutes from './notification'; import postRoutes from './post'; -import profileRoutes from './profile'; +import timelineRoutes from './timeline'; -export default function Component() +export default function () { return @@ -24,7 +24,7 @@ export default function Component() {postRoutes} {profileRoutes} - + }> diff --git a/development/social/app/components/application/ErrorHandler.tsx b/development/social/app/components/application/ErrorHandler.tsx index 60bfb621..255888ce 100644 --- a/development/social/app/components/application/ErrorHandler.tsx +++ b/development/social/app/components/application/ErrorHandler.tsx @@ -7,7 +7,7 @@ type Props = { readonly error: unknown; }; -export default function ErrorHandler({ error }: Props) +export default function ({ error }: Props) { const isUnauthorized = error?.constructor?.name === 'Unauthorized' || error === 'Invalid authorization type' diff --git a/development/social/app/components/application/Home.tsx b/development/social/app/components/application/Home.tsx index 1174d169..0d170de3 100644 --- a/development/social/app/components/application/Home.tsx +++ b/development/social/app/components/application/Home.tsx @@ -3,10 +3,9 @@ import { Column } from '@maskingtech/designsystem'; import Introduction from './components/Introduction'; import LegalInfo from './components/LegalInfo'; - import useNavigateLogin from './hooks/useNavigateLogin'; -export default function Feature() +export default function () { const login = useNavigateLogin(); diff --git a/development/social/app/components/application/Identify.tsx b/development/social/app/components/application/Identify.tsx index f18335df..470d359f 100644 --- a/development/social/app/components/application/Identify.tsx +++ b/development/social/app/components/application/Identify.tsx @@ -1,7 +1,7 @@ import useIdentify from './hooks/useIdentify'; -export default function Feature() +export default function () { useIdentify(); diff --git a/development/social/app/components/application/Login.tsx b/development/social/app/components/application/Login.tsx index 0577e30f..95722f67 100644 --- a/development/social/app/components/application/Login.tsx +++ b/development/social/app/components/application/Login.tsx @@ -1,7 +1,7 @@ import useLogin from './hooks/useLogin'; -export default function Feature() +export default function () { useLogin(); diff --git a/development/social/app/components/application/Logout.tsx b/development/social/app/components/application/Logout.tsx index c354a52c..9fd11e08 100644 --- a/development/social/app/components/application/Logout.tsx +++ b/development/social/app/components/application/Logout.tsx @@ -1,9 +1,8 @@ import LogoutPanel from './components/LogoutPanel'; - import useLogout from './hooks/useLogout'; -export default function Feature() +export default function () { const logout = useLogout(); diff --git a/development/social/app/components/application/NotFound.tsx b/development/social/app/components/application/NotFound.tsx index 83fbbb91..5fa3aaf0 100644 --- a/development/social/app/components/application/NotFound.tsx +++ b/development/social/app/components/application/NotFound.tsx @@ -1,7 +1,7 @@ import { Panel, Paragraph, Title } from '@maskingtech/designsystem'; -export default function Feature() +export default function () { return Not Found diff --git a/development/social/app/components/application/Privacy.tsx b/development/social/app/components/application/Privacy.tsx index f08a8aee..f5668d43 100644 --- a/development/social/app/components/application/Privacy.tsx +++ b/development/social/app/components/application/Privacy.tsx @@ -1,11 +1,11 @@ import { Column, List, Paragraph, Title } from '@maskingtech/designsystem'; -export default function Feature() +export default function () { return - + Privacy Policy diff --git a/development/social/app/components/application/ProtectedRoute.tsx b/development/social/app/components/application/ProtectedRoute.tsx index 65d87848..d137c4c7 100644 --- a/development/social/app/components/application/ProtectedRoute.tsx +++ b/development/social/app/components/application/ProtectedRoute.tsx @@ -2,13 +2,12 @@ import { Outlet } from 'react-router-dom'; import { useAppContext } from './contexts/AppContext'; - import Login from './Login'; -export default function ProtectedRoute() +export default function () { const { identity } = useAppContext(); - + if (identity === undefined) { return ; diff --git a/development/social/app/components/application/Routes.tsx b/development/social/app/components/application/Routes.tsx index 47719151..08e5e8c5 100644 --- a/development/social/app/components/application/Routes.tsx +++ b/development/social/app/components/application/Routes.tsx @@ -4,11 +4,11 @@ import { Route } from 'react-router-dom'; import { NotFound } from '~/components/common'; import Home from './Home'; -import Login from './Login'; import Identify from './Identify'; +import Login from './Login'; import Logout from './Logout'; -import Terms from './Terms'; import Privacy from './Privacy'; +import Terms from './Terms'; export const legalRoutes = } /> diff --git a/development/social/app/components/application/Terms.tsx b/development/social/app/components/application/Terms.tsx index 81cfd2ef..e64b66d4 100644 --- a/development/social/app/components/application/Terms.tsx +++ b/development/social/app/components/application/Terms.tsx @@ -1,10 +1,10 @@ import { Column, List, Paragraph, Text, Title } from '@maskingtech/designsystem'; -export default function Feature() +export default function () { return - + Terms of Use diff --git a/development/social/app/components/application/components/Footer.tsx b/development/social/app/components/application/components/Footer.tsx index 1165f617..5a020ecc 100644 --- a/development/social/app/components/application/components/Footer.tsx +++ b/development/social/app/components/application/components/Footer.tsx @@ -1,15 +1,15 @@ import { Column } from '@maskingtech/designsystem'; -import type { AggregatedData as AggregatedCreatorData } from '^/domain/creator/aggregate'; +import { type Creator } from '^/domain/creator'; import Menu from './Menu'; type Props = { - readonly identity: AggregatedCreatorData; + readonly identity: Creator; }; -export default function Component({ identity }: Props) +export default function ({ identity }: Props) { return diff --git a/development/social/app/components/application/components/Header.tsx b/development/social/app/components/application/components/Header.tsx index ad2afad3..a1c6bfec 100644 --- a/development/social/app/components/application/components/Header.tsx +++ b/development/social/app/components/application/components/Header.tsx @@ -1,7 +1,7 @@ import { Row } from '@maskingtech/designsystem'; -import type { AggregatedData as IdentityModel } from '^/domain/creator/aggregate'; +import { type Creator } from '^/domain/creator'; import { ConciseIdentity } from '~/components/creator'; @@ -9,11 +9,11 @@ import Logo from './Logo'; import LogoutButton from './LogoutButton'; type Props = { - readonly identity: IdentityModel; + readonly identity: Creator; readonly onLogout: () => void; }; -export default function Component({ identity, onLogout }: Props) +export default function ({ identity, onLogout }: Props) { return diff --git a/development/social/app/components/application/components/Identity.tsx b/development/social/app/components/application/components/Identity.tsx index f29c6bca..c4369545 100644 --- a/development/social/app/components/application/components/Identity.tsx +++ b/development/social/app/components/application/components/Identity.tsx @@ -1,17 +1,18 @@ import { Row } from '@maskingtech/designsystem'; -import type { AggregatedData as AggregatedCreatorData } from '^/domain/creator/aggregate'; +import { type Creator } from '^/domain/creator'; import { FullIdentity } from '~/components/creator'; + import LogoutButton from './LogoutButton'; type Props = { - readonly identity: AggregatedCreatorData; + readonly identity: Creator; readonly onLogout: () => void; }; -export default function Component({ identity, onLogout }: Props) +export default function ({ identity, onLogout }: Props) { return diff --git a/development/social/app/components/application/components/Introduction.tsx b/development/social/app/components/application/components/Introduction.tsx index cbb9e6ad..427dde52 100644 --- a/development/social/app/components/application/components/Introduction.tsx +++ b/development/social/app/components/application/components/Introduction.tsx @@ -9,7 +9,7 @@ type Props = { readonly onGetIn: () => void; }; -export default function Component({ onGetIn }: Props) +export default function ({ onGetIn }: Props) { return diff --git a/development/social/app/components/application/components/LegalHeader.tsx b/development/social/app/components/application/components/LegalHeader.tsx index f6d35487..7f5293ad 100644 --- a/development/social/app/components/application/components/LegalHeader.tsx +++ b/development/social/app/components/application/components/LegalHeader.tsx @@ -7,7 +7,7 @@ type Props = { readonly onGoHome: () => void; }; -export default function Component({ onGoHome }: Props) +export default function ({ onGoHome }: Props) { return diff --git a/development/social/app/components/application/components/LegalInfo.tsx b/development/social/app/components/application/components/LegalInfo.tsx index 1cefe1b3..c0979c31 100644 --- a/development/social/app/components/application/components/LegalInfo.tsx +++ b/development/social/app/components/application/components/LegalInfo.tsx @@ -1,7 +1,7 @@ import { Column, Link, Paragraph } from '@maskingtech/designsystem'; -export default function Component() +export default function () { return diff --git a/development/social/app/components/application/components/Logo.tsx b/development/social/app/components/application/components/Logo.tsx index 5a5067c2..d2e8f18d 100644 --- a/development/social/app/components/application/components/Logo.tsx +++ b/development/social/app/components/application/components/Logo.tsx @@ -7,7 +7,7 @@ type Props = { readonly size: 'small' | 'large'; }; -export default function Component({ size }: Props) +export default function ({ size }: Props) { const height = size === 'small' ? '1.5em' : '2.2em'; diff --git a/development/social/app/components/application/components/LogoutButton.tsx b/development/social/app/components/application/components/LogoutButton.tsx index 33a2fc37..4ee54342 100644 --- a/development/social/app/components/application/components/LogoutButton.tsx +++ b/development/social/app/components/application/components/LogoutButton.tsx @@ -7,7 +7,7 @@ type Props = { readonly onLogout: () => void; }; -export default function Component({ onLogout }: Props) +export default function ({ onLogout }: Props) { return onLogout()}> Logout diff --git a/development/social/app/components/application/components/LogoutPanel.tsx b/development/social/app/components/application/components/LogoutPanel.tsx index 6ce585b9..f5a2265a 100644 --- a/development/social/app/components/application/components/LogoutPanel.tsx +++ b/development/social/app/components/application/components/LogoutPanel.tsx @@ -5,7 +5,7 @@ type Props = { readonly onLogout: () => void; }; -export default function Component({ onLogout }: Props) +export default function ({ onLogout }: Props) { return diff --git a/development/social/app/components/application/components/Menu.tsx b/development/social/app/components/application/components/Menu.tsx index 0f24b160..e3135c49 100644 --- a/development/social/app/components/application/components/Menu.tsx +++ b/development/social/app/components/application/components/Menu.tsx @@ -1,7 +1,7 @@ import { useMemo } from 'react'; -import type { AggregatedData as AggregatedCreatorData } from '^/domain/creator/aggregate'; +import { type Creator } from '^/domain/creator'; import createActiveIcon from '~/assets/images/navigation/create-active.svg'; import createInactiveIcon from '~/assets/images/navigation/create-inactive.svg'; @@ -13,15 +13,14 @@ import profileActiveIcon from '~/assets/images/navigation/profile-active.svg'; import profileInactiveIcon from '~/assets/images/navigation/profile-inactive.svg'; import timelineActiveIcon from '~/assets/images/navigation/timeline-active.svg'; import timelineInactiveIcon from '~/assets/images/navigation/timeline-inactive.svg'; - import { Menu } from '~/components/common'; type Props = { readonly vertical: boolean; - readonly identity: AggregatedCreatorData; + readonly identity: Creator; }; -export default function Component({ vertical, identity }: Props) +export default function ({ vertical, identity }: Props) { const items = useMemo(() => [ { title: 'Timeline', route: '/timeline', activeIcon: timelineActiveIcon, inactiveIcon: timelineInactiveIcon }, diff --git a/development/social/app/components/application/components/Modal.tsx b/development/social/app/components/application/components/Modal.tsx index 252b4ec8..0aaccb08 100644 --- a/development/social/app/components/application/components/Modal.tsx +++ b/development/social/app/components/application/components/Modal.tsx @@ -1,14 +1,13 @@ -import type { ReactNode } from 'react'; - import { Border, Modal } from '@maskingtech/designsystem'; +import { type ReactNode } from 'react'; type Props = { readonly open: boolean, readonly children?: ReactNode; }; -export default function Component({ open, children }: Props) +export default function ({ open, children }: Props) { return diff --git a/development/social/app/components/application/components/Sidebar.tsx b/development/social/app/components/application/components/Sidebar.tsx index 5192e75f..1267b730 100644 --- a/development/social/app/components/application/components/Sidebar.tsx +++ b/development/social/app/components/application/components/Sidebar.tsx @@ -1,18 +1,18 @@ import { Cell, Column, Row, Ruler } from '@maskingtech/designsystem'; -import type { AggregatedData as AggregatedCreatorData } from '^/domain/creator/aggregate'; +import { type Creator } from '^/domain/creator'; import Identity from './Identity'; import Logo from './Logo'; import Menu from './Menu'; type Props = { - readonly identity: AggregatedCreatorData; + readonly identity: Creator; readonly onLogout: () => void; }; -export default function Component({ identity, onLogout }: Props) +export default function ({ identity, onLogout }: Props) { return diff --git a/development/social/app/components/application/contexts/AppContext.tsx b/development/social/app/components/application/contexts/AppContext.tsx index 6c447feb..bb7360aa 100644 --- a/development/social/app/components/application/contexts/AppContext.tsx +++ b/development/social/app/components/application/contexts/AppContext.tsx @@ -1,14 +1,13 @@ -import type { ReactNode } from 'react'; -import { createContext, useContext } from 'react'; +import { type ReactNode, createContext, useContext } from 'react'; -import type { AggregatedData as IdentityModel } from '^/domain/creator/aggregate'; +import { type Creator } from '^/domain/creator'; import useAppContextValue from './hooks/useAppContextValue'; type Context = { - identity: IdentityModel | undefined; - setIdentity: (identity: IdentityModel | undefined) => void; + identity: Creator | undefined; + setIdentity: (identity: Creator | undefined) => void; appState: Map; }; @@ -18,7 +17,7 @@ export const useAppContext = () => useContext(AppContext); type Props = { readonly values?: { - identity: IdentityModel | undefined; + identity: Creator | undefined; }; readonly children: ReactNode; }; diff --git a/development/social/app/components/application/contexts/hooks/useAppContextValue.ts b/development/social/app/components/application/contexts/hooks/useAppContextValue.ts index 9702e5db..8a252648 100644 --- a/development/social/app/components/application/contexts/hooks/useAppContextValue.ts +++ b/development/social/app/components/application/contexts/hooks/useAppContextValue.ts @@ -1,11 +1,11 @@ import { useMemo, useState } from 'react'; -import type { AggregatedData as IdentityModel } from '^/domain/creator/aggregate'; +import { type Creator } from '^/domain/creator'; -export default function useAppContextValue(initialIdentity?: IdentityModel) +export default function useAppContextValue(initialIdentity?: Creator) { - const [identity, setIdentity] = useState(initialIdentity); + const [identity, setIdentity] = useState(initialIdentity); const appState = useMemo>(() => new Map(), []); return useMemo(() => ( diff --git a/development/social/app/components/application/hooks/useIdentify.ts b/development/social/app/components/application/hooks/useIdentify.ts index 2b58bafe..ab4fa2a7 100644 --- a/development/social/app/components/application/hooks/useIdentify.ts +++ b/development/social/app/components/application/hooks/useIdentify.ts @@ -2,10 +2,10 @@ import { useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; -import { requester } from '^/domain/authentication'; -import type { AggregatedData as IdentityModel } from '^/domain/creator/aggregate'; -import getMe from '^/domain/creator/getMeAggregated'; -import { tenant } from '@comify/common/domain/tenant'; +import { requester } from '@comify/common/security'; + +import { type Creator } from '^/domain/creator'; +import getMe from '^/domain/creator/getMe'; import { useAppContext } from '../contexts/AppContext'; @@ -16,7 +16,7 @@ export default function useIdentify() const identify = () => { - const setIdentity = (identity: IdentityModel) => + const setIdentity = (identity: Creator) => { const redirectLocation = globalThis.sessionStorage.getItem('redirect'); @@ -27,7 +27,7 @@ export default function useIdentify() const getIdentity = async () => { - const identity = await getMe(tenant, requester); + const identity = await getMe(requester); setIdentity(identity); }; diff --git a/development/social/app/components/application/hooks/useLogin.ts b/development/social/app/components/application/hooks/useLogin.ts index 670ee100..3421e279 100644 --- a/development/social/app/components/application/hooks/useLogin.ts +++ b/development/social/app/components/application/hooks/useLogin.ts @@ -1,7 +1,7 @@ import { useEffect } from 'react'; -import getLoginUrl from '^/domain/authentication/getLoginUrl'; +import getLoginUrl from '^/security/authentication/getLoginUrl'; const IGNORE_PATHS = new Set(['/', '/login', '/identify']); diff --git a/development/social/app/components/application/hooks/useLogout.ts b/development/social/app/components/application/hooks/useLogout.ts index 09ae568c..2e95deb6 100644 --- a/development/social/app/components/application/hooks/useLogout.ts +++ b/development/social/app/components/application/hooks/useLogout.ts @@ -2,7 +2,7 @@ import { useCallback } from 'react'; import { useNavigate } from 'react-router-dom'; -import logout from '^/domain/authentication/logout'; +import logout from '^/security/authentication/logout'; import { useAppContext } from '../contexts/AppContext'; diff --git a/development/social/app/components/application/layouts/Application.tsx b/development/social/app/components/application/layouts/Application.tsx index edaf580c..b9fa8536 100644 --- a/development/social/app/components/application/layouts/Application.tsx +++ b/development/social/app/components/application/layouts/Application.tsx @@ -1,15 +1,13 @@ -import { useNavigate, Outlet } from 'react-router-dom'; - import { SidebarLayout } from '@maskingtech/designsystem'; +import { useNavigate, Outlet } from 'react-router-dom'; import Footer from '../components/Footer'; import Header from '../components/Header'; import Sidebar from '../components/Sidebar'; - import { useAppContext } from '../contexts/AppContext'; -export default function Page() +export default function () { const navigate = useNavigate(); const onLogout = () => navigate('/logout'); diff --git a/development/social/app/components/application/layouts/Guest.tsx b/development/social/app/components/application/layouts/Guest.tsx index 755952ed..6daf92d2 100644 --- a/development/social/app/components/application/layouts/Guest.tsx +++ b/development/social/app/components/application/layouts/Guest.tsx @@ -1,9 +1,8 @@ +import { CenteredLayout } from '@maskingtech/designsystem'; import { Outlet } from 'react-router-dom'; -import { CenteredLayout } from '@maskingtech/designsystem'; - -export default function Page() +export default function () { return diff --git a/development/social/app/components/application/layouts/Legal.tsx b/development/social/app/components/application/layouts/Legal.tsx index a6720ed9..7d3fe4f8 100644 --- a/development/social/app/components/application/layouts/Legal.tsx +++ b/development/social/app/components/application/layouts/Legal.tsx @@ -1,12 +1,11 @@ +import { PortraitLayout } from '@maskingtech/designsystem'; import { Outlet } from 'react-router-dom'; -import { PortraitLayout } from '@maskingtech/designsystem'; - import LegalHeader from '../components/LegalHeader'; import useNavigateHome from '../hooks/useNavigateHome'; -export default function Page() +export default function () { const navigateHome = useNavigateHome(); diff --git a/development/social/app/components/comic/components/Image.tsx b/development/social/app/components/comic/components/Image.tsx deleted file mode 100644 index 74a3d455..00000000 --- a/development/social/app/components/comic/components/Image.tsx +++ /dev/null @@ -1,13 +0,0 @@ - -import type { AggregatedData as AggregatedComicData } from '^/domain/comic/aggregate'; - -import { Image } from '@maskingtech/designsystem'; - -type Props = { - readonly comic: AggregatedComicData; -}; - -export default function Component({ comic }: Props) -{ - return ; -} diff --git a/development/social/app/components/common/components/BackButton.tsx b/development/social/app/components/common/components/BackButton.tsx index dec41240..c4642abb 100644 --- a/development/social/app/components/common/components/BackButton.tsx +++ b/development/social/app/components/common/components/BackButton.tsx @@ -5,7 +5,7 @@ type Props = { readonly onClick: () => void; }; -export default function Component({ onClick }: Props) +export default function ({ onClick }: Props) { return