Skip to content

Commit

Permalink
- Lifted APIs back to top level
Browse files Browse the repository at this point in the history
- Fixed errors with org/solution deletion
  • Loading branch information
mlhaufe committed Sep 5, 2024
1 parent 786196d commit 8a2aa9f
Show file tree
Hide file tree
Showing 123 changed files with 1,322 additions and 516 deletions.
8 changes: 4 additions & 4 deletions migrations/.snapshot-cathedral.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"nullable": false,
"mappedType": "uuid"
},
"organization_id": {
Expand All @@ -170,7 +170,7 @@
"unsigned": false,
"autoincrement": false,
"primary": false,
"nullable": true,
"nullable": false,
"mappedType": "uuid"
},
"role": {
Expand Down Expand Up @@ -217,7 +217,7 @@
"id"
],
"referencedTableName": "public.app_user",
"deleteRule": "cascade"
"updateRule": "cascade"
},
"app_user_organization_role_organization_id_foreign": {
"constraintName": "app_user_organization_role_organization_id_foreign",
Expand All @@ -229,7 +229,7 @@
"id"
],
"referencedTableName": "public.organization",
"deleteRule": "cascade"
"updateRule": "cascade"
}
},
"nativeEnums": {}
Expand Down
33 changes: 33 additions & 0 deletions migrations/Migration20240904172417.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Migration } from '@mikro-orm/migrations';

export class Migration20240904172417 extends Migration {

override async up(): Promise<void> {
this.addSql('alter table "app_user_organization_role" drop constraint "app_user_organization_role_app_user_id_foreign";');
this.addSql('alter table "app_user_organization_role" drop constraint "app_user_organization_role_organization_id_foreign";');

this.addSql('alter table "app_user_organization_role" alter column "app_user_id" drop default;');
this.addSql('alter table "app_user_organization_role" alter column "app_user_id" type uuid using ("app_user_id"::text::uuid);');
this.addSql('alter table "app_user_organization_role" alter column "app_user_id" set not null;');
this.addSql('alter table "app_user_organization_role" alter column "organization_id" drop default;');
this.addSql('alter table "app_user_organization_role" alter column "organization_id" type uuid using ("organization_id"::text::uuid);');
this.addSql('alter table "app_user_organization_role" alter column "organization_id" set not null;');
this.addSql('alter table "app_user_organization_role" add constraint "app_user_organization_role_app_user_id_foreign" foreign key ("app_user_id") references "app_user" ("id") on update cascade;');
this.addSql('alter table "app_user_organization_role" add constraint "app_user_organization_role_organization_id_foreign" foreign key ("organization_id") references "organization" ("id") on update cascade;');
}

override async down(): Promise<void> {
this.addSql('alter table "app_user_organization_role" drop constraint "app_user_organization_role_app_user_id_foreign";');
this.addSql('alter table "app_user_organization_role" drop constraint "app_user_organization_role_organization_id_foreign";');

this.addSql('alter table "app_user_organization_role" alter column "app_user_id" drop default;');
this.addSql('alter table "app_user_organization_role" alter column "app_user_id" type uuid using ("app_user_id"::text::uuid);');
this.addSql('alter table "app_user_organization_role" alter column "app_user_id" drop not null;');
this.addSql('alter table "app_user_organization_role" alter column "organization_id" drop default;');
this.addSql('alter table "app_user_organization_role" alter column "organization_id" type uuid using ("organization_id"::text::uuid);');
this.addSql('alter table "app_user_organization_role" alter column "organization_id" drop not null;');
this.addSql('alter table "app_user_organization_role" add constraint "app_user_organization_role_app_user_id_foreign" foreign key ("app_user_id") references "app_user" ("id") on delete cascade;');
this.addSql('alter table "app_user_organization_role" add constraint "app_user_organization_role_organization_id_foreign" foreign key ("organization_id") references "organization" ("id") on delete cascade;');
}

}
311 changes: 311 additions & 0 deletions migrations/Migration20240904183539.ts

Large diffs are not rendered by default.

313 changes: 313 additions & 0 deletions migrations/Migration20240905000351.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ type AssumptionViewModel = {
statement: string;
}
const { data: assumptions, refresh, status, error: getAssumptionsError } = await useFetch(`/api/${solutionId}/assumptions`),
const { data: assumptions, refresh, status, error: getAssumptionsError } = await useFetch(`/api/assumptions`, {
query: { solutionId }
}),
emptyAssumption = { id: emptyUuid, name: '', statement: '' };
if (getAssumptionsError.value)
Expand All @@ -37,30 +39,35 @@ const filters = ref<Record<string, { value: any, matchMode: string }>>({
});
const onCreate = async (data: AssumptionViewModel) => {
await $fetch(`/api/${solutionId}/assumptions`, {
await $fetch(`/api/assumptions`, {
method: 'post',
body: {
name: data.name,
statement: data.statement
statement: data.statement,
solutionId
}
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
const onDelete = async (id: string) => {
await $fetch(`/api/${solutionId}/assumptions/${id}`, { method: 'delete' })
await $fetch(`/api/assumptions/${id}`, {
method: 'delete',
body: { solutionId }
})
.catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
const onUpdate = async (data: AssumptionViewModel) => {
await $fetch(`/api/${solutionId}/assumptions/${data.id}`, {
await $fetch(`/api/assumptions/${data.id}`, {
method: 'put',
body: {
name: data.name,
statement: data.statement
statement: data.statement,
solutionId
}
}).catch((e) => $eventBus.$emit('page-error', e))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ const { $eventBus } = useNuxtApp(),
}
}),
solutionId = solutions.value?.[0].id,
{ data: environmentComponents, status, refresh, error: getEnvironmentComponentsError } = await useFetch(`/api/${solutionId}/environment-components`),
{ data: environmentComponents, status, refresh, error: getEnvironmentComponentsError } = await useFetch(`/api/environment-components`, {
query: { solutionId }
}),
emptyComponent = { id: emptyUuid, name: '', statement: '' }
if (getSolutionError.value)
Expand All @@ -35,29 +37,33 @@ const filters = ref({
});
const onCreate = async (data: EnvironmentComponentViewModel) => {
await $fetch(`/api/${solutionId}/environment-components`, {
await $fetch(`/api/environment-components`, {
method: 'POST',
body: {
name: data.name,
statement: data.statement
statement: data.statement,
solutionId
}
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
const onDelete = async (id: string) => {
await $fetch(`/api/${solutionId}/environment-components/${id}`, { method: 'DELETE' })
.catch((e) => $eventBus.$emit('page-error', e))
await $fetch(`/api/environment-components/${id}`, {
method: 'DELETE',
body: { solutionId }
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
const onUpdate = async (data: EnvironmentComponentViewModel) => {
await $fetch(`/api/${solutionId}/environment-components/${data.id}`, {
await $fetch(`/api/environment-components/${data.id}`, {
method: 'PUT',
body: {
name: data.name,
statement: data.statement
statement: data.statement,
solutionId
}
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ const { $eventBus } = useNuxtApp(),
}),
solution = (solutions.value ?? [])[0],
solutionId = solution.id,
{ data: constraints, status, refresh, error: getConstraintsError } = await useFetch(`/api/${solutionId}/constraints`);
{ data: constraints, status, refresh, error: getConstraintsError } = await useFetch(`/api/constraints`, {
query: { solutionId }
});
if (getSolutionError.value)
$eventBus.$emit('page-error', getSolutionError.value)
Expand All @@ -44,31 +46,35 @@ const filters = ref({
});
const onCreate = async (data: ConstraintViewModel) => {
await $fetch(`/api/${solutionId}/constraints`, {
await $fetch(`/api/constraints`, {
method: 'POST',
body: {
name: data.name,
statement: data.statement,
category: data.category
category: data.category,
solutionId
}
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
const onDelete = async (id: string) => {
await $fetch(`/api/${solutionId}/constraints/${id}`, { method: 'DELETE' })
.catch((e) => $eventBus.$emit('page-error', e))
await $fetch(`/api/constraints/${id}`, {
method: 'DELETE',
body: { solutionId }
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
const onUpdate = async (data: ConstraintViewModel) => {
await $fetch(`/api/${solutionId}/constraints/${data.id}`, {
await $fetch(`/api/constraints/${data.id}`, {
method: 'PUT',
body: {
name: data.name,
statement: data.statement,
category: data.category
category: data.category,
solutionId
}
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ type EffectViewModel = {
statement: string;
}
const { data: effects, refresh, status, error: getEffectsError } = await useFetch(`/api/${solutionId}/effects`),
const { data: effects, refresh, status, error: getEffectsError } = await useFetch(`/api/effects`, {
query: { solutionId }
}),
emptyEffect: EffectViewModel = { id: emptyUuid, name: '', statement: '' }
if (getEffectsError.value)
Expand All @@ -36,29 +38,35 @@ const filters = ref({
});
const onCreate = async (data: EffectViewModel) => {
await $fetch(`/api/${solutionId}/effects`, {
method: 'POST', body: {
await $fetch(`/api/effects`, {
method: 'POST',
body: {
name: data.name,
statement: data.statement
statement: data.statement,
solutionId
}
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
const onUpdate = async (data: EffectViewModel) => {
await $fetch(`/api/${solutionId}/effects/${data.id}`, {
await $fetch(`/api/effects/${data.id}`, {
method: 'PUT',
body: {
name: data.name,
statement: data.statement
statement: data.statement,
solutionId
}
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
const onDelete = async (id: string) => {
await $fetch(`/api/${solutionId}/effects/${id}`, { method: 'DELETE' })
await $fetch(`/api/effects/${id}`, {
method: 'DELETE',
body: { solutionId }
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ type GlossaryTermViewModel = {
statement: string;
}
const { data: glossaryTerms, refresh, status, error: getGlossaryTermsError } = await useFetch(`/api/${solutionId}/glossary-terms`),
const { data: glossaryTerms, refresh, status, error: getGlossaryTermsError } = await useFetch(`/api/glossary-terms`, {
query: { solutionId }
}),
emptyGlossaryTerm: GlossaryTermViewModel = { id: emptyUuid, name: '', statement: '' }
if (getGlossaryTermsError.value)
Expand All @@ -36,31 +38,37 @@ const filters = ref({
});
const onCreate = async (data: GlossaryTermViewModel) => {
await $fetch(`/api/${solutionId}/glossary-terms`, {
method: 'POST', body: {
await $fetch(`/api/glossary-terms`, {
method: 'POST',
body: {
name: data.name,
statement: data.statement
statement: data.statement,
solutionId
}
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
const onUpdate = async (data: GlossaryTermViewModel) => {
await $fetch(`/api/${solutionId}/glossary-terms/${data.id}`, {
method: 'PUT', body: {
await $fetch(`/api/glossary-terms/${data.id}`, {
method: 'PUT',
body: {
id: data.id,
name: data.name,
statement: data.statement
statement: data.statement,
solutionId
}
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
const onDelete = async (id: string) => {
await $fetch(`/api/${solutionId}/glossary-terms/${id}`, { method: 'DELETE' })
.catch((e) => $eventBus.$emit('page-error', e))
await $fetch(`/api/glossary-terms/${id}`, {
method: 'DELETE',
body: { solutionId }
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
</script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ type InvariantViewModel = {
statement: string;
}
const { data: invariants, refresh, status, error: getInvariantsError } = await useFetch(`/api/${solutionId}/invariants`),
const { data: invariants, refresh, status, error: getInvariantsError } = await useFetch(`/api/invariants`, {
query: { solutionId }
}),
emptyInvariant: InvariantViewModel = { id: emptyUuid, name: '', statement: '' };
if (getInvariantsError.value)
Expand All @@ -36,31 +38,36 @@ const filters = ref({
});
const onCreate = async (data: InvariantViewModel) => {
await useFetch(`/api/${solutionId}/invariants`, {
method: 'POST', body: {
await useFetch(`/api/invariants`, {
method: 'POST',
body: {
name: data.name,
statement: data.statement
statement: data.statement,
solutionId
}
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
const onUpdate = async (data: InvariantViewModel) => {
await useFetch(`/api/${solutionId}/invariants/${data.id}`, {
await useFetch(`/api/invariants/${data.id}`, {
method: 'PUT', body: {
id: data.id,
name: data.name,
statement: data.statement
statement: data.statement,
solutionId
}
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
const onDelete = async (id: string) => {
await useFetch(`/api/${solutionId}/invariants/${id}`, { method: 'DELETE' })
.catch((e) => $eventBus.$emit('page-error', e))
await useFetch(`/api/invariants/${id}`, {
method: 'DELETE',
body: { solutionId }
}).catch((e) => $eventBus.$emit('page-error', e))
refresh()
}
Expand Down
Loading

0 comments on commit 8a2aa9f

Please sign in to comment.