From 7fcc1aed6ce126ca0926d89e5712aa117020d630 Mon Sep 17 00:00:00 2001 From: Michael Haufe Date: Sat, 31 Aug 2024 20:41:26 +0000 Subject: [PATCH] - optimized page middleware - bugfixed organization delete message - bugfixed org landing page solution list after delete - refactored domain to export from index file to avoid circular dependency errors - Organization now explicitly references solutions - Solution now explicitly references associated requirements - Justifications now created w/ Solution instead of lazily on rationale page --- middleware/org-solution-check.global.ts | 8 +- migrations/.snapshot-cathedral.json | 2 +- migrations/Migration20240831162504.ts | 17 +++ pages/index.client.vue | 19 ++-- .../environment/constraints.client.vue | 2 +- .../goals/functionality.client.vue | 2 +- .../goals/rationale.client.vue | 43 +------ .../goals/scenarios.client.vue | 2 +- .../goals/stakeholders.client.vue | 3 +- .../system/functionality.client.vue | 2 +- .../system/scenarios.client.vue | 2 +- pages/o/[organization-slug]/index.client.vue | 4 +- server/api/assumptions/[id].delete.ts | 2 +- server/api/assumptions/[id].get.ts | 2 +- server/api/assumptions/[id].put.ts | 2 +- server/api/assumptions/index.get.ts | 2 +- server/api/assumptions/index.post.ts | 2 +- server/api/constraints/[id].delete.ts | 2 +- server/api/constraints/[id].get.ts | 2 +- server/api/constraints/[id].put.ts | 3 +- server/api/constraints/index.get.ts | 3 +- server/api/constraints/index.post.ts | 3 +- server/api/effects/[id].delete.ts | 2 +- server/api/effects/[id].get.ts | 2 +- server/api/effects/[id].put.ts | 2 +- server/api/effects/index.get.ts | 2 +- server/api/effects/index.post.ts | 2 +- .../api/environment-components/[id].delete.ts | 2 +- server/api/environment-components/[id].get.ts | 2 +- server/api/environment-components/[id].put.ts | 2 +- .../api/environment-components/index.get.ts | 2 +- .../api/environment-components/index.post.ts | 2 +- .../api/functional-behaviors/[id].delete.ts | 2 +- server/api/functional-behaviors/[id].get.ts | 2 +- server/api/functional-behaviors/[id].put.ts | 3 +- server/api/functional-behaviors/index.get.ts | 3 +- server/api/functional-behaviors/index.post.ts | 3 +- server/api/glossary-terms/[id].delete.ts | 2 +- server/api/glossary-terms/[id].get.ts | 2 +- server/api/glossary-terms/[id].put.ts | 2 +- server/api/glossary-terms/index.get.ts | 2 +- server/api/glossary-terms/index.post.ts | 2 +- server/api/invariants/[id].delete.ts | 2 +- server/api/invariants/[id].get.ts | 2 +- server/api/invariants/[id].put.ts | 2 +- server/api/invariants/index.get.ts | 2 +- server/api/invariants/index.post.ts | 2 +- server/api/justifications/[id].delete.ts | 2 +- server/api/justifications/[id].get.ts | 2 +- server/api/justifications/[id].put.ts | 2 +- server/api/justifications/index.get.ts | 2 +- server/api/justifications/index.post.ts | 2 +- server/api/limits/[id].delete.ts | 2 +- server/api/limits/[id].get.ts | 2 +- server/api/limits/[id].put.ts | 2 +- server/api/limits/index.get.ts | 2 +- server/api/limits/index.post.ts | 2 +- .../non-functional-behaviors/[id].delete.ts | 2 +- .../api/non-functional-behaviors/[id].get.ts | 2 +- .../api/non-functional-behaviors/[id].put.ts | 3 +- .../api/non-functional-behaviors/index.get.ts | 3 +- .../non-functional-behaviors/index.post.ts | 3 +- server/api/obstacles/[id].delete.ts | 2 +- server/api/obstacles/[id].get.ts | 2 +- server/api/obstacles/[id].put.ts | 2 +- server/api/obstacles/index.get.ts | 2 +- server/api/obstacles/index.post.ts | 2 +- server/api/organizations/index.post.ts | 3 +- server/api/outcomes/[id].delete.ts | 2 +- server/api/outcomes/[id].get.ts | 2 +- server/api/outcomes/[id].put.ts | 2 +- server/api/outcomes/index.get.ts | 2 +- server/api/outcomes/index.post.ts | 2 +- server/api/persons/[id].delete.ts | 2 +- server/api/persons/[id].get.ts | 2 +- server/api/persons/[id].put.ts | 2 +- server/api/persons/index.get.ts | 2 +- server/api/persons/index.post.ts | 2 +- server/api/solutions/[id].delete.ts | 10 +- server/api/solutions/index.get.ts | 2 +- server/api/solutions/index.post.ts | 41 ++++++- server/api/stakeholders/[id].delete.ts | 2 +- server/api/stakeholders/[id].get.ts | 2 +- server/api/stakeholders/[id].put.ts | 4 +- server/api/stakeholders/index.get.ts | 4 +- server/api/stakeholders/index.post.ts | 4 +- server/api/system-components/[id].delete.ts | 2 +- server/api/system-components/[id].get.ts | 2 +- server/api/system-components/[id].put.ts | 2 +- server/api/system-components/index.get.ts | 2 +- server/api/system-components/index.post.ts | 2 +- server/api/use-cases/[id].delete.ts | 2 +- server/api/use-cases/[id].get.ts | 2 +- server/api/use-cases/[id].put.ts | 6 +- server/api/use-cases/index.get.ts | 3 +- server/api/use-cases/index.post.ts | 8 +- server/api/user-stories/[id].delete.ts | 2 +- server/api/user-stories/[id].get.ts | 2 +- server/api/user-stories/[id].put.ts | 6 +- server/api/user-stories/index.get.ts | 3 +- server/api/user-stories/index.post.ts | 7 +- server/data/models/AssumptionSchema.ts | 3 +- server/data/models/BehaviorSchema.ts | 4 +- server/data/models/ConstraintSchema.ts | 4 +- server/data/models/EffectSchema.ts | 3 +- .../data/models/EnvironmentComponentSchema.ts | 3 +- .../data/models/FunctionalBehaviorSchema.ts | 3 +- server/data/models/GlossaryTermSchema.ts | 3 +- server/data/models/HintSchema.ts | 3 +- server/data/models/InvariantSchema.ts | 3 +- server/data/models/JustificationSchema.ts | 3 +- server/data/models/LimitSchema.ts | 3 +- .../models/NonFunctionalBehaviorSchema.ts | 3 +- server/data/models/ObstacleSchema.ts | 3 +- server/data/models/OrganizationSchema.ts | 3 +- server/data/models/OutcomeSchema.ts | 3 +- server/data/models/PersonSchema.ts | 3 +- server/data/models/ProductSchema.ts | 3 +- server/data/models/RequirementSchema.ts | 2 +- server/data/models/ScenarioSchema.ts | 3 +- server/data/models/SolutionSchema.ts | 29 ++++- server/data/models/StakeholderSchema.ts | 7 +- server/data/models/SystemComponentSchema.ts | 3 +- server/data/models/UseCaseSchema.ts | 3 +- server/data/models/UserStorySchema.ts | 3 +- server/domain/application/Organization.ts | 12 +- server/domain/application/Solution.ts | 107 +++++++++++++++++- server/domain/requirements/Actor.ts | 4 +- server/domain/requirements/Assumption.ts | 4 +- server/domain/requirements/Behavior.ts | 5 +- server/domain/requirements/Component.ts | 4 +- server/domain/requirements/Constraint.ts | 5 +- .../domain/requirements/ConstraintCategory.ts | 6 +- server/domain/requirements/Effect.ts | 4 +- .../requirements/EnvironmentComponent.ts | 4 +- server/domain/requirements/Example.ts | 4 +- .../domain/requirements/FunctionalBehavior.ts | 4 +- server/domain/requirements/Functionality.ts | 4 +- server/domain/requirements/GlossaryTerm.ts | 4 +- server/domain/requirements/Goal.ts | 4 +- server/domain/requirements/Hint.ts | 4 +- server/domain/requirements/Invariant.ts | 4 +- server/domain/requirements/Justification.ts | 4 +- server/domain/requirements/Limit.ts | 4 +- server/domain/requirements/MetaRequirement.ts | 4 +- server/domain/requirements/MoscowPriority.ts | 6 +- server/domain/requirements/Noise.ts | 4 +- .../requirements/NonFunctionalBehavior.ts | 4 +- server/domain/requirements/Obstacle.ts | 4 +- server/domain/requirements/Outcome.ts | 4 +- server/domain/requirements/Person.ts | 6 +- server/domain/requirements/Product.ts | 4 +- server/domain/requirements/Requirement.ts | 2 +- server/domain/requirements/Responsibility.ts | 4 +- server/domain/requirements/Role.ts | 4 +- server/domain/requirements/Scenario.ts | 5 +- server/domain/requirements/Silence.ts | 4 +- server/domain/requirements/Stakeholder.ts | 6 +- .../requirements/StakeholderCategory.ts | 6 +- .../requirements/StakeholderSegmentation.ts | 6 +- server/domain/requirements/SystemComponent.ts | 4 +- server/domain/requirements/Task.ts | 4 +- server/domain/requirements/TestCase.ts | 4 +- server/domain/requirements/UseCase.ts | 6 +- server/domain/requirements/UserStory.ts | 6 +- server/domain/requirements/index.ts | 38 +++++++ 166 files changed, 462 insertions(+), 335 deletions(-) create mode 100644 migrations/Migration20240831162504.ts create mode 100644 server/domain/requirements/index.ts diff --git a/middleware/org-solution-check.global.ts b/middleware/org-solution-check.global.ts index 5862f168..72791996 100644 --- a/middleware/org-solution-check.global.ts +++ b/middleware/org-solution-check.global.ts @@ -4,21 +4,21 @@ */ export default defineNuxtRouteMiddleware(async (to, from) => { if (to.params.organizationslug) { - const { data: organizations } = await useFetch('/api/organizations', { + const organizations = await $fetch('/api/organizations', { query: { slug: to.params.organizationslug } }) - if (!(organizations?.value ?? []).length) { + if (!(organizations ?? []).length) { return navigateTo('/') } else if (to.params.solutionslug) { - const { data: solutions } = await useFetch('/api/solutions', { + const solutions = await $fetch('/api/solutions', { query: { organizationSlug: to.params.organizationslug, slug: to.params.solutionslug } }) - if (!(solutions?.value ?? []).length) + if (!(solutions ?? []).length) return navigateTo(`/o/${to.params.organizationslug}`) } } diff --git a/migrations/.snapshot-cathedral.json b/migrations/.snapshot-cathedral.json index 63e694a4..0caaf51c 100644 --- a/migrations/.snapshot-cathedral.json +++ b/migrations/.snapshot-cathedral.json @@ -321,7 +321,7 @@ "id" ], "referencedTableName": "public.organization", - "deleteRule": "cascade" + "updateRule": "cascade" } }, "nativeEnums": {} diff --git a/migrations/Migration20240831162504.ts b/migrations/Migration20240831162504.ts new file mode 100644 index 00000000..c64412da --- /dev/null +++ b/migrations/Migration20240831162504.ts @@ -0,0 +1,17 @@ +import { Migration } from '@mikro-orm/migrations'; + +export class Migration20240831162504 extends Migration { + + override async up(): Promise { + this.addSql('alter table "solution" drop constraint "solution_organization_id_foreign";'); + + this.addSql('alter table "solution" add constraint "solution_organization_id_foreign" foreign key ("organization_id") references "organization" ("id") on update cascade;'); + } + + override async down(): Promise { + this.addSql('alter table "solution" drop constraint "solution_organization_id_foreign";'); + + this.addSql('alter table "solution" add constraint "solution_organization_id_foreign" foreign key ("organization_id") references "organization" ("id") on delete cascade;'); + } + +} diff --git a/pages/index.client.vue b/pages/index.client.vue index ff58382a..eccbd196 100644 --- a/pages/index.client.vue +++ b/pages/index.client.vue @@ -1,7 +1,4 @@ @@ -64,12 +61,12 @@ const handleUsers = (organization: Organization) => { {{ organization.description }} diff --git a/pages/o/[organization-slug]/[solution-slug]/environment/constraints.client.vue b/pages/o/[organization-slug]/[solution-slug]/environment/constraints.client.vue index dfad346a..25a0fa56 100644 --- a/pages/o/[organization-slug]/[solution-slug]/environment/constraints.client.vue +++ b/pages/o/[organization-slug]/[solution-slug]/environment/constraints.client.vue @@ -1,7 +1,7 @@