Skip to content

feat(layers): add layer search to the API - #73

Open
pelord wants to merge 1 commit into
nextfrom
feat/modernization-api-layers-search
Open

feat(layers): add layer search to the API#73
pelord wants to merge 1 commit into
nextfrom
feat/modernization-api-layers-search

Conversation

@pelord

@pelord pelord commented Jun 17, 2026

Copy link
Copy Markdown
Member

add layer search to the API

@pelord
pelord requested a review from alecarn June 17, 2026 15:25
@alecarn
alecarn force-pushed the feat/modernization-api branch 2 times, most recently from e2875ef to b89ac00 Compare July 3, 2026 14:15
@alecarn
alecarn changed the base branch from feat/modernization-api to next July 6, 2026 20:20
@pelord
pelord force-pushed the feat/modernization-api-layers-search branch from 5d10448 to 3e93f35 Compare July 7, 2026 13:54
Comment thread src/app.interface.ts
WSS_API: Type.String(),
KONG_API: Type.Optional(Type.String()),
ADMIN_KEY: Type.Optional(Type.String()),
WSS_API: Type.Optional(Type.String()),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ces changements sont inclus dans une autre PR

)
.orderBy(desc(rank))
.limit(limit)
.offset(offset);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[COPILOT]: Pagination is applied before authorization filtering

The DB query fetches limit rows, then silently drops those the user can't access. This means a page can return fewer results than limit even when more valid rows exist, and results shift unpredictably across pages. Consider over-fetching or doing a two-phase approach (get IDs allowed for this profil first, then paginate).

Comment thread src/layer/layer.schema.ts
type: Type.Optional(
Type.Union([Type.Literal('layer'), Type.Literal('group')])
),
limit: Type.Optional(Type.Integer({ minimum: 1 })),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On devrait imposer un maximum, 100?

'simple',
coalesce(${layerModel.layerOptions}->>'title', ${layerModel.layers}, ''),
to_tsquery('simple', ${toTextSearchString(originalQuery)}),
'StartSel=<strong>, StopSel=</strong>'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Medium] XSS vector in highlight.title

ts_headline returns the document text with ... tags injected but does not HTML-escape the surrounding text. If a layer title contains <script>...</script>, it will appear unescaped in the response. Clients that render highlight.title as raw HTML are vulnerable. Consider HTML-escaping the document before passing it to ts_headline, or documenting explicitly that consumers must sanitize this field.

type: layerModel.type,
url: layerModel.url,
layers: layerModel.layers,
global: layerModel.global,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

global column is selected but never used

return term
.split(' ')
.filter(Boolean)
.map((term) => `${term}:*`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename the .map callback parameter (e.g. word) to avoid the shadowing.


const result = response.json<ILayerSearchResult>();
t.assert.equal(Array.isArray(result.items), true);
t.assert.equal(result.items.length > 0, true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would give a poor failure message; consider using t.assert.ok(result.items.length > 0, 'expected at least one result').

/**
* Prevent to add unaccent extension on DB backend.
*/
const sqlTranslateStripAccents = (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'irais avec ton idée initiale d'utiliser l'extension unaccent qui semble incluse dans la grand majorité des versions de PostgreSQL. On pourrait ajouter une migration pour l'activer par défaut et l'utiliser dans ce cas ci

CREATE EXTENSION IF NOT EXISTS unaccent;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants