Add function to retrieve Légifrance URL & upgrade packages
This commit is contained in:
parent
c6516947f5
commit
a1f934d03b
17 changed files with 1277 additions and 887 deletions
|
@ -1,11 +1,10 @@
|
|||
.DS_Store
|
||||
node_modules
|
||||
/build
|
||||
/.svelte-kit
|
||||
/build
|
||||
/package
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
/*.env
|
||||
!/example.env
|
||||
|
||||
# Ignore files for PNPM, NPM and YARN
|
||||
pnpm-lock.yaml
|
||||
|
|
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -1,7 +1,7 @@
|
|||
.DS_Store
|
||||
node_modules
|
||||
/.svelte-kit
|
||||
/build
|
||||
/node_modules
|
||||
/package
|
||||
/*.env
|
||||
!/example.env
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
.DS_Store
|
||||
node_modules
|
||||
/.svelte-kit
|
||||
/build
|
||||
/package
|
||||
.DS_Store
|
||||
.env
|
||||
.env.*
|
||||
!.env.example
|
||||
node_modules
|
||||
/*.env
|
||||
!/example.env
|
||||
|
||||
# Ignore files for PNPM, NPM and YARN
|
||||
pnpm-lock.yaml
|
||||
package-lock.json
|
||||
pnpm-lock.yaml
|
||||
yarn.lock
|
||||
|
|
2034
package-lock.json
generated
2034
package-lock.json
generated
File diff suppressed because it is too large
Load diff
18
package.json
18
package.json
|
@ -11,12 +11,12 @@
|
|||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build",
|
||||
"check": "svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"check": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json",
|
||||
"check:watch": "svelte-kit sync && svelte-check --tsconfig ./tsconfig.json --watch",
|
||||
"configure": "node --experimental-specifier-resolution=node package/scripts/configure.js",
|
||||
"dev": "vite dev",
|
||||
"format": "prettier --write --plugin-search-dir=. .",
|
||||
"lint": "prettier --check --plugin-search-dir=. . && eslint .",
|
||||
"format": "prettier --plugin-search-dir . --write .",
|
||||
"lint": "prettier --plugin-search-dir . --check . && eslint .",
|
||||
"package": "svelte-package",
|
||||
"preview": "vite preview",
|
||||
"test": "playwright test"
|
||||
|
@ -24,13 +24,13 @@
|
|||
"devDependencies": {
|
||||
"@auditors/core": "^0.3.0",
|
||||
"@iconify-icons/codicon": "^1.2.15",
|
||||
"@iconify/svelte": "^2.2.1",
|
||||
"@iconify/svelte": "^3.0.0",
|
||||
"@playwright/test": "^1.22.2",
|
||||
"@sveltejs/adapter-node": "^1.0.0-next.87",
|
||||
"@sveltejs/kit": "^1.0.0-next.437",
|
||||
"@sveltejs/package": "^1.0.0-next.1",
|
||||
"@sveltejs/adapter-node": "^1.0.0-next.100",
|
||||
"@sveltejs/kit": "^1.0.0-next.542",
|
||||
"@sveltejs/package": "^1.0.0-next.5",
|
||||
"@tailwindcss/typography": "^0.5.3",
|
||||
"@tricoteuses/explorer-tools": "^0.1.12",
|
||||
"@tricoteuses/explorer-tools": "^0.2.0",
|
||||
"@types/fs-extra": "^9.0.13",
|
||||
"@types/he": "^1.1.2",
|
||||
"@typescript-eslint/eslint-plugin": "^5.27.0",
|
||||
|
|
|
@ -3,9 +3,9 @@ const autoprefixer = require("autoprefixer")
|
|||
|
||||
const config = {
|
||||
plugins: [
|
||||
//Some plugins, like tailwindcss/nesting, need to run before Tailwind,
|
||||
// Some plugins, like tailwindcss/nesting, need to run before Tailwind,
|
||||
tailwindcss(),
|
||||
//But others, like autoprefixer, need to run after,
|
||||
// But others, like autoprefixer, need to run after,
|
||||
autoprefixer,
|
||||
],
|
||||
}
|
||||
|
|
8
src/app.d.ts
vendored
8
src/app.d.ts
vendored
|
@ -3,11 +3,7 @@
|
|||
// and what to do when importing types
|
||||
declare namespace App {
|
||||
// interface Locals {}
|
||||
// interface PageData {}
|
||||
// interface Error {}
|
||||
// interface Platform {}
|
||||
// interface PrivateEnv {}
|
||||
// interface PublicEnv {}
|
||||
interface Session {
|
||||
title: string
|
||||
}
|
||||
// interface Stuff {}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import type { Audit, Auditor } from "@auditors/core"
|
||||
import {
|
||||
auditArray,
|
||||
auditChain,
|
||||
|
@ -13,6 +12,8 @@ import {
|
|||
auditTest,
|
||||
auditTrimString,
|
||||
auditUnique,
|
||||
type Audit,
|
||||
type Auditor,
|
||||
} from "@auditors/core"
|
||||
|
||||
import { allFollowsMutable } from "$lib/aggregates"
|
||||
|
@ -49,7 +50,7 @@ export function auditFollowWithFalseQuery(
|
|||
)
|
||||
}
|
||||
|
||||
export function auditLimitSearchParam(
|
||||
export function auditLimitQueryParameter(
|
||||
audit: Audit,
|
||||
data: { [key: string]: unknown },
|
||||
errors: { [key: string]: unknown },
|
||||
|
@ -78,7 +79,7 @@ export function auditLimitSearchParam(
|
|||
)
|
||||
}
|
||||
|
||||
export function auditOffsetSearchParam(
|
||||
export function auditOffsetQueryParameter(
|
||||
audit: Audit,
|
||||
data: { [key: string]: unknown },
|
||||
errors: { [key: string]: unknown },
|
||||
|
@ -125,8 +126,8 @@ export function auditPaginationQuery(
|
|||
const errors: { [key: string]: unknown } = {}
|
||||
const remainingKeys = new Set(Object.keys(data))
|
||||
|
||||
auditLimitSearchParam(audit, data, errors, remainingKeys)
|
||||
auditOffsetSearchParam(audit, data, errors, remainingKeys)
|
||||
auditLimitQueryParameter(audit, data, errors, remainingKeys)
|
||||
auditOffsetQueryParameter(audit, data, errors, remainingKeys)
|
||||
|
||||
// Keep the remaining keys as is.
|
||||
remainingKeys.clear()
|
||||
|
@ -134,7 +135,7 @@ export function auditPaginationQuery(
|
|||
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
|
||||
}
|
||||
|
||||
export function auditQSearchParam(
|
||||
export function auditQQueryParameter(
|
||||
audit: Audit,
|
||||
data: { [key: string]: unknown },
|
||||
errors: { [key: string]: unknown },
|
||||
|
@ -214,9 +215,9 @@ export function auditSearchQueryContent(
|
|||
errors: { [key: string]: unknown },
|
||||
remainingKeys: Set<string>,
|
||||
): void {
|
||||
auditLimitSearchParam(audit, data, errors, remainingKeys)
|
||||
auditOffsetSearchParam(audit, data, errors, remainingKeys)
|
||||
auditQSearchParam(audit, data, errors, remainingKeys)
|
||||
auditLimitQueryParameter(audit, data, errors, remainingKeys)
|
||||
auditOffsetQueryParameter(audit, data, errors, remainingKeys)
|
||||
auditQQueryParameter(audit, data, errors, remainingKeys)
|
||||
}
|
||||
|
||||
export function auditSingleton(...auditors: Auditor[]): Auditor {
|
||||
|
|
|
@ -502,6 +502,30 @@ export function bestItemForDate<T extends { "@debut": string; "@fin": string }>(
|
|||
return items[0]
|
||||
}
|
||||
|
||||
export function legifranceUrlFromLegalObject(
|
||||
type: LegalObjectType,
|
||||
object: LegalObject,
|
||||
): string {
|
||||
switch (type) {
|
||||
case "article":
|
||||
return `https://www.legifrance.gouv.fr/codes/article_lc/${
|
||||
(object as Article).META.META_COMMUN.ID
|
||||
}`
|
||||
case "dossier_legislatif":
|
||||
case "id":
|
||||
case "idcc":
|
||||
case "jo":
|
||||
case "section_ta":
|
||||
case "texte_version":
|
||||
case "textekali":
|
||||
case "textelr":
|
||||
case "versions":
|
||||
return "TODO"
|
||||
default:
|
||||
assertNeverLegalObjectType(type)
|
||||
}
|
||||
}
|
||||
|
||||
export function menuItemsFromLegalId(
|
||||
id: string | undefined | null,
|
||||
): MenuItem[] | undefined {
|
||||
|
|
|
@ -13,7 +13,7 @@ export interface Config {
|
|||
title: string
|
||||
}
|
||||
|
||||
const config = {
|
||||
const [config, error] = validateConfig({
|
||||
db: {
|
||||
host: process.env.DB_HOST,
|
||||
port: process.env.DB_PORT,
|
||||
|
@ -22,17 +22,15 @@ const config = {
|
|||
password: process.env.DB_PASSWORD,
|
||||
},
|
||||
title: process.env.TITLE,
|
||||
}
|
||||
|
||||
const [validConfig, error] = validateConfig(config) as [Config, unknown]
|
||||
}) as [Config, unknown]
|
||||
if (error !== null) {
|
||||
console.error(
|
||||
`Error in server configuration:\n${JSON.stringify(
|
||||
validConfig,
|
||||
config,
|
||||
null,
|
||||
2,
|
||||
)}\nError:\n${JSON.stringify(error, null, 2)}`,
|
||||
)
|
||||
process.exit(-1)
|
||||
}
|
||||
export default validConfig
|
||||
export default config
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
contributeUrl="https://git.en-root.org/tricoteuses/tricoteuses-legal-explorer"
|
||||
leftMenu={appMenu}
|
||||
title={$page.data.appTitle}
|
||||
url={$page.url.origin}
|
||||
/>
|
||||
|
||||
<div class="mx-auto w-11/12">
|
||||
|
|
|
@ -2,7 +2,7 @@ import { type Audit, auditSetNullish, cleanAudit } from "@auditors/core"
|
|||
import { error } from "@sveltejs/kit"
|
||||
|
||||
import type { Follow } from "$lib/aggregates"
|
||||
import { auditFollowQuery, auditQSearchParam } from "$lib/auditors/queries"
|
||||
import { auditFollowQuery, auditQQueryParameter } from "$lib/auditors/queries"
|
||||
import type { Article } from "$lib/legal"
|
||||
import { Aggregator } from "$lib/server/aggregates"
|
||||
import { db } from "$lib/server/database"
|
||||
|
@ -32,7 +32,7 @@ export function auditQuery(
|
|||
const remainingKeys = new Set(Object.keys(data))
|
||||
|
||||
auditFollowQuery(audit, data, errors, remainingKeys)
|
||||
auditQSearchParam(audit, data, errors, remainingKeys)
|
||||
auditQQueryParameter(audit, data, errors, remainingKeys)
|
||||
|
||||
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
|
||||
}
|
||||
|
|
|
@ -10,9 +10,9 @@ import type { PendingQuery, Row } from "postgres"
|
|||
import type { Follow } from "$lib/aggregates"
|
||||
import {
|
||||
auditFollowQuery,
|
||||
auditLimitSearchParam,
|
||||
auditOffsetSearchParam,
|
||||
auditQSearchParam,
|
||||
auditLimitQueryParameter,
|
||||
auditOffsetQueryParameter,
|
||||
auditQQueryParameter,
|
||||
auditSingleton,
|
||||
} from "$lib/auditors/queries"
|
||||
import type { TexteVersion } from "$lib/legal"
|
||||
|
@ -45,7 +45,7 @@ export function auditQuery(
|
|||
const remainingKeys = new Set(Object.keys(data))
|
||||
|
||||
auditFollowQuery(audit, data, errors, remainingKeys)
|
||||
auditLimitSearchParam(audit, data, errors, remainingKeys)
|
||||
auditLimitQueryParameter(audit, data, errors, remainingKeys)
|
||||
audit.attribute(
|
||||
data,
|
||||
"nature",
|
||||
|
@ -54,8 +54,8 @@ export function auditQuery(
|
|||
remainingKeys,
|
||||
auditSingleton(auditTrimString),
|
||||
)
|
||||
auditOffsetSearchParam(audit, data, errors, remainingKeys)
|
||||
auditQSearchParam(audit, data, errors, remainingKeys)
|
||||
auditOffsetQueryParameter(audit, data, errors, remainingKeys)
|
||||
auditQQueryParameter(audit, data, errors, remainingKeys)
|
||||
|
||||
return audit.reduceRemaining(data, errors, remainingKeys, auditSetNullish({}))
|
||||
}
|
||||
|
|
|
@ -12,10 +12,10 @@
|
|||
|
||||
export let data: PageData
|
||||
|
||||
let follow = data.follow
|
||||
let showArticles = false
|
||||
let showRawData = false
|
||||
|
||||
$: follow = data.follow
|
||||
$: id = data.id!
|
||||
$: texteVersion = data.texte_version![id]
|
||||
$: url = $page.url
|
||||
|
|
|
@ -10,4 +10,8 @@
|
|||
"sourceMap": true,
|
||||
"strict": true
|
||||
}
|
||||
// Path aliases are handled by https://kit.svelte.dev/docs/configuration#alias
|
||||
//
|
||||
// If you want to overwrite includes/excludes, make sure to copy over the relevant includes/excludes
|
||||
// from the referenced tsconfig.json - TypeScript does not merge them in
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import { sveltekit } from "@sveltejs/kit/vite"
|
||||
import morgan from "morgan"
|
||||
import type { UserConfig } from "vite"
|
||||
|
||||
const middlewaresPlugin = {
|
||||
name: "tricoteuses-middlewares",
|
||||
|
@ -8,8 +9,7 @@ const middlewaresPlugin = {
|
|||
},
|
||||
}
|
||||
|
||||
/** @type {import('vite').UserConfig} */
|
||||
const config = {
|
||||
const config: UserConfig = {
|
||||
plugins: [sveltekit(), middlewaresPlugin],
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue