diff --git a/src/lib/auditors/search_params.ts b/src/lib/auditors/queries.ts similarity index 85% rename from src/lib/auditors/search_params.ts rename to src/lib/auditors/queries.ts index 1806818..0f9ddf4 100644 --- a/src/lib/auditors/search_params.ts +++ b/src/lib/auditors/queries.ts @@ -17,7 +17,7 @@ import { import { allFollowsMutable } from "$lib/aggregates" -export function auditFollowSearchParams( +export function auditFollowQuery( audit: Audit, data: { [key: string]: unknown }, errors: { [key: string]: unknown }, @@ -29,11 +29,11 @@ export function auditFollowSearchParams( true, errors, remainingKeys, - auditSearchParamsOptionsSet(allFollowsMutable), + auditQueryOptionsSet(allFollowsMutable), ) } -export function auditFollowWithFalseSearchParams( +export function auditFollowWithFalseQuery( audit: Audit, data: { [key: string]: unknown }, errors: { [key: string]: unknown }, @@ -45,7 +45,7 @@ export function auditFollowWithFalseSearchParams( true, errors, remainingKeys, - auditSearchParamsOptionsSet([...allFollowsMutable, "false"]), + auditQueryOptionsSet([...allFollowsMutable, "false"]), ) } @@ -103,7 +103,7 @@ export function auditOffsetSearchParam( ) } -export function auditPaginationSearchParams( +export function auditPaginationQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -149,7 +149,7 @@ export function auditQSearchParam( auditSingleton(auditTrimString), ) } -export const auditSearchParamsArray = auditChain( +export const auditQueryArray = auditChain( auditSwitch( auditNullish, [auditTrimString, auditFunction((value) => [value])], @@ -158,32 +158,30 @@ export const auditSearchParamsArray = auditChain( auditSetNullish([]), ) -export function auditSearchParamsOptionsArray( - possibleValues: string[], -): Auditor { +export function auditQueryOptionsArray(possibleValues: string[]): Auditor { return auditChain( - auditSearchParamsArray, + auditQueryArray, auditArray(auditOptions(possibleValues)), auditUnique, auditSetNullish([]), ) } -export function auditSearchParamsOptionsSet(possibleValues: string[]): Auditor { +export function auditQueryOptionsSet(possibleValues: string[]): Auditor { return auditChain( - auditSearchParamsOptionsArray(possibleValues), + auditQueryOptionsArray(possibleValues), auditFunction((values) => new Set(values)), auditSetNullish(new Set()), ) } -export const auditSearchParamsSet = auditChain( - auditSearchParamsArray, +export const auditQuerySet = auditChain( + auditQueryArray, auditFunction((values) => new Set(values)), auditSetNullish(new Set()), ) -export function auditSearchSearchParams( +export function auditSearchQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -205,12 +203,12 @@ export function auditSearchSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditSearchSearchParamsContent(audit, data, errors, remainingKeys) + auditSearchQueryContent(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } -export function auditSearchSearchParamsContent( +export function auditSearchQueryContent( audit: Audit, data: { [key: string]: unknown }, errors: { [key: string]: unknown }, diff --git a/src/lib/components/Pagination.svelte b/src/lib/components/Pagination.svelte index 31135c4..4ff2722 100644 --- a/src/lib/components/Pagination.svelte +++ b/src/lib/components/Pagination.svelte @@ -2,7 +2,7 @@ import { cleanAudit } from "@auditors/core" import { page } from "$app/stores" - import { auditPaginationSearchParams } from "$lib/auditors/search_params" + import { auditPaginationQuery } from "$lib/auditors/queries" import type { PaginationQuery } from "$lib/queries" import { urlFromUrlAndQuery } from "$lib/urls" @@ -20,7 +20,7 @@ $: pathname = url.pathname function ensureValidQuery(query: URLSearchParams): PaginationQuery { - const [validQuery, queryError] = auditPaginationSearchParams( + const [validQuery, queryError] = auditPaginationQuery( cleanAudit, query, ) as [PaginationQuery, unknown] diff --git a/src/routes/api/articles/[id]/+server.ts b/src/routes/api/articles/[id]/+server.ts index c569cfd..2c6c107 100644 --- a/src/routes/api/articles/[id]/+server.ts +++ b/src/routes/api/articles/[id]/+server.ts @@ -1,7 +1,7 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { error } from "@sveltejs/kit" -import { auditFollowSearchParams } from "$lib/auditors/search_params" +import { auditFollowQuery } from "$lib/auditors/queries" import type { Follow } from "$lib/aggregates" import type { Article } from "$lib/legal" @@ -10,7 +10,7 @@ import { db } from "$lib/server/database" import type { RequestHandler } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -32,16 +32,13 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditFollowSearchParams(audit, data, errors, remainingKeys) + auditFollowQuery(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const GET: RequestHandler = async ({ params, url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [ + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ { follow: Set }, diff --git a/src/routes/api/recherche/+server.ts b/src/routes/api/recherche/+server.ts index e62bf77..81a8daf 100644 --- a/src/routes/api/recherche/+server.ts +++ b/src/routes/api/recherche/+server.ts @@ -2,17 +2,14 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { error } from "@sveltejs/kit" import type { Follow } from "$lib/aggregates" -import { - auditFollowSearchParams, - auditQSearchParam, -} from "$lib/auditors/search_params" +import { auditFollowQuery, auditQSearchParam } from "$lib/auditors/queries" import type { Article } from "$lib/legal" import { Aggregator } from "$lib/server/aggregates" import { db } from "$lib/server/database" import type { RequestHandler } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -34,17 +31,17 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditFollowSearchParams(audit, data, errors, remainingKeys) + auditFollowQuery(audit, data, errors, remainingKeys) auditQSearchParam(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const GET: RequestHandler = async ({ url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [{ follow: Set; q?: string }, unknown] + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ + { follow: Set; q?: string }, + unknown, + ] if (queryError !== null) { console.error( `Error in ${url.pathname} query:\n${JSON.stringify( diff --git a/src/routes/api/textes/+server.ts b/src/routes/api/textes/+server.ts index c27701a..0590800 100644 --- a/src/routes/api/textes/+server.ts +++ b/src/routes/api/textes/+server.ts @@ -9,12 +9,12 @@ import type { PendingQuery, Row } from "postgres" import type { Follow } from "$lib/aggregates" import { - auditFollowSearchParams, + auditFollowQuery, auditLimitSearchParam, auditOffsetSearchParam, auditQSearchParam, auditSingleton, -} from "$lib/auditors/search_params" +} from "$lib/auditors/queries" import type { TexteVersion } from "$lib/legal" import { Aggregator } from "$lib/server/aggregates" import { db } from "$lib/server/database" @@ -22,7 +22,7 @@ import { joinSqlClauses } from "$lib/server/sql" import type { RequestHandler } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -44,7 +44,7 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditFollowSearchParams(audit, data, errors, remainingKeys) + auditFollowQuery(audit, data, errors, remainingKeys) auditLimitSearchParam(audit, data, errors, remainingKeys) audit.attribute( data, @@ -61,10 +61,7 @@ export function auditSearchParams( } export const GET: RequestHandler = async ({ url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [ + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ { follow: Set limit: number diff --git a/src/routes/api/textes/[id]/+server.ts b/src/routes/api/textes/[id]/+server.ts index aceda4c..27b3cb6 100644 --- a/src/routes/api/textes/[id]/+server.ts +++ b/src/routes/api/textes/[id]/+server.ts @@ -1,7 +1,7 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { error } from "@sveltejs/kit" -import { auditFollowSearchParams } from "$lib/auditors/search_params" +import { auditFollowQuery } from "$lib/auditors/queries" import type { Follow } from "$lib/aggregates" import type { TexteVersion } from "$lib/legal" @@ -10,7 +10,7 @@ import { db } from "$lib/server/database" import type { RequestHandler } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -32,16 +32,13 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditFollowSearchParams(audit, data, errors, remainingKeys) + auditFollowQuery(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const GET: RequestHandler = async ({ params, url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [ + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ { follow: Set }, diff --git a/src/routes/article/+page.server.ts b/src/routes/article/+page.server.ts index 99c86e0..eceb122 100644 --- a/src/routes/article/+page.server.ts +++ b/src/routes/article/+page.server.ts @@ -1,13 +1,13 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { error } from "@sveltejs/kit" -import { auditSearchSearchParamsContent } from "$lib/auditors/search_params" +import { auditSearchQueryContent } from "$lib/auditors/queries" import type { Article } from "$lib/legal" import { db } from "$lib/server/database" import type { PageServerLoad } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -29,16 +29,16 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditSearchSearchParamsContent(audit, data, errors, remainingKeys) + auditSearchQueryContent(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const load: PageServerLoad = async ({ url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [{ limit: number; offset: number; q?: string }, unknown] + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ + { limit: number; offset: number; q?: string }, + unknown, + ] if (queryError !== null) { console.error( `Error in ${url.pathname} query:\n${JSON.stringify( diff --git a/src/routes/articles/[id]/+page.ts b/src/routes/articles/[id]/+page.ts index 25101e2..4d8e511 100644 --- a/src/routes/articles/[id]/+page.ts +++ b/src/routes/articles/[id]/+page.ts @@ -2,12 +2,12 @@ import { error } from "@sveltejs/kit" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import type { Follow, GetArticleResult } from "$lib/aggregates" -import { auditFollowWithFalseSearchParams } from "$lib/auditors/search_params" +import { auditFollowWithFalseQuery } from "$lib/auditors/queries" import { urlFromUrlAndQuery } from "$lib/urls" import type { PageLoad } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -29,16 +29,13 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditFollowWithFalseSearchParams(audit, data, errors, remainingKeys) + auditFollowWithFalseQuery(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const load: PageLoad = async ({ fetch, url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [ + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ { follow: Set }, diff --git a/src/routes/dossier_legislatif/+page.server.ts b/src/routes/dossier_legislatif/+page.server.ts index 4d96a15..c731eea 100644 --- a/src/routes/dossier_legislatif/+page.server.ts +++ b/src/routes/dossier_legislatif/+page.server.ts @@ -1,13 +1,13 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { error } from "@sveltejs/kit" -import { auditSearchSearchParamsContent } from "$lib/auditors/search_params" +import { auditSearchQueryContent } from "$lib/auditors/queries" import type { DossierLegislatif } from "$lib/legal" import { db } from "$lib/server/database" import type { PageServerLoad } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -29,16 +29,16 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditSearchSearchParamsContent(audit, data, errors, remainingKeys) + auditSearchQueryContent(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const load: PageServerLoad = async ({ url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [{ limit: number; offset: number; q?: string }, unknown] + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ + { limit: number; offset: number; q?: string }, + unknown, + ] if (queryError !== null) { console.error( `Error in ${url.pathname} query:\n${JSON.stringify( diff --git a/src/routes/id/+page.server.ts b/src/routes/id/+page.server.ts index 3c1561a..4b00f28 100644 --- a/src/routes/id/+page.server.ts +++ b/src/routes/id/+page.server.ts @@ -1,13 +1,13 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { error } from "@sveltejs/kit" -import { auditSearchSearchParamsContent } from "$lib/auditors/search_params" +import { auditSearchQueryContent } from "$lib/auditors/queries" import type { IdWrapper } from "$lib/legal" import { db } from "$lib/server/database" import type { PageServerLoad } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -29,16 +29,16 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditSearchSearchParamsContent(audit, data, errors, remainingKeys) + auditSearchQueryContent(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const load: PageServerLoad = async ({ url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [{ limit: number; offset: number; q?: string }, unknown] + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ + { limit: number; offset: number; q?: string }, + unknown, + ] if (queryError !== null) { console.error( `Error in ${url.pathname} query:\n${JSON.stringify( diff --git a/src/routes/idcc/+page.server.ts b/src/routes/idcc/+page.server.ts index 9d72d23..80e1011 100644 --- a/src/routes/idcc/+page.server.ts +++ b/src/routes/idcc/+page.server.ts @@ -1,13 +1,13 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { error } from "@sveltejs/kit" -import { auditSearchSearchParamsContent } from "$lib/auditors/search_params" +import { auditSearchQueryContent } from "$lib/auditors/queries" import type { Idcc } from "$lib/legal" import { db } from "$lib/server/database" import type { PageServerLoad } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -29,16 +29,16 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditSearchSearchParamsContent(audit, data, errors, remainingKeys) + auditSearchQueryContent(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const load: PageServerLoad = async ({ url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [{ limit: number; offset: number; q?: string }, unknown] + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ + { limit: number; offset: number; q?: string }, + unknown, + ] if (queryError !== null) { console.error( `Error in ${url.pathname} query:\n${JSON.stringify( diff --git a/src/routes/jo/+page.server.ts b/src/routes/jo/+page.server.ts index 3bb13cb..68e2f1c 100644 --- a/src/routes/jo/+page.server.ts +++ b/src/routes/jo/+page.server.ts @@ -1,13 +1,13 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { error } from "@sveltejs/kit" -import { auditSearchSearchParamsContent } from "$lib/auditors/search_params" +import { auditSearchQueryContent } from "$lib/auditors/queries" import type { Jo } from "$lib/legal" import { db } from "$lib/server/database" import type { PageServerLoad } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -29,16 +29,16 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditSearchSearchParamsContent(audit, data, errors, remainingKeys) + auditSearchQueryContent(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const load: PageServerLoad = async ({ url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [{ limit: number; offset: number; q?: string }, unknown] + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ + { limit: number; offset: number; q?: string }, + unknown, + ] if (queryError !== null) { console.error( `Error in ${url.pathname} query:\n${JSON.stringify( diff --git a/src/routes/section_ta/+page.server.ts b/src/routes/section_ta/+page.server.ts index 5be0c91..e115eea 100644 --- a/src/routes/section_ta/+page.server.ts +++ b/src/routes/section_ta/+page.server.ts @@ -1,13 +1,13 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { error } from "@sveltejs/kit" -import { auditSearchSearchParamsContent } from "$lib/auditors/search_params" +import { auditSearchQueryContent } from "$lib/auditors/queries" import type { SectionTa } from "$lib/legal" import { db } from "$lib/server/database" import type { PageServerLoad } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -29,16 +29,16 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditSearchSearchParamsContent(audit, data, errors, remainingKeys) + auditSearchQueryContent(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const load: PageServerLoad = async ({ url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [{ limit: number; offset: number; q?: string }, unknown] + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ + { limit: number; offset: number; q?: string }, + unknown, + ] if (queryError !== null) { console.error( `Error in ${url.pathname} query:\n${JSON.stringify( diff --git a/src/routes/texte_version/+page.server.ts b/src/routes/texte_version/+page.server.ts index b2f207a..0d5c29b 100644 --- a/src/routes/texte_version/+page.server.ts +++ b/src/routes/texte_version/+page.server.ts @@ -1,13 +1,13 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { error } from "@sveltejs/kit" -import { auditSearchSearchParamsContent } from "$lib/auditors/search_params" +import { auditSearchQueryContent } from "$lib/auditors/queries" import type { TexteVersion } from "$lib/legal" import { db } from "$lib/server/database" import type { PageServerLoad } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -29,16 +29,16 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditSearchSearchParamsContent(audit, data, errors, remainingKeys) + auditSearchQueryContent(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const load: PageServerLoad = async ({ url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [{ limit: number; offset: number; q?: string }, unknown] + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ + { limit: number; offset: number; q?: string }, + unknown, + ] if (queryError !== null) { console.error( `Error in ${url.pathname} query:\n${JSON.stringify( diff --git a/src/routes/textekali/+page.server.ts b/src/routes/textekali/+page.server.ts index 97fe5ed..2b1e66e 100644 --- a/src/routes/textekali/+page.server.ts +++ b/src/routes/textekali/+page.server.ts @@ -1,13 +1,13 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { error } from "@sveltejs/kit" -import { auditSearchSearchParamsContent } from "$lib/auditors/search_params" +import { auditSearchQueryContent } from "$lib/auditors/queries" import type { Textekali } from "$lib/legal" import { db } from "$lib/server/database" import type { PageServerLoad } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -29,16 +29,16 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditSearchSearchParamsContent(audit, data, errors, remainingKeys) + auditSearchQueryContent(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const load: PageServerLoad = async ({ url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [{ limit: number; offset: number; q?: string }, unknown] + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ + { limit: number; offset: number; q?: string }, + unknown, + ] if (queryError !== null) { console.error( `Error in ${url.pathname} query:\n${JSON.stringify( diff --git a/src/routes/textelr/+page.server.ts b/src/routes/textelr/+page.server.ts index 99eb014..4cf439f 100644 --- a/src/routes/textelr/+page.server.ts +++ b/src/routes/textelr/+page.server.ts @@ -1,13 +1,13 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { error } from "@sveltejs/kit" -import { auditSearchSearchParamsContent } from "$lib/auditors/search_params" +import { auditSearchQueryContent } from "$lib/auditors/queries" import type { Textelr } from "$lib/legal" import { db } from "$lib/server/database" import type { PageServerLoad } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -29,16 +29,16 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditSearchSearchParamsContent(audit, data, errors, remainingKeys) + auditSearchQueryContent(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const load: PageServerLoad = async ({ url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [{ limit: number; offset: number; q?: string }, unknown] + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ + { limit: number; offset: number; q?: string }, + unknown, + ] if (queryError !== null) { console.error( `Error in ${url.pathname} query:\n${JSON.stringify( diff --git a/src/routes/textes/[id]/+page.ts b/src/routes/textes/[id]/+page.ts index 681980b..88d3ea5 100644 --- a/src/routes/textes/[id]/+page.ts +++ b/src/routes/textes/[id]/+page.ts @@ -2,12 +2,12 @@ import { error } from "@sveltejs/kit" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import type { Follow, GetTexteResult } from "$lib/aggregates" -import { auditFollowWithFalseSearchParams } from "$lib/auditors/search_params" +import { auditFollowWithFalseQuery } from "$lib/auditors/queries" import { urlFromUrlAndQuery } from "$lib/urls" import type { PageLoad } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -29,16 +29,13 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditFollowWithFalseSearchParams(audit, data, errors, remainingKeys) + auditFollowWithFalseQuery(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const load: PageLoad = async ({ fetch, url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [ + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ { follow: Set }, diff --git a/src/routes/versions/+page.server.ts b/src/routes/versions/+page.server.ts index dad3548..0b30fcc 100644 --- a/src/routes/versions/+page.server.ts +++ b/src/routes/versions/+page.server.ts @@ -1,13 +1,13 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { error } from "@sveltejs/kit" -import { auditSearchSearchParamsContent } from "$lib/auditors/search_params" +import { auditSearchQueryContent } from "$lib/auditors/queries" import type { VersionsWrapper } from "$lib/legal" import { db } from "$lib/server/database" import type { PageServerLoad } from "./$types" -export function auditSearchParams( +export function auditQuery( audit: Audit, query: URLSearchParams, ): [unknown, unknown] { @@ -29,16 +29,16 @@ export function auditSearchParams( const errors: { [key: string]: unknown } = {} const remainingKeys = new Set(Object.keys(data)) - auditSearchSearchParamsContent(audit, data, errors, remainingKeys) + auditSearchQueryContent(audit, data, errors, remainingKeys) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) } export const load: PageServerLoad = async ({ url }) => { - const [query, queryError] = auditSearchParams( - cleanAudit, - url.searchParams, - ) as [{ limit: number; offset: number; q?: string }, unknown] + const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [ + { limit: number; offset: number; q?: string }, + unknown, + ] if (queryError !== null) { console.error( `Error in ${url.pathname} query:\n${JSON.stringify( diff --git a/vite.config.js b/vite.config.ts similarity index 100% rename from vite.config.js rename to vite.config.ts