Rename search params to query.

This commit is contained in:
Emmanuel 2022-10-09 08:07:05 +02:00
parent 1b6a2b7aed
commit c6516947f5
19 changed files with 115 additions and 135 deletions

View file

@ -17,7 +17,7 @@ import {
import { allFollowsMutable } from "$lib/aggregates" import { allFollowsMutable } from "$lib/aggregates"
export function auditFollowSearchParams( export function auditFollowQuery(
audit: Audit, audit: Audit,
data: { [key: string]: unknown }, data: { [key: string]: unknown },
errors: { [key: string]: unknown }, errors: { [key: string]: unknown },
@ -29,11 +29,11 @@ export function auditFollowSearchParams(
true, true,
errors, errors,
remainingKeys, remainingKeys,
auditSearchParamsOptionsSet(allFollowsMutable), auditQueryOptionsSet(allFollowsMutable),
) )
} }
export function auditFollowWithFalseSearchParams( export function auditFollowWithFalseQuery(
audit: Audit, audit: Audit,
data: { [key: string]: unknown }, data: { [key: string]: unknown },
errors: { [key: string]: unknown }, errors: { [key: string]: unknown },
@ -45,7 +45,7 @@ export function auditFollowWithFalseSearchParams(
true, true,
errors, errors,
remainingKeys, remainingKeys,
auditSearchParamsOptionsSet([...allFollowsMutable, "false"]), auditQueryOptionsSet([...allFollowsMutable, "false"]),
) )
} }
@ -103,7 +103,7 @@ export function auditOffsetSearchParam(
) )
} }
export function auditPaginationSearchParams( export function auditPaginationQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -149,7 +149,7 @@ export function auditQSearchParam(
auditSingleton(auditTrimString), auditSingleton(auditTrimString),
) )
} }
export const auditSearchParamsArray = auditChain( export const auditQueryArray = auditChain(
auditSwitch( auditSwitch(
auditNullish, auditNullish,
[auditTrimString, auditFunction((value) => [value])], [auditTrimString, auditFunction((value) => [value])],
@ -158,32 +158,30 @@ export const auditSearchParamsArray = auditChain(
auditSetNullish([]), auditSetNullish([]),
) )
export function auditSearchParamsOptionsArray( export function auditQueryOptionsArray(possibleValues: string[]): Auditor {
possibleValues: string[],
): Auditor {
return auditChain( return auditChain(
auditSearchParamsArray, auditQueryArray,
auditArray(auditOptions(possibleValues)), auditArray(auditOptions(possibleValues)),
auditUnique, auditUnique,
auditSetNullish([]), auditSetNullish([]),
) )
} }
export function auditSearchParamsOptionsSet(possibleValues: string[]): Auditor { export function auditQueryOptionsSet(possibleValues: string[]): Auditor {
return auditChain( return auditChain(
auditSearchParamsOptionsArray(possibleValues), auditQueryOptionsArray(possibleValues),
auditFunction((values) => new Set(values)), auditFunction((values) => new Set(values)),
auditSetNullish(new Set()), auditSetNullish(new Set()),
) )
} }
export const auditSearchParamsSet = auditChain( export const auditQuerySet = auditChain(
auditSearchParamsArray, auditQueryArray,
auditFunction((values) => new Set(values)), auditFunction((values) => new Set(values)),
auditSetNullish(new Set()), auditSetNullish(new Set()),
) )
export function auditSearchSearchParams( export function auditSearchQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -205,12 +203,12 @@ export function auditSearchSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditSearchSearchParamsContent(audit, data, errors, remainingKeys) auditSearchQueryContent(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export function auditSearchSearchParamsContent( export function auditSearchQueryContent(
audit: Audit, audit: Audit,
data: { [key: string]: unknown }, data: { [key: string]: unknown },
errors: { [key: string]: unknown }, errors: { [key: string]: unknown },

View file

@ -2,7 +2,7 @@
import { cleanAudit } from "@auditors/core" import { cleanAudit } from "@auditors/core"
import { page } from "$app/stores" 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 type { PaginationQuery } from "$lib/queries"
import { urlFromUrlAndQuery } from "$lib/urls" import { urlFromUrlAndQuery } from "$lib/urls"
@ -20,7 +20,7 @@
$: pathname = url.pathname $: pathname = url.pathname
function ensureValidQuery(query: URLSearchParams): PaginationQuery { function ensureValidQuery(query: URLSearchParams): PaginationQuery {
const [validQuery, queryError] = auditPaginationSearchParams( const [validQuery, queryError] = auditPaginationQuery(
cleanAudit, cleanAudit,
query, query,
) as [PaginationQuery, unknown] ) as [PaginationQuery, unknown]

View file

@ -1,7 +1,7 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import { error } from "@sveltejs/kit" 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 { Follow } from "$lib/aggregates"
import type { Article } from "$lib/legal" import type { Article } from "$lib/legal"
@ -10,7 +10,7 @@ import { db } from "$lib/server/database"
import type { RequestHandler } from "./$types" import type { RequestHandler } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -32,16 +32,13 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditFollowSearchParams(audit, data, errors, remainingKeys) auditFollowQuery(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const GET: RequestHandler = async ({ params, url }) => { export const GET: RequestHandler = async ({ params, url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit,
url.searchParams,
) as [
{ {
follow: Set<Follow> follow: Set<Follow>
}, },

View file

@ -2,17 +2,14 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import { error } from "@sveltejs/kit" import { error } from "@sveltejs/kit"
import type { Follow } from "$lib/aggregates" import type { Follow } from "$lib/aggregates"
import { import { auditFollowQuery, auditQSearchParam } from "$lib/auditors/queries"
auditFollowSearchParams,
auditQSearchParam,
} from "$lib/auditors/search_params"
import type { Article } from "$lib/legal" import type { Article } from "$lib/legal"
import { Aggregator } from "$lib/server/aggregates" import { Aggregator } from "$lib/server/aggregates"
import { db } from "$lib/server/database" import { db } from "$lib/server/database"
import type { RequestHandler } from "./$types" import type { RequestHandler } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -34,17 +31,17 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditFollowSearchParams(audit, data, errors, remainingKeys) auditFollowQuery(audit, data, errors, remainingKeys)
auditQSearchParam(audit, data, errors, remainingKeys) auditQSearchParam(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const GET: RequestHandler = async ({ url }) => { export const GET: RequestHandler = async ({ url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit, { follow: Set<Follow>; q?: string },
url.searchParams, unknown,
) as [{ follow: Set<Follow>; q?: string }, unknown] ]
if (queryError !== null) { if (queryError !== null) {
console.error( console.error(
`Error in ${url.pathname} query:\n${JSON.stringify( `Error in ${url.pathname} query:\n${JSON.stringify(

View file

@ -9,12 +9,12 @@ import type { PendingQuery, Row } from "postgres"
import type { Follow } from "$lib/aggregates" import type { Follow } from "$lib/aggregates"
import { import {
auditFollowSearchParams, auditFollowQuery,
auditLimitSearchParam, auditLimitSearchParam,
auditOffsetSearchParam, auditOffsetSearchParam,
auditQSearchParam, auditQSearchParam,
auditSingleton, auditSingleton,
} from "$lib/auditors/search_params" } from "$lib/auditors/queries"
import type { TexteVersion } from "$lib/legal" import type { TexteVersion } from "$lib/legal"
import { Aggregator } from "$lib/server/aggregates" import { Aggregator } from "$lib/server/aggregates"
import { db } from "$lib/server/database" import { db } from "$lib/server/database"
@ -22,7 +22,7 @@ import { joinSqlClauses } from "$lib/server/sql"
import type { RequestHandler } from "./$types" import type { RequestHandler } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -44,7 +44,7 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditFollowSearchParams(audit, data, errors, remainingKeys) auditFollowQuery(audit, data, errors, remainingKeys)
auditLimitSearchParam(audit, data, errors, remainingKeys) auditLimitSearchParam(audit, data, errors, remainingKeys)
audit.attribute( audit.attribute(
data, data,
@ -61,10 +61,7 @@ export function auditSearchParams(
} }
export const GET: RequestHandler = async ({ url }) => { export const GET: RequestHandler = async ({ url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit,
url.searchParams,
) as [
{ {
follow: Set<Follow> follow: Set<Follow>
limit: number limit: number

View file

@ -1,7 +1,7 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import { error } from "@sveltejs/kit" 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 { Follow } from "$lib/aggregates"
import type { TexteVersion } from "$lib/legal" import type { TexteVersion } from "$lib/legal"
@ -10,7 +10,7 @@ import { db } from "$lib/server/database"
import type { RequestHandler } from "./$types" import type { RequestHandler } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -32,16 +32,13 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditFollowSearchParams(audit, data, errors, remainingKeys) auditFollowQuery(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const GET: RequestHandler = async ({ params, url }) => { export const GET: RequestHandler = async ({ params, url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit,
url.searchParams,
) as [
{ {
follow: Set<Follow> follow: Set<Follow>
}, },

View file

@ -1,13 +1,13 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import { error } from "@sveltejs/kit" 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 type { Article } from "$lib/legal"
import { db } from "$lib/server/database" import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types" import type { PageServerLoad } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -29,16 +29,16 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditSearchSearchParamsContent(audit, data, errors, remainingKeys) auditSearchQueryContent(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const load: PageServerLoad = async ({ url }) => { export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit, { limit: number; offset: number; q?: string },
url.searchParams, unknown,
) as [{ limit: number; offset: number; q?: string }, unknown] ]
if (queryError !== null) { if (queryError !== null) {
console.error( console.error(
`Error in ${url.pathname} query:\n${JSON.stringify( `Error in ${url.pathname} query:\n${JSON.stringify(

View file

@ -2,12 +2,12 @@ import { error } from "@sveltejs/kit"
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import type { Follow, GetArticleResult } from "$lib/aggregates" 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 { urlFromUrlAndQuery } from "$lib/urls"
import type { PageLoad } from "./$types" import type { PageLoad } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -29,16 +29,13 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditFollowWithFalseSearchParams(audit, data, errors, remainingKeys) auditFollowWithFalseQuery(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const load: PageLoad = async ({ fetch, url }) => { export const load: PageLoad = async ({ fetch, url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit,
url.searchParams,
) as [
{ {
follow: Set<Follow | "false"> follow: Set<Follow | "false">
}, },

View file

@ -1,13 +1,13 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import { error } from "@sveltejs/kit" 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 type { DossierLegislatif } from "$lib/legal"
import { db } from "$lib/server/database" import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types" import type { PageServerLoad } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -29,16 +29,16 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditSearchSearchParamsContent(audit, data, errors, remainingKeys) auditSearchQueryContent(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const load: PageServerLoad = async ({ url }) => { export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit, { limit: number; offset: number; q?: string },
url.searchParams, unknown,
) as [{ limit: number; offset: number; q?: string }, unknown] ]
if (queryError !== null) { if (queryError !== null) {
console.error( console.error(
`Error in ${url.pathname} query:\n${JSON.stringify( `Error in ${url.pathname} query:\n${JSON.stringify(

View file

@ -1,13 +1,13 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import { error } from "@sveltejs/kit" 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 type { IdWrapper } from "$lib/legal"
import { db } from "$lib/server/database" import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types" import type { PageServerLoad } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -29,16 +29,16 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditSearchSearchParamsContent(audit, data, errors, remainingKeys) auditSearchQueryContent(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const load: PageServerLoad = async ({ url }) => { export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit, { limit: number; offset: number; q?: string },
url.searchParams, unknown,
) as [{ limit: number; offset: number; q?: string }, unknown] ]
if (queryError !== null) { if (queryError !== null) {
console.error( console.error(
`Error in ${url.pathname} query:\n${JSON.stringify( `Error in ${url.pathname} query:\n${JSON.stringify(

View file

@ -1,13 +1,13 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import { error } from "@sveltejs/kit" 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 type { Idcc } from "$lib/legal"
import { db } from "$lib/server/database" import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types" import type { PageServerLoad } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -29,16 +29,16 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditSearchSearchParamsContent(audit, data, errors, remainingKeys) auditSearchQueryContent(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const load: PageServerLoad = async ({ url }) => { export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit, { limit: number; offset: number; q?: string },
url.searchParams, unknown,
) as [{ limit: number; offset: number; q?: string }, unknown] ]
if (queryError !== null) { if (queryError !== null) {
console.error( console.error(
`Error in ${url.pathname} query:\n${JSON.stringify( `Error in ${url.pathname} query:\n${JSON.stringify(

View file

@ -1,13 +1,13 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import { error } from "@sveltejs/kit" 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 type { Jo } from "$lib/legal"
import { db } from "$lib/server/database" import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types" import type { PageServerLoad } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -29,16 +29,16 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditSearchSearchParamsContent(audit, data, errors, remainingKeys) auditSearchQueryContent(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const load: PageServerLoad = async ({ url }) => { export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit, { limit: number; offset: number; q?: string },
url.searchParams, unknown,
) as [{ limit: number; offset: number; q?: string }, unknown] ]
if (queryError !== null) { if (queryError !== null) {
console.error( console.error(
`Error in ${url.pathname} query:\n${JSON.stringify( `Error in ${url.pathname} query:\n${JSON.stringify(

View file

@ -1,13 +1,13 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import { error } from "@sveltejs/kit" 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 type { SectionTa } from "$lib/legal"
import { db } from "$lib/server/database" import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types" import type { PageServerLoad } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -29,16 +29,16 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditSearchSearchParamsContent(audit, data, errors, remainingKeys) auditSearchQueryContent(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const load: PageServerLoad = async ({ url }) => { export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit, { limit: number; offset: number; q?: string },
url.searchParams, unknown,
) as [{ limit: number; offset: number; q?: string }, unknown] ]
if (queryError !== null) { if (queryError !== null) {
console.error( console.error(
`Error in ${url.pathname} query:\n${JSON.stringify( `Error in ${url.pathname} query:\n${JSON.stringify(

View file

@ -1,13 +1,13 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import { error } from "@sveltejs/kit" 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 type { TexteVersion } from "$lib/legal"
import { db } from "$lib/server/database" import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types" import type { PageServerLoad } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -29,16 +29,16 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditSearchSearchParamsContent(audit, data, errors, remainingKeys) auditSearchQueryContent(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const load: PageServerLoad = async ({ url }) => { export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit, { limit: number; offset: number; q?: string },
url.searchParams, unknown,
) as [{ limit: number; offset: number; q?: string }, unknown] ]
if (queryError !== null) { if (queryError !== null) {
console.error( console.error(
`Error in ${url.pathname} query:\n${JSON.stringify( `Error in ${url.pathname} query:\n${JSON.stringify(

View file

@ -1,13 +1,13 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import { error } from "@sveltejs/kit" 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 type { Textekali } from "$lib/legal"
import { db } from "$lib/server/database" import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types" import type { PageServerLoad } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -29,16 +29,16 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditSearchSearchParamsContent(audit, data, errors, remainingKeys) auditSearchQueryContent(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const load: PageServerLoad = async ({ url }) => { export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit, { limit: number; offset: number; q?: string },
url.searchParams, unknown,
) as [{ limit: number; offset: number; q?: string }, unknown] ]
if (queryError !== null) { if (queryError !== null) {
console.error( console.error(
`Error in ${url.pathname} query:\n${JSON.stringify( `Error in ${url.pathname} query:\n${JSON.stringify(

View file

@ -1,13 +1,13 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import { error } from "@sveltejs/kit" 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 type { Textelr } from "$lib/legal"
import { db } from "$lib/server/database" import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types" import type { PageServerLoad } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -29,16 +29,16 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditSearchSearchParamsContent(audit, data, errors, remainingKeys) auditSearchQueryContent(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const load: PageServerLoad = async ({ url }) => { export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit, { limit: number; offset: number; q?: string },
url.searchParams, unknown,
) as [{ limit: number; offset: number; q?: string }, unknown] ]
if (queryError !== null) { if (queryError !== null) {
console.error( console.error(
`Error in ${url.pathname} query:\n${JSON.stringify( `Error in ${url.pathname} query:\n${JSON.stringify(

View file

@ -2,12 +2,12 @@ import { error } from "@sveltejs/kit"
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import type { Follow, GetTexteResult } from "$lib/aggregates" 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 { urlFromUrlAndQuery } from "$lib/urls"
import type { PageLoad } from "./$types" import type { PageLoad } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -29,16 +29,13 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditFollowWithFalseSearchParams(audit, data, errors, remainingKeys) auditFollowWithFalseQuery(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const load: PageLoad = async ({ fetch, url }) => { export const load: PageLoad = async ({ fetch, url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit,
url.searchParams,
) as [
{ {
follow: Set<Follow | "false"> follow: Set<Follow | "false">
}, },

View file

@ -1,13 +1,13 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core" import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import { error } from "@sveltejs/kit" 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 type { VersionsWrapper } from "$lib/legal"
import { db } from "$lib/server/database" import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types" import type { PageServerLoad } from "./$types"
export function auditSearchParams( export function auditQuery(
audit: Audit, audit: Audit,
query: URLSearchParams, query: URLSearchParams,
): [unknown, unknown] { ): [unknown, unknown] {
@ -29,16 +29,16 @@ export function auditSearchParams(
const errors: { [key: string]: unknown } = {} const errors: { [key: string]: unknown } = {}
const remainingKeys = new Set(Object.keys(data)) const remainingKeys = new Set(Object.keys(data))
auditSearchSearchParamsContent(audit, data, errors, remainingKeys) auditSearchQueryContent(audit, data, errors, remainingKeys)
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({})) return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
} }
export const load: PageServerLoad = async ({ url }) => { export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditSearchParams( const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
cleanAudit, { limit: number; offset: number; q?: string },
url.searchParams, unknown,
) as [{ limit: number; offset: number; q?: string }, unknown] ]
if (queryError !== null) { if (queryError !== null) {
console.error( console.error(
`Error in ${url.pathname} query:\n${JSON.stringify( `Error in ${url.pathname} query:\n${JSON.stringify(