Migrate to latest Svelte Kit.

This commit is contained in:
Emmanuel 2022-08-20 19:36:21 +02:00
parent b6c309af2e
commit 675cb024d9
68 changed files with 1316 additions and 1289 deletions

786
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -27,8 +27,9 @@
"@iconify/svelte": "^2.2.1",
"@playwright/test": "^1.22.2",
"@sveltejs/adapter-node": "^1.0.0-next.86",
"@sveltejs/kit": "next",
"@sveltejs/kit": "^1.0.0-next.427",
"@tailwindcss/typography": "^0.5.3",
"@tricoteuses/explorer-tools": "^0.1.4",
"@types/fs-extra": "^9.0.13",
"@types/he": "^1.1.2",
"@typescript-eslint/eslint-plugin": "^5.27.0",

View file

@ -1,12 +1,4 @@
import type { GetSession, Handle } from "@sveltejs/kit"
import config from "$lib/server/config"
export const getSession: GetSession = async () => {
return {
title: config.title,
}
}
import type { Handle } from "@sveltejs/kit"
export const handle: Handle = async ({ event, resolve }) => {
// Add CORS support.

View file

@ -1,3 +1,5 @@
import type { MenuItem } from "@tricoteuses/explorer-tools"
export interface Article {
META: {
META_COMMUN: MetaCommun
@ -182,6 +184,44 @@ export interface XmlHeader {
"@version": "1.0"
}
export const appMenu: MenuItem[] = [
{ href: "/recherche", label: "Recherche" },
{
items: [
{ href: "/article", label: "ARTICLE" },
{ href: "/dossier_legislatif", label: "DOSSIER_LEGISLATIF" },
{ href: "/id", label: "ID" },
{ href: "/idcc", label: "IDCC" },
{ href: "/jo", label: "JO" },
{ href: "/section_ta", label: "SECTION_TA" },
{ href: "/texte_version", label: "TEXTE_VERSION" },
{ href: "/textekali", label: "TEXTEKALI" },
{ href: "/textelr", label: "TEXTELR" },
{ href: "/versions", label: "VERSIONS" },
],
label: "Données",
},
// {
// items: [
// { href: "/jo", label: "JO" },
// ],
// label: "JORF",
// title: "Textes publiés au Journal officiel de la République française",
// },
// {
// items: [
// { href: "/article", label: "ARTICLE" },
// // { href: "/eli/ids", label: "ID" },
// { href: "/section_ta", label: "SECTION_TA" },
// { href: "/texte_version", label: "TEXTE_VERSION" },
// { href: "/textelr", label: "TEXTELR" },
// // { href: "/eli/versions", label: "VERSIONS" },
// ],
// label: "LEGI",
// title: "Codes, lois et règlements consolidés",
// },
]
export function assertNeverLegalObjectType(type: never): never {
throw `Unexpected type for legal object: ${type}`
}

View file

@ -192,9 +192,10 @@ export function summarizeLegalObject(
const dossierLegislatif = value as DossierLegislatif | undefined
return dossierLegislatif?.META.META_DOSSIER_LEGISLATIF.TITRE
}
case "id":
case "id": {
const idWrapper = value as IdWrapper | undefined
return idWrapper?.eli
}
case "idcc": {
const idcc = value as Idcc | undefined
return idcc?.META.META_SPEC.META_CONTENEUR.TITRE
@ -225,9 +226,10 @@ export function summarizeLegalObject(
const textelr = value as Textelr | undefined
return textelr?.META.META_COMMUN.ID
}
case "versions":
case "versions": {
const versionsWrapper = value as VersionsWrapper | undefined
return versionsWrapper?.eli
}
default:
assertNeverLegalObjectType(type)
}

View file

@ -0,0 +1,7 @@
import config from "$lib/server/config"
import type { LayoutServerLoad } from "./$types"
export const load: LayoutServerLoad = () => {
return { appTitle: config.title }
}

23
src/routes/+layout.svelte Normal file
View file

@ -0,0 +1,23 @@
<script lang="ts">
import "../app.postcss"
// import { NavBar } from "@tricoteuses/explorer-tools"
import NavBar from "@tricoteuses/explorer-tools/components/NavBar.svelte"
import { page } from "$app/stores"
import { appMenu } from "$lib/legal"
</script>
<svelte:head>
<title>{$page.data.appTitle}</title>
</svelte:head>
<NavBar
contributeUrl="https://git.en-root.org/tricoteuses/tricoteuses-legal-explorer"
leftMenu={appMenu}
title={$page.data.appTitle}
/>
<div class="mx-auto w-11/12">
<slot />
</div>

View file

@ -1,13 +1,7 @@
<script lang="ts">
import { session } from "$app/stores"
const title = $session.title
import { page } from "$app/stores"
</script>
<svelte:head>
<title>{title}</title>
</svelte:head>
<main>
<div class="hero bg-base-200">
<div class="hero-content flex-col lg:flex-row">
@ -17,7 +11,10 @@
src="/tricoteuses_jacobines_1301x1907.jpg"
/>
<div>
<h1 class="text-5xl font-bold">Tricoteuses</h1>
<h1 class="text-5xl font-bold">
{$page.data.appTitle}
Légifrance
</h1>
<p class="py-6">
Un site et des API pour permettre aux développeurs d'utiliser plus
facilement les données publiques légales de la <abbr

View file

@ -1,131 +0,0 @@
<script lang="ts">
import "../app.css"
import Icon from "@iconify/svelte"
import chevronDown from "@iconify-icons/codicon/chevron-down"
import chevronRight from "@iconify-icons/codicon/chevron-right"
import threeBars from "@iconify-icons/codicon/three-bars"
import { session } from "$app/stores"
type MenuItem = MenuItemLink | MenuItemSubMenu
interface MenuItemBase {
href?: string
items?: MenuItemLink[]
label: string
title?: string
}
interface MenuItemLink extends MenuItemBase {
href: string
}
interface MenuItemSubMenu extends MenuItemBase {
items: MenuItemLink[]
}
const menuItems: MenuItem[] = [
{ href: "/recherche", label: "Recherche" },
{
items: [
{ href: "/article", label: "ARTICLE" },
{ href: "/dossier_legislatif", label: "DOSSIER_LEGISLATIF" },
{ href: "/id", label: "ID" },
{ href: "/idcc", label: "IDCC" },
{ href: "/jo", label: "JO" },
{ href: "/section_ta", label: "SECTION_TA" },
{ href: "/texte_version", label: "TEXTE_VERSION" },
{ href: "/textekali", label: "TEXTEKALI" },
{ href: "/textelr", label: "TEXTELR" },
{ href: "/versions", label: "VERSIONS" },
],
label: "Données",
},
// {
// items: [
// { href: "/jo", label: "JO" },
// ],
// label: "JORF",
// title: "Textes publiés au Journal officiel de la République française",
// },
// {
// items: [
// { href: "/article", label: "ARTICLE" },
// // { href: "/eli/ids", label: "ID" },
// { href: "/section_ta", label: "SECTION_TA" },
// { href: "/texte_version", label: "TEXTE_VERSION" },
// { href: "/textelr", label: "TEXTELR" },
// // { href: "/eli/versions", label: "VERSIONS" },
// ],
// label: "LEGI",
// title: "Codes, lois et règlements consolidés",
// },
]
const title = $session.title
</script>
<div class="navbar mb-2 bg-neutral text-neutral-content">
<div class="navbar-start">
<div class="dropdown">
<button tabindex="0" class="btn btn-ghost lg:hidden">
<Icon class="h-5 w-5" icon={threeBars} />
</button>
<ul
tabindex="0"
class="dropdown-content menu rounded-box menu-compact mt-3 w-52 bg-neutral p-2 text-neutral-content shadow"
>
{#each menuItems as { href, items, label, title }}
{#if href !== undefined}
<li><a {href} {title}>{label}</a></li>
{:else if items !== undefined}
<li tabindex="0">
<span class="justify-between" {title}>
{label}
<Icon class="h-5 w-5" icon={chevronRight} />
</span>
<ul class="bg-neutral p-2 text-neutral-content">
{#each items as { href, label }}
<li><a {href} {title}>{label}</a></li>
{/each}
</ul>
</li>
{/if}
{/each}
</ul>
</div>
<a class="btn btn-ghost text-xl normal-case" href="/"> {title}</a>
</div>
<div class="navbar-center hidden lg:flex">
<ul class="menu menu-horizontal p-0">
{#each menuItems as { href, items, label, title }}
{#if href !== undefined}
<li><a {href} {title}>{label}</a></li>
{:else if items !== undefined}
<li tabindex="0">
<span class="justify-between" {title}>
{label}
<Icon class="h-5 w-5" icon={chevronDown} />
</span>
<ul class="bg-neutral p-2 text-neutral-content">
{#each items as { href, label }}
<li><a {href} {title}>{label}</a></li>
{/each}
</ul>
</li>
{/if}
{/each}
</ul>
</div>
<div class="navbar-end">
<a
class="btn"
href="https://git.en-root.org/tricoteuses/tricoteuses-legal-explorer"
>Contribuer</a
>
</div>
</div>
<div class="mx-auto w-11/12">
<slot />
</div>

View file

@ -1,11 +1,12 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
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 auditQuery(
audit: Audit,
query: URLSearchParams,
@ -33,7 +34,7 @@ export function auditQuery(
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
}
export const GET: RequestHandler = async ({ url }) => {
export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
{ limit: number; offset: number; q?: string },
unknown,
@ -46,15 +47,7 @@ export const GET: RequestHandler = async ({ url }) => {
2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
)
return {
// status: 400,
body: {
error: {
query: queryError as unknown as JSONObject,
},
},
}
throw error(400, JSON.stringify(queryError, null, 2))
}
const { limit, offset } = query
@ -65,7 +58,5 @@ export const GET: RequestHandler = async ({ url }) => {
LIMIT ${limit}
`
).map(({ data }) => data)
return {
body: { article: articles as unknown as JSONObject[] },
}
return { article: articles }
}

View file

@ -4,14 +4,14 @@
import { TreeView } from "augmented-data-viewer"
// import { page } from "$app/stores"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import Pagination from "$lib/components/Pagination.svelte"
import type { Article } from "$lib/legal"
import { summarizeArticleProperties } from "$lib/summaries"
let articles: Article[]
export { articles as article }
export let error: unknown
import type { PageData } from "./$types"
export let data: PageData
$: ({ article: articles } = data)
</script>
<header class="prose my-6 max-w-full">
@ -51,11 +51,6 @@
</div>
</form> -->
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "article" }}
frame={false}
@ -64,5 +59,4 @@
value={articles}
/>
<Pagination currentPageCount={articles.length ?? 0} />
{/if}
<Pagination currentPageCount={articles?.length ?? 0} />

View file

@ -1,38 +0,0 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import type { Article } from "$lib/legal"
import {
summarizeArticleProperties,
summarizeLegalObject,
} from "$lib/summaries"
export let error: unknown
export let article: Article
const summary = summarizeLegalObject({ key: "article" }, "article", article)
</script>
<header class="prose my-6 max-w-full">
<h2>ARTICLE</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "article" }}
frame={false}
open
summarize={summarizeArticleProperties}
value={article}
/>
{/if}

View file

@ -1,21 +0,0 @@
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import type { Article } from "$lib/legal"
import { db } from "$lib/server/database"
export const GET: RequestHandler = async ({ params }) => {
const article = (
await db<{ data: Article }[]>`
SELECT data FROM article
WHERE id = ${params.id}
`
).map(({ data }) => data)[0]
if (article === undefined) {
return { status: 404 }
}
return {
body: { article: article as unknown as JSONObject },
}
}

View file

@ -0,0 +1,20 @@
import { error } from "@sveltejs/kit"
import type { Article } from "$lib/legal"
import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types"
export const load: PageServerLoad = async ({ params }) => {
const article = (
await db<{ data: Article }[]>`
SELECT data FROM article
WHERE id = ${params.id}
`
).map(({ data }) => data)[0]
if (article === undefined) {
throw error(404, `Article ${params.id} non trouvé`)
}
return { article }
}

View file

@ -0,0 +1,33 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import {
summarizeArticleProperties,
summarizeLegalObject,
} from "$lib/summaries"
import type { PageData } from "./$types"
export let data: PageData
$: ({ article } = data)
$: summary = summarizeLegalObject({ key: "article" }, "article", article)
</script>
<header class="prose my-6 max-w-full">
<h2>ARTICLE</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
<TreeView
access={{ key: "article" }}
frame={false}
open
summarize={summarizeArticleProperties}
value={article}
/>

View file

@ -1,11 +1,12 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
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 auditQuery(
audit: Audit,
query: URLSearchParams,
@ -33,7 +34,7 @@ export function auditQuery(
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
}
export const GET: RequestHandler = async ({ url }) => {
export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
{ limit: number; offset: number; q?: string },
unknown,
@ -46,15 +47,7 @@ export const GET: RequestHandler = async ({ url }) => {
2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
)
return {
// status: 400,
body: {
error: {
query: queryError as unknown as JSONObject,
},
},
}
throw error(400, JSON.stringify(queryError, null, 2))
}
const { limit, offset } = query
@ -66,8 +59,6 @@ export const GET: RequestHandler = async ({ url }) => {
`
).map(({ data }) => data)
return {
body: {
dossier_legislatif: dossiersLegislatifs as unknown as JSONObject[],
},
dossier_legislatif: dossiersLegislatifs,
}
}

View file

@ -4,14 +4,14 @@
import { TreeView } from "augmented-data-viewer"
// import { page } from "$app/stores"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import Pagination from "$lib/components/Pagination.svelte"
import type { DossierLegislatif } from "$lib/legal"
import { summarizeDossierLegislatifProperties } from "$lib/summaries"
let dossiersLegislatifs: DossierLegislatif[]
export { dossiersLegislatifs as dossier_legislatif }
export let error: unknown
import type { PageData } from "./$types"
export let data: PageData
$: ({ dossier_legislatif: dossiersLegislatifs } = data)
</script>
<header class="prose my-6 max-w-full">
@ -51,11 +51,6 @@
</div>
</form> -->
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "dossier_legislatif" }}
frame={false}
@ -64,5 +59,4 @@
value={dossiersLegislatifs}
/>
<Pagination currentPageCount={dossiersLegislatifs.length ?? 0} />
{/if}
<Pagination currentPageCount={dossiersLegislatifs?.length ?? 0} />

View file

@ -1,43 +0,0 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import type { DossierLegislatif } from "$lib/legal"
import {
summarizeDossierLegislatifProperties,
summarizeLegalObject,
} from "$lib/summaries"
export let error: unknown
let dossierLegislatif: DossierLegislatif
export { dossierLegislatif as dossier_legislatif }
const summary = summarizeLegalObject(
{ key: "dossier_legislatif" },
"dossier_legislatif",
dossierLegislatif,
)
</script>
<header class="prose my-6 max-w-full">
<h2>DOSSIER_LEGISLATIF</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "dossier_legislatif" }}
frame={false}
open
summarize={summarizeDossierLegislatifProperties}
value={dossierLegislatif}
/>
{/if}

View file

@ -1,10 +1,11 @@
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
import type { DossierLegislatif } from "$lib/legal"
import { db } from "$lib/server/database"
export const GET: RequestHandler = async ({ params }) => {
import type { PageServerLoad } from "./$types"
export const load: PageServerLoad = async ({ params }) => {
const dossierLegislatif = (
await db<{ data: DossierLegislatif }[]>`
SELECT data FROM dossier_legislatif
@ -13,9 +14,7 @@ export const GET: RequestHandler = async ({ params }) => {
).map(({ data }) => data)[0]
if (dossierLegislatif === undefined) {
return { status: 404 }
}
return {
body: { dossier_legislatif: dossierLegislatif as unknown as JSONObject },
throw error(404, `Dossier législatif ${params.id} non trouvé`)
}
return { dossier_legislatif: dossierLegislatif }
}

View file

@ -0,0 +1,37 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import {
summarizeDossierLegislatifProperties,
summarizeLegalObject,
} from "$lib/summaries"
import type { PageData } from "./$types"
export let data: PageData
$: ({ dossier_legislatif: dossierLegislatif } = data)
$: summary = summarizeLegalObject(
{ key: "dossier_legislatif" },
"dossier_legislatif",
dossierLegislatif,
)
</script>
<header class="prose my-6 max-w-full">
<h2>DOSSIER_LEGISLATIF</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
<TreeView
access={{ key: "dossier_legislatif" }}
frame={false}
open
summarize={summarizeDossierLegislatifProperties}
value={dossierLegislatif}
/>

View file

@ -1,11 +1,12 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
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 auditQuery(
audit: Audit,
query: URLSearchParams,
@ -33,7 +34,7 @@ export function auditQuery(
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
}
export const GET: RequestHandler = async ({ url }) => {
export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
{ limit: number; offset: number; q?: string },
unknown,
@ -46,15 +47,7 @@ export const GET: RequestHandler = async ({ url }) => {
2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
)
return {
// status: 400,
body: {
error: {
query: queryError as unknown as JSONObject,
},
},
}
throw error(400, JSON.stringify(queryError, null, 2))
}
const { limit, offset } = query
@ -63,7 +56,5 @@ export const GET: RequestHandler = async ({ url }) => {
OFFSET ${offset}
LIMIT ${limit}
`
return {
body: { id: idsWrapper as unknown as JSONObject[] },
}
return { id: idsWrapper }
}

View file

@ -4,14 +4,14 @@
import { TreeView } from "augmented-data-viewer"
// import { page } from "$app/stores"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import Pagination from "$lib/components/Pagination.svelte"
import type { IdWrapper } from "$lib/legal"
import { summarizeIdWrapperProperties } from "$lib/summaries"
let idsWrapper: IdWrapper[]
export { idsWrapper as id }
export let error: unknown
import type { PageData } from "./$types"
export let data: PageData
$: ({ id: idsWrapper } = data)
</script>
<header class="prose my-6 max-w-full">
@ -51,11 +51,6 @@
</div>
</form> -->
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "id" }}
frame={false}
@ -64,5 +59,4 @@
value={idsWrapper}
/>
<Pagination currentPageCount={idsWrapper.length ?? 0} />
{/if}
<Pagination currentPageCount={idsWrapper?.length ?? 0} />

View file

@ -1,39 +0,0 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import type { IdWrapper } from "$lib/legal"
import {
summarizeIdWrapperProperties,
summarizeLegalObject,
} from "$lib/summaries"
export let error: unknown
let idWrapper: IdWrapper
export { idWrapper as id }
const summary = summarizeLegalObject({ key: "id" }, "id", idWrapper)
</script>
<header class="prose my-6 max-w-full">
<h2>ID</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "article" }}
frame={false}
open
summarize={summarizeIdWrapperProperties}
value={idWrapper}
/>
{/if}

View file

@ -1,21 +0,0 @@
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import type { IdWrapper } from "$lib/legal"
import { db } from "$lib/server/database"
export const GET: RequestHandler = async ({ params }) => {
const idWrapper = (
await db<{ data: IdWrapper }[]>`
SELECT eli, id FROM id
WHERE eli = ${params.eli}
`
)[0]
if (idWrapper === undefined) {
return { status: 404 }
}
return {
body: { id: idWrapper as unknown as JSONObject },
}
}

View file

@ -0,0 +1,20 @@
import { error } from "@sveltejs/kit"
import type { IdWrapper } from "$lib/legal"
import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types"
export const load: PageServerLoad = async ({ params }) => {
const idWrapper = (
await db<{ data: IdWrapper }[]>`
SELECT eli, id FROM id
WHERE eli = ${params.eli}
`
)[0]
if (idWrapper === undefined) {
throw error(404, `ELI ${params.eli} non trouvé`)
}
return { id: idWrapper }
}

View file

@ -0,0 +1,33 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import {
summarizeIdWrapperProperties,
summarizeLegalObject,
} from "$lib/summaries"
import type { PageData } from "./$types"
export let data: PageData
$: ({ id: idWrapper } = data)
$: summary = summarizeLegalObject({ key: "id" }, "id", idWrapper)
</script>
<header class="prose my-6 max-w-full">
<h2>ID</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
<TreeView
access={{ key: "article" }}
frame={false}
open
summarize={summarizeIdWrapperProperties}
value={idWrapper}
/>

View file

@ -1,11 +1,12 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
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 auditQuery(
audit: Audit,
query: URLSearchParams,
@ -33,7 +34,7 @@ export function auditQuery(
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
}
export const GET: RequestHandler = async ({ url }) => {
export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
{ limit: number; offset: number; q?: string },
unknown,
@ -46,15 +47,7 @@ export const GET: RequestHandler = async ({ url }) => {
2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
)
return {
// status: 400,
body: {
error: {
query: queryError as unknown as JSONObject,
},
},
}
throw error(400, JSON.stringify(queryError, null, 2))
}
const { limit, offset } = query
@ -65,7 +58,5 @@ export const GET: RequestHandler = async ({ url }) => {
LIMIT ${limit}
`
).map(({ data }) => data)
return {
body: { idcc: idccArray as unknown as JSONObject[] },
}
return { idcc: idccArray }
}

View file

@ -4,14 +4,14 @@
import { TreeView } from "augmented-data-viewer"
// import { page } from "$app/stores"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import Pagination from "$lib/components/Pagination.svelte"
import type { Idcc } from "$lib/legal"
import { summarizeIdccProperties } from "$lib/summaries"
export let error: unknown
let idccArray: Idcc[]
export { idccArray as idcc }
import type { PageData } from "./$types"
export let data: PageData
$: ({ idcc: idccArray } = data)
</script>
<header class="prose my-6 max-w-full">
@ -51,11 +51,6 @@
</div>
</form> -->
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "idcc" }}
frame={false}
@ -64,5 +59,4 @@
value={idccArray}
/>
<Pagination currentPageCount={idccArray.length ?? 0} />
{/if}
<Pagination currentPageCount={idccArray?.length ?? 0} />

View file

@ -1,35 +0,0 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import type { Idcc } from "$lib/legal"
import { summarizeIdccProperties, summarizeLegalObject } from "$lib/summaries"
export let error: unknown
export let idcc: Idcc
const summary = summarizeLegalObject({ key: "idcc" }, "idcc", idcc)
</script>
<header class="prose my-6 max-w-full">
<h2>IDCC</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "idcc" }}
frame={false}
open
summarize={summarizeIdccProperties}
value={idcc}
/>
{/if}

View file

@ -1,21 +0,0 @@
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import type { Idcc } from "$lib/legal"
import { db } from "$lib/server/database"
export const GET: RequestHandler = async ({ params }) => {
const idcc = (
await db<{ data: Idcc }[]>`
SELECT data FROM idcc
WHERE id = ${params.id}
`
).map(({ data }) => data)[0]
if (idcc === undefined) {
return { status: 404 }
}
return {
body: { idcc: idcc as unknown as JSONObject },
}
}

View file

@ -0,0 +1,20 @@
import { error } from "@sveltejs/kit"
import type { Idcc } from "$lib/legal"
import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types"
export const load: PageServerLoad = async ({ params }) => {
const idcc = (
await db<{ data: Idcc }[]>`
SELECT data FROM idcc
WHERE id = ${params.id}
`
).map(({ data }) => data)[0]
if (idcc === undefined) {
throw error(404, `IDCC ${params.id} non trouvé`)
}
return { idcc }
}

View file

@ -0,0 +1,30 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import { summarizeIdccProperties, summarizeLegalObject } from "$lib/summaries"
import type { PageData } from "./$types"
export let data: PageData
$: ({ idcc } = data)
$: summary = summarizeLegalObject({ key: "idcc" }, "idcc", idcc)
</script>
<header class="prose my-6 max-w-full">
<h2>IDCC</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
<TreeView
access={{ key: "idcc" }}
frame={false}
open
summarize={summarizeIdccProperties}
value={idcc}
/>

View file

@ -1,11 +1,12 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
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 auditQuery(
audit: Audit,
query: URLSearchParams,
@ -33,7 +34,7 @@ export function auditQuery(
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
}
export const GET: RequestHandler = async ({ url }) => {
export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
{ limit: number; offset: number; q?: string },
unknown,
@ -46,15 +47,7 @@ export const GET: RequestHandler = async ({ url }) => {
2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
)
return {
// status: 400,
body: {
error: {
query: queryError as unknown as JSONObject,
},
},
}
throw error(400, JSON.stringify(queryError, null, 2))
}
const { limit, offset } = query
@ -65,7 +58,5 @@ export const GET: RequestHandler = async ({ url }) => {
LIMIT ${limit}
`
).map(({ data }) => data)
return {
body: { jo: jos as unknown as JSONObject[] },
}
return { jo: jos }
}

View file

@ -4,14 +4,14 @@
import { TreeView } from "augmented-data-viewer"
// import { page } from "$app/stores"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import Pagination from "$lib/components/Pagination.svelte"
import type { Jo } from "$lib/legal"
import { summarizeJoProperties } from "$lib/summaries"
export let error: unknown
let jos: Jo[]
export { jos as jo }
import type { PageData } from "./$types"
export let data: PageData
$: ({ jo: jos } = data)
</script>
<header class="prose my-6 max-w-full">
@ -51,11 +51,6 @@
</div>
</form> -->
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "jo" }}
frame={false}
@ -64,5 +59,4 @@
value={jos}
/>
<Pagination currentPageCount={jos.length ?? 0} />
{/if}
<Pagination currentPageCount={jos?.length ?? 0} />

View file

@ -1,35 +0,0 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import type { Jo } from "$lib/legal"
import { summarizeJoProperties, summarizeLegalObject } from "$lib/summaries"
export let error: unknown
export let jo: Jo
const summary = summarizeLegalObject({ key: "jo" }, "jo", jo)
</script>
<header class="prose my-6 max-w-full">
<h2>JO</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "jo" }}
frame={false}
open
summarize={summarizeJoProperties}
value={jo}
/>
{/if}

View file

@ -1,21 +0,0 @@
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import type { Jo } from "$lib/legal"
import { db } from "$lib/server/database"
export const GET: RequestHandler = async ({ params }) => {
const jo = (
await db<{ data: Jo }[]>`
SELECT data FROM jo
WHERE id = ${params.id}
`
).map(({ data }) => data)[0]
if (jo === undefined) {
return { status: 404 }
}
return {
body: { jo: jo as unknown as JSONObject },
}
}

View file

@ -0,0 +1,20 @@
import { error } from "@sveltejs/kit"
import type { Jo } from "$lib/legal"
import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types"
export const load: PageServerLoad = async ({ params }) => {
const jo = (
await db<{ data: Jo }[]>`
SELECT data FROM jo
WHERE id = ${params.id}
`
).map(({ data }) => data)[0]
if (jo === undefined) {
throw error(404, `JO ${params.id} non trouvé`)
}
return { jo }
}

View file

@ -0,0 +1,30 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import { summarizeJoProperties, summarizeLegalObject } from "$lib/summaries"
import type { PageData } from "./$types"
export let data: PageData
$: ({ jo } = data)
$: summary = summarizeLegalObject({ key: "jo" }, "jo", jo)
</script>
<header class="prose my-6 max-w-full">
<h2>JO</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
<TreeView
access={{ key: "jo" }}
frame={false}
open
summarize={summarizeJoProperties}
value={jo}
/>

View file

@ -1,11 +1,12 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
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 auditQuery(
audit: Audit,
query: URLSearchParams,
@ -33,7 +34,7 @@ export function auditQuery(
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
}
export const GET: RequestHandler = async ({ url }) => {
export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
{ limit: number; offset: number; q?: string },
unknown,
@ -46,15 +47,7 @@ export const GET: RequestHandler = async ({ url }) => {
2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
)
return {
// status: 400,
body: {
error: {
query: queryError as unknown as JSONObject,
},
},
}
throw error(400, JSON.stringify(queryError, null, 2))
}
const { limit, offset, q } = query
@ -73,10 +66,8 @@ export const GET: RequestHandler = async ({ url }) => {
WHERE id = ${articleId}
`
).map(({ data }) => data)
return {
body: { articles: articles as unknown as JSONObject[], q },
return { articles, q }
}
}
}
return { body: {} }
return {}
}

View file

@ -4,13 +4,14 @@
import { TreeView } from "augmented-data-viewer"
import { page } from "$app/stores"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import Pagination from "$lib/components/Pagination.svelte"
import { summarizeArticleProperties } from "$lib/summaries"
export let articles: unknown[]
export let error: unknown
export let q: string | undefined
import type { PageData } from "./$types"
export let data: PageData
$: ({ articles, q } = data)
</script>
<header class="prose my-6 max-w-full">
@ -33,11 +34,7 @@
</div>
</form>
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null && q !== undefined}
{#if q !== undefined}
{#if articles === undefined}
<p>Aucun article trouvé</p>
{:else}

View file

@ -1,11 +1,12 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
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 auditQuery(
audit: Audit,
query: URLSearchParams,
@ -33,7 +34,7 @@ export function auditQuery(
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
}
export const GET: RequestHandler = async ({ url }) => {
export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
{ limit: number; offset: number; q?: string },
unknown,
@ -46,15 +47,7 @@ export const GET: RequestHandler = async ({ url }) => {
2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
)
return {
// status: 400,
body: {
error: {
query: queryError as unknown as JSONObject,
},
},
}
throw error(400, JSON.stringify(queryError, null, 2))
}
const { limit, offset } = query
@ -65,7 +58,5 @@ export const GET: RequestHandler = async ({ url }) => {
LIMIT ${limit}
`
).map(({ data }) => data)
return {
body: { section_ta: sectionTaArray as unknown as JSONObject[] },
}
return { section_ta: sectionTaArray }
}

View file

@ -4,14 +4,14 @@
import { TreeView } from "augmented-data-viewer"
// import { page } from "$app/stores"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import Pagination from "$lib/components/Pagination.svelte"
import type { SectionTa } from "$lib/legal"
import { summarizeSectionTaProperties } from "$lib/summaries"
export let error: unknown
let sectionTaArray: SectionTa[]
export { sectionTaArray as section_ta }
import type { PageData } from "./$types"
export let data: PageData
$: ({ section_ta: sectionTaArray } = data)
</script>
<header class="prose my-6 max-w-full">
@ -51,11 +51,6 @@
</div>
</form> -->
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "section_ta" }}
frame={false}
@ -64,5 +59,4 @@
value={sectionTaArray}
/>
<Pagination currentPageCount={sectionTaArray.length ?? 0} />
{/if}
<Pagination currentPageCount={sectionTaArray?.length ?? 0} />

View file

@ -1,43 +0,0 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import type { SectionTa } from "$lib/legal"
import {
summarizeSectionTaProperties,
summarizeLegalObject,
} from "$lib/summaries"
export let error: unknown
let sectionTa: SectionTa
export { sectionTa as section_ta }
const summary = summarizeLegalObject(
{ key: "section_ta" },
"section_ta",
sectionTa,
)
</script>
<header class="prose my-6 max-w-full">
<h2>SECTION_TA</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "section_ta" }}
frame={false}
open
summarize={summarizeSectionTaProperties}
value={sectionTa}
/>
{/if}

View file

@ -1,10 +1,11 @@
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
import type { SectionTa } from "$lib/legal"
import { db } from "$lib/server/database"
export const GET: RequestHandler = async ({ params }) => {
import type { PageServerLoad } from "./$types"
export const load: PageServerLoad = async ({ params }) => {
const sectionTa = (
await db<{ data: SectionTa }[]>`
SELECT data FROM section_ta
@ -13,9 +14,7 @@ export const GET: RequestHandler = async ({ params }) => {
).map(({ data }) => data)[0]
if (sectionTa === undefined) {
return { status: 404 }
}
return {
body: { section_ta: sectionTa as unknown as JSONObject },
throw error(404, `Section TA ${params.id} non trouvée`)
}
return { section_ta: sectionTa }
}

View file

@ -0,0 +1,37 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import {
summarizeSectionTaProperties,
summarizeLegalObject,
} from "$lib/summaries"
import type { PageData } from "./$types"
export let data: PageData
$: ({ section_ta: sectionTa } = data)
$: summary = summarizeLegalObject(
{ key: "section_ta" },
"section_ta",
sectionTa,
)
</script>
<header class="prose my-6 max-w-full">
<h2>SECTION_TA</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
<TreeView
access={{ key: "section_ta" }}
frame={false}
open
summarize={summarizeSectionTaProperties}
value={sectionTa}
/>

View file

@ -1,11 +1,12 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
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 auditQuery(
audit: Audit,
query: URLSearchParams,
@ -33,7 +34,7 @@ export function auditQuery(
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
}
export const GET: RequestHandler = async ({ url }) => {
export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
{ limit: number; offset: number; q?: string },
unknown,
@ -46,15 +47,7 @@ export const GET: RequestHandler = async ({ url }) => {
2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
)
return {
// status: 400,
body: {
error: {
query: queryError as unknown as JSONObject,
},
},
}
throw error(400, JSON.stringify(queryError, null, 2))
}
const { limit, offset } = query
@ -65,7 +58,5 @@ export const GET: RequestHandler = async ({ url }) => {
LIMIT ${limit}
`
).map(({ data }) => data)
return {
body: { texte_version: texteVersionArray as unknown as JSONObject[] },
}
return { texte_version: texteVersionArray }
}

View file

@ -4,14 +4,14 @@
import { TreeView } from "augmented-data-viewer"
// import { page } from "$app/stores"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import Pagination from "$lib/components/Pagination.svelte"
import type { TexteVersion } from "$lib/legal"
import { summarizeTexteVersionProperties } from "$lib/summaries"
export let error: unknown
let texteVersionArray: TexteVersion[]
export { texteVersionArray as texte_version }
import type { PageData } from "./$types"
export let data: PageData
$: ({ texte_version: texteVersionArray } = data)
</script>
<header class="prose my-6 max-w-full">
@ -51,11 +51,6 @@
</div>
</form> -->
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "texte_version" }}
frame={false}
@ -64,5 +59,4 @@
value={texteVersionArray}
/>
<Pagination currentPageCount={texteVersionArray.length ?? 0} />
{/if}
<Pagination currentPageCount={texteVersionArray?.length ?? 0} />

View file

@ -1,43 +0,0 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import type { TexteVersion } from "$lib/legal"
import {
summarizeTexteVersionProperties,
summarizeLegalObject,
} from "$lib/summaries"
export let error: unknown
let texteVersion: TexteVersion
export { texteVersion as texte_version }
const summary = summarizeLegalObject(
{ key: "texte_version" },
"texte_version",
texteVersion,
)
</script>
<header class="prose my-6 max-w-full">
<h2>TEXTE_VERSION</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "texte_version" }}
frame={false}
open
summarize={summarizeTexteVersionProperties}
value={texteVersion}
/>
{/if}

View file

@ -1,10 +1,11 @@
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
import type { TexteVersion } from "$lib/legal"
import { db } from "$lib/server/database"
export const GET: RequestHandler = async ({ params }) => {
import type { PageServerLoad } from "./$types"
export const load: PageServerLoad = async ({ params }) => {
const texteVersion = (
await db<{ data: TexteVersion }[]>`
SELECT data FROM texte_version
@ -13,9 +14,7 @@ export const GET: RequestHandler = async ({ params }) => {
).map(({ data }) => data)[0]
if (texteVersion === undefined) {
return { status: 404 }
}
return {
body: { texte_version: texteVersion as unknown as JSONObject },
throw error(404, `Texte version ${params.id} non trouvé`)
}
return { texte_version: texteVersion }
}

View file

@ -0,0 +1,37 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import {
summarizeTexteVersionProperties,
summarizeLegalObject,
} from "$lib/summaries"
import type { PageData } from "./$types"
export let data: PageData
$: ({ texte_version: texteVersion } = data)
$: summary = summarizeLegalObject(
{ key: "texte_version" },
"texte_version",
texteVersion,
)
</script>
<header class="prose my-6 max-w-full">
<h2>TEXTE_VERSION</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
<TreeView
access={{ key: "texte_version" }}
frame={false}
open
summarize={summarizeTexteVersionProperties}
value={texteVersion}
/>

View file

@ -1,11 +1,12 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
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 auditQuery(
audit: Audit,
query: URLSearchParams,
@ -33,7 +34,7 @@ export function auditQuery(
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
}
export const GET: RequestHandler = async ({ url }) => {
export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
{ limit: number; offset: number; q?: string },
unknown,
@ -46,15 +47,7 @@ export const GET: RequestHandler = async ({ url }) => {
2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
)
return {
// status: 400,
body: {
error: {
query: queryError as unknown as JSONObject,
},
},
}
throw error(400, JSON.stringify(queryError, null, 2))
}
const { limit, offset } = query
@ -65,7 +58,5 @@ export const GET: RequestHandler = async ({ url }) => {
LIMIT ${limit}
`
).map(({ data }) => data)
return {
body: { textekali: textekaliArray as unknown as JSONObject[] },
}
return { textekali: textekaliArray }
}

View file

@ -1,17 +1,21 @@
<script lang="ts">
throw new Error(
"@migration task: Add data prop (https://github.com/sveltejs/kit/discussions/5774#discussioncomment-3292707)",
)
// import Icon from "@iconify/svelte"
// import searchIcon from "@iconify-icons/codicon/search"
import { TreeView } from "augmented-data-viewer"
// import { page } from "$app/stores"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import Pagination from "$lib/components/Pagination.svelte"
import type { Textekali } from "$lib/legal"
import { summarizeTextekaliProperties } from "$lib/summaries"
export let error: unknown
let textekaliArray: Textekali[]
export { textekaliArray as textekali }
import type { PageData } from "./$types"
export let data: PageData
$: ({ textekali: textekaliArray } = data)
</script>
<header class="prose my-6 max-w-full">
@ -51,11 +55,6 @@
</div>
</form> -->
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "textekali" }}
frame={false}
@ -64,5 +63,4 @@
value={textekaliArray}
/>
<Pagination currentPageCount={textekaliArray.length ?? 0} />
{/if}
<Pagination currentPageCount={textekaliArray?.length ?? 0} />

View file

@ -1,42 +0,0 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import type { Textekali } from "$lib/legal"
import {
summarizeTextekaliProperties,
summarizeLegalObject,
} from "$lib/summaries"
export let error: unknown
export let textekali: Textekali
const summary = summarizeLegalObject(
{ key: "textekali" },
"textekali",
textekali,
)
</script>
<header class="prose my-6 max-w-full">
<h2>TEXTEKALI</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "textekali" }}
frame={false}
open
summarize={summarizeTextekaliProperties}
value={textekali}
/>
{/if}

View file

@ -1,10 +1,11 @@
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
import type { Textekali } from "$lib/legal"
import { db } from "$lib/server/database"
export const GET: RequestHandler = async ({ params }) => {
import type { PageServerLoad } from "./$types"
export const load: PageServerLoad = async ({ params }) => {
const textekali = (
await db<{ data: Textekali }[]>`
SELECT data FROM textekali
@ -13,9 +14,7 @@ export const GET: RequestHandler = async ({ params }) => {
).map(({ data }) => data)[0]
if (textekali === undefined) {
return { status: 404 }
}
return {
body: { textekali: textekali as unknown as JSONObject },
throw error(404, `Texte KALI ${params.id} non trouvé`)
}
return { textekali }
}

View file

@ -0,0 +1,37 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import {
summarizeTextekaliProperties,
summarizeLegalObject,
} from "$lib/summaries"
import type { PageData } from "./$types"
export let data: PageData
$: ({ textekali } = data)
$: summary = summarizeLegalObject(
{ key: "textekali" },
"textekali",
textekali,
)
</script>
<header class="prose my-6 max-w-full">
<h2>TEXTEKALI</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
<TreeView
access={{ key: "textekali" }}
frame={false}
open
summarize={summarizeTextekaliProperties}
value={textekali}
/>

View file

@ -1,11 +1,12 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
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 auditQuery(
audit: Audit,
query: URLSearchParams,
@ -33,7 +34,7 @@ export function auditQuery(
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
}
export const GET: RequestHandler = async ({ url }) => {
export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
{ limit: number; offset: number; q?: string },
unknown,
@ -46,15 +47,7 @@ export const GET: RequestHandler = async ({ url }) => {
2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
)
return {
// status: 400,
body: {
error: {
query: queryError as unknown as JSONObject,
},
},
}
throw error(400, JSON.stringify(queryError, null, 2))
}
const { limit, offset } = query
@ -65,7 +58,5 @@ export const GET: RequestHandler = async ({ url }) => {
LIMIT ${limit}
`
).map(({ data }) => data)
return {
body: { textelr: textelrArray as unknown as JSONObject[] },
}
return { textelr: textelrArray }
}

View file

@ -4,14 +4,14 @@
import { TreeView } from "augmented-data-viewer"
// import { page } from "$app/stores"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import Pagination from "$lib/components/Pagination.svelte"
import type { Textelr } from "$lib/legal"
import { summarizeTextelrProperties } from "$lib/summaries"
export let error: unknown
let textelrArray: Textelr[]
export { textelrArray as textelr }
import type { PageData } from "./$types"
export let data: PageData
$: ({ textelr: textelrArray } = data)
</script>
<header class="prose my-6 max-w-full">
@ -51,11 +51,6 @@
</div>
</form> -->
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "textelr" }}
frame={false}
@ -64,5 +59,4 @@
value={textelrArray}
/>
<Pagination currentPageCount={textelrArray.length ?? 0} />
{/if}
<Pagination currentPageCount={textelrArray?.length ?? 0} />

View file

@ -1,38 +0,0 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import type { Textelr } from "$lib/legal"
import {
summarizeTextelrProperties,
summarizeLegalObject,
} from "$lib/summaries"
export let error: unknown
export let textelr: Textelr
const summary = summarizeLegalObject({ key: "textelr" }, "textelr", textelr)
</script>
<header class="prose my-6 max-w-full">
<h2>TEXTELR</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "textelr" }}
frame={false}
open
summarize={summarizeTextelrProperties}
value={textelr}
/>
{/if}

View file

@ -1,21 +0,0 @@
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import type { Textelr } from "$lib/legal"
import { db } from "$lib/server/database"
export const GET: RequestHandler = async ({ params }) => {
const textelr = (
await db<{ data: Textelr }[]>`
SELECT data FROM textelr
WHERE id = ${params.id}
`
).map(({ data }) => data)[0]
if (textelr === undefined) {
return { status: 404 }
}
return {
body: { textelr: textelr as unknown as JSONObject },
}
}

View file

@ -0,0 +1,20 @@
import { error } from "@sveltejs/kit"
import type { Textelr } from "$lib/legal"
import { db } from "$lib/server/database"
import type { PageServerLoad } from "./$types"
export const load: PageServerLoad = async ({ params }) => {
const textelr = (
await db<{ data: Textelr }[]>`
SELECT data FROM textelr
WHERE id = ${params.id}
`
).map(({ data }) => data)[0]
if (textelr === undefined) {
throw error(404, `Texte LR ${params.id} non trouvé`)
}
return { textelr: textelr }
}

View file

@ -0,0 +1,33 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import {
summarizeTextelrProperties,
summarizeLegalObject,
} from "$lib/summaries"
import type { PageData } from "./$types"
export let data: PageData
$: ({ textelr: textelr } = data)
$: summary = summarizeLegalObject({ key: "textelr" }, "textelr", textelr)
</script>
<header class="prose my-6 max-w-full">
<h2>TEXTELR</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
<TreeView
access={{ key: "textelr" }}
frame={false}
open
summarize={summarizeTextelrProperties}
value={textelr}
/>

View file

@ -1,11 +1,12 @@
import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
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 auditQuery(
audit: Audit,
query: URLSearchParams,
@ -33,7 +34,7 @@ export function auditQuery(
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
}
export const GET: RequestHandler = async ({ url }) => {
export const load: PageServerLoad = async ({ url }) => {
const [query, queryError] = auditQuery(cleanAudit, url.searchParams) as [
{ limit: number; offset: number; q?: string },
unknown,
@ -46,15 +47,7 @@ export const GET: RequestHandler = async ({ url }) => {
2,
)}\n\nError:\n${JSON.stringify(queryError, null, 2)}`,
)
return {
// status: 400,
body: {
error: {
query: queryError as unknown as JSONObject,
},
},
}
throw error(400, JSON.stringify(queryError, null, 2))
}
const { limit, offset } = query
@ -63,7 +56,5 @@ export const GET: RequestHandler = async ({ url }) => {
OFFSET ${offset}
LIMIT ${limit}
`
return {
body: { versions: versionsWrapper as unknown as JSONObject[] },
}
return { versions: versionsWrapper }
}

View file

@ -4,14 +4,14 @@
import { TreeView } from "augmented-data-viewer"
// import { page } from "$app/stores"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import Pagination from "$lib/components/Pagination.svelte"
import type { VersionsWrapper } from "$lib/legal"
import { summarizeVersionsWrapperProperties } from "$lib/summaries"
let versionsWrapper: VersionsWrapper[]
export { versionsWrapper as versions }
export let error: unknown
import type { PageData } from "./$types"
export let data: PageData
$: ({ versions: versionsWrapper } = data)
</script>
<header class="prose my-6 max-w-full">
@ -51,11 +51,6 @@
</div>
</form> -->
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "versions" }}
frame={false}
@ -65,4 +60,3 @@
/>
<Pagination currentPageCount={versionsWrapper.length ?? 0} />
{/if}

View file

@ -1,43 +0,0 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import ErrorAlert from "$lib/components/errors/ErrorAlert.svelte"
import type { VersionsWrapper } from "$lib/legal"
import {
summarizeVersionsWrapperProperties,
summarizeLegalObject,
} from "$lib/summaries"
export let error: unknown
let versionsWrapper: VersionsWrapper
export { versionsWrapper as versions }
const summary = summarizeLegalObject(
{ key: "versions" },
"versions",
versionsWrapper,
)
</script>
<header class="prose my-6 max-w-full">
<h2>VERSIONS</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
{#if error != null}
<ErrorAlert {error} />
{/if}
{#if error == null}
<TreeView
access={{ key: "article" }}
frame={false}
open
summarize={summarizeVersionsWrapperProperties}
value={versionsWrapper}
/>
{/if}

View file

@ -1,10 +1,11 @@
import type { RequestHandler } from "@sveltejs/kit"
import type { JSONObject } from "@sveltejs/kit/types/private"
import { error } from "@sveltejs/kit"
import type { VersionsWrapper } from "$lib/legal"
import { db } from "$lib/server/database"
export const GET: RequestHandler = async ({ params }) => {
import type { PageServerLoad } from "./$types"
export const load: PageServerLoad = async ({ params }) => {
const versionsWrapper = (
await db<{ data: VersionsWrapper }[]>`
SELECT eli, id, data FROM versions
@ -13,9 +14,7 @@ export const GET: RequestHandler = async ({ params }) => {
)[0]
if (versionsWrapper === undefined) {
return { status: 404 }
}
return {
body: { versions: versionsWrapper as unknown as JSONObject },
throw error(404, `Versions ${params.eli} non trouvé`)
}
return { versions: versionsWrapper }
}

View file

@ -0,0 +1,37 @@
<script lang="ts">
import { TreeView, SummaryView } from "augmented-data-viewer"
import {
summarizeVersionsWrapperProperties,
summarizeLegalObject,
} from "$lib/summaries"
import type { PageData } from "./$types"
export let data: PageData
$: ({ versions: versionsWrapper } = data)
$: summary = summarizeLegalObject(
{ key: "versions" },
"versions",
versionsWrapper,
)
</script>
<header class="prose my-6 max-w-full">
<h2>VERSIONS</h2>
{#if summary !== undefined}
<h1>
<SummaryView {summary} />
</h1>
{/if}
</header>
<TreeView
access={{ key: "article" }}
frame={false}
open
summarize={summarizeVersionsWrapperProperties}
value={versionsWrapper}
/>

View file

@ -4,6 +4,7 @@ const typography = require("@tailwindcss/typography")
const config = {
content: [
"./src/**/*.{html,js,svelte,ts}",
"./node_modules/@tricoteuses/explorer-tools/**/*.{html,js,svelte,ts}",
"./node_modules/augmented-data-viewer/**/*.{html,js,svelte,ts}",
],