chore: implemented expand QPs for showcase#52
Conversation
| "scripts": { | ||
| "start": "ts-node src/index.ts", | ||
| "dev": "ts-node-dev src/index.ts", | ||
| "dev": "ts-node-dev --transpile-only src/index.ts", |
There was a problem hiding this comment.
Resolves 3min startup time
|
|
||
| @Get('/') | ||
| public async getAll(): Promise<ShowcasesResponse> { | ||
| public async getAll(@QueryParam('expand') expand?: ShowcaseExpand[]): Promise<ShowcasesResponse> { |
There was a problem hiding this comment.
i do not see id's being returned. now it is returning empty arrays
|
|
||
| @Get('/:slug') | ||
| public async getOne(@Param('slug') slug: string): Promise<ShowcaseResponse> { | ||
| public async getOne(@Param('slug') slug: string, @QueryParam('expand') expand?: ShowcaseExpand[]): Promise<ShowcaseResponse> { |
There was a problem hiding this comment.
i do not see id's being returned. now it is returning empty arrays
| const getResponse = await request.get(`/showcases/${createdShowcase.slug}`).expect(200) | ||
|
|
||
| // Verify no related entities are expanded | ||
| expect(getResponse.body.showcase.scenarios).toEqual([]) |
There was a problem hiding this comment.
should we not check on id's here?
| // Create a properly typed array for scenarios | ||
| const scenariosArray: Scenario[] = [] | ||
|
|
||
| for (const scenarioJoin of result.scenarios) { |
| if (expandSet.has(ShowcaseExpand.PERSONAS) && 'personas' in result && Array.isArray(result.personas)) { | ||
| const personasArray: Persona[] = [] | ||
|
|
||
| for (const personaJoin of result.personas) { |
| credentialDefinition: { | ||
| with: { | ||
| icon: true, | ||
| ...(expandSet.has(ShowcaseExpand.ASSET_CONTENT) ? { icon: true } : {}), |
There was a problem hiding this comment.
...(expandSet.has(ShowcaseExpand.ASSET_CONTENT) && { icon: true })
| const scenarioItems = scenariosMap.get(showcaseData.id) || [] | ||
| const scenariosArray: Scenario[] = [] | ||
|
|
||
| for (const scenarioJoin of scenarioItems) { |
|
|
||
| public getShowcases = async (): Promise<Showcase[]> => { | ||
| return this.showcaseRepository.findAll() | ||
| public getShowcases = async (expand?: ShowcaseExpand[]): Promise<Showcase[]> => { |
There was a problem hiding this comment.
can we create an params object for these functions? this extends much nicer in the future
| export const normalizeExpandParams = (expand?: string[]): ShowcaseExpand[] => { | ||
| const expandMap: Record<string, ShowcaseExpand> = { | ||
| scenarios: ShowcaseExpand.Scenarios, | ||
| credentialdefinitions: ShowcaseExpand.CredentialDefinitions, |
There was a problem hiding this comment.
why do we have these double? with snake case?
There was a problem hiding this comment.
yes it gives some upper/lower/snake case flexibility
|
Also tests are failing, run pnpm test from the root |
No description provided.