Rename search params to query.
This commit is contained in:
parent
1b6a2b7aed
commit
c6516947f5
19 changed files with 115 additions and 135 deletions
|
@ -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 },
|
|
@ -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]
|
||||
|
|
|
@ -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<Follow>
|
||||
},
|
||||
|
|
|
@ -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<Follow>; q?: string }, unknown]
|
||||
const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
|
||||
{ follow: Set<Follow>; q?: string },
|
||||
unknown,
|
||||
]
|
||||
if (queryError !== null) {
|
||||
console.error(
|
||||
`Error in ${url.pathname} query:\n${JSON.stringify(
|
||||
|
|
|
@ -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<Follow>
|
||||
limit: number
|
||||
|
|
|
@ -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<Follow>
|
||||
},
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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<Follow | "false">
|
||||
},
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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<Follow | "false">
|
||||
},
|
||||
|
|
|
@ -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(
|
||||
|
|
Loading…
Reference in a new issue