Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/api/src/lib/persons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { alias, and, eq, inArray, sql } from "@/services/db/sql";
export interface PersonPosition {
role: (typeof schema.personRoleTypesEnum)[number];
name: string;
/** Slug of the related organisational unit, for constructing urls to its details page. */
slug: string;
type: (typeof schema.organisationalUnitTypesEnum)[number];
/** Optional free-text note describing the person↔org relation. */
description: string | null;
Expand Down Expand Up @@ -62,6 +64,7 @@ export async function getPersonPositions(
personId: personEntityVersions.id,
role: schema.personRoleTypes.type,
name: schema.organisationalUnits.name,
slug: schema.entities.slug,
type: schema.organisationalUnitTypes.type,
description: schema.personsToOrganisationalUnits.description,
})
Expand All @@ -85,6 +88,10 @@ export async function getPersonPositions(
schema.organisationalUnits,
eq(schema.organisationalUnits.id, organisationalUnitDocumentLifecycle.publishedId),
)
.innerJoin(
schema.entities,
eq(schema.entities.id, organisationalUnitDocumentLifecycle.documentId),
)
.innerJoin(
schema.organisationalUnitTypes,
eq(schema.organisationalUnits.typeId, schema.organisationalUnitTypes.id),
Expand All @@ -103,6 +110,7 @@ export async function getPersonPositions(
items.push({
role: row.role,
name: row.name,
slug: row.slug,
type: row.type,
description: row.description,
});
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/routes/governance-bodies/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const GovernanceBodyPersonSchema = v.object({
v.object({
role: v.picklist(schema.personRoleTypesEnum),
name: v.string(),
slug: v.string(),
type: v.picklist(schema.organisationalUnitTypesEnum),
description: v.nullable(v.string()),
}),
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/routes/impact-case-studies/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export const ImpactCaseStudySchema = v.pipe(
v.object({
role: v.picklist(schema.personRoleTypesEnum),
name: v.string(),
slug: v.string(),
type: v.picklist(schema.organisationalUnitTypesEnum),
description: v.nullable(v.string()),
}),
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/routes/members-partners/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export const ContributorSchema = v.pipe(
v.object({
role: v.picklist(schema.personRoleTypesEnum),
name: v.string(),
slug: v.string(),
type: v.picklist(schema.organisationalUnitTypesEnum),
description: v.nullable(v.string()),
}),
Expand Down
2 changes: 2 additions & 0 deletions apps/api/src/routes/persons/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const PersonBaseSchema = v.pipe(
v.object({
role: v.picklist(schema.personRoleTypesEnum),
name: v.string(),
slug: v.string(),
type: v.picklist(schema.organisationalUnitTypesEnum),
description: v.nullable(v.string()),
}),
Expand Down Expand Up @@ -43,6 +44,7 @@ export const PersonSchema = v.pipe(
v.object({
role: v.picklist(schema.personRoleTypesEnum),
name: v.string(),
slug: v.string(),
type: v.picklist(schema.organisationalUnitTypesEnum),
description: v.nullable(v.string()),
}),
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/routes/spotlight-articles/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ export const SpotlightArticleSchema = v.pipe(
v.object({
role: v.picklist(schema.personRoleTypesEnum),
name: v.string(),
slug: v.string(),
type: v.picklist(schema.organisationalUnitTypesEnum),
description: v.nullable(v.string()),
}),
Expand Down
1 change: 1 addition & 0 deletions apps/api/src/routes/working-groups/schemas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ export const WorkingGroupSchema = v.pipe(
v.object({
role: v.picklist(schema.personRoleTypesEnum),
name: v.string(),
slug: v.string(),
type: v.picklist(schema.organisationalUnitTypesEnum),
description: v.nullable(v.string()),
}),
Expand Down
32 changes: 32 additions & 0 deletions apps/api/test/__snapshots__/openapi.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
],
"type": "string",
},
"slug": {
"type": "string",
},
"type": {
"enum": [
"governance_body",
Expand All @@ -432,6 +435,7 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
"required": [
"role",
"name",
"slug",
"type",
"description",
],
Expand Down Expand Up @@ -5859,6 +5863,9 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
],
"type": "string",
},
"slug": {
"type": "string",
},
"type": {
"enum": [
"governance_body",
Expand All @@ -5875,6 +5882,7 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
"required": [
"role",
"name",
"slug",
"type",
"description",
],
Expand Down Expand Up @@ -6405,6 +6413,9 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
],
"type": "string",
},
"slug": {
"type": "string",
},
"type": {
"enum": [
"governance_body",
Expand All @@ -6421,6 +6432,7 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
"required": [
"role",
"name",
"slug",
"type",
"description",
],
Expand Down Expand Up @@ -7050,6 +7062,9 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
],
"type": "string",
},
"slug": {
"type": "string",
},
"type": {
"enum": [
"governance_body",
Expand All @@ -7066,6 +7081,7 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
"required": [
"role",
"name",
"slug",
"type",
"description",
],
Expand Down Expand Up @@ -11584,6 +11600,9 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
],
"type": "string",
},
"slug": {
"type": "string",
},
"type": {
"enum": [
"governance_body",
Expand All @@ -11600,6 +11619,7 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
"required": [
"role",
"name",
"slug",
"type",
"description",
],
Expand Down Expand Up @@ -11768,6 +11788,9 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
],
"type": "string",
},
"slug": {
"type": "string",
},
"type": {
"enum": [
"governance_body",
Expand All @@ -11784,6 +11807,7 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
"required": [
"role",
"name",
"slug",
"type",
"description",
],
Expand Down Expand Up @@ -13512,6 +13536,9 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
],
"type": "string",
},
"slug": {
"type": "string",
},
"type": {
"enum": [
"governance_body",
Expand All @@ -13528,6 +13555,7 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
"required": [
"role",
"name",
"slug",
"type",
"description",
],
Expand Down Expand Up @@ -14057,6 +14085,9 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
],
"type": "string",
},
"slug": {
"type": "string",
},
"type": {
"enum": [
"governance_body",
Expand All @@ -14073,6 +14104,7 @@ exports[`openapi > GET /docs/openapi.json > should match the api contract snapsh
"required": [
"role",
"name",
"slug",
"type",
"description",
],
Expand Down
3 changes: 3 additions & 0 deletions apps/api/test/api-persons.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ describe("persons", () => {
expect.objectContaining({
role: "is_affiliated_with",
name: item.affiliation.organisationalUnit.name,
slug: item.affiliation.entity.slug,
description: item.affiliation.description,
}),
]);
Expand Down Expand Up @@ -199,6 +200,7 @@ describe("persons", () => {
expect.objectContaining({
role: "is_affiliated_with",
name: item.affiliation.organisationalUnit.name,
slug: item.affiliation.entity.slug,
description: item.affiliation.description,
}),
]);
Expand Down Expand Up @@ -298,6 +300,7 @@ describe("persons", () => {
expect.objectContaining({
role: "is_affiliated_with",
name: item.affiliation.organisationalUnit.name,
slug: item.affiliation.entity.slug,
description: item.affiliation.description,
}),
]);
Expand Down
Loading